/* Sightreader — graphite chrome, manuscript paper, brass accent. */

:root {
  --bg: #111317;
  --surface-1: #181b20;
  --surface-2: #20242b;
  --surface-3: #2a2f37;
  --line: #2b3038;
  --line-2: #3a404a;
  --text: #f0ede6;
  --text-2: #a8a69f;
  --text-3: #6f6e69;
  --paper: #faf8f2;
  --paper-edge: #ebe6da;
  --ink: #1a1917;
  --accent: #e2b04a;
  --accent-2: #b07a12;
  --accent-soft: rgba(226, 176, 74, 0.16);
  --good: #2fbf8f;
  --good-soft: rgba(47, 191, 143, 0.18);
  --bad: #e5534b;
  --bad-soft: rgba(229, 83, 75, 0.16);
  --series-1: #3987e5;
  --series-2: #d95926;
  --key-white: #262a31;
  --key-black: #0f1114;
  --key-edge: #353b45;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --rail: 84px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  display: flex;
  height: 100dvh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h2, h3 { margin: 0; letter-spacing: -0.01em; }

/* ---- Navigation rail ------------------------------------------------------ */
.rail {
  width: var(--rail); flex: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 10px;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
}
.rail-brand { margin-bottom: 10px; }
.rail-tabs { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 10px; }
.rail-tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 10px 0 8px; border-radius: var(--r-md);
  color: var(--text-3); font-size: 11.5px; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.rail-tabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-tabs button.on { background: var(--surface-3); color: var(--text); }
.rail-tabs button:not(.on):hover { color: var(--text-2); }
.rail-foot { margin-top: auto; width: 100%; padding: 0 8px; }
.midi-status { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; font-size: 10.5px; color: var(--text-3); line-height: 1.2; }
.midi-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 3px rgba(255,255,255,0.04); }
.midi-status[data-state="ok"] .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.midi-status[data-state="none"] .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.midi-text { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-hint { color: var(--text-3); }

/* ---- Views ---------------------------------------------------------------- */
main { flex: 1; min-width: 0; min-height: 0; display: flex; }
.view { display: none; flex: 1; min-height: 0; min-width: 0; flex-direction: column; }
.view.on { display: flex; }
.scroll { overflow-y: auto; padding: 22px 26px 48px; -webkit-overflow-scrolling: touch; }

/* ---- Practice: context bar ------------------------------------------------ */
#view-practice { padding: 14px 20px 14px; gap: 10px; }
.context { display: flex; align-items: center; gap: 16px; height: 44px; }
.level-pill { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.level-num { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.level-name { color: var(--text-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.context-right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13.5px; white-space: nowrap; }
.plan-timer { color: var(--accent); font-weight: 700; }
.beat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.beat-dot.pulse { animation: pulse 0.3s var(--ease-out); }
@keyframes pulse { 0% { background: var(--accent); transform: scale(1.9); } 100% { background: var(--line-2); transform: scale(1); } }

/* Segmented control with a sliding thumb */
.seg { position: relative; display: inline-flex; gap: 0; background: var(--surface-2); border-radius: 999px; padding: 3px; isolation: isolate; }
.seg button { position: relative; z-index: 1; padding: 7px 15px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 13.5px; transition: color 0.2s; }
.seg button.on { color: var(--ink); }
.seg-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: 0; border-radius: 999px; background: var(--accent); transition: left 0.28s var(--ease-out), width 0.28s var(--ease-out); }
.filters .seg button.on { color: var(--text); background: var(--surface-3); }

/* ---- Sheet ---------------------------------------------------------------- */
.sheet-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.sheet-meta { display: flex; align-items: center; gap: 14px; height: 20px; padding: 0 6px; font-size: 13.5px; color: var(--text-2); }
.sheet-key { color: var(--text); font-weight: 700; }
.replay-tag { color: var(--accent); font-weight: 700; }
.prompt { color: var(--accent); font-weight: 600; }
.session-line { margin-left: auto; color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.last-note { color: var(--text-3); min-width: 36px; text-align: right; font-weight: 700; }

.sheet {
  flex: 1; min-height: 0; position: relative;
  background: var(--paper);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 18px 50px -24px rgba(0,0,0,0.9), inset 0 0 0 1px var(--paper-edge);
}
#notation { position: absolute; inset: 0; }
#notation svg { display: block; }

.cursor { position: absolute; pointer-events: none; z-index: 2; }
.cursor.box {
  background: var(--accent-soft);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(176, 122, 18, 0.55);
  transition: left 140ms var(--ease-out), top 140ms var(--ease-out), width 140ms var(--ease-out), height 140ms var(--ease-out);
}
.cursor.box.shake { box-shadow: inset 0 0 0 2px var(--bad); background: var(--bad-soft); }
.cursor.line { width: 3px; border-radius: 2px; background: var(--accent-2); box-shadow: 0 0 0 1px rgba(255,255,255,0.4), 0 0 14px rgba(226,176,74,0.5); }

/* Feedback layer */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.ripple { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2.5px solid var(--good); animation: ripple 0.55s var(--ease-out) forwards; }
@keyframes ripple { 0% { transform: scale(0.6); opacity: 0.95; } 100% { transform: scale(4.2); opacity: 0; } }
.spark { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--good); animation: spark 0.5s var(--ease-out) forwards; }
@keyframes spark { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.burst i { position: absolute; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); animation: burst 0.9s var(--ease-out) forwards; }
.burst i:nth-child(odd) { background: var(--good); }
@keyframes burst { 0% { transform: translate(0,0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; } }

.countin {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 200px; font-weight: 800; color: rgba(26, 25, 23, 0.1); pointer-events: none; display: none;
}
.countin.show { display: block; animation: countin 0.5s var(--ease-out); }
@keyframes countin { from { transform: translate(-50%, -50%) scale(1.25); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

.result {
  position: absolute; right: 18px; top: 16px; z-index: 4;
  display: none; align-items: center; gap: 14px;
  background: var(--ink); color: var(--paper); border-radius: 16px; padding: 12px 16px 12px 12px;
  box-shadow: 0 14px 40px -12px rgba(0,0,0,0.7);
  pointer-events: none;
}
.result.show { display: flex; }
@keyframes result-in { from { transform: translateY(-14px) scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.ring { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--good) calc(var(--p) * 1%), rgba(255,255,255,0.12) 0); }
.ring.warn { background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,0.12) 0); }
.ring.bad { background: conic-gradient(var(--bad) calc(var(--p) * 1%), rgba(255,255,255,0.12) 0); }
.ring span { width: 42px; height: 42px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.result .r-title { font-weight: 800; font-size: 16px; line-height: 1.1; }
.result .r-sub { font-size: 12.5px; color: #cfcbc2; margin-top: 3px; }

.progress { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width 0.25s var(--ease-out), background 0.3s; }
.progress-fill.done { background: var(--good); }

/* ---- HUD ------------------------------------------------------------------ */
.hud {
  flex: none; display: flex; align-items: stretch; gap: 6px; overflow: hidden;
  background: var(--surface-1); border-radius: var(--r-lg); padding: 10px 12px; min-height: 76px;
  border: 1px solid var(--line);
}
.hud-stat { display: flex; flex-direction: column; justify-content: center; padding: 0 12px; min-width: 84px; border-right: 1px solid var(--line); }
.hud-stat:last-of-type { border-right: 0; }
.hud-stat.grow { flex: 1; min-width: 120px; overflow: hidden; }
.hud-stat.grow .hud-value { overflow: hidden; text-overflow: ellipsis; }
.hud-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.hud-value { font-size: 22px; font-weight: 800; line-height: 1.2; white-space: nowrap; letter-spacing: -0.01em; }
.hud-value.small { font-size: 15px; font-weight: 700; }
.hud-value.streak { color: var(--good); }
.hud-value.streak.bump { animation: bump 0.35s var(--spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }
.hud-adapt { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-actions { display: flex; align-items: center; gap: 6px; padding-left: 6px; }

button.ghost, button.primary, .btn-row button {
  border-radius: 999px; padding: 10px 14px; font-weight: 700; font-size: 13.5px; white-space: nowrap; min-height: 42px;
  transition: transform 0.12s var(--ease-out), background 0.15s, filter 0.15s;
}
button.ghost, .btn-row button { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
button.ghost:hover, .btn-row button:hover { background: var(--surface-3); }
button.primary, .btn-row button.primary { background: var(--accent); color: var(--ink); box-shadow: none; }
button.primary:hover { filter: brightness(1.06); }
button.ghost:active, button.primary:active, .btn-row button:active { transform: scale(0.96); }
button.danger { color: var(--bad); }
button[disabled] { opacity: 0.4; cursor: default; }

.toast {
  position: fixed; bottom: 108px; left: calc(50% + var(--rail) / 2); transform: translate(-50%, 16px);
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 999px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.35s var(--spring);
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.8), inset 0 0 0 1px rgba(255,255,255,0.08); z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Cards (stats + settings) --------------------------------------------- */
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px 14px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h3 { font-size: 15px; font-weight: 800; margin-bottom: 2px; }
.card-sub { margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); }
.card svg { overflow: visible; }
.muted { color: var(--text-3); font-size: 13px; margin: 6px 0; }

/* ---- Stats ---------------------------------------------------------------- */
.stats-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.stats-head h2 { font-size: 22px; font-weight: 800; margin-right: 6px; }
.filters { display: flex; align-items: center; gap: 10px; flex: 1; }
.filters-note { color: var(--text-2); margin-left: auto; font-size: 13.5px; }
.empty { color: var(--text-2); padding: 60px 0; text-align: center; }
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.tile-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.tile-value { font-size: 30px; font-weight: 800; line-height: 1.2; margin-top: 2px; letter-spacing: -0.02em; }
.tile.hero .tile-value { font-size: 50px; }
.tile-value .unit { font-size: 16px; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.tile-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.axis-label { font-size: 11px; fill: var(--text-2); font-family: var(--font); }
.value-label { font-size: 11.5px; fill: var(--text); font-family: var(--font); }
.muted-tspan { fill: var(--text-3); }
.grid { stroke: var(--line); stroke-width: 1; }
.piano { margin-top: 6px; }
.piano .pk { cursor: pointer; }
.piano-label { font-size: 11px; fill: var(--text-2); font-family: var(--font); }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.ramp { width: 90px; height: 10px; border-radius: 5px; display: inline-block; }
.legend-gap { width: 16px; }
.dot-red { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); display: inline-block; }
.piano-detail { margin-top: 8px; font-size: 13px; color: var(--text-2); min-height: 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--text-2); font-weight: 600; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.tbl-scroll { max-height: 320px; overflow: auto; }
.level-log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.level-log li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.level-log .when { color: var(--text-3); width: 56px; flex: none; }
.level-log .up { color: var(--good); font-weight: 700; width: 56px; flex: none; }
.level-log .down { color: var(--accent); font-weight: 700; width: 56px; flex: none; }
.level-log .why { color: var(--text-2); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--text-2); }
.pill strong { color: var(--text); }

/* ---- Settings ------------------------------------------------------------- */
.settings-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.settings-head h2 { font-size: 22px; font-weight: 800; }
.settings-head p { margin: 0; color: var(--text-2); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-grid .card.drill, .settings-grid .card.data { grid-column: 1 / -1; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); min-height: 46px; }
.row:last-of-type { border-bottom: 0; }
.row > span:first-child { flex: 1; }
.row .hint { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; margin-top: 1px; }
select, input[type="number"] {
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 8px 32px 8px 12px; min-height: 40px; max-width: 320px;
  appearance: none; -webkit-appearance: none;
  background-image: 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' fill='none' stroke='%23a8a69f' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="number"] { background-image: none; padding-right: 12px; }
input[type="checkbox"].switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.2s; flex: none; margin: 0; }
input[type="checkbox"].switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left 0.2s var(--ease-out); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
input[type="checkbox"].switch:checked { background: var(--accent); }
input[type="checkbox"].switch:checked::after { left: 21px; }
input[type="range"] { accent-color: var(--accent); width: 170px; }
.range-wrap { display: flex; align-items: center; gap: 10px; }
.range-wrap output { min-width: 170px; text-align: right; color: var(--text-2); font-size: 13px; }
.drill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; margin: 8px 0 12px; }
.drill-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.drill-grid label select, .drill-grid label input[type="number"] { max-width: none; }
.drill-grid .span2 { grid-column: span 2; }
.drill-grid label.check { flex-direction: row; align-items: center; gap: 10px; grid-column: span 2; color: var(--text); }
.dual { display: flex; gap: 8px; }
.dual input { flex: 1; width: auto; }
.keys { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.keys > span { margin-right: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 999px; padding: 5px 11px 5px 8px; color: var(--text); cursor: pointer; }
.chip:has(input:checked) { background: var(--accent); color: var(--ink); box-shadow: none; font-weight: 700; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip { padding: 6px 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Session summary ------------------------------------------------------- */
.session-summary {
  position: absolute; inset: 0; z-index: 5; background: rgba(17, 19, 23, 0.94); color: var(--text);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 30px;
}
.session-summary.show { display: flex; animation: result-in 0.5s var(--spring); }
.session-summary h2 { font-size: 30px; font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 14px 0 20px; width: 100%; max-width: 900px; }
.summary-grid > div { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.summary-grid .up { color: var(--good); font-weight: 700; }
.summary-grid .down { color: var(--bad); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (max-width: 900px) {
  .tiles, .charts, .settings-grid { grid-template-columns: 1fr; }
  .drill-grid { grid-template-columns: 1fr 1fr; }
  .level-name { display: none; }
}

/* ---- Progress ------------------------------------------------------------- */
.head-sub { margin: 0; color: var(--text-2); font-size: 13.5px; }
.progress-hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-bottom: 12px; }
.hero-main { background: linear-gradient(135deg, var(--surface-2), var(--surface-1)); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 22px; }
.hero-value { font-size: 64px; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; margin-top: 4px; }
.hero-value .unit { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: 0; margin-top: 6px; }
.hero-change { margin-top: 12px; font-weight: 700; font-size: 16px; }
.hero-change.up { color: var(--good); }
.hero-change.down { color: var(--bad); }
.hero-note { margin: 10px 0 0; font-size: 12.5px; color: var(--text-3); max-width: 60ch; }
.hero-side { display: grid; grid-template-rows: 1fr 1fr; gap: 12px; }
.hero-side > div { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.tbl.week td:first-child { color: var(--text-2); }
.tbl.week .up { color: var(--good); font-weight: 700; }
.tbl.week .down { color: var(--bad); font-weight: 700; }
.charts { margin-top: 12px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 2px; }
.swatch + span { margin-right: 10px; }
.dashed { width: 22px; height: 0; border-top: 2px dashed var(--text-3); display: inline-block; }
.pb { list-style: none; margin: 0; padding: 0; }
.pb li { display: grid; grid-template-columns: 1.3fr 0.8fr 1.4fr; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pb li:last-child { border-bottom: 0; }
.pb-label { color: var(--text-2); }
.pb-value { font-weight: 800; font-size: 16px; }
.pb-sub { color: var(--text-3); font-size: 12px; }

/* ---- Profiles ------------------------------------------------------------- */
.rail-foot { display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }
.profile-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border-radius: var(--r-md); width: 100%; color: var(--text-2); font-size: 11.5px; font-weight: 600; transition: background 0.15s; }
.profile-btn:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: var(--ink); background: var(--accent); }
.avatar[data-i="1"] { background: #7fd1b9; } .avatar[data-i="2"] { background: #e59ac0; } .avatar[data-i="3"] { background: #8fb4f0; } .avatar[data-i="4"] { background: #f2a66a; }
.profile-name { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu { position: absolute; left: calc(100% + 10px); bottom: 0; width: 260px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 8px; box-shadow: 0 20px 50px -20px rgba(0,0,0,0.9); z-index: 20; animation: result-in 0.3s var(--spring); }
.profile-menu[hidden] { display: none; }
.profile-menu .pm-title { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 6px 10px 4px; }
.profile-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-md); text-align: left; color: var(--text); }
.profile-menu button:hover { background: var(--surface-3); }
.profile-menu button.on { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--accent); }
.profile-menu .pm-meta { display: flex; flex-direction: column; line-height: 1.2; }
.profile-menu .pm-meta small { color: var(--text-3); font-size: 11.5px; }

/* ---- Next level strip ----------------------------------------------------- */
.next-level { flex: none; display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 16px; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-md); font-size: 12.5px; color: var(--text-2); }
.nl-label { font-weight: 700; color: var(--text); white-space: nowrap; }
.pips { display: inline-flex; gap: 6px; }
.pip { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-3); box-shadow: inset 0 0 0 1.5px var(--line-2); position: relative; }
.pip.pass { background: var(--good); box-shadow: none; }
.pip.fail { background: var(--bad); box-shadow: none; }
.pip.pass::after { content: ''; position: absolute; left: 5.5px; top: 2.5px; width: 3px; height: 8px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.pip.fail::after { content: ''; position: absolute; left: 4px; top: 7px; width: 8px; height: 2px; background: var(--ink); }
.pip.new { animation: bump 0.4s var(--spring); }
.nl-meters { display: flex; gap: 14px; }
.meter { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.meter .bar { width: 72px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: visible; position: relative; }
.meter .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s var(--ease-out); max-width: 100%; }
.meter.ok .bar i { background: var(--good); }
.meter .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-2); left: 80%; border-radius: 1px; }
.meter strong { color: var(--text); font-weight: 700; }
.meter.ok strong { color: var(--good); }
.nl-text { margin-left: auto; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nl-text.ready { color: var(--good); }

.midi-log { margin: 4px 0 8px; max-height: 220px; overflow: auto; font-size: 12.5px; }
.midi-log tr.dup td { color: var(--accent); }
button.ghost.small { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }

/* ---- Key x clef table ----------------------------------------------------- */
.tbl.kc td { vertical-align: middle; }
.tbl.kc td strong { font-weight: 800; }
.kc-sub { display: block; font-size: 11.5px; color: var(--text-2); }
.kc-empty { color: var(--text-3); }
.kc-total td { border-top: 2px solid var(--line-2); font-weight: 700; }
.notes-opts .keys { margin-top: 4px; }

/* ---- Notes-mode bar ------------------------------------------------------- */
.notes-bar { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 6px; }
.notes-bar[hidden] { display: none; }
.nb-label { font-size: 12.5px; color: var(--text-3); font-weight: 700; }
.seg-small button { padding: 5px 11px; font-size: 12.5px; }
.seg-small button.on { background: var(--surface-3); color: var(--text); }
.nb-keys { gap: 4px; }
.nb-keys .chip { padding: 4px 9px; font-size: 12.5px; }

/* ---- Notes proficiency panel --------------------------------------------- */
.sheet-row { flex: 1; min-height: 0; display: flex; gap: 10px; }
.sheet-row .sheet { flex: 1; min-width: 0; }
.note-panel { width: 244px; flex: none; display: flex; flex-direction: column; gap: 6px; background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px 10px 8px; min-height: 0; }
.note-panel[hidden] { display: none; }
.np-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.np-reset { font-size: 11.5px; font-weight: 700; color: var(--accent); padding: 2px 6px; border-radius: 6px; }
.np-reset:hover { background: var(--surface-2); }
.np-cols { flex: 1; min-height: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; overflow: hidden; }
.np-col { display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.np-col-title { font-size: 10.5px; color: var(--text-3); font-weight: 700; text-align: center; margin-bottom: 2px; }
.np-note { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 5px; padding: 0 6px; overflow: hidden; height: 100%; min-height: 16px; border-radius: 6px; font-size: 11.5px; font-weight: 700; color: var(--ink); cursor: pointer; border: 0; width: 100%; line-height: 1; transition: transform 0.12s var(--ease-out), opacity 0.15s; }
.np-note:active { transform: scale(0.96); }
.np-name { text-align: left; }
.np-acc { font-weight: 800; font-size: 11px; }
.np-n { font-weight: 600; font-size: 10px; opacity: 0.75; min-width: 18px; text-align: right; }
.np-note.unseen { background: var(--surface-3); color: var(--text-2); }
.np-note.excluded { opacity: 0.32; text-decoration: line-through; }
.np-note.excluded::after { content: ''; }
.np-legend { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-3); flex-wrap: wrap; }
.np-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-left: 4px; }
.np-swatch.np-unseen { background: var(--surface-3); }
.np-hint { font-size: 10.5px; color: var(--text-3); }

/* ---- Phrase summary sheet ------------------------------------------------- */
.phrase-summary { position: absolute; top: 14px; right: 14px; max-height: calc(100% - 28px); width: min(460px, 52%); z-index: 4; display: flex; flex-direction: column; gap: 10px; background: var(--ink); color: var(--paper); border-radius: 16px; padding: 16px 18px 14px; box-shadow: 0 20px 50px -18px rgba(0,0,0,0.8); overflow: hidden; }
.phrase-summary[hidden] { display: none; }
.ps-top { display: flex; align-items: center; gap: 14px; }
.ps-top .ring { width: 64px; height: 64px; }
.ps-top .ring span { width: 50px; height: 50px; font-size: 15px; }
.ps-title { font-size: 22px; font-weight: 800; line-height: 1.1; }
.ps-sub { font-size: 13px; color: #cfcbc2; margin-top: 3px; }
.ps-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; min-height: 0; overflow: auto; }
.ps-block h4 { margin: 0 0 4px; font-size: 11.5px; font-weight: 700; color: #a9a59a; }
.ps-block ul { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.ps-block li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.ps-block li span:last-child { color: #cfcbc2; white-space: nowrap; }
.ps-block li.bad span:first-child { color: #f08a84; }
.ps-block li.slow span:last-child { color: var(--accent); }
.ps-block .ps-empty { color: #8f8b82; font-size: 12.5px; }
.ps-level { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #cfcbc2; }
.ps-level .pips .pip { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.25); }
.ps-level .pip.pass, .ps-level .pip.fail { box-shadow: none; }
.ps-piece { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: #cfcbc2; padding: 6px 0; border-top: 1px solid rgba(255,255,255,0.08); border-bottom: 1px solid rgba(255,255,255,0.08); }
.ps-piece button { flex: none; color: var(--paper); border-color: rgba(255,255,255,0.25); }
.dual-sel { display: inline-flex; align-items: center; gap: 6px; }
.ps-foot { margin-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ps-continue { font-weight: 800; font-size: 14px; color: var(--accent); animation: ps-pulse 1.6s ease-in-out infinite; }
@keyframes ps-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.ps-foot button.ghost { background: rgba(255,255,255,0.1); box-shadow: none; color: var(--paper); min-height: 36px; padding: 6px 12px; font-size: 13px; }

.ps-chart { flex: none; }
.ps-chart h4 { margin: 0 0 2px; font-size: 11.5px; font-weight: 700; color: #a9a59a; display: flex; justify-content: space-between; gap: 8px; }
.ps-chart h4 span { color: var(--accent); font-weight: 700; }
.ps-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.ps-chart .ps-grid-line { stroke: rgba(255,255,255,0.12); stroke-width: 1; }
.ps-chart .ps-axis { fill: #8f8b82; font-size: 10px; font-weight: 600; font-family: inherit; }
.ps-chart .ps-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ps-chart .ps-dot { fill: var(--ink); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ps-chart .ps-dot.now { fill: var(--accent); }
.ps-chart .ps-val { fill: var(--paper); font-size: 11px; font-weight: 800; font-family: inherit; }
.ps-chart .ps-empty { color: #8f8b82; font-size: 12.5px; margin: 4px 0 0; }

/* ---- Live timer and accuracy on the sheet ---------------------------------- */
.live { position: absolute; top: 12px; left: 16px; z-index: 2; display: flex; gap: 22px; pointer-events: none; }
.live-item { display: flex; flex-direction: column; line-height: 1.05; }
.live-label { font-size: 11px; font-weight: 700; color: #a9a59a; }
.live-value { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.live-value.good { color: #1f9a73; }
.live-value.warn { color: #b07a12; }
.live-value.bad { color: #d4463b; }
.live-value.waiting { color: #a9a59a; }
.version { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-weight: 600; }

/* ---- Scrolling stream ----------------------------------------------------- */
#notation.stream { right: auto; will-change: transform; transition: transform 220ms var(--ease-out); }
#notation.stream.snap { transition: none; }
.clefcard { position: absolute; left: 0; top: 0; bottom: 0; z-index: 1; background: var(--paper); box-shadow: 8px 0 14px -8px rgba(0,0,0,0.18); }
.clefcard[hidden] { display: none; }
.nb-group { display: inline-flex; align-items: center; gap: 10px; }
.nb-group[hidden] { display: none; }

/* ---- Simplified layout -------------------------------------------------- */
.context { flex-wrap: nowrap; gap: 12px; }
.context .seg button { white-space: nowrap; }
.mode-seg button { padding: 7px 10px; font-size: 13px; }
.seg-small button { padding: 5px 8px; }
.nb-keys .chip { padding: 3px 7px; }
.context { gap: 10px; }
.sheet.real .live { top: auto; left: auto; bottom: 12px; right: 16px; }
.summary-grid.three { grid-template-columns: repeat(3, 1fr); max-width: 640px; }
.settings-grid .card.data { grid-column: 1 / -1; }

/* ---- Recently played pieces ----------------------------------------------- */
.ps-piece-btns { display: flex; gap: 6px; flex: none; }
.recent-list { max-height: 360px; overflow: auto; }
table.recent { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.recent td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.recent tr:last-child td { border-bottom: 0; }
table.recent .rc-piece .hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 1px; }
table.recent .rc-when { color: var(--text-3); white-space: nowrap; font-size: 12.5px; width: 1%; padding-right: 14px; }
table.recent .rc-btn { width: 1%; text-align: right; padding-right: 0; }
