/* Low End on the web. One look: white and black, one red light. Space Grotesk for
   text, Doto's dot-matrix digits for numbers, flat keys with a 1px black edge.
   Names follow Theme.swift (color system, type system, spacing system). */

@font-face { font-family: "Space Grotesk"; font-weight: 400; src: url("../fonts/SpaceGrotesk-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Space Grotesk"; font-weight: 600; src: url("../fonts/SpaceGrotesk-SemiBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Space Grotesk"; font-weight: 700; src: url("../fonts/SpaceGrotesk-Bold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Doto"; font-weight: 900; src: url("../fonts/Doto-Black.ttf") format("truetype"); font-display: swap; }

:root {
  /* Surfaces */
  --page: #F4F4F4;
  --card: #FFFFFF;
  --inverse: #0A0A0A;
  /* Text */
  --text-primary: #0A0A0A;
  --text-secondary: #555555;
  --text-tertiary: #6B6B6B;
  --text-disabled: #8C8C8C;
  --text-on-inverse: #F4F4F4;
  /* Accent: the one color */
  --accent: #D71921;
  --accent-text: #D71921;
  --on-accent: #FFFFFF;
  --accent-tint: rgba(215, 25, 33, 0.10);
  --accent-glow: rgba(215, 25, 33, 0.18);
  --accent-muted: rgba(215, 25, 33, 0.55);
  /* Lines */
  --line-divider: rgba(10, 10, 10, 0.10);
  --line-control: rgba(10, 10, 10, 0.20);
  --line-strong: #0A0A0A;
  /* Fills */
  --fill-track: rgba(10, 10, 10, 0.06);
  --fill-mark: rgba(10, 10, 10, 0.35);

  --sans: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono: "Doto", "Space Grotesk", monospace;

  /* Spacing */
  --hair: 2px; --tight: 4px; --inset: 6px; --close: 8px; --related: 12px; --group: 16px;
  --edge: 18px; --section: 24px; --end: 32px; --wide: 44px; --major: 56px;

  --column: 430px;
  --ease: cubic-bezier(0.2, 0.8, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
input:focus, textarea:focus, button:focus { outline: none; }
button:focus-visible, .key:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--line-strong); outline-offset: 2px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Type system: 12 · 14 · 16 · 18 · 20 · 28, plus the two display numerals. */
.t-display { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.3px; }
.t-wordmark { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.5px; }
.t-title { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.2px; }
.t-headline { font-size: 18px; line-height: 24px; font-weight: 600; }
.t-body { font-size: 16px; line-height: 24px; font-weight: 400; }
.t-body-strong { font-size: 16px; line-height: 24px; font-weight: 600; }
.t-reading { font-size: 16px; line-height: 26px; font-weight: 400; }
.t-secondary { font-size: 14px; line-height: 20px; font-weight: 400; }
.t-secondary-strong { font-size: 14px; line-height: 20px; font-weight: 600; }
.t-key { font-size: 14px; line-height: 20px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; }
.t-caption { font-size: 12px; line-height: 16px; font-weight: 400; letter-spacing: 0.1px; }
.t-caption-strong { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.1px; }
.t-tab { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; }
.t-mono-label { font-family: var(--mono); font-weight: 900; font-size: 14px; line-height: 18px; letter-spacing: 1.4px; text-transform: uppercase; }
.t-mono-small { font-family: var(--mono); font-weight: 900; font-size: 12px; line-height: 16px; letter-spacing: 1.2px; text-transform: uppercase; }
.t-mono-digit { font-family: var(--mono); font-weight: 900; font-size: 16px; line-height: 20px; }
.t-numeral-l { font-family: var(--mono); font-weight: 900; font-size: 40px; line-height: 40px; }
.t-numeral-xl { font-family: var(--mono); font-weight: 900; font-size: 96px; line-height: 96px; }

.c-primary { color: var(--text-primary); }
.c-secondary { color: var(--text-secondary); }
.c-tertiary { color: var(--text-tertiary); }
.c-disabled { color: var(--text-disabled); }
.c-accent { color: var(--accent-text); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- App frame ---------- */

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 var(--edge) var(--inset);
  padding-top: calc(var(--close) + env(safe-area-inset-top));
  padding-bottom: calc(var(--inset) + env(safe-area-inset-bottom));
  height: 100dvh;
}
.app-header { height: 44px; flex: 0 0 auto; }
.app-body {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  margin-top: var(--tight);
  margin-bottom: var(--hair);
}
.app-body > .tab { position: absolute; inset: 0; display: none; flex-direction: column; }
.app-body > .tab.on { display: flex; }
.app-nav { flex: 0 0 auto; }

/* On a laptop the column sits on the left of a wide page, with the nav as a rail
   beside it, so the layout stays the app's but the screen is not one thin strip. */
@media (min-width: 900px) and (min-height: 560px) {
  :root { --column: 480px; }
  .app {
    max-width: none;
    width: calc(var(--column) + 240px);
    display: grid;
    grid-template-columns: 200px var(--column);
    grid-template-rows: 44px 1fr;
    column-gap: 40px;
    padding-top: 40px;
    padding-bottom: 32px;
    height: 100dvh;
  }
  .app-header { grid-column: 2; grid-row: 1; }
  .app-body { grid-column: 2; grid-row: 2; margin-top: 8px; }
  .app-nav { grid-column: 1; grid-row: 1 / span 2; align-self: start; position: sticky; top: 40px; }
  .app-nav .nav { flex-direction: column; align-items: stretch; gap: 4px; }
  .app-nav .nav button { position: relative; flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 14px; height: 48px; padding: 0 12px 0 20px; border-radius: 12px; }
  .app-nav .nav button .dot { position: absolute; left: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; }
  .app-nav .nav .t-tab { font-size: 14px; line-height: 20px; }
  .rail-mark { display: block; margin: 0 0 28px 16px; }
  .rail-hint { display: block; margin: 28px 0 0 16px; }
}
.rail-mark, .rail-hint { display: none; }

/* ---------- Header ---------- */

.header {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 var(--inset);
}
.wordmark { text-decoration: none; font-weight: 700; font-size: 28px; letter-spacing: -0.5px; color: var(--text-primary); }
.wordmark .dot { color: var(--accent); }
.streak { display: flex; align-items: center; gap: var(--close); }
.streak .caps { display: flex; gap: var(--tight); }
.header-key { width: 44px; height: 44px; display: grid; place-items: center; }

.lesson-bar { display: flex; align-items: center; gap: var(--group); height: 44px; }
.lesson-bar .crumb { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.lesson-bar .done { display: flex; align-items: center; gap: var(--close); height: 44px; padding: 0 var(--group) 0 var(--related); }

/* ---------- Keys and cards ---------- */

.key {
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 0.06s ease-out;
  user-select: none;
}
.key:active { opacity: 0.85; }
.key.r12 { border-radius: 12px; }
.key.r16 { border-radius: 16px; }
.key.r14 { border-radius: 14px; }
.key.r11 { border-radius: 11px; }
.key.r10 { border-radius: 10px; }
.key-label { display: flex; align-items: center; justify-content: center; gap: var(--related); width: 100%; height: 60px; }
.key-label.h56 { height: 56px; }
.key-label.h52 { height: 52px; }
.ghost-key {
  border: 1.5px solid var(--line-control); border-radius: 16px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: var(--related) var(--group); min-height: 52px; width: 100%;
}
.outline-key {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1.5px solid var(--line-control); border-radius: 11px; background: transparent;
}

.card {
  background: var(--card);
  border: 1px solid var(--line-divider);
  border-radius: 18px;
}
.card.r20 { border-radius: 20px; }
.card.r16 { border-radius: 16px; }
.card.r14 { border-radius: 14px; }
.card.r28 { border-radius: 28px; }

.digit-cap {
  display: inline-grid; place-items: center;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  font-family: var(--mono); font-weight: 900; color: var(--text-primary);
}
.digit-cap span { display: block; transform: translateX(var(--nudge, 0)); }

.pixel-icon { display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.pixel-icon rect { shape-rendering: crispEdges; }

.number-badge {
  width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1.5px solid var(--line-control); border-radius: 8px;
  font-family: var(--mono); font-weight: 900; font-size: 16px; color: var(--text-tertiary);
}
.number-badge.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.number-badge.done { background: var(--inverse); border-color: var(--inverse); }

.divider { height: 1px; background: var(--line-divider); }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: var(--close) var(--group);
  border: 1.5px solid var(--line-control); border-radius: 12px; font-weight: 600; font-size: 14px; line-height: 20px;
}
.chip.on { background: var(--inverse); color: var(--text-on-inverse); border-color: var(--line-strong); }
.flow { display: flex; flex-wrap: wrap; gap: var(--close); }

/* ---------- Scrolling tabs ---------- */

.scroll {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: visible;
  scrollbar-width: none;
  padding-bottom: var(--end);
  /* Content fades into the page at the bottom (and at the top once scrolled). */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,var(--top-fade, 1)) 0, rgba(0,0,0,calc(0.35 + 0.65 * var(--top-fade, 1))) 22px, #000 48px, #000 calc(100% - 32px), transparent 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,var(--top-fade, 1)) 0, rgba(0,0,0,calc(0.35 + 0.65 * var(--top-fade, 1))) 22px, #000 48px, #000 calc(100% - 32px), transparent 100%);
}
.scroll::-webkit-scrollbar { display: none; }
.scroll.scrolled { --top-fade: 0; }

/* ---------- Nav ---------- */

.nav { display: flex; gap: var(--tight); }
.nav button {
  flex: 1 1 0; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--tight);
  color: var(--text-secondary);
}
.nav button .dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; transition: background 0.2s ease-out; }
.nav button.on .dot { background: var(--accent); }

/* ---------- Click ---------- */

.click { gap: var(--group); padding-top: var(--related); }
.timer-card { position: relative; overflow: hidden; }
.timer-fill { position: absolute; inset: 0 auto 0 0; width: 0; transition: width 0.25s linear; pointer-events: none;
  background-image: radial-gradient(circle, var(--line-divider) 1px, transparent 1.1px); background-size: 5px 5px; background-position: 2.5px 2.5px; }
.timer-slot { position: relative; height: 118px; width: 100%; display: block; cursor: pointer; }
.timer-digits, .beat-squares { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
.timer-digits { gap: var(--tight); }
.timer-digits .colon { color: var(--accent); padding: 0 var(--tight); font-family: var(--mono); font-weight: 900; font-size: 40px; line-height: 40px; }
.timer-slot.running .timer-digits { transform: translateY(-118px); opacity: 0; }
.timer-slot:not(.running) .beat-squares { transform: translateY(118px); opacity: 0; }
.beat-squares { gap: 26px; }
.beat-squares .patch { background: var(--card); border-radius: 14px; padding: 12px; }
.beat-squares .sq { display: grid; grid-template-columns: repeat(5, 9px); grid-template-rows: repeat(5, 9px); }
.beat-squares .sq i { width: 9px; height: 9px; display: grid; place-items: center; }
.beat-squares .sq i::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--line-divider); }
.beat-squares .sq.on i::before { background: var(--text-primary); }
.beat-squares .sq.on.down i::before { background: var(--accent); }
.today-line { display: flex; align-items: baseline; justify-content: space-between; gap: var(--close); padding: 0 var(--inset); }
.today-line .status { display: flex; align-items: center; gap: var(--inset); }

.tempo { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: var(--section); cursor: ew-resize; user-select: none; touch-action: pan-y; border-radius: 18px; }
.tempo:focus-visible { outline-offset: -2px; }
.tempo .readout { display: flex; flex-direction: column; align-items: center; gap: var(--tight); }
.tempo .bpm { font-family: var(--mono); font-weight: 900; font-size: 96px; line-height: 96px; transform: translateX(4.8px); font-variant-numeric: tabular-nums; }
.tempo-scale { position: relative; height: 72px; margin: 0 calc(-1 * var(--edge)); overflow: hidden; }
.tempo-scale canvas { display: block; width: 100%; height: 72px; }
.tempo-scale .needle { position: absolute; left: 50%; top: 0; width: 3px; height: 72px; margin-left: -1.5px; background: var(--accent); box-shadow: 0 0 4px var(--accent-muted); }

.transport { position: relative; height: 56px; display: flex; align-items: stretch; width: 100%; border-radius: 16px; overflow: hidden; }
.transport.h64 { height: 64px; }
.transport .wash { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-tint); pointer-events: none; }
.transport .main { flex: 1 1 auto; display: flex; align-items: center; gap: var(--related); padding: 0 var(--group) 0 var(--edge); min-width: 0; position: relative; }
.transport .main .detail { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport .sep { width: 1px; height: 28px; background: var(--line-divider); align-self: center; position: relative; }
.transport .settings { width: 64px; display: grid; place-items: center; position: relative; }
.player-wrap { position: relative; padding-bottom: var(--end); }

.toast {
  position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: 20px;
  display: flex; align-items: center; gap: var(--group); height: 52px; padding: 0 var(--inset) 0 var(--edge);
  background: var(--inverse); color: var(--text-on-inverse); border-radius: 16px;
  box-shadow: 0 10px 14px var(--line-control);
  opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity 0.22s ease-out, transform 0.22s ease-out;
  z-index: 5;
}
.toast.shown { opacity: 1; transform: none; pointer-events: auto; }
.toast .undo { color: var(--accent); padding: 0 var(--related); height: 44px; display: grid; place-items: center; margin-left: auto; }
.toast .text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Coach ---------- */

.coach { position: relative; }
.coach-setup { display: flex; flex-direction: column; gap: var(--related); height: 100%; }
.coach-setup .scroll { padding-bottom: var(--group); }
.coach-intro { padding: var(--wide) var(--inset) 0; display: flex; flex-direction: column; gap: var(--group); }
.coach-label { display: flex; align-items: center; gap: var(--close); color: var(--accent-text); }
.suggestion { display: flex; align-items: center; justify-content: space-between; gap: var(--group); width: 100%; min-height: 48px; padding: var(--related) var(--group); border: 1.5px solid var(--line-control); border-radius: 14px; }
.composer { display: flex; gap: var(--close); padding-bottom: var(--end); }
.composer .field { flex: 1 1 auto; display: flex; align-items: center; min-height: 56px; padding: var(--related) var(--edge); }
.composer input { flex: 1 1 auto; border: 0; background: transparent; min-width: 0; caret-color: var(--accent); }
.composer input::placeholder { color: var(--text-tertiary); }
.composer .send { width: 56px; height: 56px; flex: 0 0 auto; }
.composer.in-sheet { padding: var(--close) 0 var(--related); }
.conversation { display: flex; flex-direction: column; gap: var(--group); padding: var(--group) var(--inset) 0; min-height: 100%; justify-content: flex-end; }
.you-bubble { align-self: flex-end; max-width: calc(100% - 60px); padding: var(--related) var(--group); background: var(--card); border: 1px solid var(--line-strong); border-radius: 18px; }
.coach-line { display: flex; flex-direction: column; gap: var(--close); }
.coach-line.faded { opacity: 0.55; }
.coach-question { display: flex; flex-direction: column; gap: var(--related); padding-top: var(--inset); }
.question-rule { display: flex; align-items: center; gap: var(--related); padding-top: var(--tight); }
.question-rule .divider { flex: 1 1 auto; }
.building-list { display: flex; flex-direction: column; gap: var(--related); padding: var(--group); }
.building-list .row { display: flex; align-items: center; gap: var(--related); }
.mark20 { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; flex: 0 0 auto; border: 1.5px solid var(--line-control); }
.mark20.done { background: var(--inverse); border-color: var(--inverse); }
.mark20.now { border-color: var(--accent); }
.mark20.now::before { content: ""; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); box-shadow: 5px 0 0 var(--accent), -5px 0 0 var(--accent); }

