:root {
  --bg: #0b0f16; --panel: #121821; --panel2: #18202c; --line: #263040; --text: #e6edf3; --muted: #8b98a9;
  --accent: #ffd166; --r: #4cc9f0; --l: #f4a261; --ok: #3ddc84; --bad: #ff5d5d;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, sans-serif; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
header > * { min-width: 0; flex-shrink: 0; }
header #song { flex-shrink: 1; max-width: 360px; }
header #midiIn { flex-shrink: 1; max-width: 170px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.brand { font-weight: 700; font-size: 16px; color: var(--accent); }
.grow { flex: 1; }
select, input[type=number] { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; min-height: 34px; }
select { cursor: pointer; }
select:hover, input[type=number]:hover { border-color: #3a4a63; }
input[type=number] { width: 58px; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; white-space: nowrap; }
.pill.lvl b { color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #555; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:hover { border-color: #3a4a63; }
.btn.small { padding: 5px 10px; font-size: 13px; min-height: 34px; }
.btn.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 700; }
.btn.wide { flex: 1; }
.btn.stop { background: var(--bad); border-color: var(--bad); color: #fff; }
kbd { background: #0b0f16; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 11px; color: var(--muted); }
main { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr); }
aside { background: var(--panel); overflow-y: auto; padding: 10px 12px; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }
h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
section { margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.muted { color: var(--muted); } .tiny { font-size: 12px; }
.checks { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.seg { display: flex; gap: 4px; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 6px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); cursor: pointer; font-size: 13px; }
.seg small { color: var(--muted); font-size: 11px; }
.seg input:checked + span { border-color: var(--accent); background: #2a2515; }
#chunks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.chunk { position: relative; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 2px; text-align: center; cursor: pointer; font-size: 12px; }
.chunk.sel { border-color: var(--accent); }
.chunk .st { display: block; color: var(--accent); letter-spacing: 1px; min-height: 14px; font-size: 11px; }
.chunk.due::after { content: ''; position: absolute; top: 4px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
#stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.coachbox { padding: 8px 14px; background: #161d29; border-bottom: 1px solid var(--line); min-height: 40px; }
#canvasWrap { flex: 1; min-height: 0; position: relative; }
#roll { display: block; }
#hud { position: absolute; top: 10px; right: 14px; text-align: right; font-weight: 700; font-size: 20px; text-shadow: 0 1px 4px #000; pointer-events: none; }
#hud small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs button { flex: 1; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 8px 5px; min-height: 38px; cursor: pointer; font: inherit; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.big { font-size: 42px; font-weight: 800; line-height: 1; }
.stars { color: var(--accent); font-size: 20px; letter-spacing: 3px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; padding: 2px 0; }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #0b0f16; margin: 6px 0; }
.bar i { display: block; }
.hm { display: flex; flex-wrap: wrap; gap: 2px; }
.hm b { width: 14px; height: 14px; border-radius: 3px; display: block; font-size: 0; }
.ach { padding: 3px 0; } .ach.locked { opacity: .4; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
td, th { text-align: left; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.good { color: var(--ok); } .warn { color: var(--accent); } .bad { color: var(--bad); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222b3a; border: 1px solid var(--accent); padding: 8px 16px; border-radius: 10px; opacity: 0; transition: opacity .25s; pointer-events: none; }
#toast.show { opacity: 1; }


#fingerBar { position: absolute; top: 0; left: 0; right: 0; z-index: 5; opacity: .96; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 14px; background: #1d2433; border-bottom: 1px solid var(--line); }
#fingerBar[hidden] { display: none; }
#fingerBar .fb { width: 34px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-weight: 700; cursor: pointer; }
#fingerBar .fb.on { background: var(--accent); color: #111; border-color: var(--accent); }
#fingerBar .fb.auto { background: #fff; color: #111; }
#roll.edit { cursor: pointer; }

#auth { position: fixed; inset: 0; background: rgba(5, 8, 12, .92); z-index: 50; display: flex; align-items: center; justify-content: center; }
#auth[hidden] { display: none; }
.authbox { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; width: 340px; display: flex; flex-direction: column; gap: 10px; }
.authbox h2 { margin: 0; color: var(--accent); } .authbox h3 { margin: 0 0 4px; text-transform: none; font-size: 15px; color: var(--text); letter-spacing: 0; }
.authbox label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.authbox input { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.authbox label[hidden] { display: none; }

#fingerBar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
#fingerBar .fb.sm { width: 26px; height: 24px; font-size: 12px; }
#fingerBar .btn.on { background: var(--accent); color: #111; border-color: var(--accent); }

.overlay { position: fixed; inset: 0; background: rgba(5, 8, 12, .8); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.overlay[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; width: min(720px, 100%); }
.mhead { display: flex; justify-content: space-between; align-items: center; } .mhead h2 { margin: 0; color: var(--accent); font-size: 18px; }
.drop { margin: 12px 0; border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.drop:hover, body.dragging .drop { border-color: var(--accent); background: #1d2433; }
.big2 { font-size: 17px; font-weight: 600; }
.upfile { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chips span { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chips .r { border-color: var(--r); color: var(--r); } .chips .l { border-color: var(--l); color: var(--l); }
.tracks { margin: 6px 0; }
.warns { margin: 6px 0; padding-left: 18px; color: var(--accent); font-size: 13px; }
.notice { background: #2a2515; border: 1px solid var(--accent); border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-size: 13px; }
.fields { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.fields label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.fields input[type=text], .fields input:not([type]), .fields input[type=number] { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px; font: inherit; }
.fields fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.fields legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.fields label.inl { flex-direction: row; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); }
#pieceList h4 { margin: 14px 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.prow { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--panel2); flex-wrap: wrap; }
.prow.cur { border-color: var(--accent); }
.pact { display: flex; gap: 6px; flex-wrap: wrap; }
.pact a.btn { text-decoration: none; color: var(--text); }
.btn.danger { color: var(--bad); }
.badge { font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); margin-left: 4px; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
#dropHint { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(255, 209, 102, .12); border: 4px dashed var(--accent); color: var(--accent); font-size: 24px; font-weight: 700; align-items: center; justify-content: center; pointer-events: none; }
body.dragging #dropHint { display: flex; }

#sheetWrap { flex: 0 0 clamp(150px, 30%, 270px); position: relative; border-bottom: 3px solid #2a3342; background: #f7f4ea; min-height: 0; }
#sheetWrap.page { flex: 0 0 clamp(300px, 64%, 720px); overflow: hidden; }
#sheetWrap[hidden] { display: none; }
#sheet { display: block; cursor: pointer; }

#tab-teacher { margin: 0 -4px; }
#teacher { display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 130px); }
#teacher.collapsed #tBody { display: none; } #teacher.collapsed { height: auto; }
#tabTeacher[hidden] { display: none; }
.thead { display: flex; align-items: center; gap: 6px; padding: 2px 4px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.thead #tBar { min-width: 84px; text-align: center; font-weight: 600; }
.thead .tf { font-size: 12px; color: var(--muted); }
.ttabs { display: flex; gap: 4px; width: 100%; } .ttabs button { flex: 1; }
.ttabs button { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; cursor: pointer; font: inherit; }
.ttabs button.on { color: var(--text); border-color: var(--accent); }
#tBody { flex: 1; overflow-y: auto; padding: 8px 2px; min-height: 0; }
.tcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; margin-bottom: 7px; }
.tcard p { margin: 4px 0; line-height: 1.45; } .tcard p.sub { margin-left: 16px; color: #c9d4e3; font-size: 13px; }
.tcard.sel { border-color: var(--accent); } .tcard.mine { border-color: var(--ok); }
.tcard .say { color: var(--accent); font-style: italic; }
.tline { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0; flex-wrap: wrap; }
.tcard textarea, .tcard input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
.chips2 { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); } .chip.on { color: #111; background: var(--accent); border-color: var(--accent); }

.authbox label.check { flex-direction: row; gap: 8px; align-items: flex-start; color: var(--text); font-size: 13px; }
.authbox label.check input { margin-top: 3px; width: auto; }
.modal.small { width: min(460px, 100%); }
#profile .fields input[type=email], #profile .fields input[type=password], #profile .fields input:not([type]) { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px; font: inherit; }
#who { cursor: pointer; } #who:hover { border-color: var(--accent); }

.authbox a, .modal a { color: var(--accent); }

.lessonBack { position: fixed; right: 14px; bottom: 14px; z-index: 40; background: var(--accent); color: #1b1b1b; font-weight: 700; padding: 8px 14px; border-radius: 999px; text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.45); }

/* ---- menus, panels and small screens ---- */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-block; }
.menu > summary::-webkit-details-marker { display: none; }
.menu .menuList { position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; min-width: 240px; max-width: min(340px, calc(100vw - 20px)); max-height: calc(100vh - 80px); overflow-y: auto; display: flex; flex-direction: column; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); }
.menu .menuList a { color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: 8px; white-space: nowrap; min-height: 40px; display: flex; align-items: center; }
.menu .menuList .mlab { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 12px 2px; }
.menu .menuList .mlab:first-child { padding-top: 2px; }
.menu .menuList a:hover { background: var(--panel2); }
.menu .menuList a[aria-current="page"] { color: var(--accent); font-weight: 700; }
#setupBtn, #resultsBtn, #fabStart, .panelClose { display: none; }
:focus-visible { outline: 3px solid #7aa7ff; outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@media (max-width: 1100px) {
  main { grid-template-columns: 270px minmax(0, 1fr); }
  #resultsBtn { display: inline-flex; }
  #right { display: block; position: fixed; top: 0; right: 0; bottom: 0; width: min(94vw, 400px); z-index: 60; transform: translateX(105%); transition: transform .2s ease; box-shadow: -10px 0 30px rgba(0, 0, 0, .55); }
  body.show-results #right { transform: none; }
  #right .panelClose, #left .panelClose { display: inline-flex; margin-bottom: 8px; }
  #left .panelClose { display: none; }
}
@media (pointer: coarse) { .btn, .btn.small, select { min-height: 44px; } .seg span { padding: 10px 4px; } } /* finger-sized on touch screens */
@media (max-width: 760px) {
  .menu .menuList { position: fixed; left: 10px; right: 10px; top: 96px; max-width: none; }
  header { flex-wrap: wrap; row-gap: 6px; padding: 6px 10px; }
  header .brand { font-size: 15px; }
  header #song { flex: 1; min-width: 0; max-width: 100%; }
  header #goal, header #streak, header #level, header #midiIn, header #export { display: none; }
  #setupBtn { display: inline-flex; }
  main { display: block; position: relative; }
  #stage { height: 100%; }
  #left { position: fixed; top: 0; left: 0; bottom: 0; width: min(94vw, 400px); z-index: 60; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 10px 0 30px rgba(0, 0, 0, .55); }
  body.show-setup #left { transform: none; }
  #left .panelClose { display: inline-flex; }
  #fabStart { display: inline-flex; position: fixed; right: 14px; bottom: 14px; z-index: 45; padding: 12px 20px; border-radius: 999px; font-size: 16px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); }
  .coachbox { padding: 6px 10px; font-size: 13px; }
  #hud { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { #left, #right { transition: none !important; } }

/* ---- daily practice tracking: session pill, save state, live meters, result extras ---- */
.pill.sess { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; }
.pill.sess:hover { border-color: var(--accent); }
.ring { width: 16px; height: 16px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 3; }
.ring .ringBg { stroke: var(--line); }
.ring .ringFg { stroke: var(--r); stroke-linecap: round; transition: stroke-dasharray .4s; }
.ring.met .ringFg { stroke: var(--ok); }
.sessPart:not(:empty)::after { content: ' ·'; color: var(--muted); }
.pill.save { font-size: 12px; color: var(--muted); }
.pill.save.ok { color: var(--ok); border-color: #24583b; }
.pill.save.wait { color: var(--accent); border-color: #5a4a1f; }
.pill.save.bad { color: var(--bad); border-color: #5a2a2a; text-decoration: none; }
.runbar { height: 5px; background: #0b0f16; flex: none; }
.runbar[hidden] { display: none; }
.runbar i { display: block; height: 100%; width: 0; background: var(--r); transition: width .25s linear; }
.meters { position: absolute; top: 10px; left: 14px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; font-size: 12px; background: rgba(11, 15, 22, .72); border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; z-index: 4; }
.meters[hidden] { display: none; }
.mtr { display: grid; grid-template-columns: 50px 110px 64px; align-items: center; gap: 6px; }
.mtr[hidden] { display: none; }
.mtr span { color: var(--muted); }
.mtr b { position: relative; display: block; height: 8px; border-radius: 4px; background: #0b0f16; overflow: hidden; }
.mtr b i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--ok); border-radius: 4px; transition: width .25s linear; }
.mtr.needle b { overflow: visible; background: linear-gradient(90deg, #4a2b2b 0, #0b0f16 30%, #18402b 45%, #18402b 55%, #0b0f16 70%, #4a2b2b 100%); }
.mtr.needle b i { width: 3px; left: 50%; top: -3px; bottom: -3px; margin-left: -1px; background: var(--text); transition: left .25s linear; }
.mtr em { font-style: normal; text-align: right; white-space: nowrap; }
.devs { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.devs li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.devs li .dot { flex: none; }
.devs .heard { color: var(--muted); font-size: 12px; }
#kbdHelp summary { cursor: pointer; color: var(--accent); padding: 4px 0; min-height: 32px; display: flex; align-items: center; }
#kbdHelp ul { margin: 4px 0; padding-left: 18px; }
#kbdHelp li { margin: 3px 0; }
.subs { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 4px; }
.sub { display: grid; grid-template-columns: 82px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.sub .bar { margin: 0; height: 9px; }
.sub em { font-style: normal; text-align: right; }
.sub.na { opacity: .5; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); } .delta.same { color: var(--muted); }
.barstrip { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0; }
.barstrip button { min-width: 30px; height: 26px; border-radius: 5px; border: 1px solid var(--line); color: #10141b; font: 600 11px system-ui, sans-serif; cursor: pointer; padding: 0 4px; }
.barstrip button:focus-visible { outline-offset: 1px; }
.celebrate { border-color: var(--accent); background: #2a2515; animation: celebrate .6s ease-out 1; }
@keyframes celebrate { 0% { transform: scale(.96); opacity: .3; } 60% { transform: scale(1.02); opacity: 1; } 100% { transform: none; } }
.badge.pb { color: #1a1a1a; background: var(--accent); border-color: var(--accent); }
.badge.partial { color: var(--l); border-color: var(--l); }
.badge.kbd { color: var(--r); border-color: var(--r); }
.saveline { font-size: 12px; margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
#tab-log a.logrow { color: inherit; text-decoration: none; display: block; }
#tab-log a.logrow:hover { color: var(--accent); }
#tab-log a { color: var(--accent); }
.logfilter { display: flex; gap: 6px; align-items: center; margin: 0 0 8px; flex-wrap: wrap; font-size: 12px; }
.menu .menuList button.menuBtn { background: none; border: 0; color: var(--text); text-align: left; font: inherit; padding: 9px 12px; border-radius: 8px; min-height: 40px; cursor: pointer; }
.menu .menuList button.menuBtn:hover { background: var(--panel2); }
.menu .menuList .phoneOnly { display: none; }
#sessBody .kv { gap: 10px; }
#sessBody ul { margin: 4px 0; padding-left: 18px; }
@media (max-width: 760px) {
  header #goal { display: inline-flex; }
  header #goal .sessPart, header #endSess { display: none; }
  .menu .menuList .phoneOnly { display: block; }
  .meters { top: 6px; left: 8px; padding: 4px 7px; flex-direction: row; flex-wrap: wrap; gap: 4px 10px; right: 8px; }
  .mtr { grid-template-columns: auto 60px auto; }
}
@media (prefers-reduced-motion: reduce) {
  .celebrate { animation: none; }
  .ring .ringFg, .runbar i, .mtr b i { transition: none; }
}
@media print { .meters, .runbar, #saveInd, #endSess { display: none !important; } }
