/* Brand tokens follow the song-piano-brand repo: gold #B28A38 for lines and fills only; darker gold for text. */
:root {
  --ink: #211c18; --ink-2: #57504a; --ink-3: #6f675f;
  --canvas: #f4f1ea; --paper: #ffffff; --line: #e7e1d6; --line-2: #d8d0c2;
  --gold: #b28a38; --gold-ink: #6e5022; --gold-wash: #f5ecdc;
  --alert: #b3261e; --alert-ink: #8c1d18; --alert-wash: #fbeceb;
  --radius: 12px;
  --tint-0: #f3e6c8; --ink-0: #5f4414;
  --tint-1: #dbe8f5; --ink-1: #1f4d7a;
  --tint-2: #e0efdf; --ink-2c: #2f5a2c;
  --tint-3: #f5e0e6; --ink-3c: #7a2e46;
  --tint-4: #e6e1f4; --ink-4: #45397a;
  --tint-5: #dff0ee; --ink-5: #1f5953;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink); background: var(--canvas);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.shell { max-width: 1120px; margin: auto; padding: 28px 24px 80px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.logo { display: block; width: auto; height: 60px; margin: -8px 0 0 -14px; }
.eyebrow { margin: 0 0 4px; color: var(--gold-ink); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
h2 { margin: 0; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions label { color: var(--ink-3); font-size: 13px; }
#language { width: auto; min-width: 104px; min-height: 36px; padding: 6px 10px; }
.top-actions button { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.demo-badge { padding: 6px 10px; border-radius: 999px; color: var(--gold-ink); background: var(--gold-wash); font-size: 12px; font-weight: 600; white-space: nowrap; }
.notice { margin: 18px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--gold-wash); color: #5a4420; font-size: 14px; line-height: 1.5; }
.notice.alert { background: var(--alert-wash); color: var(--alert-ink); }

input, textarea, select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper); }
input[type="search"] { border: 0; background: #e9e4da; border-radius: 10px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--alert); }
textarea { resize: vertical; }
button { min-height: 44px; padding: 9px 16px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper); font-weight: 600; }
button:hover { background: #faf7f1; }
button:disabled { opacity: .55; cursor: default; }
button.primary { border-color: var(--ink); background: var(--ink); color: #fff; }
button.primary:hover { background: #3a332d; }
button.danger { color: var(--alert-ink); border-color: #e6b8b4; }
button.danger:hover { background: var(--alert-wash); }
.text-button { min-height: 36px; padding: 6px 4px; border: 0; background: none; color: var(--gold-ink); font-weight: 600; }
.text-button:hover { background: none; text-decoration: underline; }
.text-button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

.content { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 8px; }

/* List */
.list-panel { position: sticky; top: 16px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.list-head h2 { font-size: 22px; font-weight: 700; }
.add-student { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; }
.add-student:hover { background: #3a332d; }
.add-student span:first-child { font-size: 20px; line-height: 1; font-weight: 500; }
.search-area { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: end; gap: 6px 8px; min-height: 76px; padding: 12px; border: 2px solid transparent; border-radius: var(--radius); background: var(--paper); text-align: left; }
.tile:hover { background: var(--paper); border-color: var(--line-2); }
.tile[aria-pressed="true"] { border-color: var(--gold); }
.tile-dot { grid-column: 1; width: 26px; height: 26px; border-radius: 50%; }
.tile-dot.active { background: var(--gold); }
.tile-dot.review { background: var(--alert); }
.tile-label { grid-column: 1; grid-row: 2; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.tile-count { grid-column: 2; grid-row: 1 / 3; align-self: start; font-size: 26px; font-weight: 700; }
.list-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.segmented { display: inline-flex; padding: 2px; border-radius: 10px; background: #e9e4da; }
.segmented button { min-height: 32px; padding: 4px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 14px; }
.segmented button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgb(33 28 24 / .12); }
.result-count { margin: 4px 4px 8px; color: var(--ink-3); font-size: 13px; }
.list-group + .list-group { margin-top: 14px; }
.group-title { margin: 0 14px 6px; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.rows { margin: 0; padding: 0; list-style: none; border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.rows li + li .student-row { border-top: 1px solid var(--line); }
.student-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 9px 14px; border: 0; border-radius: 0; background: var(--paper); text-align: left; font-weight: 400; }
.student-row:hover { background: #faf7f1; }
.student-row.selected { background: var(--gold-wash); box-shadow: inset 3px 0 0 var(--gold); }
.row-text { display: grid; flex: 1; min-width: 0; }
.row-name { font-weight: 600; }
.row-sub { overflow: hidden; color: var(--ink-3); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.review-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); }
.empty { padding: 28px 12px; color: var(--ink-3); line-height: 1.5; text-align: center; }

.avatar { display: inline-grid; flex: none; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #ece7de; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.avatar-lg { width: 68px; height: 68px; font-size: 22px; }
.avatar[data-color="0"] { background: var(--tint-0); color: var(--ink-0); }
.avatar[data-color="1"] { background: var(--tint-1); color: var(--ink-1); }
.avatar[data-color="2"] { background: var(--tint-2); color: var(--ink-2c); }
.avatar[data-color="3"] { background: var(--tint-3); color: var(--ink-3c); }
.avatar[data-color="4"] { background: var(--tint-4); color: var(--ink-4); }
.avatar[data-color="5"] { background: var(--tint-5); color: var(--ink-5); }

/* Detail */
.detail-panel { min-height: 320px; }
.detail-panel > .empty { padding: 80px 12px; }
.detail-bar { display: flex; align-items: center; justify-content: flex-end; min-height: 36px; }
.back { display: none; min-height: 36px; margin-right: auto; padding: 6px 2px; border: 0; background: none; color: var(--gold-ink); font-weight: 600; }
.back:hover { background: none; }
.hero { padding: 0 12px 18px; text-align: center; }
.hero h2 { margin-top: 10px; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.chip { padding: 4px 10px; border-radius: 999px; background: #ece7de; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.chip.gold { background: var(--gold-wash); color: var(--gold-ink); }
.chip.alert { background: var(--alert-wash); color: var(--alert-ink); }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.quick:has(+ .quick-to) { margin-bottom: 6px; }
.quick-to { margin: 0 0 18px; text-align: center; font-size: 13px; color: var(--ink-3); }
.quick-action { display: grid; place-items: center; min-height: 52px; border-radius: var(--radius); background: var(--paper); color: var(--gold-ink); font-weight: 600; text-decoration: none; }
.quick-action:hover { background: var(--gold-wash); }
.group { margin-bottom: 18px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 0 14px 4px; }
.group-head h3, .past-group summary { margin: 0; color: var(--ink-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.group-body { border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.group-body > * + * { border-top: 1px solid var(--line); }
.group-empty { margin: 0; padding: 14px; color: var(--ink-3); }
.past-group summary { display: flex; align-items: center; min-height: 36px; padding: 0 14px 4px; cursor: pointer; }
.past-group summary::marker { color: var(--ink-3); }
.kv { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr) auto; align-items: center; gap: 4px 12px; min-height: 50px; padding: 8px 14px; }
.kv-label { color: var(--ink-3); font-size: 13px; }
.kv-value { overflow-wrap: anywhere; font-weight: 500; }
.kv-value.missing { color: var(--ink-3); font-weight: 400; }
.kv-value a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.copy { min-height: 36px; padding: 4px 8px; border: 0; background: none; color: var(--gold-ink); font-size: 14px; }
.copy:hover { background: var(--gold-wash); }
.piece { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 8px 10px 8px 12px; }
.check { position: relative; flex: none; width: 44px; height: 44px; min-height: 0; margin: -4px 0; padding: 0; border: 0; border-radius: 50%; background: none; }
.check::before { content: ""; position: absolute; inset: 10px; border: 2px solid var(--gold); border-radius: 50%; }
.check:hover { background: var(--gold-wash); }
.past .check::before { background: var(--gold); }
.past .check::after { content: ""; position: absolute; left: 18px; top: 15px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.piece-text { display: grid; flex: 1; min-width: 0; }
.piece-title { font-weight: 600; }
.past .piece-title { color: var(--ink-2); font-weight: 500; }
.piece-meta, .piece-note { color: var(--ink-3); font-size: 13px; }
.row-action { min-height: 36px; padding: 4px 8px; border: 0; background: none; color: var(--gold-ink); font-size: 14px; }
.row-action:hover { background: var(--gold-wash); }
.sibling { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 14px; border: 0; border-radius: 0; background: var(--paper); text-align: left; font-weight: 500; }
.sibling .avatar { width: 30px; height: 30px; font-size: 12px; }
.sibling span:nth-child(2) { flex: 1; }
.chevron { color: var(--gold-ink); font-size: 20px; }
.manage { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.status { margin: 0 0 14px; color: #2d6a4f; text-align: center; }

/* Forms */
.detail-panel > h2 { margin: 6px 0 16px; font-size: 22px; }
form { padding: 18px; border-radius: var(--radius); background: var(--paper); }
form .status { text-align: left; margin-top: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid[hidden] { display: none; }
.form-grid label { display: grid; gap: 6px; font-weight: 600; }
.form-grid small { color: var(--alert-ink); font-weight: 400; }
.review-field { display: flex !important; align-items: center; gap: 8px; margin: 2px 0 8px; }
.review-field input { width: 22px; min-height: 22px; accent-color: var(--ink); }
.muted { color: var(--ink-3); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 10px 10px 10px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 14px; transform: translateX(-50%); box-shadow: 0 8px 24px rgb(33 28 24 / .22); }
.toast[hidden] { display: none; }
.toast button { min-height: 36px; padding: 4px 12px; border: 0; background: rgb(255 255 255 / .14); color: #fff; }
.toast button:hover { background: rgb(255 255 255 / .24); }

@media (max-width: 700px) {
  .shell { padding: 16px 16px 96px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .top-actions { order: -1; justify-content: flex-end; }
  h1 { display: none; }
  .logo { height: 52px; margin: -6px 0 -6px -12px; }
  .content { display: block; }
  .list-panel { position: static; }
  body[data-view="detail"] .list-panel, body[data-view="detail"] .topbar, body[data-view="detail"] .notice:not(.alert) { display: none; }
  body[data-view="list"] .detail-panel { display: none; }
  .list-head h2 { font-size: 30px; }
  .add-student { position: fixed; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 10; width: 56px; height: 56px; padding: 0; justify-content: center; box-shadow: 0 6px 18px rgb(33 28 24 / .25); }
  .add-student span:first-child { font-size: 28px; }
  #add-student-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  body[data-view="detail"] .add-student { display: none; }
  .back { display: inline-flex; align-items: center; }
  .detail-bar { justify-content: space-between; }
  .kv { grid-template-columns: minmax(0, 1fr) auto; }
  .kv-label { grid-column: 1 / -1; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  .student-row, .tile, .check, .quick-action { transition: background-color .15s ease, border-color .15s ease; }
}
