/* Chordli
   Colours are set by js/app.js from the chosen background, so every screen stays readable
   on light or dark colours. These are the light defaults used before the script runs. */

:root {
  --bg: #FFFFFF;
  --ink: #1C2230;
  --ink-2: #586170;
  --grid: #A3AAB5;
  --line: #DCDFE4;
  --panel: #F6F7F8;
  --control: #EDEEF0;
  --control-strong: #E2E4E7;
  --root: #1F5E8C;
  --on-root: #FFFFFF;
  --on-ink: #FFFFFF;
  --selection: #E4ECF3;
  --font: "Avenir Next", Avenir, "Nunito Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-s: 8px;
  --radius-m: 12px;
  --topbar: 56px;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--root); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--root); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.icon { display: inline-flex; width: 1.3em; height: 1.3em; flex: none; }
.icon svg {
  width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon svg .solid { fill: currentColor; stroke: none; }

/* ---------------------------------------------------------------- Top bar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.nylo {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 10px 0 6px;
  border-radius: var(--radius-s);
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 600;
}
.nylo:hover { background: var(--control); }

.brand {
  color: var(--ink); text-decoration: none;
  font-size: 21px; font-weight: 800; letter-spacing: -0.02em;
  padding-left: 12px; border-left: 1px solid var(--line);
}

.instruments, .mode-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--control); border-radius: 10px;
}
.instruments { margin-left: auto; }
.instruments a, .mode-switch a {
  padding: 6px 14px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 15px;
}
.instruments a[aria-current], .mode-switch a[aria-current] {
  background: var(--bg); color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.settings-button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px;
  border: 0; border-radius: var(--radius-s);
  background: transparent; font-weight: 600; font-size: 15px;
}
.settings-button { margin-left: auto; }
.instruments + .settings-button { margin-left: 0; }
.settings-button:hover { background: var(--control); }

/* ---------------------------------------------------------------- Home */

.home {
  max-width: 1120px; margin: 0 auto;
  padding: clamp(32px, 7vw, 88px) max(20px, env(safe-area-inset-right, 0px)) 48px max(20px, env(safe-area-inset-left, 0px));
}

.wordmark {
  font-size: clamp(64px, 14vw, 152px);
  font-weight: 800; letter-spacing: -0.045em; line-height: 0.9;
}
.lede {
  margin-top: 20px; max-width: 30ch;
  font-size: clamp(20px, 2.6vw, 28px); line-height: 1.3; color: var(--ink-2);
}

.choices {
  display: grid; grid-template-columns: 1fr; gap: 24px;
  margin-top: clamp(36px, 6vw, 72px);
}
@media (min-width: 760px) { .choices { grid-template-columns: 1fr 1fr; gap: 32px; } }

.choice {
  display: flex; flex-direction: column;
  color: inherit; text-decoration: none;
  border-top: 3px solid var(--ink);
}
.choice-art {
  display: flex; align-items: center; justify-content: center;
  height: clamp(200px, 24vw, 260px); padding: 20px;
  background: var(--panel);
}
.choice-art svg { max-height: 100%; width: auto; max-width: 100%; }
.guitar-art svg { height: 100%; }
.bass-art { padding: 20px 12px; }
.bass-art svg { width: 100%; height: auto; pointer-events: none; }
.choice-text { padding: 20px 2px 0; }
.choice-text h2 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.choice-text p { margin-top: 6px; max-width: 46ch; color: var(--ink-2); font-size: 17px; }
.choice-go {
  display: inline-block; margin-top: 16px; padding: 10px 16px;
  border-radius: var(--radius-s); background: var(--ink); color: var(--bg);
  font-weight: 700; font-size: 15px;
}
.choice:hover .choice-go, .choice:focus-visible .choice-go { background: var(--root); color: var(--on-root); }

.home-footer { margin-top: 64px; color: var(--ink-2); font-size: 14px; }

/* ---------------------------------------------------------------- Workspace: list beside page */

.workspace {
  display: grid; grid-template-columns: minmax(250px, 300px) 1fr;
  height: calc(100vh - var(--topbar) - env(safe-area-inset-top, 0px));
  height: calc(100dvh - var(--topbar) - env(safe-area-inset-top, 0px));
}

.list-pane {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line);
}
.list-top { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 0; }
.list-top .mode-switch { align-self: stretch; }
.list-top .mode-switch a { flex: 1; text-align: center; }
.search { padding: 14px 14px 8px; }
.list-top .search { padding: 0 0 8px; }
.search input {
  width: 100%; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg);
}
.list-body {
  flex: 1; overflow-y: auto; padding: 4px 0 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
.list-group { padding: 6px 0; }
.list-heading { padding: 10px 18px 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.list-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 18px; color: var(--ink); text-decoration: none;
}
.list-row:hover { background: var(--control); }
.list-row[aria-current] { background: var(--selection); }
.list-row[aria-current] .row-name { font-weight: 700; }
.row-symbol { color: var(--ink-2); font-size: 15px; }
.list-row.jump { color: var(--root); font-weight: 700; }
.list-empty { padding: 12px 18px; color: var(--ink-2); font-size: 15px; }

.page-pane { overflow-y: auto; min-width: 0; }
.page {
  padding: 28px clamp(20px, 3vw, 40px) 56px;
  padding-bottom: max(56px, env(safe-area-inset-bottom, 0px));
  max-width: 1200px;
}
.back-link { display: none; }

/* ---------------------------------------------------------------- Chord heading and controls */

.chord-head .symbol {
  font-size: clamp(52px, 7vw, 80px); font-weight: 700;
  letter-spacing: -0.03em; line-height: 1;
}
.chord-head .quality { margin-top: 8px; font-size: 18px; color: var(--ink-2); }
.chord-head .relative { margin-top: 4px; font-size: 16px; color: var(--ink-2); }

.tones { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 18px 0 0; padding: 0; list-style: none; }
.tones li { display: flex; flex-direction: column; align-items: center; min-width: 2ch; }
.tone-note { font-size: 21px; font-weight: 700; }
.tone-label { font-size: 13px; color: var(--ink-2); }
.tones .is-root .tone-note { color: var(--root); }

.controls { display: flex; flex-direction: column; gap: 14px; margin-top: 26px; }

.roots { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; max-width: 760px; }
.root-button {
  min-height: 40px; padding: 0 2px;
  border: 0; border-radius: var(--radius-s);
  background: var(--control); font-weight: 700; font-size: 16px;
}
.root-button:hover { background: var(--control-strong); }
.root-button[aria-pressed="true"] { background: var(--root); color: var(--on-root); }

.control-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--control); border-radius: 10px; }
.segmented button {
  min-height: 34px; padding: 0 14px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--ink-2); font-weight: 600; font-size: 15px;
}
.segmented button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.select-field { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.select-field select {
  min-height: 40px; padding: 0 30px 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg); color: var(--ink); font-weight: 600;
}

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 36px 0 16px; }
.section-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.hint { color: var(--ink-2); font-size: 15px; max-width: 70ch; }
.empty { color: var(--ink-2); max-width: 60ch; }

