:root {
  --grey:   #b9bec6;
  --red:    #e4564f;
  --yellow: #f2c14e;
  --green:  #4caf6d;
  --bg:     #f4f5f7;
  --card:   #ffffff;
  --ink:    #1f2329;
  --muted:  #6b7280;
  --line:   #e3e6ea;
  --accent: #3d6fd6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-version { font-size: .7rem; color: var(--muted); margin-left: -.5rem; align-self: flex-end; padding-bottom: .15rem; }
/* shared main navigation (built by header.js) */
.mainnav { display: inline-flex; align-items: center; gap: .15rem; flex-wrap: wrap; }
.context-nav { margin-left: auto; display: inline-flex; align-items: center; gap: .6rem; }
.context-nav:empty { display: none; }

.nav-link { color: var(--muted); font-size: .92rem; padding: .4rem .55rem; border-radius: 8px; }
.nav-link:hover { background: #f0f2f5; text-decoration: none; color: var(--ink); }
.nav-link.disabled, .nav-link.disabled:hover { color: #b3b9c2; cursor: default; background: none; }

.nav-item { position: relative; display: inline-flex; }
.nav-btn {
  font: inherit; font-size: .92rem; color: var(--ink); background: none; border: none;
  cursor: pointer; padding: .4rem .55rem; border-radius: 8px; display: inline-flex; align-items: center; gap: .3rem;
}
.nav-btn:hover { background: #f0f2f5; }
.piece-name { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: .3rem; z-index: 50; display: flex; flex-direction: column;
}
.menu-item {
  display: block; text-align: left; font: inherit; font-size: .9rem; color: var(--ink);
  background: none; border: none; cursor: pointer; padding: .45rem .6rem; border-radius: 7px;
  width: 100%; box-sizing: border-box;
}
.menu-item:hover { background: #f0f2f5; text-decoration: none; }
.menu-item.disabled, .menu-item.disabled:hover { color: #b3b9c2; cursor: default; background: none; }
.menu-item.menu-sub { padding-left: 1.3rem; }
.menu-item.chosen { font-weight: 600; color: var(--accent); }
.menu-group { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .4rem .6rem .15rem; }
.menu-sep { height: 1px; background: var(--line); margin: .3rem .2rem; }

/* piece picker (modal popup) — search + recents + by-composer + tags */
.picker-backdrop {
  position: fixed; inset: 0; background: rgba(20,24,31,.4); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 1rem;
}
.picker {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; width: 100%;
  max-width: 560px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.picker-head { display: flex; gap: .5rem; align-items: center; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
.picker-search { flex: 1; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.picker-close { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1.1rem; padding: .3rem .5rem; }
.picker-close:hover { color: var(--ink); }
.picker-body { overflow-y: auto; padding: .3rem .5rem; }
.picker-section-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .55rem .55rem .2rem; }
.picker-group { font-size: .82rem; font-weight: 600; color: var(--ink); padding: .5rem .55rem .15rem; }
.picker-row {
  display: flex; align-items: center; gap: .7rem; width: 100%; box-sizing: border-box;
  padding: .5rem .55rem; border-radius: 9px; cursor: pointer; text-align: left;
}
.picker-row:hover { background: #f0f2f5; }
.picker-row.chosen { background: #eaf0fb; }
.picker-row.chosen .picker-title::after { content: " ✓"; color: var(--accent); }
.picker-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.picker-title { font-weight: 500; color: var(--ink); }
.picker-comp { color: var(--muted); font-weight: 400; font-size: .9em; }
.picker-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.picker-tag {
  font: inherit; font-size: .72rem; color: var(--accent); background: #eef3fc; border: 1px solid #d6e2f7;
  border-radius: 999px; padding: .05rem .45rem; cursor: pointer;
}
.picker-tag:hover { background: #dce8fb; }
.picker-gauge { flex: none; width: 90px; margin: 0; }
.picker-gauge .gauge-bar { width: 100%; }
.picker-nostatus { flex: none; width: 90px; color: var(--muted); font-size: .8rem; text-align: center; }
.picker-foot { border-top: 1px solid var(--line); padding: .6rem .8rem; }
.picker-empty { padding: 1.4rem; text-align: center; }

/* tags editor on the piece view */
.piece-tags-edit { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin-top: .55rem; }
.tags-label { font-size: .8rem; color: var(--muted); margin-right: .1rem; }
.tag-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; background: #eef3fc; color: var(--accent); border: 1px solid #d6e2f7; border-radius: 999px; padding: .1rem .2rem .1rem .55rem; }
.tag-x { border: none; background: none; color: inherit; cursor: pointer; font-size: .95rem; line-height: 1; padding: 0 .2rem; }
.tag-x:hover { color: var(--red); }
.tag-input { font: inherit; font-size: .8rem; border: 1px dashed var(--line); border-radius: 999px; padding: .12rem .55rem; min-width: 6rem; }
.tag-input:focus { outline: none; border-color: var(--accent); border-style: solid; }

/* Layout ⇄ Practice toggle */
.mode-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--card); }
.mode-toggle .seg {
  padding: .5rem .85rem; font: inherit; line-height: 1; color: var(--ink);
  cursor: pointer; text-decoration: none; border: none; background: transparent;
}
.mode-toggle .seg:hover { background: #f0f2f5; text-decoration: none; }
.mode-toggle .seg.active { background: var(--accent); color: #fff; cursor: default; }

main { max-width: 1000px; margin: 0 auto; padding: 1.25rem; }

/* ---- headings / layout ---- */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
.composer { color: var(--muted); margin: .15rem 0 0; }
.muted { color: var(--muted); font-weight: 400; }
.hint {
  background: #eef3fb; border: 1px solid #d8e3f7; color: #33405a;
  padding: .6rem .8rem; border-radius: var(--radius); font-size: .9rem; margin: 0 0 1rem;
}
.empty { color: var(--muted); padding: 1rem 0; }
.empty.small { padding: .25rem 0; font-size: .9rem; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}

/* ---- buttons ---- */
.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  padding: .5rem .85rem; border-radius: 9px; line-height: 1;
}
.btn:hover { border-color: #c8cdd4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #335fc0; }
.btn.ghost { background: transparent; }
.btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- forms ---- */
label { display: block; margin-bottom: .7rem; font-size: .9rem; color: var(--muted); }
input[type=text] {
  display: block; width: 100%; margin-top: .25rem;
  padding: .55rem .65rem; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
}
.form-actions { display: flex; gap: .5rem; }
.hidden { display: none !important; }
.new-piece-form { max-width: 420px; }

/* ---- file upload ---- */
.upload-form .file-label {
  display: inline-block; cursor: pointer; margin: 0 .5rem .5rem 0;
}
.upload-form .file-label input { display: none; }
.upload-form .file-label span {
  display: inline-block; padding: .55rem .85rem; border: 1px dashed #b9c0cb;
  border-radius: 9px; color: var(--accent); background: #f7f9fd;
}
.upload-status { font-size: .9rem; color: var(--muted); margin-left: .5rem; }

/* ---- dashboard ---- */
.piece-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; cursor: pointer; }
.piece-head-main { flex: 1; min-width: 0; }
.piece-toggle {
  border: none; background: none; cursor: pointer; color: var(--muted); font-size: .9rem;
  padding: .15rem .25rem; margin-top: .35rem; line-height: 1; transition: transform .12s ease;
}
.piece-card.expanded .piece-toggle { transform: rotate(90deg); }
.piece-pages { display: none; }
.piece-card.expanded .piece-pages { display: block; }
.badge {
  background: #eef1f5; color: var(--muted); border-radius: 999px;
  padding: .2rem .6rem; font-size: .8rem; white-space: nowrap;
}
.piece-card-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.piece-card-actions .btn { font-size: .82rem; padding: .3rem .6rem; }
.piece-card-actions .piece-delete { color: #a33; }
.piece-card-actions .piece-delete:hover { background: #fdeded; border-color: #e0b4b4; }
.btn.disabled { opacity: .45; pointer-events: none; }
.piece-edit-form { display: flex; flex-direction: column; gap: .4rem; }
.piece-edit-form input { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.piece-edit-form .pe-title { font-size: 1.05rem; font-weight: 600; }
.pe-actions { display: flex; gap: .4rem; }
.page-table { width: 100%; border-collapse: collapse; margin-top: .75rem; }
.page-table th { text-align: left; font-size: .78rem; color: var(--muted); font-weight: 600; padding: .35rem .4rem; }
.page-table td { padding: .45rem .4rem; border-top: 1px solid var(--line); cursor: pointer; }
.page-table tbody tr:hover { background: #f8fafc; }
.page-table .num { text-align: right; color: var(--muted); }

/* ---- fuel gauge ---- */
.gauge { margin: .5rem 0; }
.gauge-bar {
  display: flex; height: 16px; border-radius: 8px; overflow: hidden;
  background: var(--grey); border: 1px solid var(--line);
}
.gauge.mini .gauge-bar { height: 10px; }
.seg { height: 100%; }
.seg-grey   { background: var(--grey); }
.seg-red    { background: var(--red); }
.seg-yellow { background: var(--yellow); }
.seg-green  { background: var(--green); }
.gauge-legend { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.chip {
  font-size: .76rem; padding: .12rem .5rem; border-radius: 999px;
  text-transform: capitalize; color: #fff;
}
.chip-grey   { background: var(--grey); color: #2b2f36; }
.chip-red    { background: var(--red); }
.chip-yellow { background: var(--yellow); color: #4a3b00; }
.chip-green  { background: var(--green); }

/* ---- piece page thumbnails ---- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.page-thumb { padding: .5rem; display: block; text-align: center; }
.page-thumb img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 8px; background: #eee; border: 1px solid var(--line);
}
.page-thumb-label { display: block; margin-top: .4rem; color: var(--muted); font-size: .85rem; }

/* ---- page editor ---- */
.editor { position: relative; }
.image-wrap {
  position: relative; display: inline-block; max-width: 100%;
  line-height: 0; user-select: none; -webkit-user-select: none;
}
.image-wrap img { max-width: 100%; height: auto; display: block; border-radius: 8px; }
.overlay { position: absolute; inset: 0; }
/* right-click / long-press measure menu */
.ctx-menu {
  position: fixed; z-index: 60; background: var(--card);
  border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 8px 28px rgba(0,0,0,.20); padding: .45rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.ctx-colors { display: flex; gap: .35rem; }
.ctx-menu .sw {
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  border: 2px solid rgba(0,0,0,.18); padding: 0;
}
.ctx-menu .sw-grey   { background: var(--grey); }
.ctx-menu .sw-red    { background: var(--red); }
.ctx-menu .sw-yellow { background: var(--yellow); }
.ctx-menu .sw-green  { background: var(--green); }
.ctx-menu .sw:hover  { border-color: rgba(0,0,0,.55); }
.ctx-menu .sw.current { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset, 0 0 0 4px var(--ink); }
/* notation value picker (fingering digits / accidental glyphs) */
.ctx-vals { display: flex; gap: .3rem; }
.ctx-vals .ctx-val { min-width: 2em; padding: .3rem .45rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.ctx-vals .ctx-val:hover { border-color: var(--accent); }
.ctx-vals .ctx-val.current { border-color: var(--ink); background: var(--ink); color: #fff; }

/* notation layer (fingering / accidental glyphs + circle / rectangle shapes) */
.notation { position: absolute; z-index: 5; }
.note-glyph {
  transform: translate(-50%, -50%); font-weight: 700; font-size: 1rem; line-height: 1;
  padding: 1px 3px; border-radius: 4px; background: rgba(255,255,255,.72); cursor: move; user-select: none;
}
.note-fingering  { color: #1769aa; }
.note-accidental { color: #8a1a1a; font-size: 1.15rem; }
.note-shape { border: 2px solid #d11; background: rgba(221,17,17,.06); cursor: move; box-sizing: border-box; }
.note-circle { border-radius: 50%; }
.note-handle {
  position: absolute; right: -7px; bottom: -7px; width: 13px; height: 13px;
  background: #fff; border: 2px solid #d11; border-radius: 3px; cursor: se-resize;
}
.ctx-item, .ctx-del {
  font: inherit; cursor: pointer; border: none; background: transparent;
  padding: .45rem .55rem; border-radius: 8px; text-align: left; white-space: nowrap;
}
.ctx-item { color: var(--ink); }
.ctx-item:hover { background: #eef1f5; }
.ctx-del { color: var(--red); }
.ctx-del:hover { background: #fdeceb; }

/* ---- systems, measures, lines, handles ---- */
.system {
  position: absolute; box-sizing: border-box;
  /* same weight/colour as the internal measure lines */
  border: 3px solid rgba(20,30,60,.9);
  border-radius: 2px;
}

.measure {
  position: absolute; top: 0; bottom: 0; box-sizing: border-box;
  cursor: pointer; transition: background .12s;
  /* iOS: suppress the long-press image/selection callout so long-press = our menu */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.measure.s-grey   { background: transparent; }
.measure.s-red    { background: rgba(228,86,79,.50); }
.measure.s-yellow { background: rgba(242,193,78,.55); }
.measure.s-green  { background: rgba(76,175,109,.50); }
.measure:hover { filter: brightness(.94); }

/* measure number, sitting just above the system box, centred over its cell */
.measure-num {
  position: absolute; top: -3px; left: 0;
  transform: translate(-50%, -100%);
  font-size: 11px; line-height: 1; color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none; white-space: nowrap;
}

/* draggable / right-clickable measure line between two cells */
.divider {
  position: absolute; top: 0; bottom: 0; width: 11px;
  transform: translateX(-50%); cursor: ew-resize; z-index: 4;
  background:
    linear-gradient(to right, transparent 4px, rgba(20,30,60,.9) 4px,
                    rgba(20,30,60,.9) 7px, transparent 7px);
}
.divider:hover {
  background: linear-gradient(to right, transparent 4px, var(--accent) 4px,
              var(--accent) 7px, transparent 7px);
}

/* resize handles — always visible */
.handle {
  position: absolute; width: 13px; height: 13px; box-sizing: border-box;
  background: #fff; border: 1.5px solid var(--accent); border-radius: 3px; z-index: 5;
}
.h-nw { left: 0;   top: 0;   transform: translate(-50%,-50%); cursor: nwse-resize; }
.h-n  { left: 50%; top: 0;   transform: translate(-50%,-50%); cursor: ns-resize; }
.h-ne { left: 100%;top: 0;   transform: translate(-50%,-50%); cursor: nesw-resize; }
.h-e  { left: 100%;top: 50%; transform: translate(-50%,-50%); cursor: ew-resize; }
.h-se { left: 100%;top: 100%;transform: translate(-50%,-50%); cursor: nwse-resize; }
.h-s  { left: 50%; top: 100%;transform: translate(-50%,-50%); cursor: ns-resize; }
.h-sw { left: 0;   top: 100%;transform: translate(-50%,-50%); cursor: nesw-resize; }
.h-w  { left: 0;   top: 50%; transform: translate(-50%,-50%); cursor: ew-resize; }

.draw-rect {
  position: absolute; border: 2px dashed var(--accent);
  background: rgba(61,111,214,.15); pointer-events: none;
}
/* vertical guide that follows the cursor while adding lines */
.lines-guide {
  position: absolute; width: 0; border-left: 2px dashed var(--accent);
  pointer-events: none;
}

/* cursors: empty area draws a system; cells colour; handles/lines drag */
.overlay { cursor: crosshair; }
.measure { cursor: pointer; }
.editor.lines-on .measure { cursor: copy; }
.hidden { display: none !important; }

/* ---- practice screen (Phase 2) ---- */
.session-line { color: var(--muted); margin: .15rem 0 0; font-size: .9rem; }

.practice-stage {
  position: relative; width: 100%; height: 56vh; max-height: 640px;
  overflow: hidden; background: #eef0f3;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.practice-stage .image-wrap {
  position: absolute; top: 0; left: 0; width: 100%;
  transform-origin: 0 0; transition: transform .35s ease; display: block;
}
.practice-stage .image-wrap img { width: 100%; height: auto; display: block; }
.practice-stage .measure { cursor: pointer; }
.practice-stage .measure.selected {
  outline: 3px solid #2d6cff; outline-offset: -2px; filter: brightness(1.06) saturate(1.2);
}

/* page-jump bar (practice + layout) */
.page-bar { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.page-bar:empty { display: none; }
.page-bar .btn { min-width: 2.4em; text-decoration: none; }
.page-nav-btn:disabled { opacity: .4; cursor: default; }

/* layout image brightness/contrast control */
.img-adjust { display: inline-flex; align-items: center; gap: .6rem; }
.img-adjust label { display: inline-flex; align-items: center; gap: .25rem; margin: 0; color: var(--muted); }
.img-adjust input[type=range] { width: 88px; }

/* two-up practice pages */
.pages-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.pages-two.single { grid-template-columns: minmax(0, 52%); }
.page-panel .panel-label { font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.page-panel .image-wrap { position: relative; display: block; width: 100%; line-height: 0; }
.page-panel .image-wrap img {
  width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 8px; background: #eef0f3;
}
.page-panel .overlay { position: absolute; inset: 0; }
.page-panel .measure { cursor: pointer; }
.page-panel .measure.selected { outline: 3px solid #2d6cff; outline-offset: -2px; filter: brightness(1.06) saturate(1.2); }

/* per-measure zoom icon (only on selected measures) */
.measure-zoom {
  display: none; position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; padding: 0; line-height: 1; font-size: 11px;
  border: none; border-radius: 5px; background: rgba(255,255,255,.9); cursor: pointer;
  align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.35); z-index: 3;
}
.measure.selected .measure-zoom { display: flex; }
.measure-zoom:hover { background: #fff; }

/* zoom-to-play modal */
.zoom-modal { position: fixed; inset: 0; z-index: 90; background: rgba(18,22,30,.93); display: flex; flex-direction: column; }
.zoom-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .45rem 1rem; color: #fff; font-size: .82rem; }
.zoom-head #zoom-title { margin-right: .5rem; white-space: nowrap; }
.zoom-head .btn { color: #fff; border-color: rgba(255,255,255,.4); background: transparent; padding: .32rem .6rem; }
.zoom-head .btn:hover { background: rgba(255,255,255,.12); }
.zoom-timer { display: inline-flex; align-items: center; gap: .6rem; margin-left: auto; margin-right: .8rem; }
.zoom-clock { color: #fff; font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.zoom-head .btn.danger { border-color: rgba(255,120,120,.7); color: #fff; }
.zoom-viewport { position: relative; flex: 1; overflow-y: auto; }
/* focused-practice journal pinned to the popup bottom: fixed title + scrolling list.
   Height is user-set by dragging .zoom-resize (persisted); the list scrolls inside. */
.zoom-resize {
  flex: 0 0 auto; height: 12px; cursor: row-resize; background: #e8edf4;
  position: relative; touch-action: none; user-select: none;
}
.zoom-resize:hover { background: #dbe4f0; }
.zoom-resize::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 3px; border-radius: 3px; background: #9aa3b0;
}
.zoom-recent { flex: 0 0 auto; height: 165px; display: flex; flex-direction: column;
  background: #fff; padding: .5rem .9rem .7rem; box-sizing: border-box; }
.zoom-recent-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex: 0 0 auto; }
.zoom-recent-head .zoom-recent-title { margin-bottom: 0; }
.zoom-recent-head .jo-new { color: var(--accent); font-weight: 600; }
.zoom-recent-head .jo-new:disabled { color: var(--muted); opacity: .5; cursor: default; background: none; }
.zoom-recent-title { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 .15rem; color: var(--muted); flex: 0 0 auto; }
.zoom-recent-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.jo-draft { border-left: 3px solid var(--accent); padding-left: .5rem; }
/* practice popup: selected measures as cropped snippets in a 4-column grid */
.zoom-snippets { display: grid; grid-template-columns: repeat(5, 1fr); gap: .7rem; padding: .9rem; align-content: start; }
.snippet-cell { background: #fff; border: 4px solid #b9c0cc; border-radius: 7px; padding: .35rem .45rem; min-width: 0; cursor: context-menu; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.snippet-canvas { -webkit-touch-callout: none; }
.snippet-cell[data-status="red"]    { border-color: var(--red); }
.snippet-cell[data-status="yellow"] { border-color: var(--yellow); }
.snippet-cell[data-status="green"]  { border-color: var(--green); }
#snippet-menu { z-index: 120; }   /* above the practice popup (z-90) */
.snippet-label { color: var(--muted); font-size: .78rem; font-weight: 600; margin-bottom: .3rem; }
.snippet-frame { position: relative; line-height: 0; }
.snippet-canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 3px; background: #fff; }
/* notation overlay on a snippet (fingering/accidental glyphs + circle/rectangle shapes) */
.snippet-notes { position: absolute; inset: 0; }
.snip-note { position: absolute; }
.snip-fingering, .snip-accidental {
  transform: translate(-50%, -50%); font-weight: 700; font-size: .95rem; line-height: 1;
  padding: 0 2px; border-radius: 3px; background: rgba(255,255,255,.72); cursor: move; user-select: none;
}
.snip-fingering  { color: #1769aa; }
.snip-accidental { color: #8a1a1a; font-size: 1.1rem; }
.snip-shape { border: 2px solid #d11; background: rgba(221,17,17,.06); cursor: move; box-sizing: border-box; }
.snip-circle { border-radius: 50%; }
.snip-handle { position: absolute; right: -7px; bottom: -7px; width: 13px; height: 13px; background: #fff; border: 2px solid #d11; border-radius: 3px; cursor: se-resize; }

/* fingering = a vertical stack of digits (chords); hand sets the order/colour */
.note-fingering, .snip-fingering { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.fing-num { font-weight: 700; font-size: .92rem; }
.fing-lh .fing-num { color: #1769aa; }    /* left hand */
.fing-rh .fing-num { color: #146b2e; }    /* right hand */

/* fingering editor (hand toggle + 1–5 multi-select) inside the right-click menu */
.fing-editor { display: flex; flex-direction: column; gap: .35rem; padding: .1rem; }
.fing-hands, .fing-digits { display: flex; gap: .3rem; }
.fing-hand, .fing-dig {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 7px; padding: .25rem .45rem; min-width: 2em;
}
.fing-dig { min-width: 2.1em; font-weight: 600; }
.fing-hand.on, .fing-dig.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.zoom-empty { color: #fff; opacity: .8; text-align: center; padding: 2rem; grid-column: 1 / -1; }
@media (max-width: 900px) { .zoom-snippets { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .zoom-snippets { grid-template-columns: repeat(2, 1fr); } }

/* practice selection bar (opens the popup) */
.practice-bar { display: flex; align-items: center; gap: .8rem; margin: .2rem 0 .9rem; }
.practice-bar .sel-count { color: var(--muted); }

/* popup timer controls (in the zoom header) */
.zoom-controls { display: inline-flex; align-items: center; gap: .5rem; margin-left: auto; margin-right: .8rem; flex-wrap: wrap; }
.zoom-presets { display: inline-flex; gap: .3rem; }
.zoom-running { display: inline-flex; align-items: center; gap: .6rem; }

/* popup stage 2: log-the-practice note */
.zoom-note { width: 100%; max-width: 640px; margin: 0 auto; padding: 1.6rem 1.2rem; box-sizing: border-box; color: #fff; }
.zoom-note h2 { color: #fff; margin: 0 0 .7rem; }
#zoom-note-text { width: 100%; box-sizing: border-box; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; line-height: 1.4; resize: vertical; }
.zoom-note-meta { color: #cfd6e0; font-size: .85rem; margin: .6rem 0 1rem; }
.zoom-note-actions { display: flex; gap: .6rem; }
@media (max-width: 700px) {
  .pages-two { grid-template-columns: 1fr; }
  .pages-two.single { grid-template-columns: 1fr; }
}

.journal-card { margin-top: 1rem; }
.journal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.journal-head h2 { font-size: 1.05rem; margin: 0; }
.journal-status { font-size: .8rem; color: var(--muted); white-space: nowrap; }
#journal-text {
  display: block; width: 100%; box-sizing: border-box; resize: vertical;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; line-height: 1.45; min-height: 5.5em;
}

.practice-panel { margin-top: 1rem; }
.timer-block { text-align: center; }
.presets { display: flex; gap: .5rem; justify-content: center; margin-bottom: .6rem; }
.countdown {
  font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
.timer-buttons { display: flex; gap: .6rem; justify-content: center; margin: .6rem 0 .2rem; }
.timer-buttons .btn { min-width: 100px; }
.sel-count { color: var(--muted); text-align: center; margin: .3rem 0 0; }

.rate-block h2 { text-align: center; }
.set-all { display: flex; align-items: center; gap: .4rem; justify-content: center; margin-bottom: .7rem; color: var(--muted); }
#rate-list { display: flex; flex-direction: column; gap: .45rem; max-width: 360px; margin: 0 auto .8rem; }
.rate-row { display: flex; align-items: center; gap: .5rem; }
.rate-label { width: 48px; color: var(--muted); font-variant-numeric: tabular-nums; }
#chunk-note {
  display: block; width: 100%; max-width: 360px; margin: 0 auto .8rem;
  padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; line-height: 1.4; resize: vertical;
}
.rate-actions { display: flex; gap: .6rem; justify-content: center; }

/* colour swatches (rating + context menu) */
.sw { width: 36px; height: 36px; border-radius: 8px; cursor: pointer; border: 2px solid rgba(0,0,0,.18); padding: 0; }
.sw-grey { background: var(--grey); } .sw-red { background: var(--red); }
.sw-yellow { background: var(--yellow); } .sw-green { background: var(--green); }
.sw:hover { border-color: rgba(0,0,0,.55); }
.sw.chosen { border-color: #111; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #111; }

/* ---- day view ---- */
.day-nav .btn { min-width: 2.4em; }
.summary-total { font-size: 1.1rem; }
.summary-breakdown { font-size: .9rem; margin-top: .2rem; }

/* Daily reflection: three notebook blocks stacked vertically (was a 3-up row).
   The category lives in the red margin, so each block needs no header. */
.day-reflect { display: flex; flex-direction: column; gap: .7rem; }
.reflect-card { display: flex; flex-direction: column; gap: .2rem; }
.reflect-card .journal-status { align-self: flex-end; }
/* reflection labels (e.g. "Goals / next steps") wrap inside the margin */
.day-reflect .ruled-actlabel {
  height: auto; align-items: flex-start; padding: 2px 2px 0;
  white-space: normal; line-height: 1.15;
  overflow-wrap: break-word; word-break: break-word;
}

/* Journal tabs: a slim rail of activity tabs + the active panel. Labels wrap so
   the rail stays narrow; the active tab is highlighted, a running one shows ●. */
.journal-tabbed { display: flex; gap: 1rem; align-items: flex-start; }
.journal-tabs { display: flex; flex-direction: column; gap: .4rem; flex: 0 0 auto; width: 94px; }
.jtab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center; padding: .55rem .3rem; cursor: pointer; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 10px; font: inherit;
  transition: background .12s, border-color .12s;
}
.jtab:hover { background: #f8fafc; }
.jtab.active { background: #eef3fd; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.jtab-icon { font-size: 1.15rem; line-height: 1; position: relative; }
.jtab-run { position: absolute; top: -3px; right: -11px; color: var(--accent); font-size: .55rem; }
.jtab-label { font-size: .72rem; line-height: 1.12; font-weight: 600; overflow-wrap: anywhere; word-break: break-word; }
.jtab-total { font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.jtab.running .jtab-label { color: var(--accent); }

.journal-panel { flex: 1; min-width: 0; }
.journal-panel .activity-body { display: block; padding: 0; border-top: none; }
.panel-h { font-size: .95rem; margin: 1.2rem 0 .55rem; }
.journal-panel .day-summary { margin: 0 0 .2rem; }

@media (max-width: 700px) {
  .journal-tabbed { flex-direction: column; }
  .journal-tabs { flex-direction: row; flex-wrap: wrap; width: auto; }
  .jtab { flex: 1 1 78px; }
}

/* collapsible activity sections */
.activity { padding: 0; overflow: hidden; }
.activity-head {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  background: none; border: none; cursor: pointer; font: inherit; text-align: left;
  padding: .8rem 1.1rem; color: var(--ink);
}
.activity-head:hover { background: #f8fafc; }
.act-icon { font-size: 1.1rem; }
.act-label { font-weight: 600; }
.act-total { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.act-run { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.act-caret { transition: transform .15s; color: var(--muted); }
.activity.open .act-caret { transform: rotate(90deg); }
.activity.running { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(61,111,214,.18); }

.activity-body { display: none; padding: 0 1.1rem 1rem; border-top: 1px solid var(--line); }
.activity.open .activity-body { display: block; }
.act-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding-top: .8rem; }
.act-clock { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.8em; }
.act-timer-btns { margin-left: auto; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.act-timer-btns .presets { display: inline-flex; gap: .3rem; }
.act-timer-btns .manual { display: inline-flex; align-items: center; gap: .25rem; color: var(--muted); }
.act-timer-btns .manual-min { width: 4.5em; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: #cf463f; }

.undo-toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: .8rem; z-index: 80;
  background: var(--ink); color: #fff; padding: .6rem .7rem .6rem 1rem;
  border-radius: 11px; box-shadow: 0 8px 28px rgba(0,0,0,.28);
}
.undo-toast .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.undo-toast .btn:hover { background: rgba(255,255,255,.12); }
.act-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.act-meta .act-note {
  flex: 1; min-width: 200px; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; line-height: 1.4; resize: none; overflow: hidden;
}
.piece-select { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; align-self: flex-start; }

.entries { margin-top: .7rem; max-height: 260px; overflow-y: auto; }
.entry-row { display: flex; align-items: flex-start; gap: .5rem; padding: .4rem 0; border-top: 1px solid var(--line); }
.entry-row:first-child { border-top: none; }
.entry-min { width: 4.5em; padding: .3rem .4rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; margin-top: 2px; }
.entry-body { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 2px; }
.entry-note {
  width: 100%; box-sizing: border-box; padding: .35rem .5rem; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; line-height: 1.4; resize: none; overflow: hidden;
}
/* Notebook-paper note: light-blue ruled lines that grow one line at a time.
   A fixed px line-height + zero vertical padding makes the textarea's
   scrollHeight an exact multiple of the line band, so auto-grow keeps every
   line sitting on a rule. background-attachment:local scrolls the rules with
   the text. Starts at two lines (min-height = 2 bands). */
.act-meta .act-note.ruled-note,
.entry-note.ruled-note,
.reflect-note.ruled-note,
.jo-note.ruled-note {
  font-size: 12px;
  line-height: 26px;
  padding: 2px .6rem 0 58px;     /* big left pad clears the red margin line */
  min-height: 54px;             /* 2px top + two 26px ruled lines */
  border: 1px solid #cfe0f3;
  border-radius: 7px;
  background-color: #fff;
  /* layer 1: vertical red margin line (full height, no repeat)
     layer 2: horizontal light-blue rules (one per 26px line) */
  background-image:
    linear-gradient(to right, transparent 0 47px, #e6a9a9 47px, #e6a9a9 49px, transparent 49px),
    linear-gradient(to bottom, transparent 0, transparent 25px, #bcdcff 25px, #bcdcff 26px);
  background-size: 100% 100%, 100% 26px;
  background-position: 0 0, 0 2px;
  background-repeat: no-repeat, repeat;
  background-attachment: local, local;
}
.act-meta .act-note.ruled-note:focus,
.entry-note.ruled-note:focus,
.reflect-note.ruled-note:focus,
.jo-note.ruled-note:focus { border-color: #8fbdf0; outline: none; }
.reflect-note.ruled-note { min-height: 80px; }   /* starts at three ruled lines */

/* notebook margin: holds the activity label beside the first line */
.ruled-wrap { position: relative; width: 100%; }
.act-meta .ruled-wrap { flex: 1; min-width: 200px; }
.ruled-wrap > .ruled-note { width: 100%; box-sizing: border-box; }
.ruled-actlabel {
  position: absolute; left: 0; top: 2px; width: 46px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; line-height: 1.1; text-align: center;
  color: #c0392b; text-transform: lowercase; letter-spacing: .2px;
  pointer-events: none; overflow: hidden;
}

/* JournalObject component: clickable margin category + save/delete icons */
.journal-object { width: 100%; }
button.ruled-actlabel.jo-cat { pointer-events: auto; cursor: pointer; background: none; border: 0; padding: 0; }
button.ruled-actlabel.jo-cat:hover { text-decoration: underline; }
.jo-cat-select {                                 /* dropdown overlays the margin, wide enough to read */
  position: absolute; left: 2px; top: 2px; z-index: 6;
  min-width: 9rem; font: inherit; font-size: 12px;
  padding: .2rem .3rem; border: 1px solid var(--accent); border-radius: 7px; background: #fff;
}
.jo-toolbar { display: flex; justify-content: flex-end; gap: .2rem; margin-bottom: .35rem; }
/* small, low-detail glyph buttons (save / edit / delete / cancel) */
.jo-act {
  background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: .8rem; line-height: 1; padding: .15rem .3rem; border-radius: 5px;
}
.jo-act:hover { color: var(--ink); background: #eef3fd; }
.jo-act-save { color: #2c6e49; }
.jo-del:hover, .jo-cancel:hover { color: #a33; background: #fdeded; }
.jo-latest-item { margin: .2rem 0 .9rem; }
.jo-latest-actions { display: flex; justify-content: flex-end; align-items: center; gap: .1rem; margin-bottom: .1rem; }
/* autosave status ("Editing… / Saving… / Saved") shown next to the entry's actions */
.jo-status { font-size: .7rem; color: var(--muted); margin-right: .3rem; }
/* per-activity compose toolbar (status · discard · new) above the journal-object box */
.act-compose-bar { display: flex; justify-content: flex-end; align-items: center; gap: .25rem; margin: .6rem 0 .15rem; }
/* meta line beneath a journal note: duration · piece · measures (left), clock (right) */
.jo-meta { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; font-size: 11px; color: var(--muted); padding-left: 58px; margin-top: 2px; }
.jo-meta-left { font-variant-numeric: tabular-nums; }
.jo-meta-clock { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.entry-piece { font-size: .78rem; font-style: italic; color: var(--muted); padding-left: .15rem; }
/* meta line under a note: plain (clickable) text for time / piece / measures —
   no boxes; an editable value only becomes an input once clicked */
.entry-meta { display: flex; flex-wrap: wrap; gap: .15rem .7rem; align-items: baseline; margin-top: 3px; padding-left: .15rem; }
.meta-chip {
  font: inherit; font-size: .78rem; color: var(--muted);
  background: none; border: none; padding: 0; line-height: 1.5; cursor: pointer;
}
.meta-chip.static { cursor: default; }
.meta-chip:not(.static):hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-style: dotted; }
.meta-badge { font-weight: 600; color: var(--ink); }
.meta-clock { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: auto; }
.meta-piece { font-style: italic; }
.meta-edit { font: inherit; font-size: .82rem; padding: .12rem .35rem; border: 1px solid var(--accent); border-radius: 7px; background: #fff; }
.meta-edit[type="number"] { width: 5em; }
.meta-edit-measures { width: 8em; }

/* Settings page */
.settings-card { max-width: 560px; }
.settings-form label { display: block; font-weight: 600; margin: .6rem 0 .2rem; }
.settings-form input[type="text"], .settings-form input[type="password"], .settings-form select { width: 100%; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.settings-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.settings-saved { color: #2c6e49; font-weight: 600; }
.entry-del { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: .3rem .4rem; margin-top: 2px; }

/* unified journaling view */
.journal-compose { padding-top: .8rem; }
.j-radios { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-bottom: .5rem; }
.j-radio { display: inline-flex; align-items: center; gap: .3rem; margin: 0; color: var(--ink); font-size: .9rem; }
.journal-compose .act-note { display: block; width: 100%; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; line-height: 1.4; resize: none; overflow: hidden; }
.j-add-row { display: flex; gap: .5rem; align-items: center; margin-top: .5rem; }
.j-add-row .manual-min { width: 9em; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.journal-tools { display: flex; gap: .5rem; align-items: center; margin: .9rem 0 .3rem; flex-wrap: wrap; }
.journal-tools #j-search { flex: 1 1 12rem; min-width: 9rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.journal-tools select, .journal-tools .j-measures { padding: .45rem .5rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.journal-tools .j-measures { width: 8.5em; }
.journal-tools #j-clear { padding: .4rem .7rem; }
.j-badge { min-width: 6.5em; font-size: .8rem; color: var(--muted); margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- practice plan ---- */
.plan-page { max-width: 820px; margin: 0 auto; }
.plan-head h1 { margin-bottom: .15rem; }
.plan-program { margin: 0 0 1rem; }
.plan-block h2, .card > h2 { margin-top: 0; }
.plan-inline {
  font: inherit; border: none; border-bottom: 1px dashed var(--line); background: none;
  color: var(--ink); padding: 0 .15rem; min-width: 6rem;
}
.plan-inline:focus { outline: none; border-bottom-color: var(--accent); }
.plan-text {
  width: 100%; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; line-height: 1.45; resize: none; overflow: hidden;
}
.plan-structure-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.plan-item { display: flex; align-items: flex-start; gap: .65rem; padding: .7rem 0; border-top: 1px solid var(--line); }
.plan-item:first-child { border-top: none; }
.plan-item-num {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 999px; background: #eef1f5;
  color: var(--muted); font-weight: 700; font-size: .85rem; display: flex; align-items: center;
  justify-content: center; margin-top: .15rem;
}
.plan-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.plan-item-titlerow { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.plan-item-title { font: inherit; font-weight: 600; border: none; background: none; color: var(--ink); padding: .1rem 0; flex: 1; min-width: 8rem; }
.plan-item-title:focus { outline: none; }
.plan-item-target { font: inherit; font-size: .82rem; color: var(--muted); border: none; background: none; padding: .1rem 0; width: 9rem; }
.plan-item-target:focus { outline: none; color: var(--ink); }
.plan-item-detail {
  width: 100%; box-sizing: border-box; padding: .35rem .5rem; border: 1px solid var(--line);
  border-radius: 7px; font: inherit; font-size: .9rem; line-height: 1.4; color: var(--muted);
  resize: none; overflow: hidden;
}
.plan-item-min { flex: none; display: flex; align-items: center; gap: .3rem; margin-top: .1rem; }
.plan-min { width: 4.2em; padding: .4rem .45rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; font-size: 12px; text-align: right; }
.plan-min-unit { color: var(--muted); font-size: 12px; }
.plan-del { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: .3rem .35rem; margin-top: .15rem; }
.plan-del:hover { color: var(--red); }
.plan-total-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  border-top: 2px solid var(--ink); margin-top: .4rem; padding: .6rem .2rem .2rem; font-size: 1.05rem;
}
.plan-total-row b { font-size: 1.15rem; }

@media (max-width: 800px) { .day-cols { grid-template-columns: 1fr; } }
.entry-del:hover { color: var(--red); }

.piece-row { display: block; padding: .7rem .2rem; border-top: 1px solid var(--line); color: inherit; }
.piece-row:first-child { border-top: none; }
.piece-row:hover { background: #f8fafc; text-decoration: none; }
.piece-row-head { margin-bottom: .35rem; }

/* measure-practice launcher (searchable piece -> pages -> practice/popout) */
.mp-launch { padding-top: .8rem; }
#mp-search { width: 100%; box-sizing: border-box; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
#mp-list { margin-top: .5rem; }
.mp-piece { border-top: 1px solid var(--line); }
.mp-piece:first-child { border-top: none; }
.mp-piece-head { display: flex; align-items: baseline; gap: .4rem; width: 100%; text-align: left; background: none; border: none; cursor: pointer; font: inherit; padding: .5rem .2rem; color: var(--ink); }
.mp-piece-head:hover { background: #f8fafc; }
.mp-piece-head .small { margin-left: auto; }
.mp-pages { padding: .2rem 0 .5rem; }
.mp-page { display: flex; align-items: center; gap: .6rem; padding: .35rem .2rem; }
.mp-page img { width: 38px; height: 50px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; background: #eee; }
.mp-page-label { min-width: 4.5em; color: var(--muted); }
.mp-tally { margin: .8rem 0 0; }

@media (max-width: 600px) {
  main { padding: .85rem; }
  .page-head { align-items: flex-start; }
  .practice-stage { height: 48vh; }
  .countdown { font-size: 2.6rem; }
  .day-cols { grid-template-columns: 1fr; }
}

/* ---- auth pages + header user menu (added 2026-06-01) ------------------ */
.user-menu { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.user-menu .user-name { opacity: .8; }
.user-menu .user-link { text-decoration: none; }
.logout-form { margin: 0; }
.logout-btn { cursor: pointer; border: 1px solid currentColor; background: transparent;
  color: inherit; border-radius: 6px; padding: .2rem .55rem; font-size: .8rem; opacity: .85; }
.logout-btn:hover { opacity: 1; }

.flashes { list-style: none; margin: 1rem auto; padding: .6rem .9rem; max-width: 560px;
  background: #fff6d6; border: 1px solid #e6cf7a; border-radius: 8px; color: #5a4a10; }
.flashes li + li { margin-top: .3rem; }

.auth-card { max-width: 420px; margin: 3rem auto; padding: 1.6rem 1.8rem;
  border: 1px solid #ddd; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.auth-card h1 { margin-top: 0; font-size: 1.4rem; }
.auth-form { display: flex; flex-direction: column; gap: .9rem; margin: 1rem 0; }
.auth-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 600; }
.auth-form input { padding: .55rem .6rem; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; }
.auth-form .primary, .button-link.primary, .primary { background: #2c6e49; color: #fff; border: none;
  border-radius: 8px; padding: .6rem .9rem; font-size: 1rem; cursor: pointer; }
.auth-hint { font-size: .82rem; color: #666; line-height: 1.4; }
.button-link { display: inline-block; text-decoration: none; padding: .55rem .9rem;
  border: 1px solid #ccc; border-radius: 8px; color: inherit; margin-top: .5rem; }
.button-link.primary { color: #fff; border: none; }

.totp-qr { width: 200px; height: 200px; margin: 1rem auto; }
.totp-qr svg { width: 100%; height: 100%; }
.totp-manual { margin: .5rem 0; font-size: .85rem; }
.totp-secret { display: inline-block; margin-top: .4rem; padding: .3rem .5rem; background: #f3f3f3;
  border-radius: 6px; letter-spacing: 1px; word-break: break-all; }
.recovery-codes { columns: 2; list-style: none; padding: .8rem 1rem; margin: 1rem 0;
  background: #f7f7f7; border-radius: 8px; }
.recovery-codes code { font-size: .95rem; }
.invite-link { display: flex; gap: .5rem; margin: 1rem 0; }
.invite-link input { flex: 1; padding: .5rem; border: 1px solid #ccc; border-radius: 8px; }

.admin-page { max-width: 900px; margin: 1.5rem auto; padding: 0 1rem; }
.admin-section { margin-bottom: 2rem; }
.admin-invite-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.admin-invite-form input[type=email] { flex: 1; min-width: 220px; padding: .5rem; border: 1px solid #ccc; border-radius: 8px; }
.admin-invite-form select { padding: .5rem; border: 1px solid #ccc; border-radius: 8px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th, .admin-table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid #eee; }
.admin-actions { display: flex; gap: .4rem; }
.admin-actions form { margin: 0; }
.admin-actions button { cursor: pointer; border: 1px solid #ccc; background: #fafafa;
  border-radius: 6px; padding: .25rem .5rem; font-size: .8rem; }

/* ---- simplified header nav + Focused piece links (2026-06-01) ---------- */
.nav-link.active { font-weight: 700; border-bottom: 2px solid currentColor; }
/* Focused launcher uses the Plan page's bordered piece-row table for consistency */
.mp-launch-table { margin-top: .3rem; }
.mp-launch-table .plan-line-c2.mp-sub { padding: .25rem .55rem; color: var(--muted); font-size: 12px; }

/* ---- Library category tabs (2026-06-01) ------------------------------- */
.lib-tabs { display: flex; gap: .25rem; margin: 1rem 0 .75rem; border-bottom: 1px solid #ddd; }
.lib-tab { background: transparent; border: none; padding: .5rem .9rem; font: inherit;
  cursor: pointer; color: #666; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lib-tab:hover { color: #2c6e49; }
.lib-tab.active { color: #1d1d1f; font-weight: 700; border-bottom-color: #2c6e49; }
.lib-tab-count { font-size: .78rem; color: #999; }

/* ---- edit-piece form + category badge (2026-06-01) -------------------- */
.piece-cat-badge { display: inline-block; margin-left: .5rem; padding: .05rem .5rem;
  font-size: .72rem; border: 1px solid #ccc; border-radius: 999px; color: #666; vertical-align: middle; }
.edit-piece-form { display: flex; flex-direction: column; gap: .6rem; max-width: 460px; }
.edit-piece-form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.edit-piece-form input, .edit-piece-form select { padding: .5rem .6rem; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; }
.edit-piece-form .form-actions { flex-direction: row; gap: .5rem; }

/* ---- right-click value pickers: fingering 5·4·3·2·1 | 1·2·3·4·5 (2026-06-01) ---- */
.ctx-label { font-size: .7rem; color: #888; margin: .4rem .15rem .15rem; text-transform: uppercase; letter-spacing: .03em; }
.ctx-fingers, .fing-row { display: flex; align-items: center; gap: .2rem; flex-wrap: nowrap; }
.ctx-finger { min-width: 1.9em; padding: .3rem .35rem; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.ctx-finger:hover { border-color: var(--accent); }
.ctx-finger.fing-lh { background: #eef4ff; }   /* left hand tint */
.ctx-finger.fing-rh { background: #fff3ec; }   /* right hand tint */
.ctx-finger-sep, .fing-sep { width: .55rem; flex: 0 0 auto; }
.fing-dig.fing-lh { background: #eef4ff; }
.fing-dig.fing-rh { background: #fff3ec; }
.fing-dig.fing-lh.on, .fing-dig.fing-rh.on { background: var(--accent); color: #fff; }

/* ---- practice popup note stage: clear Save (green) / Discard (red) (2026-06-01) ---- */
#zoom-save { background: #2c6e49; border-color: #2c6e49; color: #fff; }
#zoom-save:hover { background: #255b3c; }
#zoom-discard { background: #b3261e; border-color: #b3261e; color: #fff; }
#zoom-discard:hover { background: #8f1e18; }

/* ---- practice popup perfect/goof tally (2026-06-01) ------------------- */
.zoom-tally { display: inline-flex; align-items: center; gap: .4rem; margin-right: .4rem; }
.tally-perfect { color: #1d6b35; border-color: #9ccfae; }
.tally-perfect:hover { background: #eaf6ee; }
.tally-goof { color: #a32018; border-color: #e0a8a3; }
.tally-goof:hover { background: #fbeceb; }
.zoom-tally b { font-variant-numeric: tabular-nums; }
.tally-total { font-size: .85rem; color: #ccc; white-space: nowrap; }
.entry-tally { font-size: .8rem; color: #555; margin: .15rem 0 .1rem; }

/* tally now lives in the dark zoom header — light, distinguishable colours */
.zoom-head .tally-perfect { color: #8fe0ab; border-color: rgba(143,224,171,.6); }
.zoom-head .tally-goof    { color: #f0a39c; border-color: rgba(240,163,156,.6); }
.zoom-head .tally-perfect:hover { background: rgba(143,224,171,.15); }
.zoom-head .tally-goof:hover    { background: rgba(240,163,156,.15); }

/* ---- Practice Plan: revision bar + history + read-only (2026-06-02) ---- */
.plan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.plan-revbar { display: flex; align-items: center; gap: .6rem; }
.plan-revinfo { font-size: .85rem; color: #777; white-space: nowrap; }
.plan-readonly-banner { background: #fff6d6; border: 1px solid #e6cf7a; color: #5a4a10;
  border-radius: 8px; padding: .6rem .9rem; margin: .8rem 0; display: flex; align-items: center; gap: .8rem; }
.plan-history-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.plan-history-list li { padding: .25rem 0; border-bottom: 1px solid #eee; }
.plan-rev-link { background: transparent; border: none; color: #2c6e49; font: inherit;
  font-weight: 600; cursor: pointer; padding: 0; }
.plan-rev-link:hover { text-decoration: underline; }

/* ---- Practice Plan: sections + lines + pickers + Start (2026-06-02) ---- */
.plan-section .plan-kind { padding: .3rem; border: 1px solid #ccc; border-radius: 6px; font: inherit; font-size: 12px; }
/* plan lines as a 3-column table: title-as-start-link · instruction · ✕.
   Cell (column) borders form the grid; the fields are borderless so the cell
   border frames them. */
.plan-lines-wrap { margin: .45rem 0; }
.plan-lines { width: 100%; border-collapse: collapse; }
.plan-lines td { border: 1px solid var(--line); vertical-align: middle; }
.plan-line-c1 { white-space: nowrap; padding: .25rem .55rem; }   /* title (sizes to content) */
.plan-line-c2 { width: 100%; }                                   /* instruction fills the row */
.plan-line-c2:focus-within { background: #f4f8ff; }
.plan-line-c3 { width: 1%; text-align: center; }                 /* ✕ — narrowest */
.plan-line-start { font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }
.plan-line-start:hover { text-decoration: underline; }
.plan-line-piece { font-weight: 600; }
.plan-line-piece.disabled { color: var(--muted); cursor: not-allowed; }
.plan-line-text, .plan-line-note {
  width: 100%; box-sizing: border-box; padding: .35rem .5rem;
  border: none; background: transparent; font: inherit; color: #555;
}
.plan-line-text:focus, .plan-line-note:focus { outline: none; }
.plan-line-del { border: none; background: transparent; cursor: pointer; color: #a33; font-size: 1rem; padding: 0 .35rem; }
/* permanent add-piece row: picker (col1, title size) + hint & buttons (col2, note size) */
.plan-addrow .plan-pickpiece { width: 100%; box-sizing: border-box; border: none; background: transparent; font: inherit; font-size: 14px; padding: .35rem .5rem; cursor: pointer; }
.plan-addrow .plan-line-c2 { font-size: 10px; color: #555; padding: .2rem .5rem; }
.plan-addhint { color: var(--muted); }
.plan-addnew { font: inherit; font-size: 10px; cursor: pointer; border: 1px solid #cdd9ee; border-radius: 5px; background: #fff; padding: .15rem .45rem; margin-left: .3rem; white-space: nowrap; color: var(--accent); }
.plan-addnew:hover { background: #f4f8ff; }
.plan-addline { display: flex; gap: .5rem; margin-top: .45rem; flex-wrap: wrap; }
.plan-pickpiece { padding: .35rem; border: 1px solid #ccc; border-radius: 6px; font: inherit; }
.plan-addfree { border: 1px dashed #bbb; background: transparent; border-radius: 6px; padding: .3rem .65rem; cursor: pointer; font: inherit; }
.plan-noline { margin: .2rem 0; }

/* ---- practice two-up: measure dividing lines + rubber-band select (2026-06-02) ---- */
.page-panel .measure { border-left: 2px solid rgba(20,30,60,.55); }   /* measure lines (system box already outlined) */
.select-band { position: fixed; z-index: 95; border: 1.5px solid #2d6cff;
  background: rgba(45,108,255,.12); pointer-events: none; border-radius: 2px; }

/* ---- practice colour menu: per-measure vs all-selected rows (2026-06-02) ---- */
.ctx-colorrow { display: flex; align-items: center; gap: .5rem; margin: .15rem 0; }
.ctx-colorlabel { font-size: .78rem; color: #555; min-width: 6.5rem; }

/* ---- Practice Plan calendar (2026-06-02) ------------------------------ */
.plan-cal-title { margin: 0 0 .2rem; }
.plan-cal-head { display: flex; align-items: center; justify-content: space-between; margin: .3rem 0; max-width: 340px; }
.cal-nav { border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: .1rem .6rem; cursor: pointer; font-size: 1rem; }
.cal-month { font-weight: 700; }
.plan-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; max-width: 340px; }
.cal-dow { text-align: center; font-size: .7rem; color: #999; padding: .2rem 0; }
.cal-day { position: relative; aspect-ratio: 1; border: 1px solid #e4e4e4; background: #fff;
  border-radius: 6px; cursor: pointer; font: inherit; font-size: .85rem; padding: 0; }
.cal-day:hover:not(.disabled) { border-color: #2c6e49; }
.cal-day.today { font-weight: 700; border-color: #2c6e49; }
.cal-day.selected { background: #2c6e49; color: #fff; border-color: #2c6e49; }
.cal-day.has-rev::after { content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: #e4554f; }
.cal-day.selected.has-rev::after { background: #fff; }
.cal-day.disabled { color: #ccc; background: #f7f7f7; cursor: not-allowed; }

/* plan lines: the instruction note stays small; the piece/free title is larger
   so it's easy to read (2026-06-03) */
.plan-line-note { font-size: 10px; }
.plan-line-piece, .plan-line-text, .plan-line-start { font-size: 14px; }

/* ---- day entry: editable title chip (2026-06-03) ---------------------- */
input.meta-title { border: 1px solid #d8d8d8; background: #fff; color: inherit; font: inherit;
  font-size: .8rem; padding: .12rem .5rem; border-radius: 999px; min-width: 6rem; max-width: 16rem; }
input.meta-title:focus { border-color: #2c6e49; outline: none; }
