/* ─────────────────────────────────────────────
   STROBE TUNER — stylesheet
   ───────────────────────────────────────────── */

:root {
  --bg:        #0e0e0f;
  --surface:   #161618;
  --surface2:  #1e1e21;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.13);
  --text:      #e8e6e0;
  --muted:     #6b6a66;
  --muted2:    #4a4948;
  --accent:    #d4a843;
  --green:     #2db882;
  --green-dim: #0e3326;
  --red:       #d94f4f;
  --mono:      'DM Mono', monospace;
  --sans:      'Instrument Sans', sans-serif;
  --radius:    10px;
  --radius-sm: 6px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100svh;
  padding:
    env(safe-area-inset-top,    0)
    env(safe-area-inset-right,  0)
    env(safe-area-inset-bottom, 0)
    env(safe-area-inset-left,   0);
}

/* ── LAYOUT ── */
#app {
  width: 100%;
  max-width: 520px;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 0 16px 24px;
}

/* ── TOP BAR ── */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 10px;
  flex-shrink: 0;
}
#topbar-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted2);
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 2px;
}
#topbar-spacer { flex: 1; }
#topbar-a4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--muted2);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}

/* ── TOPBAR PICKER DROPDOWNS ── */
.topbar-picker { position: relative; flex-shrink: 0; }

.picker-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 12px;
  font-size: 12px;
  border-radius: 99px;
  border: 0.5px solid var(--border2);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
  transition: all .12s;
  white-space: nowrap;
}
.picker-trigger:hover { border-color: var(--muted); }
.picker-trigger.open  { border-color: var(--accent); color: var(--accent); }
.picker-trigger svg {
  width: 10px; height: 10px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .15s;
  flex-shrink: 0;
}
.picker-trigger.open svg { transform: rotate(180deg); }
#disp-trigger { color: var(--accent); }
#disp-trigger:not(.open) { opacity: .85; }

.picker-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 100;
  min-width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  flex-direction: column;
  gap: 2px;
}
.picker-dropdown.open { display: flex; }
#disp-dropdown { left: auto; right: 0; }

.dropdown-item {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--sans);
  text-align: left;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.dropdown-item:hover  { background: var(--surface2); color: var(--text); }
.dropdown-item.active { color: var(--text); background: var(--surface2); }
#disp-dropdown .dropdown-item.active { color: var(--accent); }

/* ── SETTINGS BUTTON ── */
#settings-btn {
  width: 32px; height: 32px;
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
#settings-btn:hover  { background: var(--surface2); }
#settings-btn.active { border-color: var(--accent); background: var(--surface2); }
#settings-btn svg { stroke: var(--muted); transition: stroke .12s; }
#settings-btn.active svg { stroke: var(--accent); }

/* ── SETTINGS PANEL ── */
#settings-panel {
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#settings-panel.open { display: flex; }

.settings-section {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-divider { height: 0.5px; background: var(--border); }
.settings-section-title {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted2);
  margin-bottom: 2px;
}
.setting-row { display: flex; flex-direction: column; gap: 7px; }
.setting-label {
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}

/* Pills (inside settings panel) */
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 99px;
  border: 0.5px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--sans);
  transition: all .12s;
  white-space: nowrap;
}
.pill:hover  { border-color: var(--muted); color: var(--text); }
.pill.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* A4 stepper */
#a4-row { display: flex; align-items: center; justify-content: space-between; }
#a4-stepper {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.a4-btn {
  width: 34px; height: 34px;
  background: transparent; border: none;
  color: var(--muted); font-size: 17px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
  font-family: var(--mono); flex-shrink: 0;
}
.a4-btn:hover { background: var(--border); color: var(--text); }
#a4-val {
  font-family: var(--mono); font-size: 13px; color: var(--text);
  padding: 0 12px; white-space: nowrap; letter-spacing: .02em;
  min-width: 36px; text-align: center;
}
#a4-presets { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.a4-preset {
  padding: 3px 9px; font-size: 11px; border-radius: 99px;
  border: 0.5px solid var(--border2); background: transparent;
  color: var(--muted2); cursor: pointer; font-family: var(--mono);
  transition: all .12s;
}
.a4-preset:hover  { color: var(--text); border-color: var(--muted); }
.a4-preset.active { color: var(--accent); border-color: var(--accent); }

/* ── TUNING SUB-ROW ── */
#tuning-sub-row {
  display: none;
  gap: 5px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}
.tsub-pill {
  padding: 3px 10px; font-size: 11px; border-radius: 99px;
  border: 0.5px solid var(--border); background: transparent;
  color: var(--muted2); cursor: pointer; font-family: var(--sans);
  transition: all .12s; white-space: nowrap;
}
.tsub-pill:hover  { border-color: var(--muted); color: var(--muted); }
.tsub-pill.active { background: var(--surface2); color: var(--text); border-color: var(--border2); }

