:root {
  /* Playground (light) defaults — applyTheme() overrides these per theme.
     Keeping them here avoids a flash of unstyled colour before JS runs. */
  --bg:        #fff7ea;
  --surface:   #fff1d8;
  --panel:     #ffffff;
  --border:    #2a2150;
  --border-hi: #2a2150;
  --brass:     #7c5cff;
  --brass-hi:  #9a7dff;
  --brass-deep:#5a3fd6;
  --brass-glow:rgba(124,92,255,0.16);
  --brass-glow-hi:rgba(124,92,255,0.5);
  --shadow-soft:rgba(124,92,255,0.20);
  --cream:     #2a2150;
  --cream-dim: #5a5080;
  --muted:     #a99fc9;
  --red:       #ff6b81;
  --red-hi:    #ff506c;
  --green:     #3ddc97;
  --green-hi:  #23c684;
  --lcd:       #7c5cff;
  --lcd-bg:    #2a2150;
  --lcd-border:#1d1640;
  --lcd-glow:  rgba(124,92,255,0.7);
  --lcd-glow-far: rgba(124,92,255,0.3);
  --lcd-ghost: rgba(124,92,255,0.14);

  --font-body:    'Nunito', system-ui, sans-serif;
  --font-display: 'Baloo 2', cursive;
}

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

body {
  font-family: var(--font-body);
  font-weight: 600;
  background: var(--bg);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-image:
    radial-gradient(900px 520px at 10% -12%, var(--brass-glow) 0%, transparent 60%),
    radial-gradient(760px 520px at 102% 0%, var(--shadow-soft) 0%, transparent 60%);
}

/* ── Navbar ── */
.navbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 3px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--cream);
  flex: 1;
  text-align: left;
}
.nav-logo em {
  font-style: normal;
  color: var(--brass);
}
.nav-btn {
  background: var(--panel);
  color: var(--cream-dim);
  border: 2.5px solid var(--border);
  border-radius: 12px;
  padding: 8px 15px;
  font-size: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, color 0.12s, background 0.12s;
  flex: none;
  box-shadow: 0 3px 0 var(--border);
}
.nav-btn:hover { color: var(--brass); transform: translateY(-2px); box-shadow: 0 5px 0 var(--border); }
.nav-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.nav-btn.active { color: #fff; background: var(--brass); border-color: var(--brass); box-shadow: 0 3px 0 var(--brass-deep); }

/* ── Layout ── */
.main-content { flex: 1; display: flex; overflow: hidden; }

/* ── Footer ── */
.site-footer {
  height: 40px;
  background: var(--surface);
  border-top: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--cream-dim);
  flex-shrink: 0;
  z-index: 50;
}
.site-footer a { color: var(--cream-dim); text-decoration: none; transition: color 0.2s; }
.site-footer a:hover { color: var(--brass); }
.site-footer .sep { color: var(--muted); }

/* ── Changelog modal ── */
.changelog-backdrop {
  position: fixed; inset: 0;
  background: var(--brass-glow-hi);
  z-index: 200; display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(5px);
}
.changelog-backdrop.open { display: flex; }
.changelog-box {
  background: var(--panel);
  border-radius: 24px; padding: 30px;
  max-width: 520px; width: 90%; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 12px 12px 0 var(--shadow-soft);
  border: 4px solid var(--border);
}
.changelog-box h2 {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 800;
  color: var(--cream);
  margin-bottom: 20px; text-align: center;
}
.changelog-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; }
.changelog-entry { display: flex; gap: 16px; padding: 13px 0; border-bottom: 2px solid var(--border-hi); opacity: 0.92; }
.changelog-entry:last-child { border-bottom: none; }
.changelog-date {
  font-size: 11px; color: #fff; background: var(--brass);
  min-width: 84px; height: fit-content; padding: 4px 9px; border-radius: 8px;
  flex-shrink: 0; letter-spacing: 0.3px; font-weight: 700; text-align: center;
  font-family: var(--font-display);
}
.changelog-desc { font-size: 14px; color: var(--cream-dim); line-height: 1.55; }
.changelog-close-row { margin-top: 22px; display: flex; justify-content: center; }
.changelog-close-btn {
  background: var(--surface); color: var(--cream-dim);
  border: 2.5px solid var(--border); border-radius: 12px;
  padding: 11px 30px; font-size: 14px;
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px;
  cursor: pointer; transition: transform 0.12s, box-shadow 0.12s, color 0.12s;
  box-shadow: 0 4px 0 var(--border);
}
.changelog-close-btn:hover { color: var(--brass); transform: translateY(-2px); box-shadow: 0 6px 0 var(--border); }
.changelog-close-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }

/* ── Camera panel ── */
.mirror-panel {
  flex: 2; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); position: relative;
  border-left: 3px solid var(--border);
}
.mirror-panel video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-msg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: var(--cream-dim); font-size: 15px; font-weight: 700; text-align: center;
  width: 80%; line-height: 1.7; letter-spacing: 0.2px; pointer-events: none;
}
.cam-controls {
  position: absolute; top: 14px; left: 14px;
  z-index: 10; display: flex; flex-direction: row; align-items: center; gap: 8px;
}
.cam-controls button {
  background: var(--brass); color: #fff; border: 2.5px solid var(--border);
  padding: 8px 14px; border-radius: 12px;
  font-size: 12px; font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer; flex: none; transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 0 var(--brass-deep);
}
.cam-controls button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--brass-deep); }
.cam-controls button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brass-deep); }
.cam-exp-group {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  padding-left: 10px; border-left: 2px solid var(--border-hi);
}
.cam-exp-label {
  font-size: 11px; color: var(--muted); letter-spacing: 0.2px;
  font-family: var(--font-display); font-weight: 700; line-height: 1.1;
  max-width: 84px;
}
.puff-banner {
  position: absolute; top: 0; left: 0; right: 0;
  background: var(--red); color: #fff;
  text-align: center; font-size: 20px; font-weight: 800;
  font-family: var(--font-display);
  padding: 14px; z-index: 20; display: none; letter-spacing: 0.5px;
}
#meshCanvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 5; transform: scaleX(-1);
}
.calibration-overlay {
  position: absolute; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel); color: var(--cream);
  padding: 12px 24px; border-radius: 14px; font-size: 15px; font-weight: 700;
  z-index: 20; text-align: center;
  border: 3px solid var(--border); box-shadow: 0 6px 0 var(--shadow-soft);
}

/* ── Metronome panel ── */
.metronome-panel {
  flex: 1; display: flex; flex-direction: column;
  justify-content: flex-start; align-items: center;
  padding: 20px 16px;
  min-width: 400px; max-width: 440px;   /* never shrink below the timer row's content width */
  background: var(--surface);
  overflow-y: auto;
  scrollbar-width: none;        /* no visible scrollbar; content still scrolls if a short window needs it */
}
.metronome-panel::-webkit-scrollbar { display: none; }
.container {
  background: var(--panel);
  border-radius: 24px; padding: 18px 20px; width: 100%;
  border: 4px solid var(--border);
  box-shadow: 8px 8px 0 var(--shadow-soft);
  margin: 0; /* anchored to the top of the column */
}
.section-title {
  text-align: center; margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 21px; font-weight: 800;
  letter-spacing: 0.2px; color: var(--brass);
}

/* ── Beat dots ── */
.beat-display { display: flex; justify-content: center; align-items: center; gap: 11px; margin-bottom: 14px; }
.beat-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--border-hi);
  transition: transform 0.08s, background 0.08s, box-shadow 0.08s;
}
.beat-dot.active { background: var(--red); border-color: var(--red); transform: scale(1.18); box-shadow: 0 0 0 5px var(--brass-glow); }
.beat-dot.accent { background: var(--brass); border-color: var(--brass); transform: scale(1.18); box-shadow: 0 0 0 5px var(--brass-glow-hi); }

/* ── Sub-beat dots ── */
.beat-dot-sub {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.05s, transform 0.05s;
  align-self: center;
}
.beat-dot-sub.active {
  background: var(--brass);
  transform: scale(1.3);
}

