:root {
  --ink: #15122a;
  --ink2: #1f1b3d;
  --ink3: #2e2960;
  --line: #3d3778;
  --lamp: #fff1cf;
  --dim: #aaa6d0;
  --brass: #e9b54a;
  --brass-ink: #2a1b00;
  --curtain: #a3234a;
  --rose: #ee6c8f;
  --teal: #5cc8c2;
  --ok: #86dcae;
  --warn: #ffb36b;
  --display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ink); color: var(--lamp); }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.wrap { max-width: 560px; margin: 0 auto; padding: 0 18px; }
.num { font-variant-numeric: tabular-nums; }

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.brand { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: 0.01em; line-height: 1; margin: 0; }
.who { margin: 2px 0 0; color: var(--dim); font-size: 15px; }
.who select {
  background: transparent; border: 0; border-bottom: 1px dashed var(--dim); color: var(--lamp);
  padding: 0 14px 0 0; border-radius: 0;
}
.iconbtn {
  min-width: 44px; min-height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--ink2); display: grid; place-items: center; padding: 0;
}
.iconbtn svg { width: 20px; height: 20px; stroke: var(--lamp); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="true"] { background: var(--brass); border-color: var(--brass); }
.iconbtn[aria-pressed="true"] svg { stroke: var(--brass-ink); }

/* nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--ink2); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { max-width: 560px; margin: 0 auto; display: flex; }
.nav button {
  flex: 1; min-height: 64px; background: none; border: 0; color: var(--dim);
  font-family: var(--display); font-weight: 700; font-size: 19px; position: relative;
}
.nav button[aria-current="page"] { color: var(--lamp); }
.nav button[aria-current="page"]::after {
  content: ""; position: absolute; left: 28%; right: 28%; top: 0; height: 4px; background: var(--brass); border-radius: 0 0 4px 4px;
}

h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.05; }
.section { margin: 22px 0 10px; font-size: 22px; }
.muted { color: var(--dim); }
.small { font-size: 14px; }

/* ticket */
.ticket {
  --accent: var(--teal);
  position: relative; margin: 14px 0 20px; background: var(--ink2); border-radius: 18px;
  border: 1px solid var(--line); overflow: hidden;
}
.ticket[data-inst="Piano"] { --accent: var(--brass); }
.ticket[data-inst="Cello"] { --accent: var(--rose); }
.ticket-head { padding: 18px 18px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-left: 8px solid var(--accent); }
.ticket-head h2 { font-size: 40px; }
.venue { color: var(--dim); font-size: 15px; text-align: right; }
.perf { position: relative; height: 0; border-top: 2px dashed var(--line); margin: 0 18px; }
.perf::before, .perf::after {
  content: ""; position: absolute; top: -13px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); border: 1px solid var(--line);
}
.perf::before { left: -31px; } .perf::after { right: -31px; }
.ticket-body { padding: 18px; }
.clock { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.clock b { font-family: var(--display); font-size: 48px; line-height: 1; font-weight: 800; }
.clock span { color: var(--dim); }
.bar { height: 14px; background: var(--ink); border-radius: 8px; margin: 10px 0 4px; overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 8px; transition: width 0.4s ease; }
.dots { display: flex; gap: 8px; margin: 16px 0 4px; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--accent); }
.dot.on { background: var(--accent); }
.note { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--ink); border: 1px solid var(--line); font-size: 15px; }
.note.go { border-color: var(--ok); }
.note.warn { border-color: var(--warn); }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  min-height: 52px; padding: 0 22px; border-radius: 14px; border: 2px solid var(--accent, var(--brass));
  background: var(--accent, var(--brass)); color: var(--brass-ink); font-weight: 700; font-size: 18px;
}
.ticket[data-inst="Cello"] .btn:not(.ghost) { color: #3a0a1c; }
.btn.ghost { background: transparent; color: var(--lamp); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--dim); }
.btn.danger { background: transparent; border-color: var(--rose); color: var(--rose); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 10px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.main { --accent: var(--brass); }

/* day strip */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 4px; }
.cell { text-align: center; font-size: 12px; color: var(--dim); }
.cell .d { display: grid; place-items: center; width: 100%; aspect-ratio: 1; max-width: 46px; margin: 3px auto 0; border-radius: 50%; font-weight: 700; font-size: 14px; border: 2px solid var(--line); }
.cell.met .d { background: var(--accent); border-color: var(--accent); color: var(--brass-ink); }
.cell.short .d { border-color: var(--accent); border-style: dashed; color: var(--lamp); }
.cell.missed .d { color: var(--dim); }
.cell.lesson .d { border-color: var(--dim); color: var(--lamp); }
.cell.encore .d { background: var(--accent); border-color: var(--accent); color: var(--brass-ink); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--accent); }
.cell.pass .d { border-color: var(--dim); background: var(--ink3); color: var(--lamp); }
.cell.open .d { border-color: var(--lamp); color: var(--lamp); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--dim); margin: 6px 0 0; }

