/* griff — light theme by default, dark theme via <html data-theme="dark">.
   Every color lives in the variables below; the rules further down only use them.
   The fretboard itself stays wood-colored in both themes. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f7f8fa;          /* buttons, inputs */
  --btn-hover: #eceef2;
  --btn-hover-line: #b9bec8;
  --line: #d9dce3;
  --text: #1d2129;
  --muted: #646b78;
  --accent: #f07c00;           /* griff orange: fills, lines */
  --accent-text: #b85c00;      /* orange that's readable as text */
  --on-bg: #fff1e0;            /* a pressed/selected button */
  --on-text: #9a4d00;
  --play-on-bg: #ffe2c2;
  --cursor: #1f86e0;
  --cursor-text: #1767b0;
  --ok: #23874d;
  --warn: #b26a00;
  --danger: #d93345;

  --fb-wrap: #ebe6de;          /* the area around the neck */
  --grid-bg: #ffffff;
  --grid-row: #ffffff;
  --grid-row-alt: #f6f7f9;
  --grid-sub: #eef0f3;
  --grid-beat: #d5d9e0;
  --grid-bar: #8a92a2;
  --grid-header: #eef0f4;
  --grid-header-hover: #e2e6ec;
  --cursor-zone: rgba(31, 134, 224, .10);
  --barsel-fill: rgba(240, 124, 0, .08);
  --barsel-line: rgba(240, 124, 0, .75);
  --note-line: rgba(0, 0, 0, .25);
  --note-selected: #1d2129;
  --dot-one-line: #d9a46a;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06);

  /* one color per finger: on the neck, the timeline and the legend */
  --f1: #4ea1ff;
  --f2: #3fc474;
  --f3: #ffae26;
  --f4: #ff5d6c;
  --fT: #b388ff;
  --fO: #e4e6ea;
  --fNone: #9aa0ac;

  --wood: #3a2416;
  --wood-edge: #2a190e;
  --fret: #c8c9cc;
  --nut: #efe6cf;
  --string: #d9d3c2;
  --wound: #c2a878;
  --inlay: #e8dcc0;
}

:root[data-theme="dark"] {
  --bg: #14161b;
  --panel: #1d2027;
  --panel-2: #252932;
  --btn-hover: #2d323c;
  --btn-hover-line: #4a5160;
  --line: #333845;
  --text: #e7e8ec;
  --muted: #9097a6;
  --accent: #ff8c1a;
  --accent-text: #ffb066;
  --on-bg: #3a2a18;
  --on-text: #ffd2a6;
  --play-on-bg: #4a2a10;
  --cursor: #3ea6ff;
  --cursor-text: #9fd0ff;
  --ok: #57c785;
  --warn: #f0b44c;
  --danger: #ff5d6c;

  --fb-wrap: #101216;
  --grid-bg: #15181e;
  --grid-row: #181b21;
  --grid-row-alt: #1c1f26;
  --grid-sub: #23272f;
  --grid-beat: #343a46;
  --grid-bar: #6a7284;
  --grid-header: #20242c;
  --grid-header-hover: #282d37;
  --cursor-zone: rgba(62, 166, 255, .12);
  --barsel-fill: rgba(255, 140, 26, .10);
  --barsel-line: rgba(255, 140, 26, .7);
  --note-line: rgba(0, 0, 0, .4);
  --note-selected: #ffffff;
  --dot-one-line: #6b5338;
  --shadow: none;

  --f2: #4cd07d;
  --f3: #ffb02e;
  --fO: #e9e9e9;
  --fNone: #8a8f9c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px 32px;
}

.mono { font-variant-numeric: tabular-nums; }

button, select, input[type=text], input[type=number] {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--btn-hover-line); background: var(--btn-hover); }
button:disabled { opacity: .4; cursor: default; }
button.on, button.toggle.on { background: var(--on-bg); border-color: var(--accent); color: var(--on-text); }
button.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
input[type=number] { width: 70px; }
input[type=checkbox] { accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 160px; vertical-align: middle; }
label { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
label input[type=text] { color: var(--text); }
kbd {
  font: 12px ui-monospace, Menlo, monospace;
  background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; margin: 0 1px; color: var(--text);
}

.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* ---------- layout ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; flex-wrap: wrap;
}
.brand { font-size: 24px; font-weight: 800; letter-spacing: -.5px; color: var(--accent); }
.tagline { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.library { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.library select { max-width: 260px; }
.save-status { font-size: 13px; margin-left: 6px; }
.save-status.ok { color: var(--ok); }
.save-status.warn { color: var(--warn); }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.riff-info, .practice { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.riff-info .grow { flex: 1 1 240px; }
.riff-info .grow input { flex: 1; min-width: 0; }

.practice .play { min-width: 96px; font-weight: 600; }
.practice .play.on { background: var(--play-on-bg); }

/* Docked to the bottom of the window: it never moves while the page scrolls.
   app.js pads the bottom of the page by the bar's height so nothing hides behind it. */
.player-bar {
  position: fixed; left: 16px; right: 16px; z-index: 20;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)); /* clear of the iPad's home indicator */
  margin: 0; gap: 10px 12px;
  box-shadow: 0 -2px 18px rgba(0, 0, 0, .14), var(--shadow);
}
.player-bar .play { min-width: 96px; padding: 7px 14px; }
.player-bar input[type=range] { width: 110px; }
.player-bar .speed span { min-width: 112px; }
.player-bar select { max-width: 210px; }
.player-bar .position { min-width: 104px; }
.beat-pos { display: flex; align-items: center; gap: 12px; margin-left: auto; white-space: nowrap; }
.beat-pos .beat-dots { margin-left: 0; }
@media (max-width: 900px) {
  .player-bar { gap: 8px 12px; padding: 8px 10px; }
  .player-bar .position { min-width: 0; }
}
.speed span { min-width: 120px; color: var(--text); }

.beat-dots { display: flex; gap: 6px; margin-left: auto; }
.beat-dots .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--line);
}
.beat-dots .dot-one { border-color: var(--dot-one-line); }
.beat-dots .dot.lit { background: var(--cursor); border-color: var(--cursor); }
.beat-dots .dot-one.lit { background: var(--accent); border-color: var(--accent); }
.position { min-width: 150px; text-align: right; color: var(--text); }