/* ── BPM ── */
.bpm-section { text-align: center; margin-bottom: 8px; }
.bpm-value { cursor: text; }
.bpm-value input {
  width: 150px;
  font-family: var(--font-display);
  font-size: 48px; font-weight: 800;
  background: transparent; border: none;
  color: var(--brass); text-align: center; outline: none;
  -moz-appearance: textfield;
  letter-spacing: -1px;
  line-height: 1;
}
.bpm-value input:focus { color: var(--brass-hi); }
.bpm-value input::-webkit-outer-spin-button,
.bpm-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-label { font-size: 12px; color: var(--cream-dim); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; margin-top: 2px; }

/* ── Slider ── */
input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 8px;
  background: var(--surface); border: 2px solid var(--border-hi);
  border-radius: 10px; outline: none; margin: 8px 0 12px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px;
  background: var(--brass); border: 3px solid var(--border); border-radius: 50%; cursor: pointer;
  box-shadow: 0 3px 0 var(--brass-deep);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  background: var(--brass); border: 3px solid var(--border); border-radius: 50%; cursor: pointer;
}

/* ── Buttons ── */
button {
  flex: 1; padding: 12px; border: none; border-radius: 14px;
  font-size: 14px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s, color 0.12s;
}
.controls { display: flex; gap: 10px; margin-bottom: 10px; }
.btn-start {
  background: var(--brass); color: #fff;
  font-size: 16px;
  box-shadow: 0 5px 0 var(--brass-deep);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--brass-deep); }
.btn-start:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--brass-deep); }
.btn-start.running { background: var(--green); color: #fff; box-shadow: 0 5px 0 var(--green-hi); }
.btn-start.running:hover { box-shadow: 0 7px 0 var(--green-hi); }
.btn-tap {
  background: var(--surface); color: var(--cream-dim);
  border: 2.5px solid var(--border); box-shadow: 0 4px 0 var(--border);
}
.btn-tap:hover { color: var(--brass); transform: translateY(-2px); box-shadow: 0 6px 0 var(--border); }
.btn-tap:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }

/* ── Rows ── */
.row { display: flex; gap: 10px; margin-bottom: 8px; align-items: center; }
.row label { font-size: 12px; color: var(--cream-dim); font-weight: 700; min-width: 70px; letter-spacing: 0.3px; }
select {
  flex: 1; padding: 9px 12px; border-radius: 12px;
  border: 2.5px solid var(--border);
  background: var(--surface); color: var(--cream);
  font-size: 14px; font-family: var(--font-body); font-weight: 700;
  cursor: pointer; outline: none; transition: border-color 0.2s;
}
select:hover { border-color: var(--brass); }

/* ── Subdivision buttons ── */
.subdivide-btns {
  display: flex;
  gap: 6px;
  flex: 1;
}
.subdivide-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7px 2px;
  border: 2.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--cream-dim);
  cursor: pointer;
  line-height: 1.2;
  transition: transform 0.1s, background 0.12s, color 0.12s, border-color 0.12s;
}
.subdivide-btn .sub-sym {
  font-size: 15px;
}
.subdivide-btn .sub-num {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.7;
}
.subdivide-btn:hover {
  border-color: var(--brass);
  color: var(--brass);
  transform: translateY(-1px);
}
.subdivide-btn.active {
  background: var(--brass);
  color: #fff;
  border-color: var(--brass);
}

/* ── Row sections (Timer / Elapsed) ── */
.row-section { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 2px dashed var(--border-hi); }
.row-section-label { font-size: 12px; color: var(--brass); font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase; flex-shrink: 0; min-width: 46px; font-family: var(--font-display); }

/* ── LCD displays (playful chunky readouts) ── */
.lcd-wrap {
  position: relative; display: inline-flex; align-items: center;
  background: var(--lcd-bg); border-radius: 12px; padding: 5px 10px;
  border: 3px solid var(--border-hi);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.28);
  flex-shrink: 0;
}
/* The ghost "88:88" stays in flow and reserves a fixed width, so the readout
   never resizes as the digits change (Baloo 2 is a proportional font). The live
   time is overlaid on top — the classic ghosted-LCD look. */