/* ---------------------------------------------------------------- Guitar shapes */

.shape-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 16px;
}
.shape { position: relative; text-align: center; }
.shape-play {
  display: block; width: 100%; padding: 8px 8px 4px;
  border: 1.5px solid transparent; border-radius: var(--radius-m);
  background: transparent;
}
.shape-play:hover { background: var(--panel); }
.shape.selected .shape-play { border-color: var(--root); background: var(--selection); }
.shape-play svg { display: block; width: 100%; height: auto; }
.shape-meta { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; margin-top: 4px; }
.shape-text { grid-column: 2; display: flex; flex-direction: column; min-width: 0; }
.shape-position { font-weight: 700; font-size: 15px; }
.shape-tab { font-size: 14px; color: var(--ink-2); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.shape-enlarge {
  grid-column: 3;
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink-2);
}
.shape-enlarge:hover { background: var(--control); color: var(--ink); }

/* Chord box colours */
.cb-wire { stroke: var(--grid); stroke-width: 1; }
.cb-string { stroke: var(--ink); opacity: 0.75; }
.cb-nut, .cb-barre, .cb-dot { fill: var(--ink); }
.cb-dot.root { fill: var(--root); }
.cb-fretnum { fill: var(--ink-2); font-weight: 600; }
.cb-mute { stroke: var(--ink-2); stroke-width: 1.4; fill: none; }
.cb-open { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.cb-open.root { stroke: var(--root); stroke-width: 2; }
.cb-dot-label { fill: var(--on-ink); font-weight: 700; }
.cb-dot-label.root { fill: var(--on-root); }
.cb-open-label { fill: var(--ink-2); font-weight: 700; }
.cb-open-label.root { fill: var(--root); }

/* ---------------------------------------------------------------- Bass neck */

.neck-section { margin-top: 28px; }
.neck-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.summary { font-size: 18px; font-weight: 600; max-width: 70ch; }
.extremes { display: flex; flex-wrap: wrap; gap: 2px 24px; color: var(--ink); font-size: 15px; }
.tapped { min-height: 1.5em; color: var(--root); font-weight: 700; }

.neck-holder { width: 100%; overflow-x: auto; }
.neck-holder svg { display: block; margin: 0 auto; max-width: none; }

.neck.finish-rosewood {
  --board: #3B2921; --fret: #C9CED4; --nut: #EEE7D7; --inlay: #E9E2D0; --string: #D7DADF;
  --n-root: #3F9BE0; --n-on-root: #FFFFFF; --n-tone: #F2EEE5; --n-on-tone: #1C2230; --n-ring: #FFFFFF;
}
.neck.finish-maple {
  --board: #E5C690; --fret: #8A9099; --nut: #F7F1E3; --inlay: #2B2622; --string: #6F757E;
  --n-root: #1F5E8C; --n-on-root: #FFFFFF; --n-tone: #2B2622; --n-on-tone: #FFFFFF; --n-ring: #2B2622;
}
.neck.finish-plain {
  --board: var(--control); --fret: var(--grid); --nut: var(--ink); --inlay: var(--grid); --string: var(--ink);
  --n-root: var(--root); --n-on-root: var(--on-root); --n-tone: var(--ink); --n-on-tone: var(--on-ink); --n-ring: var(--ink);
}
.nk-board { fill: var(--board); }
.nk-fret { stroke: var(--fret); stroke-width: 1.8; }
.nk-nut { stroke: var(--nut); stroke-width: 6; }
.nk-inlay { fill: var(--inlay); opacity: 0.85; }
.nk-string { stroke: var(--string); }
.finish-plain .nk-string { opacity: 0.6; }
.nk-name { fill: var(--ink-2); font-weight: 700; }
.nk-number { fill: var(--ink-2); }
.nk-number.marked { fill: var(--ink); font-weight: 700; }
.nk-ring { fill: none; stroke-width: 2; }
.nk-dot-label { font-weight: 700; pointer-events: none; }
.nk-note { cursor: pointer; outline: none; }
.nk-note.dim { opacity: 0.16; }
.nk-note:focus-visible .nk-dot { stroke: var(--root); stroke-width: 3; }

/* Scale degrees */
.degree-section { margin-top: 24px; }
.degrees { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.degree {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 62px; height: 58px;
  border: 2px solid var(--c); border-radius: var(--radius-m);
  background: var(--c); color: var(--t);
}
.degree.is-root { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.degree-label { font-size: 19px; font-weight: 800; line-height: 1.1; }
.degree-note { font-size: 13px; font-weight: 700; }
.degree.dimmed { background: transparent; border-style: dashed; color: var(--ink-2); }
.show-all { margin-left: 8px; }

/* ---------------------------------------------------------------- Buttons and dialogs */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--bg); font-weight: 700; font-size: 15px;
}
.button:hover { background: var(--control); }
.button.primary { background: var(--root); border-color: var(--root); color: var(--on-root); }
.button:disabled { opacity: 0.4; cursor: default; }
.icon-button {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--radius-s); background: transparent; font-size: 18px;
}
.icon-button:hover { background: var(--control); }

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 16px;
  background: var(--bg); color: var(--ink);
  box-shadow: 0 24px 60px rgba(15, 20, 30, 0.28);
}
dialog::backdrop { background: rgba(12, 16, 24, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }

.viewer-inner { padding: 18px 22px 22px; }
.viewer-art { margin: 8px auto 0; max-width: 340px; touch-action: pan-y; }
.viewer-art svg { display: block; width: 100%; height: auto; }
.viewer-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 20px; justify-content: center; margin: 12px 0 0; text-align: center; }
.viewer-facts dt { font-size: 13px; color: var(--ink-2); }
.viewer-facts dd { margin: 0; font-weight: 700; }
.viewer-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.viewer-count { min-width: 7ch; text-align: center; color: var(--ink-2); font-weight: 600; }
.viewer-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