.plan { display: flex; flex-direction: column; gap: var(--section); padding-top: var(--end); }
.this-week { display: flex; flex-direction: column; gap: var(--group); padding: 0 var(--inset) var(--group); }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--close); flex-wrap: wrap; }
.week { display: flex; gap: var(--close); }
.week .day { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: var(--close); }
.week .tile { position: relative; width: 100%; height: 44px; border-radius: 10px; background: var(--card); border: 1px solid var(--line-divider); display: flex; align-items: flex-end; justify-content: center; }
.week .tile.future { background: transparent; border: 1px dashed var(--line-control); }
.week .tile.today::after { content: ""; position: absolute; inset: -4px; border: 1.5px solid var(--line-strong); border-radius: 12.5px; }
.week .bar { width: 4px; border-radius: 2px; background: var(--accent); margin-bottom: var(--inset); min-height: 4px; }
.week .bar.full { box-shadow: 0 0 5px var(--accent-muted); }
.focus { padding: var(--group); display: flex; flex-direction: column; gap: var(--group); margin-bottom: var(--section); }
.focus-row { display: flex; align-items: center; gap: var(--group); padding: var(--related) 0; }
.focus-row .text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--tight); }
.focus-row .text .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-header { display: flex; flex-direction: column; gap: var(--related); padding: 0 var(--inset); }
.plan-bar { position: relative; height: 22px; }
.plan-bar .track { position: absolute; left: 0; right: 0; top: 0; height: 12px; border-radius: 6px; background: var(--card); border: 1px solid var(--line-divider); }
.plan-bar .fill { position: absolute; left: 0; top: 0; height: 12px; border-radius: 6px; background: linear-gradient(to bottom, var(--accent-muted), var(--accent)); box-shadow: 0 0 4px var(--accent-muted); transition: width 0.35s ease-out; min-width: 12px; }
.plan-bar .fill::after { content: ""; position: absolute; left: 4px; right: 4px; top: 2px; height: 3px; border-radius: 2px; background: rgba(255,255,255,0.35); }
.plan-bar canvas { position: absolute; inset: 0; width: 100%; height: 22px; pointer-events: none; }
.topics { padding: 0 var(--inset); }
.topic-row { display: flex; align-items: center; gap: var(--related); width: 100%; padding: var(--group) 0; position: relative; }
.topic-row .title { flex: 1 1 auto; min-width: 0; }
.topic-row .status { white-space: nowrap; }
.topic-row .chev { transition: transform 0.22s ease-out; }
.topic-row .chev.open { transform: rotate(90deg); }
.topic-row.ruled::before { content: ""; position: absolute; left: 38px; right: 0; top: 0; height: 1px; background: var(--line-divider); }
.items { padding-left: 38px; padding-bottom: var(--inset); }
.item-row { display: flex; align-items: center; gap: var(--group); padding: var(--related) 0; position: relative; }
.item-row::before { content: ""; position: absolute; left: 38px; right: 0; top: 0; height: 1px; background: var(--line-divider); }
.item-row.done { opacity: 0.5; }
.item-row .box { width: 44px; height: 44px; margin: 0 -10px; display: grid; place-items: center; flex: 0 0 auto; }
.item-row .box i { width: 24px; height: 24px; border-radius: 7px; border: 1.5px solid var(--line-control); display: grid; place-items: center; }
.item-row .box i.next { border-color: var(--accent); }
.item-row .box i.done { background: var(--inverse); border-color: var(--inverse); }
.item-row .open { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--tight); }
.item-row .open .title.done { text-decoration: line-through; text-decoration-color: var(--fill-mark); }