.lcd-ghost {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: 0.5px;
  color: var(--lcd-ghost);
  pointer-events: none; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.elapsed-display, .timer-display {
  position: absolute; left: 10px; top: 0; bottom: 0;
  display: flex; align-items: center;
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700; line-height: 1; letter-spacing: 0.5px;
  color: var(--lcd);
  text-shadow: 0 0 8px var(--lcd-glow), 0 0 16px var(--lcd-glow-far);
  z-index: 1; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timer-display.timer-done {
  color: var(--red);
  text-shadow: 0 0 8px var(--red), 0 0 16px rgba(255,107,129,0.4);
  animation: pulse 1s infinite;
}

/* ── Row icon buttons ── */
.row-icon-btn {
  background: var(--surface); border: 2.5px solid var(--border);
  color: var(--cream-dim); font-size: 14px; cursor: pointer;
  padding: 6px 9px; border-radius: 11px; line-height: 1;
  flex: none; transition: transform 0.1s, border-color 0.12s, color 0.12s, background 0.12s; font-family: inherit;
}
.row-icon-btn:hover:not(:disabled) { border-color: var(--brass); color: var(--brass); transform: translateY(-1px); }
.row-icon-btn:disabled { opacity: 0.3; cursor: default; }
.row-icon-btn.running { background: var(--red); border-color: var(--red); color: #fff; }
.row-icon-btn.running:hover { background: var(--red-hi); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Timer preset dropdown ── */
.timer-preset-wrap { position: relative; flex: none; }
.timer-preset-menu {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 3px solid var(--border);
  border-radius: 14px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: 6px 6px 0 var(--shadow-soft); z-index: 200; min-width: 86px;
}
.timer-preset-menu.hidden { display: none; }
.timer-preset-menu button {
  background: none; border: none; color: var(--cream-dim); font-family: var(--font-body); font-weight: 700;
  font-size: 13px; padding: 6px 11px; border-radius: 9px; cursor: pointer; text-align: left;
  white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.timer-preset-menu button:hover { background: var(--surface); color: var(--brass); }
.timer-preset-menu button.selected { color: #fff; background: var(--brass); }

/* ── Theme popup ── */
.theme-popup {
  position: fixed;
  top: 64px; right: 16px;
  width: 420px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  background: var(--panel);
  border: 4px solid var(--border);
  border-radius: 22px;
  padding: 20px;
  z-index: 300;
  box-shadow: 10px 10px 0 var(--shadow-soft);
  display: none;
}
.theme-popup.open { display: block; }
.theme-section-label {
  font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 8px; padding-bottom: 4px;
  border-bottom: 2px solid var(--border-hi); font-weight: 700;
}
.theme-section-label:first-child { margin-top: 0; }
.theme-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  font-size: 18px; font-family: var(--font-display); font-weight: 800;
  color: var(--cream);
}
.theme-popup-close {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1;
  transition: color 0.15s;
}
.theme-popup-close:hover { color: var(--brass); }
.theme-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.theme-swatch {
  display: flex; flex-direction: column; align-items: center;
  gap: 7px; padding: 10px 4px 8px;
  border-radius: 14px; cursor: pointer;
  border: 2.5px solid var(--border);
  background: var(--surface);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.theme-swatch:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--border); }
.theme-swatch.active { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-glow-hi); }
.theme-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--border);
  flex-shrink: 0;
}
.theme-label {
  font-size: 10px; color: var(--cream-dim); font-weight: 700;
  letter-spacing: 0.2px; text-align: center; line-height: 1.3;
}

/* ── Theme mode toggle ── */
.theme-mode-pill {
  display: flex; flex: none;
  background: var(--surface);
  border: 2.5px solid var(--border);
  border-radius: 20px;
  padding: 2px; gap: 2px;
}
.theme-mode-opt {
  flex: none; padding: 5px 13px; border: none;
  border-radius: 16px; font-size: 11px;
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted); background: transparent;
  cursor: pointer; transition: all 0.15s;
}
.theme-mode-opt.active { background: var(--brass); color: #fff; }
.theme-mode-opt:hover:not(.active) { color: var(--brass); }
.theme-popup-close { flex: none; }

/* ── Settings popup ── */
.settings-popup {
  position: fixed; top: 64px; right: 16px; width: 290px;
  background: var(--panel); border: 4px solid var(--border);
  border-radius: 22px; padding: 20px; z-index: 300;
  box-shadow: 10px 10px 0 var(--shadow-soft); display: none;
}
.settings-popup.open { display: block; }
.settings-popup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.settings-popup-header span { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--cream); }
.settings-row { margin-bottom: 16px; }
.settings-row:last-child { margin-bottom: 0; }
.settings-label { display: block; font-family: var(--font-body); font-size: 12px; font-weight: 700; letter-spacing: 0.2px; color: var(--cream-dim); margin-bottom: 8px; }
.settings-input-row { display: flex; gap: 8px; }
.settings-input-row input { flex: 1; background: var(--surface); border: 2.5px solid var(--border); border-radius: 11px; color: var(--cream); font-family: var(--font-body); font-weight: 700; font-size: 14px; padding: 8px 11px; outline: none; transition: border-color 0.2s; width: 0; }
.settings-input-row input:focus { border-color: var(--brass); }
.settings-save-btn { background: var(--brass); color: #fff; border: none; border-radius: 11px; font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: 0.3px; padding: 8px 15px; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; flex: none; box-shadow: 0 4px 0 var(--brass-deep); }
.settings-save-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--brass-deep); }
.settings-save-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brass-deep); }
.settings-reset-btn { background: var(--surface); color: var(--cream-dim); border: 2.5px solid var(--border); border-radius: 11px; font-family: var(--font-body); font-weight: 700; font-size: 12px; letter-spacing: 0.2px; padding: 9px 12px; cursor: pointer; width: 100%; text-align: left; transition: border-color 0.2s, color 0.2s; }
.settings-reset-btn:hover { border-color: var(--brass); color: var(--brass); }

