:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}

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

html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: flex; flex-direction: column;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

/* ---- Header ---- */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid #2a2a3a;
  min-height: 64px;
}
.app-header h1 {
  font-size: 24px; font-weight: 700; letter-spacing: 0.3px;
  flex: 1;
}
.hint {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Body ---- */
.screen-body {
  flex: 1; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
  overflow: hidden;
}
.foot-hint {
  margin-top: auto;
  text-align: center;
  font-size: 13px; color: var(--text-muted);
}

/* ---- Home menu ---- */
.menu { display: flex; flex-direction: column; gap: 14px; }
.menu-btn {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-height: 92px;
  padding: 14px 20px;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  text-align: left;
  color: var(--text-primary);
}
.menu-title { font-size: 22px; font-weight: 600; }
.menu-desc { font-size: 14px; color: var(--text-secondary); }

/* ---- Reference ---- */
.readout {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}
.readout-note { font-size: 56px; font-weight: 700; line-height: 1; }
.readout-freq { font-size: 26px; color: var(--accent); margin-top: 6px; font-variant-numeric: tabular-nums; }

.note-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.note-btn {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-primary);
}
.note-name { font-size: 22px; font-weight: 600; }
.note-freq { font-size: 12px; color: var(--text-secondary); margin-top: 2px; font-variant-numeric: tabular-nums; }
.note-btn.playing {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 18px rgba(0, 255, 136, 0.45);
}
.note-btn.playing .note-name { color: var(--accent-secondary); }

.oct-row {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.oct-btn {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-width: 96px; min-height: 56px;
  font-size: 20px; font-weight: 600;
  color: var(--text-primary);
}
.oct-display { font-size: 18px; color: var(--text-secondary); }
.oct-display strong { color: var(--text-primary); font-size: 22px; }

/* ---- Listen ---- */
.listen-body { align-items: center; justify-content: flex-start; gap: 12px; padding-top: 24px; }
.tuner-note {
  font-size: 92px; font-weight: 700; line-height: 1;
  color: var(--text-primary);
  transition: color 0.12s ease, text-shadow 0.12s ease;
}
.tuner-note.in-tune {
  color: var(--accent-secondary);
  text-shadow: 0 0 26px rgba(0, 255, 136, 0.6);
}
.tuner-freq { font-size: 24px; color: var(--accent); font-variant-numeric: tabular-nums; }

.meter {
  position: relative;
  width: 90%; height: 64px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-top: 6px;
  overflow: hidden;
}
.meter-zone {
  position: absolute; top: 0; bottom: 0;
  left: 45%; width: 10%;
  background: rgba(0, 255, 136, 0.15);
  border-left: 1px solid rgba(0, 255, 136, 0.4);
  border-right: 1px solid rgba(0, 255, 136, 0.4);
}
.meter-center {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px;
  background: var(--accent-secondary);
}
.needle {
  position: absolute; top: 6px; bottom: 6px;
  left: 50%; width: 5px; margin-left: -2.5px;
  background: var(--text-primary);
  border-radius: 3px;
  transition: left 0.08s linear, background 0.12s ease, box-shadow 0.12s ease;
}
.needle.good {
  background: var(--accent-secondary);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.7);
}
.meter-label {
  position: absolute; bottom: 4px;
  font-size: 11px; color: var(--text-muted);
}
.meter-label.left { left: 8px; }
.meter-label.mid { left: 50%; transform: translateX(-50%); }
.meter-label.right { right: 8px; }

.tuner-cents { font-size: 30px; font-weight: 600; min-height: 36px; font-variant-numeric: tabular-nums; }
.tuner-status { font-size: 15px; color: var(--text-secondary); text-align: center; min-height: 20px; }

.btn-primary {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-height: 88px; width: 90%;
  font-size: 22px; font-weight: 600;
  color: var(--text-primary);
  margin-top: auto;
}

/* ---- Settings ---- */
.setting-block {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.setting-label { font-size: 17px; color: var(--text-secondary); }
.stepper-row { display: flex; align-items: center; justify-content: center; gap: 18px; }
.a4-value { font-size: 30px; font-weight: 700; min-width: 130px; text-align: center; font-variant-numeric: tabular-nums; }
.preset-row { display: flex; gap: 12px; }
.chip {
  flex: 1;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-height: 56px;
  font-size: 18px; font-weight: 600;
  color: var(--text-primary);
}
.chip.active {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  color: var(--accent);
}

/* ---- Help ---- */
.help-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.help-list li {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 16px; line-height: 1.4;
  color: var(--text-secondary);
}
.help-list strong { color: var(--text-primary); }