/* history list */
.day { border-top: 1px solid var(--line); padding: 12px 0; }
.day h3 { font-size: 20px; margin-bottom: 6px; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 3px 0; }
.row .what { display: flex; gap: 8px; align-items: baseline; }
.tag { display: inline-block; border: 1px solid var(--accent, var(--line)); color: var(--lamp); border-radius: 999px; padding: 0 10px; font-size: 13px; line-height: 22px; }
.tag.piano { --accent: var(--brass); } .tag.cello { --accent: var(--rose); }
.tag.ok { border-color: var(--ok); } .tag.bad { border-color: var(--warn); }
.sess { color: var(--dim); font-size: 15px; padding-left: 8px; }

/* marquee */
.marquee { position: relative; background: var(--curtain); border-radius: 22px; padding: 34px 26px 26px; margin: 14px 0 12px; text-align: center; }
.marquee .b { position: absolute; background-image: radial-gradient(circle, var(--brass) 3.5px, transparent 4px); }
.marquee .b.t, .marquee .b.u { left: 12px; right: 12px; height: 14px; background-size: 20px 14px; background-repeat: repeat-x; background-position: center; }
.marquee .b.t { top: 10px; } .marquee .b.u { bottom: 10px; }
.marquee .b.l, .marquee .b.r { top: 12px; bottom: 12px; width: 14px; background-size: 14px 20px; background-repeat: repeat-y; background-position: center; }
.marquee .b.l { left: 10px; } .marquee .b.r { right: 10px; }
.marquee p { margin: 0; }
.marquee .inst { font-family: var(--display); font-weight: 700; font-size: 18px; color: #ffd9e3; }
.marquee .name { font-family: var(--display); font-weight: 800; font-size: clamp(34px, 11vw, 52px); line-height: 1; margin: 6px 0 4px; color: var(--lamp); }
.marquee .lvl { color: #ffd9e3; font-size: 15px; }
.next { margin: 6px 0 18px; }
.ladder { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: l; }
.ladder li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); color: var(--dim); }
.ladder li .n { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.ladder li.on { color: var(--lamp); }
.ladder li.on .n { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.ladder li.now { font-weight: 700; }
.counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 6px; }
.count { background: var(--ink2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.count b { display: block; font-family: var(--display); font-size: 34px; line-height: 1; font-weight: 800; }
.count span { color: var(--dim); font-size: 14px; }
.reward { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.reward p { margin: 0; }

/* sheets */
.scrim { position: fixed; inset: 0; background: rgba(8, 6, 20, 0.72); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--ink2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto;
}
.sheet h2 { font-size: 30px; margin-bottom: 6px; }
.sheet p { margin: 8px 0; }
.timeinput { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 6px; }
.timeinput input {
  width: 4.2ch; text-align: center; font-family: var(--display); font-weight: 800; font-size: 64px; line-height: 1.1;
  background: var(--ink); border: 2px solid var(--line); border-radius: 16px; padding: 4px 0;
}
.timeinput input.sec { width: 3ch; }
.timeinput .colon { font-family: var(--display); font-size: 56px; font-weight: 800; }
.labels { display: flex; justify-content: center; gap: 70px; color: var(--dim); font-size: 14px; margin-bottom: 8px; }
.field { display: block; margin: 12px 0; }
.field span { display: block; color: var(--dim); font-size: 14px; margin-bottom: 4px; }
.field input, .field select {
  width: 100%; min-height: 48px; background: var(--ink); border: 2px solid var(--line); border-radius: 12px; padding: 0 12px;
}
.pin { text-align: center; letter-spacing: 0.4em; font-size: 28px !important; }
.err { color: var(--warn); margin: 8px 0 0; min-height: 1.4em; }
.sheet .actions { margin-top: 18px; }
.sheet .actions .btn { flex: 1; }
.won { display: flex; gap: 12px; align-items: center; background: var(--ink); border: 1px solid var(--brass); border-radius: 14px; padding: 12px 14px; margin: 10px 0; animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.won b { font-family: var(--display); font-size: 22px; }
.won .star { width: 36px; height: 36px; flex: none; fill: var(--brass); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate .card { width: 100%; max-width: 420px; }
.gate h1 { font-family: var(--display); font-weight: 800; font-size: 44px; margin: 0 0 6px; line-height: 1; }

/* parent */
.sub { display: flex; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.sub button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; }
.sub button[aria-pressed="true"] { background: var(--lamp); color: var(--ink); border-color: var(--lamp); }
.cardx { background: var(--ink2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }
.cardx.hi { border-color: var(--warn); }
.prow { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.prow p { margin: 0; }
.pbtns { display: flex; gap: 6px; }
.inline { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom)); background: var(--lamp); color: var(--ink); padding: 10px 16px; border-radius: 12px; z-index: 30; font-weight: 600; max-width: 90vw; }
.spinner { text-align: center; color: var(--dim); padding: 60px 0; }

@media (prefers-reduced-motion: reduce) {
  .bar i { transition: none; }
  .won { animation: none; }
}

.reward > .tag { white-space: nowrap; flex: none; }