/* ── Notes panel ── */
.notes-panel {
  position: fixed; top: 56px; right: 0; bottom: 40px; width: 348px;
  background: var(--panel); border-left: 4px solid var(--border);
  z-index: 100; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.25s ease;
  box-shadow: -8px 0 40px var(--shadow-soft);
}
.notes-panel.open { transform: translateX(0); }
.notes-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 14px; border-bottom: 3px solid var(--border); flex-shrink: 0;
}
.notes-panel-header h2 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  color: var(--cream);
}
.notes-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 6px; line-height: 1; flex: none; transition: color 0.2s; }
.notes-close:hover { color: var(--brass); }
.notes-panel-session { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; color: var(--brass); flex: 1; text-align: right; padding-right: 8px; }
.notes-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.notes-list:empty::after { content: 'No notes yet 🎵'; color: var(--muted); font-size: 14px; font-weight: 700; }
.note-entry { background: var(--surface); border: 2.5px solid var(--border-hi); border-radius: 14px; padding: 11px 13px; position: relative; }
.note-entry-date { font-size: 11px; color: var(--brass); font-weight: 700; margin-bottom: 5px; letter-spacing: 0.2px; }
.note-entry-text { font-size: 14px; color: var(--cream-dim); white-space: pre-wrap; word-break: break-word; line-height: 1.6; padding-right: 48px; }
.note-entry-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; }
.note-entry-actions button { background: none; border: none; font-size: 14px; cursor: pointer; padding: 3px 6px; line-height: 1; flex: none; border-radius: 8px; color: var(--muted); transition: all 0.15s; }
.note-entry-actions .edit-btn:hover { color: var(--brass); background: var(--brass-glow); }
.note-entry-actions .delete-btn:hover { color: var(--red); background: rgba(255,107,129,0.14); }
.note-entry-edit-area {
  width: 100%; background: var(--panel); border: 2.5px solid var(--brass);
  border-radius: 11px; color: var(--cream); font-family: var(--font-body); font-weight: 600;
  font-size: 14px; padding: 9px 11px; resize: vertical; min-height: 60px;
  outline: none; margin-top: 7px;
}
.note-entry-edit-actions { display: flex; gap: 7px; margin-top: 8px; }
.note-entry-edit-actions button { flex: 1; padding: 7px; font-size: 13px; border-radius: 10px; cursor: pointer; border: none; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px; }
.note-save-btn { background: var(--brass); color: #fff; box-shadow: 0 3px 0 var(--brass-deep); }
.note-save-btn:hover { transform: translateY(-1px); }
.note-cancel-btn { background: var(--surface); color: var(--cream-dim); border: 2.5px solid var(--border); }
.note-cancel-btn:hover { border-color: var(--brass); color: var(--brass); }
.notes-shortcut-hint { font-size: 11px; color: var(--muted); font-weight: 600; text-align: center; padding: 9px 0 0; letter-spacing: 0.2px; }
.notes-add { padding: 14px 16px; border-top: 3px solid var(--border); flex-shrink: 0; }
.notes-add textarea {
  width: 100%; background: var(--surface); border: 2.5px solid var(--border-hi);
  border-radius: 12px; color: var(--cream); font-family: var(--font-body); font-weight: 600;
  font-size: 14px; padding: 10px 12px; resize: vertical; min-height: 72px;
  outline: none; margin-bottom: 10px; transition: border-color 0.2s;
}
.notes-add textarea:focus { border-color: var(--brass); }
.notes-add textarea::placeholder { color: var(--muted); }
.btn-add-note { background: var(--brass); color: #fff; width: 100%; font-size: 15px; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px; box-shadow: 0 4px 0 var(--brass-deep); }
.btn-add-note:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--brass-deep); }
.btn-add-note:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brass-deep); }
.notes-io-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-notes-io { flex: 1; background: var(--surface); color: var(--cream-dim); border: 2.5px solid var(--border); font-size: 12px; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.2px; padding: 8px 0; border-radius: 11px; cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.btn-notes-io:hover { border-color: var(--brass); color: var(--brass); }

/* ── Notes modal ── */
.notes-modal-backdrop { position: fixed; inset: 0; background: var(--brass-glow-hi); z-index: 200; display: none; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.notes-modal-backdrop.open { display: flex; }
.notes-modal-box {
  background: var(--panel); border-radius: 24px; padding: 28px;
  max-width: 460px; width: 90%; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 12px 12px 0 var(--shadow-soft); border: 4px solid var(--border);
}
.notes-modal-header { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 14px; flex-shrink: 0; }
.notes-modal-header h2 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  color: var(--cream); margin-bottom: 0; flex: 1;
}
.notes-modal-dismiss-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px; line-height: 1; transition: color 0.2s; flex: none; }
.notes-modal-dismiss-btn:hover { color: var(--brass); }
.notes-modal-list-header { display: flex; justify-content: flex-end; margin-bottom: 8px; flex-shrink: 0; }
.notes-modal-add-btn { background: var(--brass); color: #fff; border: none; border-radius: 10px; width: 30px; height: 30px; min-width: 30px; max-width: 30px; font-size: 18px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none; transition: transform 0.12s; padding: 0; box-shadow: 0 3px 0 var(--brass-deep); }
.notes-modal-add-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--brass-deep); }