/* ---------- fretboard ---------- */

.fretboard-wrap {
  position: relative;
  background: var(--fb-wrap); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 10px 8px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.fb-svg { display: block; width: 100%; height: auto; user-select: none; }
.fb-neck { fill: var(--wood); stroke: var(--wood-edge); stroke-width: 2; }
.fb-head { fill: #24160c; stroke: var(--wood-edge); stroke-width: 2; }
.fb-inlay { fill: var(--inlay); opacity: .55; }
.fb-fret { stroke: var(--fret); stroke-width: 3; }
.fb-nut { fill: var(--nut); }
.fb-string { stroke: var(--string); }
.fb-wound { stroke: var(--wound); }
.fb-fretnum { fill: var(--muted); font-size: 13px; text-anchor: middle; }
.fb-fretnum-dot { fill: var(--text); font-weight: 700; }
.fb-strlabel { fill: var(--text); font-size: 16px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.fb-hit { fill: transparent; cursor: pointer; }
.fb-markers, .fb-hover { pointer-events: none; }

/* markers sit on the wood, so these colors are the same in both themes */
.fb-hover circle { fill: rgba(62, 166, 255, .25); stroke: #3ea6ff; stroke-width: 2; stroke-dasharray: 3 3; }
.fb-hover text { fill: #cfe8ff; font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
/* capo: a dark rubber-covered bar; the neck behind it is dimmed because it can't be played */
.fb-behind-capo { fill: rgba(0, 0, 0, .38); pointer-events: none; }
.fb-capo { fill: #1d1d22; stroke: #55555f; stroke-width: 1.5; pointer-events: none; }
.fb-capo-label { fill: var(--text); font-size: 12px; font-weight: 700; text-anchor: middle; letter-spacing: .3px; }
.fb-hover-blocked circle { fill: rgba(220, 60, 60, .2); stroke: #e05555; }
.fb-hover-blocked text { fill: #ffd0d0; }

.finger-1 { --fc: var(--f1); }
.finger-2 { --fc: var(--f2); }
.finger-3 { --fc: var(--f3); }
.finger-4 { --fc: var(--f4); }
.finger-T { --fc: var(--fT); }
.finger-open { --fc: var(--fO); }
.finger-none { --fc: var(--fNone); }

.fb-marker text { font-size: 15px; font-weight: 800; text-anchor: middle; dominant-baseline: central; }

.fb-current .fb-marker-body circle { fill: var(--fc); stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 0 6px var(--fc)); }
.fb-current .fb-marker-body text { fill: #111; }
.fb-current .fb-marker-body { animation: pop .18s ease-out; transform-box: fill-box; transform-origin: center; }

.fb-next .fb-marker-body circle { fill: rgba(16, 18, 22, .75); stroke: var(--fc); stroke-width: 2.5; stroke-dasharray: 4 3; }
.fb-next .fb-marker-body text { fill: var(--fc); }

.fb-prev .fb-marker-body circle { fill: rgba(140, 145, 155, .35); stroke: rgba(200, 200, 210, .5); stroke-width: 1.5; }
.fb-prev .fb-marker-body text { fill: rgba(235, 235, 240, .75); }

.fb-selected-ring { fill: none; stroke: #3ea6ff; stroke-width: 2.5; }

@keyframes pop {
  from { transform: scale(1.45); }
  to { transform: scale(1); }
}

.countin {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 120px; font-weight: 800; color: rgba(255, 140, 26, .9);
  text-shadow: 0 4px 24px rgba(0, 0, 0, .6); pointer-events: none;
}
[hidden] { display: none !important; }

.fb-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 2px 6px 0; min-height: 22px; flex-wrap: wrap; }
.hover-info { color: var(--cursor-text); font-size: 13px; font-weight: 600; }
.legend { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lg {
  display: inline-flex; width: 18px; height: 18px; border-radius: 50%; align-items: center; justify-content: center;
  background: var(--fc); color: #111; font-weight: 800; font-size: 11px; margin-left: 8px;
  border: 1px solid var(--note-line);
}
.lg-next { background: transparent; border: 2px dashed var(--muted); color: var(--muted); }
.lg-block { border-radius: 4px; width: 20px; }
.timeline-key { margin: 2px 0 6px; }
.timeline-key .tb-label { margin-right: 2px; }
.timeline-key .key-note { margin-left: 6px; }

/* ---------- editor ---------- */

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.tb-label { color: var(--muted); margin-right: 2px; }
.tb-label.muted { font-style: italic; }
.seg { display: inline-flex; align-items: center; gap: 3px; }
.seg button { padding: 4px 9px; min-width: 34px; }
.seg button.on[class*="finger-"] { background: var(--fc); border-color: var(--fc); color: #111; }

.grid-wrap {
  overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 8px;
  background: var(--grid-bg);
}
.grid-svg { display: block; font-size: 12px; user-select: none; cursor: crosshair; }
.g-row { fill: var(--grid-row); }
.g-row-alt { fill: var(--grid-row-alt); }
.g-label { fill: var(--text); font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.g-labelbg { fill: var(--grid-bg); stroke: var(--line); }
.g-labels { pointer-events: none; }
.g-sub { stroke: var(--grid-sub); stroke-width: 1; }
.g-beat { stroke: var(--grid-beat); stroke-width: 1; }
.g-bar { stroke: var(--grid-bar); stroke-width: 2; }
.g-header { fill: var(--grid-header); cursor: pointer; }
.g-header:hover { fill: var(--grid-header-hover); }
.g-barnum { fill: var(--muted); font-size: 11px; font-weight: 700; pointer-events: none; }
.g-strum { fill: var(--accent-text); font-size: 14px; font-weight: 700; pointer-events: none; }
.g-chordname { fill: var(--text); font-size: 12px; font-weight: 700; pointer-events: none; }
.chord-words { font-weight: 700; color: var(--accent-text); white-space: nowrap; min-width: 150px; }
.chord-tools select#chord-voicing { min-width: 230px; font-variant-numeric: tabular-nums; }
.g-barsel { fill: var(--barsel-fill); stroke: var(--barsel-line); stroke-width: 1.5; pointer-events: none; }
.g-cursor { stroke: var(--cursor); stroke-width: 2; }
.g-cursor-zone { fill: var(--cursor-zone); }
.g-playhead { stroke: var(--accent); stroke-width: 2.5; }
.g-note { cursor: pointer; }
.g-note rect { fill: var(--fc); opacity: .88; stroke: var(--note-line); }
.g-note text { fill: #111; font-weight: 800; dominant-baseline: central; pointer-events: none; }
.g-note:hover rect { opacity: 1; }
.g-note text.g-finger { font-size: 10px; font-weight: 800; text-anchor: end; opacity: .85; }
.g-note text.g-finger-auto { font-weight: 600; opacity: .6; }
.g-selected rect { stroke: var(--note-selected); stroke-width: 2.5; opacity: 1; }

.selection-panel { margin-top: 10px; min-height: 64px; }
.selection-panel .hint { color: var(--muted); margin: 6px 0; }
.sel-info { margin-bottom: 8px; }
.sel-info .pitch { color: var(--accent-text); font-weight: 700; }
.sel-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.help { margin-top: 10px; color: var(--muted); }
.help summary { cursor: pointer; color: var(--text); }
.help ol { padding-left: 20px; }
.help li { margin: 4px 0; }
.help b { color: var(--text); }
.help .keys { line-height: 2; }

body.is-playing .fb-hit { cursor: default; }

/* ---------- bars: selection, copy/paste, play scope ---------- */

.bar-tools { padding-top: 8px; border-top: 1px solid var(--line); }
.bar-tools input[type=number] { width: 58px; }
.bar-info { color: var(--muted); min-width: 250px; }
.bar-info.on { color: var(--on-text); font-weight: 600; }
.play-scope { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.play-scope.on { color: var(--on-text); font-weight: 600; }
button.mini { padding: 0 6px; font-size: 12px; line-height: 18px; }

/* ---------- touch screens (tablets) ---------- */
/* No double-tap zoom on controls, the neck or the timeline (and no tap delay). */
button, select, input, label, .fb-svg, .grid-svg { touch-action: manipulation; }
html.touch { -webkit-tap-highlight-color: transparent; }
html.touch .fb-svg, html.touch .grid-svg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* Finger-sized controls: about 44 px, Apple's and Google's guidance for tap targets. */
html.touch button, html.touch select, html.touch input[type=text], html.touch input[type=number] {
  min-height: 42px; padding: 8px 12px;
}
html.touch .seg button { min-width: 44px; }
html.touch input[type=checkbox] { width: 22px; height: 22px; }
html.touch input[type=range] { height: 36px; }
html.touch label { gap: 8px; }
.sel-done { margin-left: 12px; }
