[hidden] { display: none !important; }
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;

  --color-bg: #f5efe4;
  --color-surface: #fffbf4;
  --color-surface-2: #f3ebdd;
  --color-border: #e2d6c2;
  --color-divider: #ebe1d0;
  --color-text: #22201c;
  --color-text-muted: #6a6356;
  --color-text-faint: #a1988a;
  --color-text-inverse: #fffbf4;

  --color-primary: #3346a8;
  --color-primary-hover: #283a8f;
  --color-primary-active: #1f2e74;
  --color-primary-highlight: #e1e4f5;

  --color-gold: #e0a526;
  --color-gold-soft: #f7e6bd;

  --color-maj: #3346a8; --color-maj-bg: #e1e4f5;
  --color-min: #7a3e9d; --color-min-bg: #eee1f4;
  --color-dim: #a5432a; --color-dim-bg: #f6e0d6;

  --color-success: #2f7a3b; --color-success-bg: #dfeedd;
  --color-error: #b0304a; --color-error-bg: #f6dfe3;
  --color-warning: #8a5a00; --color-warning-bg: #f7ebcf;

  --radius-sm: 0.5rem; --radius-md: 0.75rem; --radius-lg: 1.125rem; --radius-xl: 1.5rem; --radius-full: 9999px;
  --shadow-sm: 0 1px 2px oklch(0.3 0.03 70 / 0.08);
  --shadow-md: 0 6px 20px oklch(0.3 0.03 70 / 0.10);
  --shadow-lg: 0 16px 40px oklch(0.3 0.03 70 / 0.16);
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --font-display: 'Chillax', 'General Sans', system-ui, sans-serif;
  --font-body: 'General Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-size-adjust: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  min-height: 100dvh; line-height: 1.55; font-family: var(--font-body); font-size: var(--text-base);
  color: var(--color-text); background: var(--color-bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
svg { display: block; }
b, strong { font-weight: 600; }
input, button { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; touch-action: manipulation; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; }
p, li { text-wrap: pretty; }
:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a, button, input { transition: color var(--transition-interactive), background var(--transition-interactive), border-color var(--transition-interactive), box-shadow var(--transition-interactive), transform var(--transition-interactive); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* Layout */
.topbar, .stats, .stage, .footnote { width: min(100% - 2 * var(--space-4), 560px); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-block: var(--space-4) var(--space-3); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); color: var(--color-text); }
.brand-mark { width: 30px; height: 30px; color: var(--color-primary); }
.icon-btn { width: 44px; height: 44px; border-radius: var(--radius-full); display: grid; place-items: center; color: var(--color-text-muted); }
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-bottom: var(--space-3); }
.stat { background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); display: flex; align-items: baseline; justify-content: center; gap: var(--space-2); }
.stat-num { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--text-xs); color: var(--color-text-muted); }

.stage { padding-bottom: var(--space-4); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md); padding: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-4);
  animation: rise 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); }
.card h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); }
.card h3 { font-size: var(--text-base); font-weight: 600; }
.eyebrow { font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-primary); }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-sm); }
.footnote { font-size: var(--text-xs); color: var(--color-text-muted); text-align: center; padding-bottom: var(--space-8); }