.notes-modal-add-form { margin-bottom: 12px; flex-shrink: 0; }
.notes-modal-add-form.hidden { display: none; }
.notes-modal-add-form textarea { width: 100%; background: var(--surface); border: 2.5px solid var(--border-hi); border-radius: 12px; color: var(--cream); font-family: var(--font-body); font-weight: 600; font-size: 14px; padding: 10px 12px; resize: vertical; min-height: 60px; outline: none; margin-bottom: 8px; transition: border-color 0.2s; box-sizing: border-box; }
.notes-modal-add-form textarea:focus { border-color: var(--brass); }
.notes-modal-add-form textarea::placeholder { color: var(--muted); }
.notes-modal-add-actions { display: flex; gap: 7px; }
.notes-modal-add-actions button { flex: 1; padding: 7px; font-size: 13px; border-radius: 10px; cursor: pointer; border: none; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px; }
.notes-modal-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.notes-modal-entry { background: var(--surface); border: 2.5px solid var(--border-hi); border-radius: 12px; padding: 11px 13px; position: relative; }
.notes-modal-entry-date { font-size: 11px; color: var(--brass); font-weight: 700; margin-bottom: 4px; }
.notes-modal-entry-text { font-size: 14px; color: var(--cream-dim); white-space: pre-wrap; word-break: break-word; line-height: 1.6; padding-right: 48px; }
.notes-modal-empty { color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; padding: 10px 0; }
.btn-understood { background: var(--brass); color: #fff; width: 100%; font-size: 16px; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.3px; flex-shrink: 0; padding: 13px; box-shadow: 0 5px 0 var(--brass-deep); }
.btn-understood:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--brass-deep); }
.btn-understood:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--brass-deep); }

