/* Guitar Positions Studio — minimal, neutral styles (system fonts, no third-party requests). */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --subtle: #f4f4f3;
  --line: #e5e5e3;
  --line-strong: #cfcfcc;
  --text: #141414;
  --muted: #73736f;
  --ink: #141414;
  --on-ink: #ffffff;
  --accent: #d6401f;      /* root notes only */
  --on-accent: #ffffff;
  --ghost: #d9d9d6;
  --board: #fafaf9;
  --fret: #c9c9c5;
  --nut: #141414;
  --string: #8f8f8a;
  --inlay: #e2e2de;
  --focus: #141414;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111;
  --surface: #111111;
  --subtle: #1a1a1a;
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #ececea;
  --muted: #8e8e8a;
  --ink: #ececea;
  --on-ink: #111111;
  --accent: #ff5b36;
  --on-accent: #111111;
  --ghost: #333333;
  --board: #151515;
  --fret: #3d3d3d;
  --nut: #ececea;
  --string: #6f6f6b;
  --inlay: #2a2a2a;
  --focus: #ececea;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111111;
    --surface: #111111;
    --subtle: #1a1a1a;
    --line: #262626;
    --line-strong: #3a3a3a;
    --text: #ececea;
    --muted: #8e8e8a;
    --ink: #ececea;
    --on-ink: #111111;
    --accent: #ff5b36;
    --on-accent: #111111;
    --ghost: #333333;
    --board: #151515;
    --fret: #3d3d3d;
    --nut: #ececea;
    --string: #6f6f6b;
    --inlay: #2a2a2a;
    --focus: #ececea;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--on-ink); padding: 8px 12px; z-index: 20; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 40px;
  height: 56px;
  padding: 0 clamp(16px, 3vw, 40px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); text-decoration: none; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }

.modes { display: flex; gap: 28px; height: 100%; flex: 1; }
.modes button { position: relative; height: 100%; color: var(--muted); font-weight: 500; }
.modes button:hover { color: var(--text); }
.modes button[aria-selected="true"] { color: var(--text); }
.modes button[aria-selected="true"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }

.top-actions { display: flex; gap: 2px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 6px; }
.icon-btn svg { width: 18px; height: 18px; fill: var(--muted); }
.icon-btn:hover svg, .icon-btn[aria-expanded="true"] svg { fill: var(--text); }
#soundBtn .off { display: none; }
#soundBtn[aria-pressed="false"] .on { display: none; }
#soundBtn[aria-pressed="false"] .off { display: inline; }

.settings { padding: 16px clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--line); background: var(--subtle); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 24px; max-width: 1200px; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text); padding-top: 18px; }
select { appearance: none; -webkit-appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2373736f'/%3E%3C/svg%3E") no-repeat right 10px center; border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 28px 6px 10px; font-size: 13px; color: var(--text); }
.settings select { font-size: 14px; padding-top: 7px; padding-bottom: 7px; }
.settings input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--ink); }

/* ---------- Layout ---------- */
.stage { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 40px) 48px; flex: 1; display: flex; flex-direction: column; gap: 28px; }

.selector { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.keys { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: 0 0 auto; min-width: 38px; height: 34px; padding: 0 8px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.keys button:hover { color: var(--text); background: var(--subtle); }
.keys button[aria-checked="true"] { background: var(--ink); color: var(--on-ink); }

.combo { position: relative; }
.combo-btn { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 240px; height: 36px; padding: 0 10px 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 500; }
.combo-btn svg { width: 18px; height: 18px; fill: var(--muted); }
.combo-btn:hover { border-color: var(--muted); }
.combo-panel { position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, calc(100vw - 32px)); max-height: min(520px, 70vh); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, .12); z-index: 15; overflow: hidden; }
.combo-panel input { margin: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); outline: none; }
.combo-panel input:focus { border-color: var(--line-strong); }
.combo-list { overflow-y: auto; padding: 0 4px 6px; }
.combo-group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.combo-item { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 4px; }
.combo-item:hover, .combo-item.active { background: var(--subtle); }
.combo-item[aria-selected="true"] { font-weight: 650; }
.combo-item small { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }

