: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 {
  padding: 18px 24px 12px;
  border-bottom: 1px solid #23233a;
  background: var(--bg-primary);
  flex: 0 0 auto;
}
.app-header h1 { font-size: 26px; font-weight: 700; letter-spacing: 0.4px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 3px; }

/* ---------- Toolbar (home) ---------- */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid #23233a;
}
.tbtn {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 700;
}
.oct-readout {
  flex: 1 1 auto;
  text-align: center;
  font-size: 15px;
  color: var(--text-secondary);
}
.oct-readout b { color: var(--text-primary); font-size: 18px; }
.menu-pill { margin-left: 2px; }

/* ---------- Readout (home) ---------- */
.readout {
  flex: 0 0 auto;
  padding: 12px 24px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid #23233a;
}
.ro-note {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--accent);
}
.ro-sub {
  margin-top: 6px;
  font-size: 16px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ---------- Keyboard (home) ---------- */
.kbd-wrap {
  flex: 1 1 auto;
  padding: 16px 16px 10px;
  display: flex;
  align-items: stretch;
  min-height: 0;
}
.keyboard {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
}
.white-row {
  display: flex;
  gap: 0;
  height: 100%;
  width: 100%;
}
.black-row {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 62%;
  pointer-events: none;
}
.key {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
}
.key.white {
  flex: 1 1 0;
  height: 100%;
  background: linear-gradient(#eef0f6, #d2d5e0);
  border-radius: 0 0 8px 8px;
  padding-bottom: 14px;
  border-right: 2px solid #b6b9c6;
}
.white-row .key.white:last-child { border-right: 0; }
.key.white .key-label {
  color: #15151d;
  font-weight: 800;
  font-size: 20px;
}
.key.black {
  position: absolute;
  top: 0;
  width: 46px;
  height: 100%;
  background: linear-gradient(#2a2a36, #131319);
  border-radius: 0 0 7px 7px;
  padding-bottom: 9px;
  z-index: 3;
}
.key.black .key-label {
  color: #d6d9e6;
  font-weight: 700;
  font-size: 13px;
}
.key.white.playing { background: linear-gradient(#c7ecff, #8ad4f2); }
.key.black.playing { background: linear-gradient(#1f7fa6, #0f5570); }
/* Focus must win over playing/base for visibility */
.key:focus { z-index: 5; }
.key.white:focus { border-color: var(--focus-ring); }

.hint {
  flex: 0 0 auto;
  padding: 9px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-top: 1px solid #23233a;
}

/* ---------- Menu list ---------- */
.list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.menu-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  width: 100%;
  min-height: 72px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border-left: 5px solid var(--accent);
  justify-content: center;
}
.mc-title { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.mc-title b { color: var(--accent-secondary); }
.mc-sub { font-size: 14px; color: var(--text-secondary); }
.menu-card.back { border-left-color: var(--text-muted); min-height: 60px; }

/* ---------- Guide ---------- */
.gloss-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gcard {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent);
}
.gloss-term { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.gloss-def { margin-top: 5px; font-size: 14px; line-height: 1.45; color: var(--text-secondary); }

/* ---------- Intervals ---------- */
.iv-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.iv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-secondary);
}
.iv-name { flex: 1 1 auto; font-size: 16px; font-weight: 600; color: var(--text-primary); }
.iv-meta { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.iv-note {
  min-width: 58px;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- Nav bar ---------- */
.navbar {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 12px 18px 16px;
  background: var(--bg-primary);
  border-top: 1px solid #23233a;
}
.navbtn {
  flex: 1 1 0;
  min-height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}
.navbtn.wide { flex: 1 1 100%; }