.key-title { font-size: var(--text-xl) !important; }
.prompt { font-weight: 600; font-size: var(--text-base); text-align: center; }
.status { min-height: 1.5em; font-size: var(--text-sm); color: var(--color-text-muted); text-align: center; font-variant-numeric: tabular-nums; }
.status:empty { display: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 48px; padding: var(--space-3) var(--space-5); border-radius: var(--radius-full); font-weight: 600; font-size: var(--text-sm); text-align: center; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-lg { min-height: 56px; font-size: var(--text-base); }
.btn-sm { min-height: 40px; padding: var(--space-2) var(--space-4); }
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary { background: var(--color-primary-highlight); color: var(--color-primary-active); }
.btn-secondary:hover { background: #d2d7f0; }
.btn-ghost { color: var(--color-primary); }
.btn-ghost:hover { background: var(--color-primary-highlight); }
.actions { display: flex; flex-direction: column; gap: var(--space-2); }
.actions-row { flex-direction: row; }
.actions-row .btn { flex: 1; padding-inline: var(--space-3); }
.stop { align-self: center; }
.reveal-btn { align-self: center; }

/* Welcome */
.hero h1 { margin-top: calc(-1 * var(--space-1)); }
.legend { display: grid; gap: var(--space-2); list-style: none; font-size: var(--text-sm); }
.legend li { display: flex; align-items: center; gap: var(--space-3); }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 3rem; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); line-height: 1.3; }
.pill-maj { background: var(--color-maj-bg); color: var(--color-maj); }
.pill-min { background: var(--color-min-bg); color: var(--color-min); }
.pill-dim { background: var(--color-dim-bg); color: var(--color-dim); }

/* Segmented control */
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label { font-size: var(--text-sm); font-weight: 600; display: flex; justify-content: space-between; gap: var(--space-2); }
.field-label .muted { font-weight: 500; }
.seg { display: flex; flex-wrap: wrap; gap: var(--space-1); background: var(--color-surface-2); padding: var(--space-1); border-radius: var(--radius-lg); }
.seg button { flex: 1 1 auto; min-height: 44px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); white-space: nowrap; }
.seg button:hover { color: var(--color-text); }
.seg button.on { background: var(--color-surface); color: var(--color-primary-active); font-weight: 600; box-shadow: var(--shadow-sm); }

/* Keyboard */
.keyboard { width: 100%; height: 92px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--color-border); background: #fff; }
.keyboard .kw { fill: #fffdf8; stroke: #d9cdb8; stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill 120ms; }
.keyboard .kb { fill: #2a2722; transition: fill 120ms; }
.keyboard .kw.on { fill: var(--color-gold); }
.keyboard .kb.on { fill: #c4870b; }

/* Arpeggio indicator */
.arp { display: flex; justify-content: center; gap: var(--space-1); flex-wrap: nowrap; }
.arp span { min-width: 2.5rem; padding: var(--space-2) var(--space-2); border-radius: var(--radius-full); background: var(--color-surface-2); color: var(--color-text-muted); text-align: center; font-family: var(--font-display); font-weight: 600; font-size: var(--text-sm); transition: background 120ms, color 120ms, transform 120ms; }
.arp span.on { background: var(--color-gold); color: #2a1d00; transform: scale(1.08); }

/* Scale strip */
.scale { list-style: none; display: grid; grid-template-columns: repeat(8, 1fr); gap: var(--space-1); }
.scale li { display: flex; flex-direction: column; align-items: center; padding: var(--space-2) 0; border-radius: var(--radius-md); background: var(--color-surface-2); transition: background 120ms; }
.scale li.active { background: var(--color-gold-soft); }
.scale .deg { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); }
.scale .nn { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Progress slots */
.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: var(--space-2); }
.slot { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-1); border-radius: var(--radius-md); background: var(--color-surface-2); border: 2px solid transparent; transition: border-color 150ms, background 150ms; }
.slot.current { border-color: var(--color-gold); background: var(--color-surface); }
.slot-num { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; white-space: nowrap; }
.beats { display: flex; gap: 5px; }
.beats i { width: 10px; height: 10px; border-radius: 50%; background: var(--color-border); transition: background 100ms, transform 100ms; }
.beats i.on { background: var(--color-gold); }
.slot.current .beats i.on:last-of-type { transform: none; }
.slot-val { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); min-height: 1.5em; }
.slot-mark { font-weight: 700; font-size: var(--text-sm); }
.slot.ok { background: var(--color-success-bg); }
.slot.ok .slot-mark { color: var(--color-success); }
.slot.bad { background: var(--color-error-bg); border-color: var(--color-error); }
.slot.bad .slot-mark { color: var(--color-error); }

/* Answer */
.answer-form { display: flex; flex-direction: column; gap: var(--space-3); }
.answer-input { width: 100%; min-height: 56px; padding: var(--space-3) var(--space-4); border: 2px solid var(--color-border); border-radius: var(--radius-lg); background: #fff; font-family: var(--font-display); font-weight: 600; font-size: 1.375rem; letter-spacing: 0.02em; }
.answer-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-highlight); }
.answer-input::placeholder { color: var(--color-text-faint); font-weight: 500; }
.keypad { display: flex; flex-direction: column; gap: var(--space-3); }
.kp-group { display: flex; flex-direction: column; gap: var(--space-1); }
.kp-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; letter-spacing: 0.04em; }
.kp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.key-btn { min-height: 50px; min-width: 0; border-radius: var(--radius-md); background: var(--color-surface-2); border: 1px solid var(--color-divider); font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; padding: 0; }
.key-btn:hover { background: var(--color-primary-highlight); }
.key-btn:active { transform: scale(0.96); background: var(--color-primary-highlight); }
.kp-maj .key-btn { color: var(--color-maj); }
.kp-min .key-btn { color: var(--color-min); }
.kp-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.kp-tools .key-btn { font-family: var(--font-body); font-size: var(--text-base); }
.kp-tools .key-btn:first-child { color: var(--color-dim); font-family: var(--font-display); }
@media (min-width: 640px) { .kp-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); } }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: calc(-1 * var(--space-2)); }
.result .card-top { width: 100%; text-align: left; }
.new-btn { flex-shrink: 0; padding-inline: var(--space-3); min-height: 40px; }