/* ── Session banner ── */
.notes-modal-session-banner { display: flex; flex-direction: column; align-items: center; padding: 4px 0 18px; margin-bottom: 16px; border-bottom: 2px dashed var(--border-hi); flex-shrink: 0; }
.notes-modal-session-label { font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.modal-quote { font-family: var(--font-display); font-size: 18px; font-weight: 600; font-style: italic; color: var(--cream); text-align: center; margin-top: 12px; line-height: 1.5; }

/* ── Flip clock ── */
.flip-clock { display: flex; gap: 4px; align-items: center; }
.flip-digit-wrapper { perspective: 160px; }
.flip-digit { position: relative; width: 42px; height: 56px; }
.flip-top, .flip-bottom, .flip-flap-upper, .flip-flap-lower {
  position: absolute; left: 0; right: 0; overflow: hidden;
  background: #2a2150; border: none;
  text-align: center; color: #fff;
  font-family: var(--font-display); font-size: 34px; font-weight: 800;
}
.flip-top, .flip-flap-upper { top: 0; height: 28px; border-radius: 9px 9px 0 0; border-bottom: 1px solid rgba(0,0,0,0.4); }
.flip-bottom, .flip-flap-lower { top: 28px; height: 28px; border-radius: 0 0 9px 9px; border-top: none; }
.flip-top span, .flip-bottom span, .flip-flap-upper span, .flip-flap-lower span { display: block; height: 56px; line-height: 56px; }
.flip-bottom span, .flip-flap-lower span { margin-top: -28px; }
.flip-flap-upper { transform-origin: bottom center; z-index: 2; }
.flip-flap-lower { transform-origin: top center; z-index: 2; }
@keyframes flip-upper-fold { from { transform: rotateX(0deg); } to { transform: rotateX(-90deg); } }
@keyframes flip-lower-unfold { from { transform: rotateX(90deg); } to { transform: rotateX(0deg); } }
.flip-digit-wrapper.new-digit { opacity: 0; }
@keyframes flip-digit-slide-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.flip-digit-wrapper.slide-in { animation: flip-digit-slide-in 0.22s ease-out forwards; }

/* ── Stacked layout: portrait windows, or anything narrower than ~820px ── */
@media (max-width: 820px), (orientation: portrait) {
  body { height: auto; min-height: 100dvh; overflow: auto; }

  .main-content { flex-direction: column; overflow: visible; }

  .metronome-panel {
    flex: none;
    min-width: 0;
    max-width: none;
    width: 100%;
    padding: 22px 16px;
    align-items: center;
    overflow-y: visible;
  }
  /* Keep the card a comfortable width and centred instead of stretching full-width */
  .container { max-width: 440px; margin: 0 auto; }

  .mirror-panel {
    flex: none;
    width: 100%;
    height: 56vw;
    min-height: 280px;
    border-left: none;
    border-top: 3px solid var(--border);
  }

  .site-footer { height: auto; padding: 12px; }

  .theme-popup, .settings-popup { left: 12px; right: 12px; width: auto; }
  .theme-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── Phone-specific tightening ── */
@media (max-width: 640px) {
  .navbar { padding: 0 12px; gap: 8px; }
  .nav-logo {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  .nav-btn { padding: 7px 11px; font-size: 11px; letter-spacing: 0.2px; white-space: nowrap; flex: none; }
  .nav-btn-label { display: none; }

  .metronome-panel { padding: 16px 14px; }
  .mirror-panel { height: 50vw; min-height: 220px; }
  .theme-grid { grid-template-columns: repeat(4, 1fr); }
}