.settings-inner { padding: 20px 22px 22px; }
.settings-note { margin-top: 2px; font-size: 14px; color: var(--ink-2); }
.settings section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.settings h3 { font-size: 18px; font-weight: 700; }
.choice-group { margin: 14px 0 0; padding: 0; border: 0; }
.choice-group legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.choice-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.choice-group.inline .choice-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.option {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-s); cursor: pointer;
}
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border-color: var(--root); box-shadow: inset 0 0 0 1px var(--root); background: var(--selection); }
.option:has(input:focus-visible) { outline: 2px solid var(--root); outline-offset: 2px; }
.swatch {
  width: 22px; height: 22px; flex: none; border-radius: 50%;
  border: 1px solid var(--grid);
  background: linear-gradient(135deg, #FFFFFF 50%, #1A1D23 50%);
}
.fonts .option-name { font-size: 17px; }
.colour-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); font-weight: 600; }
.colour-field.active { border-color: var(--root); box-shadow: inset 0 0 0 1px var(--root); background: var(--selection); }
.colour-field input { width: 52px; height: 32px; padding: 0; border: 0; background: none; }
.field-help { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 12px; cursor: pointer;
}
.toggle-text { display: flex; flex-direction: column; font-weight: 600; }
.toggle-help { font-weight: 400; font-size: 14px; color: var(--ink-2); }
.toggle input { width: 22px; height: 22px; accent-color: var(--root); flex: none; }
.settings-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 24px; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); z-index: 50;
  padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 700;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- Narrow screens: list, then page */