.feedback { border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.feedback.bad { background: #fbf0f2; border: 1px solid #efc9d0; }
.feedback.warn { background: var(--color-warning-bg); color: #4d3500; }

/* Results */
.result { align-items: center; text-align: center; }
.badge { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; font-weight: 700; animation: pop 420ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.badge-ok { background: var(--color-success-bg); color: var(--color-success); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.streak { font-weight: 600; color: #8a5a00; background: var(--color-gold-soft); padding: var(--space-1) var(--space-4); border-radius: var(--radius-full); font-size: var(--text-sm); }
.result .actions { width: 100%; }
.answer-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-2); }
.answer-line .pill { font-size: var(--text-lg); min-width: 3.5rem; padding: var(--space-2) var(--space-3); }
.dash { color: var(--color-text-faint); font-weight: 600; }

/* Reveal */
.howto { background: var(--color-surface-2); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.howto ol { padding-left: var(--space-5); display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.reveal-list { display: grid; gap: var(--space-3); }
.reveal-item { border: 1px solid var(--color-divider); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); }
.reveal-item header { display: flex; align-items: center; gap: var(--space-3); }
.reveal-item .chord-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-base); }
.reveal-item sub { font-size: 0.7em; color: var(--color-text-muted); }
.reveal-item .btn { align-self: flex-start; }

/* Settings sheet */
.sheet-backdrop { position: fixed; inset: 0; background: oklch(0.2 0.02 70 / 0.35); opacity: 0; transition: opacity 200ms; z-index: 10; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; left: 50%; bottom: 0; width: min(100%, 560px); max-height: 90dvh; overflow-y: auto; z-index: 11;
  background: var(--color-surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--space-5);
  transform: translate(-50%, 100%); transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--color-border); margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); }
.sheet-note { font-size: var(--text-xs); color: var(--color-text-muted); }
input[type="range"] { width: 100%; accent-color: var(--color-primary); height: 32px; }
.range-ends { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--color-text-muted); }

@media (min-width: 640px) {
  .card { padding: var(--space-8); }
  .keyboard { height: 110px; }
  .topbar { padding-top: var(--space-8); }
}
@media (max-width: 360px) {
  .card { padding: var(--space-5) var(--space-4); }
}

