/* Canvas-inspired design tokens (light palette) */
:root {
  --bg-editor: #FCFCFC;
  --bg-chrome: #F8F8F8;
  --bg-elevated: #FCFCFC;
  --text-primary: rgba(20, 20, 20, 0.94);
  --text-secondary: rgba(20, 20, 20, 0.74);
  --text-tertiary: rgba(20, 20, 20, 0.54);
  --text-quaternary: rgba(20, 20, 20, 0.36);
  --stroke-primary: rgba(20, 20, 20, 0.2);
  --stroke-secondary: rgba(20, 20, 20, 0.12);
  --stroke-tertiary: rgba(20, 20, 20, 0.08);
  --fill-secondary: rgba(20, 20, 20, 0.14);
  --fill-tertiary: rgba(20, 20, 20, 0.08);
  --fill-quaternary: rgba(20, 20, 20, 0.06);
  --accent: #3685BF;
  --accent-hover: #2E76AB;
  --accent-muted: rgba(54, 133, 191, 0.12);
  --danger: #CF2D56;
  --danger-muted: rgba(207, 45, 86, 0.1);
  --success: #1F8A65;
  --success-muted: rgba(31, 138, 101, 0.12);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.43;
  color: var(--text-primary);
  background: var(--bg-chrome);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-chrome);
}

/* App bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 12px 0 8px;
  background: var(--bg-chrome);
  border-bottom: 1px solid var(--stroke-tertiary);
}

.app-bar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 590;
  line-height: 22px;
  color: var(--text-primary);
}

.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  border-radius: var(--radius-md);
}

.nav-back:active {
  background: var(--fill-quaternary);
}

.app-main {
  flex: 1;
  padding: 20px 16px 32px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Typography */
.eyebrow {
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.home-title {
  font-size: 24px;
  line-height: 30px;
  font-weight: 590;
  margin-bottom: 8px;
}

.home-thesis {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* Meta list */
.meta-list {
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  margin-bottom: 28px;
  overflow: hidden;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke-tertiary);
}

.meta-row:last-child {
  border-bottom: none;
}

.meta-row dt {
  font-size: 14px;
  color: var(--text-secondary);
}

.meta-row dd {
  font-size: 14px;
  font-weight: 590;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 590;
  line-height: 20px;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #FCFCFC;
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--stroke-primary);
}

.btn-ghost:active {
  background: var(--fill-quaternary);
}

.btn-voice {
  flex: 1;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--stroke-primary);
}

.btn-voice.recording {
  background: var(--danger-muted);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger {
  flex: 1;
  background: var(--danger);
  color: #FCFCFC;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Loading */
.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.loading-ring {
  width: 40px;
  height: 40px;
  border: 2px solid var(--stroke-secondary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-size: 16px;
  font-weight: 590;
  line-height: 22px;
  margin-bottom: 6px;
}

.loading-sub {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
}

/* Quiz progress */
.quiz-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.step-dots {
  display: flex;
  gap: 6px;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stroke-secondary);
  transition: background 0.2s;
}

.step-dot.active {
  background: var(--accent);
}

.step-dot.done {
  background: var(--success);
}

.progress-label {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  font-weight: 590;
}

/* Panels */
.panel {
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  margin-bottom: 16px;
}

.panel-head {
  padding: 10px 16px 0;
}

.panel-tag {
  display: inline-block;
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  color: var(--accent);
}

.question-body {
  padding: 8px 16px 16px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 400;
}

/* Answer */
.answer-block {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

#answer-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--stroke-primary);
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
  background: var(--bg-elevated);
  resize: none;
}

#answer-input:focus {
  outline: none;
  border-color: var(--accent);
}

#answer-input::placeholder {
  color: var(--text-quaternary);
}

#answer-input:disabled {
  background: var(--fill-quaternary);
  color: var(--text-secondary);
}

.voice-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.field-hint {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  margin-top: 6px;
  min-height: 16px;
}

/* Result */
.result-panel {
  padding: 16px;
}

.result-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--stroke-tertiary);
}

.result-score-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-score-value {
  font-size: 24px;
  line-height: 30px;
  font-weight: 590;
  color: var(--accent);
}

.result-score-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 2px;
}

.result-section {
  margin-bottom: 16px;
}

.result-heading {
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.result-body {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
}

/* Summary */
.summary-header {
  text-align: center;
  margin-bottom: 24px;
}

.summary-title {
  font-size: 18px;
  line-height: 24px;
  font-weight: 590;
  margin-bottom: 12px;
}

.summary-score {
  font-size: 24px;
  line-height: 30px;
  font-weight: 590;
  color: var(--accent);
}

.summary-score-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-left: 2px;
}

.summary-caption {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.score-breakdown {
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  margin-bottom: 24px;
  overflow: hidden;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke-tertiary);
  font-size: 14px;
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-item .q-num {
  color: var(--text-secondary);
}

.summary-item .q-score {
  font-weight: 590;
  color: var(--text-primary);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
}

.history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--stroke-tertiary);
  cursor: pointer;
}

.history-card:active {
  background: var(--fill-quaternary);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.history-card-main {
  flex: 1;
  min-width: 0;
}

.history-card .date {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.history-card .score {
  font-size: 16px;
  line-height: 22px;
  font-weight: 590;
  color: var(--text-primary);
}

.history-card .status {
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--success-muted);
  color: var(--success);
  flex-shrink: 0;
  margin-left: 12px;
}

.history-card .status.pending {
  background: var(--fill-secondary);
  color: var(--text-secondary);
}

.history-detail {
  margin-top: 8px;
}

.detail-item {
  border: 1px solid var(--stroke-secondary);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.detail-item .q-title {
  font-size: 12px;
  line-height: 16px;
  font-weight: 590;
  color: var(--accent);
  margin-bottom: 8px;
}

.detail-item .q-text {
  font-size: 14px;
  line-height: 20px;
  font-weight: 590;
  margin-bottom: 12px;
}

.detail-item .a-label {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.detail-item .a-text {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.detail-item .a-text:last-child {
  margin-bottom: 0;
}

.empty-state {
  text-align: center;
  padding: 48px 0;
  font-size: 14px;
  color: var(--text-tertiary);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-elevated);
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 18px;
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}
