:root {
  color-scheme: light dark;
  --bg: #f6f3ed;
  --fg: #1f2933;
  --accent: #0f766e;
  --card-bg: #ffffff;
  --border: #d8d2c4;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.6;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.app__header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.app__subtitle {
  margin: 0;
  color: #55606b;
  font-size: 0.9rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.field__label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: #55606b;
}

.field input,
.field select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--fg);
}

button {
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: #55606b;
}

.notice {
  min-height: 1.2em;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

.notice[data-state="error"] {
  color: var(--danger);
}

.notice[data-state="warn"] {
  color: #b45309;
}

.script-text {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 1.05rem;
  background: #f0ede4;
  border-radius: 8px;
  padding: 1rem;
}

.countdown {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

.countdown span {
  color: var(--accent);
}

.status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.status[data-state="error"] {
  color: var(--danger);
}

.status[data-state="ok"] {
  color: var(--accent);
}

.result-json {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  background: #f0ede4;
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
}

.raw-json-details {
  margin-top: 0.5rem;
}

.raw-json-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #55606b;
}

/* ---- T-022: レポートUI ---- */
.report {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.report__radar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.report__radar-canvas {
  position: relative;
  height: 280px;
  width: 100%;
}

.report__axis-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.report__axis-item {
  background: #f0ede4;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.report__axis-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.95rem;
  font-weight: 600;
}

.report__axis-value {
  color: var(--accent);
}

.report__axis-suggest {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: #55606b;
}

.report__part {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.report__part h3 {
  margin: 0 0 0.6rem;
  font-size: 0.98rem;
}

.report__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  color: #55606b;
}

.report__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.report__legend-swatch {
  width: 0.9em;
  height: 0.9em;
  border-radius: 3px;
  display: inline-block;
  background: #ccc;
}

.report__legend-item.hl-filler .report__legend-swatch {
  background: #fde68a;
}

.report__legend-item.hl-hesitation-after .report__legend-swatch {
  background: transparent;
  border-bottom: 3px solid #ea580c;
  border-radius: 0;
}

.report__legend-item.hl-low-confidence .report__legend-swatch {
  background: transparent;
  border-bottom: 3px dotted #6b7280;
  border-radius: 0;
}

.report__legend-item.hl-weak-ending .report__legend-swatch {
  background: transparent;
  border-bottom: 3px dotted #2563eb;
  border-radius: 0;
}

.report__transcript {
  line-height: 2.1;
  font-size: 1rem;
  background: #f0ede4;
  border-radius: 8px;
  padding: 0.9rem;
  word-break: break-word;
}

.hl-word {
  padding: 0 1px;
}

.hl-filler {
  background: #fde68a;
  border-radius: 3px;
}

.hl-hesitation-after {
  border-bottom: 3px solid #ea580c;
}

.hl-low-confidence {
  border-bottom: 3px dotted #6b7280;
}

.hl-weak-ending {
  border-bottom: 3px dotted #2563eb;
}

.report__accuracy-summary {
  margin-top: 0.6rem;
  font-size: 0.88rem;
}

.report__accuracy-summary p {
  margin: 0;
}

.report__missing-note {
  font-size: 0.88rem;
  color: #b45309;
}

.report__intonation-fallback {
  font-size: 0.88rem;
  color: #55606b;
}

/* ---- T-031/T-032/T-033: 履歴・比較・エクスポート ---- */
.settings-details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.settings-details summary {
  cursor: pointer;
  color: #55606b;
}

.settings-details .field {
  margin-top: 0.6rem;
  margin-bottom: 0.5rem;
}

.history-section {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.history-section h3 {
  margin: 0 0 0.6rem;
  font-size: 0.98rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-item__btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-items: flex-start;
  background: #f0ede4;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-weight: 400;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  margin-top: 0;
}

.history-item__date {
  font-size: 0.78rem;
  color: #55606b;
}

.history-item__title {
  font-weight: 600;
}

.history-item__summary {
  font-size: 0.78rem;
  color: #55606b;
  font-variant-numeric: tabular-nums;
}

.history-detail {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.report__axis-diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.3rem;
  font-size: 0.8rem;
}

.report__diff--up {
  color: var(--accent);
}

.report__diff--down {
  color: var(--danger);
}

.report__diff--flat,
.report__diff--na {
  color: #55606b;
}

.report__sparkline {
  margin-top: 0.35rem;
  color: var(--accent);
  line-height: 0;
}

.report__baseline-note {
  font-size: 0.85rem;
  color: #55606b;
  background: #f0ede4;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin: 0 0 0.6rem;
}

.report__history-header {
  margin-bottom: 0.6rem;
}

.report__history-date {
  margin: 0;
  font-size: 0.85rem;
  color: #55606b;
}

.report__history-script {
  margin: 0.15rem 0 0;
  font-weight: 600;
}

.report__history-note {
  font-size: 0.82rem;
  color: #55606b;
  margin: 0 0 0.4rem;
}

.report__transcript--plain {
  white-space: pre-wrap;
}

.report__history-notices {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: #55606b;
}

.report__history-notices-list {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ---- T-041: オンボーディング ---- */
.onboarding__block {
  margin-bottom: 1.1rem;
}

.onboarding__block h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.onboarding__block p {
  margin: 0;
  font-size: 0.9rem;
}

.onboarding__steps,
.onboarding__list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.onboarding__steps li,
.onboarding__list li {
  margin-bottom: 0.35rem;
}

/* ---- T-042: モバイル対応(タップサイズ44px以上・375/390px幅で水平スクロールなし) ---- */
button {
  min-height: 44px;
}

@media (max-width: 480px) {
  .app {
    padding: 1rem 0.75rem 2.5rem;
    gap: 1rem;
  }

  .card {
    padding: 1rem;
  }

  .app__header h1 {
    font-size: 1.25rem;
  }

  .report__radar-canvas {
    height: 220px;
  }

  .script-text {
    font-size: 1rem;
    padding: 0.85rem;
  }

  .history-item__summary {
    word-break: break-word;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181b;
    --fg: #e6e6e6;
    --card-bg: #1e2328;
    --border: #333c42;
  }

  .field input,
  .field select {
    background: #12161a;
    color: var(--fg);
  }

  .result-json,
  .script-text {
    background: #12161a;
  }

  .hint {
    color: #9aa5ad;
  }

  .report__axis-item,
  .report__transcript {
    background: #12161a;
  }

  .raw-json-details summary,
  .report__axis-suggest,
  .report__legend,
  .report__intonation-fallback {
    color: #9aa5ad;
  }

  .history-item__btn,
  .report__baseline-note {
    background: #12161a;
  }

  .history-item__date,
  .history-item__summary,
  .settings-details summary,
  .report__history-date,
  .report__history-note,
  .report__history-notices,
  .report__diff--flat,
  .report__diff--na {
    color: #9aa5ad;
  }
}