@media (max-width: 759px) {
  :root { --topbar: 52px; }
  .topbar { gap: 8px; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
  .nylo-name, .settings-name { display: none; }
  .nylo { padding: 0 8px; }
  .settings-button { padding: 0 8px; }
  .brand { font-size: 19px; padding-left: 10px; }
  .instruments a { padding: 6px 10px; font-size: 14px; }

  .workspace { display: block; height: auto; }
  .workspace.show-page .list-pane { display: none; }
  .workspace.show-list .page-pane { display: none; }
  .list-pane { border-right: 0; min-height: calc(100dvh - var(--topbar)); }
  .list-body { overflow: visible; }
  .page-pane { overflow: visible; }
  .page { padding: 12px 16px 48px; }
  .back-link {
    display: inline-flex; align-items: center; gap: 2px;
    margin: 0 0 8px -6px; padding: 6px 8px 6px 2px; border-radius: var(--radius-s);
    font-weight: 700; text-decoration: none;
  }
  .roots { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .control-row .segmented { flex: 1 1 100%; }
  .control-row .segmented button { flex: 1; padding: 0 8px; }
  .shape-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 10px; }
  .degree { width: calc((100% - 48px) / 7); min-width: 40px; height: 54px; }
  .degree-label { font-size: 16px; }
  .degree-note { font-size: 12px; }
  .show-all { margin-left: 0; }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .settings-inner, .viewer-inner { padding: 16px; }
  .viewer-facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