/* ---- Level 2 additions: topbar, level tag, minor-key visual ---- */
.top-right { display: flex; align-items: center; gap: var(--space-1); }
.home-btn { width: 44px; height: 44px; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); }
.home-btn:hover { background: var(--color-surface-2); }
.brand-name { white-space: nowrap; }
.level-select-wrap { position: relative; display: flex; align-items: center; }
.level-select {
  appearance: none; -webkit-appearance: none; min-height: 44px; padding: var(--space-2) calc(var(--space-6) + var(--space-2)) var(--space-2) var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface);
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-sm); color: var(--color-primary-active); cursor: pointer; max-width: 62vw;
}
.level-select:hover { border-color: var(--color-primary); }
.level-select-wrap .chev { position: absolute; right: var(--space-2); pointer-events: none; color: var(--color-primary); }
@media (max-width: 520px) { .brand-name { display: none; } }

.level-tag { align-self: flex-start; font-size: var(--text-xs); font-weight: 600; padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); margin-top: calc(-1 * var(--space-2)); }
.level-tag.level-1 { background: var(--color-maj-bg); color: var(--color-maj); }
.level-tag.level-2 { background: var(--color-min-bg); color: var(--color-min); }
.result .level-tag { align-self: flex-start; }

.mv { background: var(--color-surface-2); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.mv-cap { font-size: var(--text-sm); font-weight: 600; text-align: center; }
.mv-row { display: flex; flex-direction: column; gap: var(--space-1); }
.mv-label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.scale.mini li { background: var(--color-surface); padding: var(--space-1) 0; }
.scale.mini li.active { background: var(--color-gold); }
.scale.mini li.active .nn { color: #2a1d00; }
.mv-shift { text-align: center; font-size: var(--text-xs); font-weight: 600; color: #8a5a00; }
.mv-table { width: 100%; border-collapse: separate; border-spacing: 0 var(--space-1); }
.mv-table th { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-align: center; padding-bottom: var(--space-1); }
.mv-table td { text-align: center; vertical-align: middle; padding: 0; }
.mv-table tr td:first-child .pill, .mv-table tr td:last-child .pill { min-width: 3.4rem; }
.mv-chord { background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-1) var(--space-2) !important; font-family: var(--font-display); font-weight: 600; line-height: 1.2; }
.mv-q { display: block; font-family: var(--font-body); font-weight: 500; font-size: var(--text-xs); color: var(--color-text-muted); }
.mv-arrow { color: var(--color-text-faint); font-weight: 600; width: 1.25rem; }
.mv-summary { text-align: center; display: flex; flex-direction: column; gap: var(--space-2); align-items: center; }
.mv-summary .answer-line { flex-wrap: nowrap; gap: var(--space-1); }
.mv-summary .answer-line .pill { font-size: var(--text-sm); min-width: 0; padding: var(--space-1) var(--space-2); }

/* ---- Menu + Random Chord Generator ---- */
.menu-wrap { position: relative; }
.menu { position: absolute; top: calc(100% + var(--space-2)); left: 0; z-index: 40; width: min(300px, calc(100vw - 2 * var(--space-4)));
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-1); animation: rise 180ms cubic-bezier(0.16, 1, 0.3, 1); }
.menu-item { display: flex; align-items: center; gap: var(--space-3); text-align: left; padding: var(--space-3); border-radius: var(--radius-md); min-height: 56px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--color-surface-2); }
.menu-item b { display: block; font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
.menu-item small { display: block; font-size: var(--text-xs); color: var(--color-text-muted); }
.menu-item.current { background: var(--color-primary-highlight); }
.menu-ico { flex: 0 0 auto; width: 44px; height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--color-surface-2);
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; color: var(--color-primary); white-space: nowrap; }
.menu-item.current .menu-ico { background: var(--color-surface); }
.menu-item[data-go="gen"] .menu-ico { font-size: 1.1rem; color: #0f5d93; }
html[data-section="gen"] #levelWrap { display: none; }
html[data-section="gen"] .numbers-only { display: none; }

.level-tag.level-gen { background: #d7ecfb; color: #0f5d93; }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { flex: 1 1 0; min-width: 6.5rem; min-height: 52px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  border: 2px solid var(--color-border); background: var(--color-surface); font-weight: 600; font-size: var(--text-sm); color: var(--color-text-muted); }
@media (hover: hover) { .chip:not(.on):hover { border-color: #8cc4ec; color: var(--color-text); } }
.chip.on { background: #cfe8fb; border-color: #3d97d6; color: #0b4a75; }
.chip.on.bad { background: #fbe3e7; border-color: var(--color-error); color: var(--color-error); }
.chip.on.good { background: var(--color-success-bg); border-color: var(--color-success); color: var(--color-success); }

.gen-dots { display: flex; justify-content: center; gap: var(--space-3); padding-block: var(--space-4); }
.gen-dots i { width: 18px; height: 18px; border-radius: 50%; background: var(--color-surface-2); border: 2px solid var(--color-border); transition: background 120ms, border-color 120ms, transform 120ms; }
.gen-dots i.on { background: #3d97d6; border-color: #3d97d6; transform: scale(1.12); }

.gen-answer { display: flex; flex-direction: column; gap: var(--space-4); width: 100%; text-align: left; }
.result .gen-answer ~ .btn, .gen-answer ~ .btn { align-self: stretch; }
.tones-box > p { text-align: left; }
.pill-pos { background: #d7ecfb; color: #0f5d93; }
.gen-answer .answer-line .pill { min-width: 0; font-size: var(--text-base); }
.gen-name { text-align: center; font-size: var(--text-base); }
.tones-box { background: var(--color-surface-2); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.tones { list-style: none; display: flex; flex-direction: column-reverse; gap: var(--space-1); }
.tone { display: grid; grid-template-columns: 4.25rem 1fr auto; align-items: center; gap: var(--space-3); background: var(--color-surface);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); border: 2px solid transparent; transition: border-color 120ms, background 120ms; }
.tone.on { border-color: var(--color-gold); background: var(--color-gold-soft); }
.tone-pos { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tone-name { font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); }
.tone-num { min-width: 3rem; }
.gap { font-size: var(--text-sm); padding: var(--space-1) var(--space-3) var(--space-1) calc(4.25rem + var(--space-3) + var(--space-3)); color: var(--color-text); }
.gap-arrow { color: var(--color-text-faint); font-weight: 700; margin-right: var(--space-2); }
@media (max-width: 380px) { .gap { padding-left: var(--space-4); } .tone { grid-template-columns: 3.5rem 1fr auto; } }

/* ---- Level 3: inversions ---- */
html[data-level="3"] .l12-only { display: none; }
html:not([data-level="3"]) .l3-only { display: none; }
.level-tag.level-3 { background: #dff0e6; color: #22683f; }
.fig { font-size: 0.6em; font-weight: 600; line-height: 1; margin-left: 0.08em; }
sup.fig { vertical-align: 0.75em; }
.fig-stack { display: inline-flex; flex-direction: column; vertical-align: middle; margin-left: 0.1em; line-height: 0.95; }
.pill-stack { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.pos-label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); white-space: nowrap; line-height: 1.2; }
.l3-line { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 5.5rem)); justify-content: center; gap: var(--space-2); }
.l3-line .pill { min-width: 3.25rem; font-size: var(--text-lg); padding: var(--space-2) var(--space-3); }
.l3-line .pos-label { white-space: normal; text-align: center; max-width: 5.5rem; }
.reveal-item .pos-label { white-space: nowrap; }
.inv-legend li { display: flex; align-items: center; gap: var(--space-3); }
.inv-legend .pill { min-width: 3.25rem; }
.pos-grid { display: flex; flex-direction: column; gap: var(--space-2); }
.pos-row { display: grid; grid-template-columns: 4.25rem repeat(3, 1fr); gap: var(--space-2); align-items: center; }
.pos-num { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.pos-chip { min-width: 0; min-height: 46px; padding: var(--space-1) var(--space-2); }
.fb-list { list-style: none; display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); }
.reveal-item header { flex-wrap: wrap; }
@media (max-width: 360px) { .pos-row { grid-template-columns: 3.5rem repeat(3, 1fr); } }