/* ── NOTE READOUT ── */
#note-readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 2px;
}
#note-name-wrap { display: flex; align-items: baseline; gap: 4px; line-height: 1; }
#note-name {
  font-family: var(--mono); font-size: 72px; font-weight: 300;
  color: var(--text); transition: color .15s;
  letter-spacing: -.02em; min-width: 56px;
}
#note-octave {
  font-family: var(--mono); font-size: 28px; font-weight: 300;
  color: var(--muted); padding-bottom: 8px;
}
#right-readout {
  text-align: right; display: flex; flex-direction: column;
  gap: 4px; align-items: flex-end;
}
#cents-readout {
  font-family: var(--mono); font-size: 28px; font-weight: 400;
  color: var(--muted); transition: color .15s; letter-spacing: -.01em;
}
#freq-readout {
  font-family: var(--mono); font-size: 12px;
  color: var(--muted2); letter-spacing: .04em;
}
#confidence-bar-wrap {
  display: block; width: 48px; height: 2px;
  background: var(--surface2); border-radius: 1px; overflow: hidden;
}
#confidence-bar {
  display: block; height: 100%; width: 0%; border-radius: 1px;
  background: var(--muted2); transition: width .08s linear, background .15s;
}

/* ── STROBE DISPLAY WRAPPER ── */
#strobe-wrap {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

/* Wheel */
#wheel-canvas { display: block; width: 100%; aspect-ratio: 1; max-height: 280px; margin: 0 auto; }

/* Columns */
#cols-wrap { display: grid; grid-template-columns: repeat(4,1fr); gap: 0; height: 220px; }
.col-band {
  position: relative; overflow: hidden;
  border-right: 0.5px solid var(--border);
}
.col-band:last-child { border-right: none; }
.col-band canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
.col-band-label {
  position: absolute; bottom: 7px; left: 0; right: 0;
  text-align: center; font-family: var(--mono); font-size: 9px;
  color: var(--muted2); pointer-events: none; z-index: 2; letter-spacing: .05em;
}

/* Needle */
#needle-wrap { padding: 16px 12px 12px; }
#needle-svg  { display: block; width: 100%; }

/* Spectrum */
#spectrum-canvas { display: block; width: 100%; height: 220px; }

/* ── TUNING BAR ── */
#tuning-bar-wrap { padding: 0 2px; }
#tuning-bar-track {
  height: 3px; background: var(--surface2);
  border-radius: 2px; position: relative;
}
#tuning-bar-fill {
  position: absolute; height: 100%; border-radius: 2px;
  top: 0; transition: background .15s;
}
#tuning-center-mark {
  position: absolute; left: 50%; top: -4px;
  width: 1px; height: 11px; background: var(--border2);
  transform: translateX(-50%);
}
#tuning-needle-dot {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  top: -3.5px; transform: translateX(-50%);
  transition: left .06s linear, background .15s; background: var(--text);
}
#tuning-labels {
  display: flex; justify-content: space-between; margin-top: 6px;
  font-family: var(--mono); font-size: 9px; color: var(--muted2);
}

/* ── STRING ROW ── */
#string-row {
  display: flex; justify-content: center;
  gap: 8px; flex-wrap: wrap; padding: 4px 0;
}
.str-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  border: 0.5px solid var(--border2); background: transparent;
  cursor: pointer; transition: all .15s; gap: 1px;
}
.str-btn .sn { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--muted); transition: color .15s; }
.str-btn .sf { font-family: var(--mono); font-size: 9px; color: var(--muted2); transition: color .15s; }
.str-btn:hover            { border-color: var(--muted); }
.str-btn:hover .sn        { color: var(--text); }
.str-btn.str-active       { border-color: var(--accent); }
.str-btn.str-active .sn   { color: var(--accent); }
.str-btn.str-active .sf   { color: var(--accent); opacity: .6; }
.str-btn.str-intune       { border-color: var(--green); background: var(--green-dim); }
.str-btn.str-intune .sn   { color: var(--green); }
.str-btn.str-intune .sf   { color: var(--green); opacity: .6; }

/* ── BOTTOM BAR ── */
#bottom-bar {
  display: flex; align-items: center; gap: 10px;
  margin-top: auto; padding-top: 16px; flex-shrink: 0;
}
#start-btn {
  flex: 1; height: 48px; border-radius: var(--radius);
  font-size: 15px; font-family: var(--sans);
  cursor: pointer; font-weight: 500; letter-spacing: .02em;
  transition: all .15s; border: 0.5px solid var(--border2);
  background: var(--surface); color: var(--text);
}
#start-btn:hover  { background: var(--surface2); }
#start-btn.active { background: var(--green-dim); border-color: var(--green); color: var(--green); }

#status-line {
  font-family: var(--mono); font-size: 11px; color: var(--muted2);
  text-align: center; margin-top: 6px; letter-spacing: .04em; min-height: 15px;
}

/* ── RESPONSIVE ── */
@media (min-height: 700px) {
  #wheel-canvas    { max-height: 320px; }
  #cols-wrap       { height: 260px; }
  #spectrum-canvas { height: 260px; }
}
@media (min-width: 420px) {
  #note-name    { font-size: 88px; }
  #cents-readout { font-size: 32px; }
}