.lesson { display: flex; flex-direction: column; gap: var(--end); padding: var(--end) var(--inset) 0; }
.lesson .meta { margin-top: -22px; }
.lesson .practice-key { margin-top: -12px; }
.lesson h2.t-title { margin-top: var(--group); margin-bottom: -20px; }
.try-this { background: var(--fill-track); border: 1px solid var(--line-control); border-radius: 10px; padding: var(--group); display: flex; flex-direction: column; gap: var(--inset); }
.steps { display: flex; flex-direction: column; gap: var(--group); }
.steps .step { display: flex; align-items: flex-start; gap: var(--group); }
.figure { display: flex; flex-direction: column; gap: var(--group); padding: var(--wide) 0; border-top: 1px solid var(--line-divider); border-bottom: 1px solid var(--line-divider); margin: var(--related) 0; }
.figure svg { width: 100%; height: auto; display: block; }
.figure .legend { display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--text-secondary); }
.figure .legend span { display: inline-flex; align-items: center; gap: 6px; }
.figure .legend svg.sw { width: 12px; height: 12px; flex: 0 0 auto; }

.sheet-back { position: fixed; inset: 0; background: rgba(10,10,10,0.35); display: flex; align-items: flex-end; justify-content: center; z-index: 50; opacity: 0; transition: opacity 0.25s ease-out; }
.sheet-back.shown { opacity: 1; }
.sheet {
  width: 100%; max-width: var(--column); max-height: calc(100dvh - 24px); background: var(--page);
  border-radius: 28px 28px 0 0; display: flex; flex-direction: column; transform: translateY(40px); transition: transform 0.3s var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-back.shown .sheet { transform: none; }
@media (min-width: 900px) and (min-height: 560px) {
  .sheet-back { align-items: center; }
  .sheet { border-radius: 28px; max-height: min(760px, calc(100dvh - 48px)); }
}
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line-control); margin: 8px auto 0; }
.sheet-header { display: flex; align-items: center; gap: var(--related); padding: var(--group) var(--group) var(--close); }
.sheet-header .close { width: 44px; height: 44px; display: grid; place-items: center; }
.sheet-header .close i { width: 36px; height: 36px; border-radius: 50%; background: var(--line-divider); display: grid; place-items: center; }
.sheet-header .titles { flex: 1 1 auto; text-align: center; display: flex; flex-direction: column; gap: var(--hair); min-width: 0; }
.sheet-header .spacer { width: 44px; height: 44px; }
.sheet .scroll { padding: var(--close) var(--section) var(--group); flex: 1 1 auto; }
.sheet .foot { padding: var(--close) var(--edge) var(--related); }
.edit-thread { display: flex; flex-direction: column; gap: var(--group); }
.change-list { padding: 0 var(--group); }
.change-row { display: flex; align-items: center; gap: var(--related); padding: var(--related) 0; position: relative; }
.change-row + .change-row::before { content: ""; position: absolute; left: 36px; right: 0; top: 0; height: 1px; background: var(--line-divider); }
.op-mark { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: 0 0 auto; border: 1.5px solid var(--line-control); }
.op-mark.add { background: var(--accent); border-color: var(--accent); }
.pair { display: flex; gap: var(--close); }
.pair > * { flex: 1 1 0; }