/* ---------- Headline ---------- */
.headline { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.headline h1 { margin: 0 0 14px; font-size: clamp(28px, 3.6vw, 44px); line-height: 1.05; letter-spacing: -0.03em; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 0; }
.chip { display: flex; flex-direction: column; align-items: flex-start; min-width: 44px; padding: 0 14px 0 0; text-align: left; }
.chip b { font-size: 17px; font-weight: 600; }
.chip i { font-style: normal; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.role-root b { color: var(--accent); }
button.chip:hover b { text-decoration: underline; text-underline-offset: 3px; }

.play-box { display: flex; align-items: center; gap: 20px; }
.play { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border: 1px solid var(--ink); border-radius: 6px; font-weight: 500; }
.play:hover { background: var(--ink); color: var(--on-ink); }
.play svg { width: 14px; height: 14px; fill: currentColor; }
.play .i-stop { display: none; }
.play.playing { background: var(--ink); color: var(--on-ink); }
.play.playing .i-play { display: none; }
.play.playing .i-stop { display: inline; }
.tempo { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.tempo input { width: 110px; accent-color: var(--ink); }
.tempo output { font-variant-numeric: tabular-nums; min-width: 2.2em; color: var(--text); }

/* ---------- Fretboard ---------- */
.board-card { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 20px 0 14px; }
.board-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.board-scroll.vertical { overflow-x: hidden; overflow-y: auto; max-height: 72vh; display: flex; justify-content: center; }
#fretboard svg { display: block; }
#fretboard .fb-horizontal { width: 100%; min-width: 940px; height: auto; }
#fretboard .fb-vertical { width: min(100%, 400px); height: auto; }

.fb-wood { fill: var(--board); }
.fb-fret { fill: var(--fret); }
.fb-nut { fill: var(--nut); }
.fb-inlay { fill: var(--inlay); }
.fb-string { stroke: var(--string); }
.fb-fretnum { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.fb-fretnum.strong { fill: var(--text); }
.fb-openlabel { fill: var(--muted); font-size: 12px; font-weight: 500; }
.fb-mute { fill: var(--muted); font-size: 18px; }
.fb-barre { fill: none; stroke: var(--ink); stroke-width: 1.5; opacity: .5; }
.fb-cell { fill: transparent; cursor: pointer; }
.fb-cell:hover { fill: color-mix(in srgb, var(--ink) 7%, transparent); }

.fb-note { cursor: pointer; }
.fb-note circle { fill: var(--ink); stroke: var(--ink); stroke-width: 1.5; }
.fb-note text { font-size: 11.5px; font-weight: 600; fill: var(--on-ink); pointer-events: none; }
.fb-note text.small { font-size: 9.5px; }
.fb-note.role-root circle { fill: var(--accent); stroke: var(--accent); }
.fb-note.role-root text { fill: var(--on-accent); }
.fb-note.role-tension circle { fill: var(--board); }
.fb-note.role-tension text { fill: var(--ink); }
.fb-note.state-ghost circle { fill: var(--ghost); stroke: none; }
.fb-note.state-ghost.role-root circle { fill: color-mix(in srgb, var(--accent) 35%, var(--board)); }
.fb-note.state-ghost:hover circle { fill: var(--muted); }
.fb-note.playing circle { stroke: var(--accent); stroke-width: 3; }
.fb-note:not(.state-ghost):hover circle { stroke-width: 3; }
.interactive .fb-note { pointer-events: none; }

.legend { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); border: 1.5px solid var(--ink); }
.legend .role-root::before { background: var(--accent); border-color: var(--accent); }
.legend .role-tension::before { background: transparent; }
.legend .hint::before { background: var(--ghost); border-color: var(--ghost); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: space-between; margin-top: -8px; }
.positions { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.positions::-webkit-scrollbar { display: none; }
.pos-btn { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; min-width: 64px; padding: 6px 10px; border-radius: 6px; font-weight: 600; text-align: left; }
.pos-btn small { font-weight: 400; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pos-btn:hover { background: var(--subtle); }
.pos-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.pos-btn[aria-pressed="true"] small { color: inherit; opacity: .7; }
.control-group { display: flex; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.seg button { padding: 6px 12px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Chord shapes ---------- */
.finder-head, .namer-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.finder h2, .namer h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.finder-head p, .namer-head p { margin: 4px 0 0; font-size: 13px; }
.source-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.source-tabs button { position: relative; padding: 0 0 10px; font-size: 15px; font-weight: 500; color: var(--muted); }
.source-tabs button:hover { color: var(--text); }
.source-tabs button[aria-pressed="true"] { color: var(--text); }
.source-tabs button[aria-pressed="true"]::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); }
.source-tabs small { color: var(--muted); font-size: 12px; margin-left: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.group-head { grid-column: 1 / -1; padding: 14px 10px 8px; font-size: 13px; font-weight: 600; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--subtle); }
.group-head span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; }
.card:hover { background: var(--subtle); }
.card[aria-pressed="true"] { background: var(--subtle); box-shadow: inset 0 -2px 0 var(--ink); }
.card b { font-size: 14px; font-weight: 600; }
.card span { font-size: 12px; color: var(--muted); }
.card .frets { font-family: var(--mono); font-size: 12px; color: var(--text); letter-spacing: .06em; }
.cd { width: 104px; height: auto; margin: 2px 0 6px; }
.cd-fret { stroke: var(--line-strong); stroke-width: 1; }
.cd-string { stroke: var(--line-strong); stroke-width: 1; }
.cd-nut { fill: var(--ink); }
.cd-start { fill: var(--muted); font-size: 10px; }
.cd-mark { fill: var(--muted); font-size: 11px; }
.cd-open { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.cd-dot { fill: var(--ink); }
.cd-dot.root { fill: var(--accent); }
.cd-barre { fill: var(--ink); opacity: .9; }
.cd-finger { fill: var(--on-ink); font-size: 9px; font-weight: 700; }
.empty { grid-column: 1 / -1; padding: 32px; text-align: center; color: var(--muted); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.empty button { color: var(--text); text-decoration: underline; text-underline-offset: 3px; margin: 0 4px; }

/* ---------- Chord namer ---------- */
.namer-actions { display: flex; gap: 8px; }
.ghost-btn { height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; font-weight: 500; font-size: 14px; }
.ghost-btn:hover { border-color: var(--ink); }
.namer-body { display: grid; grid-template-columns: minmax(220px, 1fr) 2fr; gap: 40px; border-top: 1px solid var(--line); padding-top: 20px; }
.namer-result { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.namer-result .big { font-size: clamp(36px, 5vw, 56px); font-weight: 650; letter-spacing: -0.03em; line-height: 1; }
.namer-result .sub { color: var(--muted); font-size: 14px; }
.namer-result .sub b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.namer-result .ghost-btn { margin-top: 12px; }
.namer-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.namer-lists h3 { margin: 0 0 10px; font-size: 13px; font-weight: 500; color: var(--muted); }
.pill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.pill-list button { width: 100%; text-align: left; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.pill-list button:hover { text-decoration: underline; text-underline-offset: 3px; }
.pill-list .partial { color: var(--muted); }

/* ---------- Footer & toast ---------- */
.footer { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between; padding: 20px clamp(16px, 3vw, 40px); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.footer nav { display: flex; gap: 20px; flex-wrap: wrap; }
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--ink); color: var(--on-ink); padding: 9px 14px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; font-size: 13px; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 16px; border: 1px solid var(--line); }

/* ---------- Shortcut overview ---------- */
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; font: 500 12px/1.4 var(--font); text-align: center; color: var(--text); background: var(--surface); }
.help { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.help-panel { width: min(880px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 20px 48px rgba(0, 0, 0, .18); padding: 20px 24px 24px; }
.help-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.help-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 32px; }
.help h3 { margin: 12px 0 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.help dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: baseline; font-size: 14px; }
.help dt { white-space: nowrap; }
.help dd { margin: 0; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 0 16px; padding-top: 12px; }
  .brand { flex: 1; }
  .modes { order: 3; flex: 0 0 100%; height: 44px; gap: 22px; overflow-x: auto; scrollbar-width: none; }
  .modes button { flex: 0 0 auto; }
  .kbd-hint { display: none; }
  .namer-body { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 640px) {
  .stage { gap: 22px; padding-top: 20px; }
  .combo, .combo-btn { width: 100%; }
  .type-row { width: 100%; }
  .headline { align-items: flex-start; }
  .play-box { width: 100%; justify-content: space-between; }
  .tempo input { width: 90px; }
  .namer-lists { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .cd { width: 92px; }
  .control-group { width: 100%; }
  .filters { width: 100%; }
  .filters .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .filters .seg::-webkit-scrollbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
