/* ================================================
   styles.css — Harmo Rush
   Flat design, Bulma-based, mobile-first
   Font: Syne + DM Mono
   ================================================ */

:root {
  --primary:        #4f46e5;
  --primary-light:  #818cf8;
  --primary-dark:   #3730a3;
  --accent:         #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #0f172a;
  --text-muted:     #64748b;
  /* Piano */
  --key-white:      #ffffff;
  --key-black:      #1e293b;
  --key-sel-white:  #c7d2fe;
  --key-sel-black:  #4f46e5;
  --key-root-white: #fde68a;   /* amber — root note in memo */
  --key-root-black: #d97706;
  --key-correct:    #bbf7d0;
  --key-missed:     #fecaca;
  --r:              12px;
  --navbar-h:       56px;
}

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

html, body {
  height: 100%;
  font-family: 'Syne', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ===== NAVBAR ===== */
.navbar {
  height: var(--navbar-h);
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 0.75rem;
}
.navbar-brand {
  width: 100%;
  display: flex;
  align-items: center;
  height: var(--navbar-h);
  gap: 0;
}
.navbar-item {
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.navbar-item.ml-auto { margin-left: auto; }
.ml-1 { margin-left: 0.25rem; }

.logo-mark {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  font-weight: 900; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; flex-shrink: 0;
}
.app-title {
  font-size: 17px; font-weight: 700;
  color: var(--text); letter-spacing: -0.3px;
  margin-left: 8px;
}
.app-title strong { color: var(--primary); }

/* ===== MAIN ===== */
.main-layout {
  min-height: calc(100vh - var(--navbar-h));
  padding-top: var(--navbar-h);
  display: flex; flex-direction: column;
}
.screen-panel { flex: 1; display: flex; flex-direction: column; }

/* ===== READY ===== */
.ready-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem; text-align: center; gap: 1rem;
}
.ready-icon { font-size: 56px; line-height: 1; }
.ready-title {
  font-size: 2rem; font-weight: 900; color: var(--text); margin: 0;
}
.ready-title strong { color: var(--primary); }
.ready-sub { font-size: 0.95rem; color: var(--text-muted); margin: 0; }
.start-btn {
  font-size: 1.1rem !important; font-weight: 800 !important;
  padding: 0.75rem 2.5rem !important;
  background: var(--primary) !important; border-color: var(--primary) !important;
  color: #fff !important; border-radius: var(--r) !important;
}
.start-btn:hover { filter: brightness(1.1); }
.mt-3 { margin-top: 0.75rem; }

/* ===== CHORD DISPLAY BAR ===== */
.chord-display-bar {
  background: var(--primary);
  color: #fff;
  padding: 1.25rem 1.5rem 1rem;
  text-align: center;
  position: sticky; top: var(--navbar-h); z-index: 30;
  border-bottom: 3px solid rgba(0,0,0,0.15);
}
.chord-name-big {
  font-family: 'DM Mono', monospace;
  font-size: clamp(2.8rem, 12vw, 5rem);
  font-weight: 500; line-height: 1; letter-spacing: -1px; color: #fff;
}
.chord-meta {
  font-size: 0.85rem; color: rgba(255,255,255,0.75);
  margin-top: 4px; letter-spacing: 0.5px; min-height: 1.2em;
}

/* ===== RUN ZONE ===== */
.run-zone { flex: 1; display: flex; flex-direction: column; padding: 0 0 1rem; }

/* ===== FEEDBACK ===== */
.feedback-bar {
  padding: 10px 1rem; text-align: center;
  font-weight: 700; font-size: 0.95rem; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.feedback-bar.is-correct { background: #d1fae5; color: #065f46; }
.feedback-bar.is-wrong   { background: #fee2e2; color: #991b1b; }

/* ===== PIANO SECTION ===== */
.piano-section {
  flex: 1; display: flex; flex-direction: column; padding: 0.75rem 0 0;
}
.piano-scroll-wrap {
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px 16px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.piano-scroll-wrap::-webkit-scrollbar { height: 6px; }
.piano-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Container sized + positioned by JS */
.piano-keys {
  background: #f1f5f9;
  border-radius: var(--r);
  border: 2px solid var(--border);
  flex-shrink: 0;
}

/* ===== WHITE KEYS ===== */
.pkey.white-key {
  position: absolute;
  bottom: 8px;
  width: 60px; height: 200px;
  background: var(--key-white);
  border: 2px solid #cbd5e1;
  border-radius: 0 0 10px 10px;
  cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 10px;
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 12px; color: #475569;
  user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background 0.1s, transform 0.08s;
  box-shadow: 0 4px 0 #cbd5e1;
}
.pkey.white-key:active { transform: translateY(2px); box-shadow: 0 2px 0 #cbd5e1; }

.pkey.white-key.is-selected { background: var(--key-sel-white); border-color: var(--primary); color: var(--primary); }
.pkey.white-key.is-root     { background: var(--key-root-white); border-color: #d97706; color: #92400e; }
.pkey.white-key.is-correct  { background: var(--key-correct); border-color: var(--accent); }
.pkey.white-key.is-missed   { background: var(--key-missed); border-color: var(--danger); }

/* ===== BLACK KEYS ===== */
.pkey.black-key {
  position: absolute;
  top: 8px;
  width: 40px; height: 126px;
  background: var(--key-black);
  border: 2px solid #0f172a;
  border-radius: 0 0 8px 8px;
  z-index: 10; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 8px;
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 9px; color: #94a3b8;
  user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background 0.1s, transform 0.08s;
  box-shadow: 0 6px 0 #000;
}
.pkey.black-key:active { transform: translateY(2px); box-shadow: 0 3px 0 #000; }

.pkey.black-key.is-selected { background: var(--key-sel-black); border-color: var(--primary-light); color: #fff; }
.pkey.black-key.is-root     { background: var(--key-root-black); border-color: #fbbf24; color: #fff; }
.pkey.black-key.is-correct  { background: #059669; border-color: #34d399; color: #fff; }
.pkey.black-key.is-missed   { background: #dc2626; border-color: #fca5a5; color: #fff; }

.piano-legend {
  padding: 6px 1rem; font-size: 0.82rem; color: var(--text-muted);
}
.selected-notes-pill { font-family: 'DM Mono', monospace; font-weight: 500; color: var(--primary); }

/* ===== QUIZ ACTIONS ===== */
.quiz-actions {
  display: flex; gap: 12px; padding: 0.75rem 1rem; justify-content: center;
}
.quiz-actions .button {
  flex: 1; max-width: 220px; font-weight: 700;
  border-radius: var(--r); height: 48px; font-size: 0.95rem;
}
.quiz-actions .button.is-primary { background: var(--primary); border-color: var(--primary); }

/* ===== STATS STRIP ===== */
.stats-strip {
  display: flex; justify-content: space-around;
  padding: 0.5rem 1rem; border-top: 1px solid var(--border);
  background: var(--surface); margin-top: auto;
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.stat-val   { font-family: 'DM Mono', monospace; font-size: 1.3rem; font-weight: 500; color: var(--text); }

/* ===== STOP ===== */
.stop-wrap { display: flex; justify-content: center; padding: 0.5rem 1rem 1rem; }

/* ===== METRONOME ===== */
.metro-bar {
  display: flex; justify-content: center; gap: 20px; padding: 1.5rem 1rem 1rem;
}
.beat-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--border); transition: background 0.08s, transform 0.08s;
}
.beat-dot.is-active { background: var(--primary-light); transform: scale(1.2); }
.beat-dot.is-accent.is-active {
  background: var(--primary); transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.2);
}
.metro-info { text-align: center; font-size: 0.9rem; color: var(--text-muted); padding: 0 1rem 0.5rem; }
.metro-controls { display: flex; justify-content: center; gap: 12px; padding: 0.5rem 1rem; }
.metro-controls .button { border-radius: var(--r); }
.train-next-info { text-align: center; padding: 0.5rem 1rem; font-size: 0.9rem; color: var(--text-muted); }

/* ===== SETTINGS CHIPS ===== */
.checkbox-card {
  display: flex; align-items: center; gap: 10px;
  border: 2px solid var(--border); border-radius: var(--r); padding: 12px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.checkbox-card:has(input:checked) { border-color: var(--primary); background: #eff6ff; }
.checkbox-card input { accent-color: var(--primary); }
.cc-label { font-size: 0.9rem; font-weight: 700; line-height: 1.3; }
.cc-label small { font-weight: 400; color: var(--text-muted); }

.chord-type-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-chip {
  display: flex; align-items: center; gap: 6px;
  border: 2px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 0.82rem; font-weight: 700;
  cursor: pointer; transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.ct-chip:has(input:checked) { border-color: var(--primary); background: var(--primary); color: #fff; }
.ct-chip input { display: none; }

/* Saved custom voicings: chip with toggle + delete */
#customVoicingsList {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px;
}
.cv-empty { font-size: 0.85rem; color: var(--text-muted); }
.cv-chip {
  display: inline-flex; align-items: stretch;
  border: 2px solid var(--border); border-radius: 999px; overflow: hidden;
}
.cv-chip .cv-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 12px; cursor: pointer;
  font-family: 'DM Mono', monospace; font-weight: 500; font-size: 0.85rem;
  color: var(--text-muted);
}
.cv-chip .cv-toggle input { accent-color: var(--primary); margin: 0; }
.cv-chip:has(.cv-toggle input:checked) { border-color: var(--primary); }
.cv-chip:has(.cv-toggle input:checked) .cv-toggle { color: var(--primary); }
.cv-chip .cv-del {
  border: none; background: transparent; cursor: pointer;
  padding: 0 10px; color: var(--text-muted); font-size: 0.9rem;
  border-left: 2px solid var(--border);
}
.cv-chip .cv-del:hover { color: var(--danger); background: #fef2f2; }

/* Root filter quick actions */
.roots-actions { display: flex; gap: 8px; }
.roots-actions .button { border-radius: 999px; }

/* Inline voicing degrees shown next to the chord name (quiz/train) */
.voicing-degrees {
  font-size: 0.78em;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}
.voicing-sep { color: rgba(255,255,255,0.4); font-weight: 400; padding: 0 0.12em; }

.seg-btn { font-weight: 700 !important; }
.seg-btn.is-active {
  background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important;
}

input[type="range"].slider {
  -webkit-appearance: none; height: 6px; border-radius: 3px;
  background: var(--border); outline: none; cursor: pointer; width: 100%;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); cursor: pointer; box-shadow: 0 2px 6px rgba(79,70,229,0.4);
}

/* ===== STATS CARDS ===== */
.stat-card {
  background: var(--bg); border: 2px solid var(--border);
  border-radius: var(--r); padding: 1rem; text-align: center;
}
.stat-card-val   { font-family: 'DM Mono', monospace; font-size: 1.8rem; font-weight: 500; color: var(--primary); }
.stat-card-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* ===== EXERCISES ===== */
.exo-progress {
  font-family: 'DM Mono', monospace; font-size: 0.8rem; font-weight: 500;
  color: rgba(255,255,255,0.85); margin-bottom: 4px; letter-spacing: 0.3px;
}
#readyExercises {
  width: 100%; max-width: 460px; margin-top: 28px;
  border-top: 2px dashed var(--border); padding-top: 18px;
}
.ready-exercises-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.ready-exercises-title { font-weight: 800; font-size: 1.05rem; }
#exerciseList { display: flex; flex-direction: column; gap: 10px; }
.exo-card {
  border: 2px solid var(--border); border-radius: var(--r);
  background: var(--surface); padding: 12px; text-align: left;
}
.exo-card-top { display: flex; align-items: center; gap: 8px; }
.exo-card-name { font-weight: 800; font-size: 1rem; flex: 1; }
.exo-card-sum { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.exo-card-actions { display: flex; gap: 6px; }
.exo-card-actions .button { border-radius: 8px; }
.exo-empty { color: var(--text-muted); font-size: 0.9rem; padding: 8px 0; }

.exo-chord-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 8px; }
.exo-chord-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary); color: #fff; border-radius: 999px;
  padding: 4px 6px; font-family: 'DM Mono', monospace; font-weight: 500; font-size: 0.9rem;
}
.exo-chord-chip .exo-chord-lbl { padding: 0 4px; }
.exo-chord-chip .exo-chord-move,
.exo-chord-chip .exo-chord-del {
  border: none; background: rgba(255,255,255,0.22); color: #fff; cursor: pointer;
  border-radius: 999px; width: 22px; height: 22px; line-height: 1; font-size: 0.9rem;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.exo-chord-chip .exo-chord-move:disabled { opacity: 0.3; cursor: default; }
.exo-chord-chip .exo-chord-move:not(:disabled):hover,
.exo-chord-chip .exo-chord-del:hover { background: rgba(255,255,255,0.45); }
.exo-chord-empty { color: var(--text-muted); font-size: 0.85rem; }

.exo-builder { display: flex; flex-direction: column; gap: 10px; }
.exo-builder-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.exo-builder-row .memo-ctrl-label { min-width: 92px; padding-top: 6px; }
#exoRootPick .ct-chip, #exoTransposeRoots .ct-chip { padding: 4px 9px; font-size: 0.8rem; }
#exoChordTypeGrid .ct-chip { padding: 4px 9px; font-size: 0.8rem; }
/* single-select highlight for builder chips */
#exoRootPick .ct-chip:has(input:checked),
#exoChordTypeGrid .ct-chip:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== EXERCISE EDITOR SCREEN ===== */
.editor-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 2px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.editor-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.editor-body { flex: 1; overflow-y: auto; padding: 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.editor-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 2px solid var(--border); background: var(--bg);
}
.editor-foot-actions { display: flex; gap: 8px; }
.tempo-row { display: flex; align-items: center; gap: 10px; }
.tempo-input { max-width: 90px; text-align: center; font-family: 'DM Mono', monospace; font-weight: 700; }
.tempo-unit { font-weight: 700; color: var(--text-muted); }

/* ===== SESSION SUMMARY ===== */
.session-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.session-foot-actions { display: flex; gap: 8px; }
.session-save-hint {
  font-size: 0.85rem; color: var(--accent); font-weight: 700;
}

/* ===== MODAL ===== */
.modal-card {
  width: min(560px, 95vw); max-height: 90vh;
  border-radius: var(--r); overflow: hidden;
}
.modal-card-head {
  border-radius: var(--r) var(--r) 0 0;
  background: var(--surface); border-bottom: 2px solid var(--border);
}
.modal-card-foot {
  background: var(--surface); border-top: 2px solid var(--border);
  border-radius: 0 0 var(--r) var(--r);
}
.modal-card-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-height: calc(90vh - 140px);
}

/* ===== MEMO MODAL ===== */
.memo-modal-card {
  width: min(680px, 98vw);
  max-height: 96vh;
}
.memo-body {
  padding: 1rem;
  max-height: calc(96vh - 120px) !important;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.memo-controls {
  display: flex; flex-direction: column; gap: 0.75rem;
}
.memo-ctrl-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.memo-ctrl-label {
  font-weight: 700; font-size: 0.85rem; color: var(--text-muted);
  min-width: 110px; text-transform: uppercase; letter-spacing: 0.3px;
}

/* Styled native select */
.select-styled {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234f46e5' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 8px 36px 8px 12px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  min-width: 180px;
}
.select-styled:focus { outline: none; border-color: var(--primary); }
.select-styled optgroup { font-weight: 400; color: var(--text-muted); }
.select-styled option  { font-weight: 700; color: var(--text); }

/* Chord display in memo */
.memo-chord-display {
  text-align: center;
  padding: 1rem;
  background: var(--primary);
  border-radius: var(--r);
  min-height: 100px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
}
.memo-instruction {
  color: rgba(255,255,255,0.7); font-size: 0.9rem;
}
.memo-chord-name {
  font-family: 'DM Mono', monospace;
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 500; color: #fff; line-height: 1;
}
.memo-chord-notes {
  font-size: 0.9rem; color: rgba(255,255,255,0.8); letter-spacing: 0.5px;
}
.memo-piano-scroll {
  padding: 8px 0 12px;
}

/* ===== UTILS ===== */
.is-hidden { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  .chord-name-big { font-size: clamp(4rem, 8vw, 6rem); }
  .pkey.white-key { width: 60px; height: 200px; }
}

.piano-keys { -webkit-user-select: none; user-select: none; }
.key-label  { pointer-events: none; }