/* ---------- Inspire ---------- */

.inspire { padding-top: var(--inset); display: flex; flex-direction: column; gap: var(--group); }
.spotlight { display: block; width: 100%; height: 236px; }
.landing-text { padding: 0 var(--section) var(--section); display: flex; flex-direction: column; }
.inspire-card { overflow: hidden; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--fill-track); overflow: hidden; display: block; width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb img.filtered { filter: grayscale(1) contrast(0.82) brightness(1.12); }
.thumb .nopic { position: absolute; inset: 0; display: grid; place-items: center; background-image: radial-gradient(circle, var(--line-control) 1px, transparent 1.1px); background-size: 6px 6px; }
.thumb-chip { position: absolute; top: var(--related); height: 26px; display: flex; align-items: center; padding: 0 var(--close); background: var(--card); border: 1px solid var(--line-control); border-radius: 8px; }
.thumb-chip.left { left: var(--related); }
.thumb-chip.right { right: var(--related); padding: 0 6px; }
.inspire-card .text { display: flex; align-items: flex-start; gap: var(--tight); padding: var(--related) var(--inset) var(--related) var(--group); }
.inspire-card .text .col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--inset); padding-top: var(--hair); }
.inspire-card .note { padding: var(--inset) var(--group) var(--section); color: var(--text-secondary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.placeholder { border: 1.5px dashed var(--fill-mark); border-radius: 20px; overflow: hidden; cursor: pointer; }
.placeholder .thumb { display: grid; place-items: center; }
.placeholder .title { padding: var(--group); display: flex; flex-direction: column; gap: var(--close); }
.placeholder .line { width: 72px; height: 8px; border-radius: 4px; background: var(--fill-track); }
.field-well { display: flex; align-items: center; min-height: 52px; padding: 0 var(--group); flex: 1 1 auto; min-width: 0; }
.field-well input, .field-well textarea { flex: 1 1 auto; border: 0; background: transparent; min-width: 0; width: 100%; caret-color: var(--accent); resize: none; }
.field-well input::placeholder, .field-well textarea::placeholder { color: var(--text-tertiary); }
.swap-row { display: flex; align-items: center; gap: var(--related); padding: var(--related) 0; width: 100%; }
.swap-row .thumb { width: 80px; flex: 0 0 auto; border-radius: 8px; }
.swap-row .title { flex: 1 1 auto; min-width: 0; }
.mark24 { width: 24px; height: 24px; border-radius: 7px; border: 1.5px solid var(--line-control); display: grid; place-items: center; flex: 0 0 auto; }
.mark24.on { background: var(--accent); border-color: var(--accent); }
.inspire .toast { position: fixed; left: 50%; right: auto; bottom: 90px; width: calc(min(100vw, var(--column)) - 2 * var(--edge)); transform: translate(-50%, 14px); margin: 0; }
.inspire .toast.shown { transform: translate(-50%, 0); }

/* ---------- Progress ---------- */

.progress { display: flex; flex-direction: column; gap: var(--major); }
.scene-card { display: flex; flex-direction: column; gap: var(--related); padding-top: var(--section); }
.scene { position: relative; border-radius: 16px; overflow: hidden; border: 1.5px solid var(--line-control); background: #fff; }
.scene svg { display: block; width: 100%; height: auto; }
.scene .arrows { position: absolute; right: 10px; bottom: 10px; display: flex; gap: var(--close); }
.scene-row { display: flex; align-items: center; gap: var(--group); padding: 0 10px 0 var(--inset); }
.scene-row .col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--inset); }
.scene-row .line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resume { width: 96px; height: 44px; flex: 0 0 auto; }
.highlights { display: flex; flex-direction: column; gap: var(--group); }
.hcard { padding: var(--section); display: flex; flex-direction: column; gap: var(--group); border-radius: 20px; background: var(--card); border: 1px solid var(--line-divider); }
.hcard.dashed { background: transparent; border: 1px dashed var(--line-control); }
.month-chart { display: flex; flex-direction: column; gap: var(--related); }
.month-chart canvas { display: block; width: calc(100% + 16px); height: 80px; margin: -8px -8px 0; }
.month-chart .axis { display: flex; justify-content: space-between; }
.stat-pair { display: flex; gap: var(--related); align-items: stretch; }
.stat-pair .hcard { flex: 1 1 0; }
.finished-row { display: flex; align-items: center; gap: var(--group); padding: var(--group) 0; }
.finished-row:first-child { padding-top: var(--tight); }
.finished-row:last-child { padding-bottom: var(--tight); }
.finished-row + .finished-row { border-top: 1px solid var(--line-divider); }
.finished-row .col { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: var(--tight); }
.tile28 { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; background: var(--accent-tint); }
.tile28.dashed { background: transparent; border: 1px dashed var(--line-control); }
.comeback-dots { display: flex; gap: var(--inset); }
.comeback-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-glow); display: grid; place-items: center; font-family: var(--mono); font-weight: 900; font-size: 12px; letter-spacing: 1.2px; color: var(--accent-text); }
.comeback-dots i.last { background: var(--accent); color: var(--on-accent); }
.tempo-gain { display: block; width: 100%; height: 50px; }

.moment { position: fixed; inset: 0; background: var(--page); z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--section) var(--edge); gap: var(--group); }
.moment::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 34%, var(--accent-glow), transparent 260px); pointer-events: none; }
.moment canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.moment > * { position: relative; }
.moment .caps { display: flex; gap: var(--inset); transition: transform 0.6s var(--ease); }
.moment .actions { position: absolute; left: var(--edge); right: var(--edge); bottom: var(--section); display: flex; flex-direction: column; gap: var(--close); align-items: center; }
.moment .actions .key { width: 100%; }
@media (min-width: 900px) and (min-height: 560px) { .moment .actions { left: 50%; right: auto; width: 400px; transform: translateX(-50%); } }

.settings { padding: var(--section) var(--section) var(--wide); display: flex; flex-direction: column; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: var(--group); min-height: 54px; padding: var(--close) 0; border-top: 1px solid var(--line-divider); }
.settings select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--text-tertiary); font: inherit; text-align: right; padding-right: 0; cursor: pointer; }
.settings input[type="time"] { border: 0; background: transparent; color: var(--text-tertiary); font: inherit; }
.switch { width: 51px; height: 31px; border-radius: 16px; background: var(--fill-mark); position: relative; transition: background 0.2s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.2s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-in { animation: slideIn 0.34s var(--ease); }
@keyframes slideIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
