/* Mat Notes — "Film Room" design system. See DESIGN.md for tokens and rationale.
   Strict CSP: no inline styles; geometry arrives through CSSOM custom properties. */
@layer reset, tokens, base, shell, components, library, plans, practice, auth, utilities;

@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/assets/fonts/manrope-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/assets/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }
  html,
  body,
  h1,
  h2,
  h3,
  p,
  ul,
  ol,
  figure,
  fieldset {
    margin: 0;
    padding: 0;
  }
  ul,
  ol {
    list-style: none;
  }
  fieldset {
    border: 0;
    min-width: 0;
  }
  button,
  input,
  select,
  textarea {
    font: inherit;
    color: inherit;
  }
  img,
  video,
  iframe,
  svg {
    display: block;
  }
  [hidden] {
    display: none !important;
  }
}

@layer tokens {
  :root {
    /* Surfaces */
    --graphite: #111615;
    --graphite-2: #1a211f;
    --graphite-3: #242c29;
    --graphite-line: #2f3935;
    --graphite-edge: #64716a;
    --mineral: #f3f3ef;
    --mineral-2: #e9eae4;
    --paper: #ffffff;
    --stone: #e4e6df;
    --line: #dcded7;
    --line-strong: #858f88;
    /* Text */
    --ink: #18211d;
    --muted: #59655e;
    --on-dark: #eef1ec;
    --on-dark-muted: #a3ada6;
    /* Signal */
    --mint: #c4f568;
    --mint-deep: #3f6a00;
    --danger: #b42318;
    --danger-dark: #ff8f80;
    --warn: #8a5300;
    --warn-dark: #f4c862;
    --warn-bg: #fff4dc;
    /* Shape */
    --r-xs: 8px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --pill: 999px;
    --shadow-1: 0 1px 2px rgb(17 22 21 / 0.06), 0 2px 10px rgb(17 22 21 / 0.04);
    --shadow-2: 0 14px 36px -14px rgb(17 22 21 / 0.28), 0 2px 8px rgb(17 22 21 / 0.07);
    --shadow-3: 0 30px 80px -24px rgb(17 22 21 / 0.45), 0 6px 18px rgb(17 22 21 / 0.12);
    /* Type */
    --sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --display: "Barlow Condensed", "Manrope", ui-sans-serif, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-md: 0.9375rem;
    --fs-lg: 1.0625rem;
    --fs-xl: clamp(1.5rem, 1rem + 1.2vw, 2rem);
    /* Layout */
    --rail-w: 88px;
    --pad: clamp(16px, 2vw, 28px);
    --insp-w: 360px;
    --ring: var(--ink);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  }
  @media (max-width: 1099px) {
    :root {
      --rail-w: 76px;
      --insp-w: 320px;
    }
  }
  @media (max-width: 760px) {
    :root {
      --rail-w: 0px;
    }
  }
}

@layer base {
  html {
    background: var(--mineral);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 100%;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: "ss01", "cv11";
    scroll-padding-top: 72px;
  }
  body {
    min-height: 100dvh;
    font-size: var(--fs-md);
  }
  h1,
  h2,
  h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    text-wrap: balance;
  }
  a {
    color: inherit;
  }
  :focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }
  .rail,
  .stage,
  .dock,
  .study-stage,
  .tile,
  .toast,
  .auth-poster {
    --ring: var(--mint);
  }
  ::selection {
    background: color-mix(in oklab, var(--mint) 70%, white);
    color: var(--ink);
  }
  .mono,
  .timecode,
  kbd {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
  }
  kbd {
    display: inline-grid;
    place-items: center;
    min-width: 1.45em;
    height: 1.45em;
    padding: 0 0.3em;
    border-radius: 5px;
    border: 1px solid currentColor;
    font-size: 0.72em;
    opacity: 0.75;
  }
  .icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex: none;
  }
  .icon.big {
    width: 28px;
    height: 28px;
  }
  .sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
  }
  .mark-dot {
    fill: var(--mark-dot, currentColor);
  }
  .muted,
  .help {
    color: var(--muted);
    font-size: var(--fs-sm);
  }
  .eyebrow {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  body.busy {
    cursor: progress;
  }
}

/* ---------------------------------------------------------------- shell */
@layer shell {
  .shell {
    display: grid;
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
    min-height: 100dvh;
  }
  body[data-view="auth"] .shell,
  body[data-view="loading"] .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  body[data-view="auth"] .rail,
  body[data-view="loading"] .rail {
    display: none;
  }
  main {
    min-width: 0;
  }

  .rail {
    position: sticky;
    top: 0;
    z-index: 30;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 18px 10px 16px;
    background: var(--graphite);
    color: var(--on-dark);
    --mark-dot: var(--mint);
  }
  .brand {
    display: grid;
    justify-items: center;
    gap: 6px;
    text-decoration: none;
    border-radius: var(--r-sm);
    padding: 4px;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
    color: var(--on-dark);
  }
  .brand-name {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--on-dark-muted);
    white-space: nowrap;
  }
  .nav {
    display: grid;
    gap: 6px;
    width: 100%;
  }
  .nav a {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 5px;
    padding: 11px 4px 9px;
    border-radius: var(--r-md);
    text-decoration: none;
    color: var(--on-dark-muted);
    font-size: 11.5px;
    font-weight: 600;
    transition:
      background 0.16s var(--ease),
      color 0.16s var(--ease);
  }
  .nav a:hover {
    background: var(--graphite-2);
    color: var(--on-dark);
  }
  .nav a[aria-current="page"] {
    background: var(--graphite-3);
    color: var(--on-dark);
  }
  .nav a[aria-current="page"] .nav-icon {
    color: var(--mint);
  }
  .nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--mint);
  }
  .nav a[data-dirty="true"]::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warn-dark);
    box-shadow: 0 0 0 2px var(--graphite);
  }
  .nav-icon {
    width: 22px;
    height: 22px;
  }
  .identity {
    margin-top: auto;
  }
  .account-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--graphite-edge);
    background: var(--graphite-2);
    color: var(--on-dark);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-weight: 700;
  }
  .account-btn:hover {
    border-color: var(--mint);
  }
  .avatar {
    font-size: 15px;
  }
  .account-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  @media (max-width: 760px) {
    .shell {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto 1fr;
    }
    .rail {
      height: 60px;
      flex-direction: row;
      gap: 6px;
      padding: 8px 10px;
      width: 100%;
    }
    .brand {
      padding: 2px;
    }
    .brand-mark {
      width: 30px;
      height: 30px;
    }
    .brand-name {
      display: none;
    }
    .nav {
      display: flex;
      flex: 1;
      justify-content: center;
      gap: 4px;
    }
    .nav a {
      flex: 1;
      max-width: 104px;
      padding: 6px 2px 5px;
      gap: 2px;
      font-size: 11px;
    }
    .nav a[aria-current="page"]::before {
      left: 26%;
      right: 26%;
      top: auto;
      bottom: -8px;
      width: auto;
      height: 3px;
      border-radius: 3px 3px 0 0;
    }
    .nav-icon {
      width: 20px;
      height: 20px;
    }
    .identity {
      margin: 0;
    }
    .account-btn {
      width: 40px;
      height: 40px;
    }
  }

  /* status toast: never a bar, never blocks input */
  .toast {
    position: fixed;
    z-index: 60;
    left: calc(var(--rail-w) + 20px);
    bottom: 20px;
    max-width: min(440px, calc(100vw - var(--rail-w) - 40px));
    padding: 10px 16px 10px 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-radius: var(--r-md);
    background: var(--graphite);
    color: var(--on-dark);
    font-size: var(--fs-sm);
    font-weight: 500;
    box-shadow: var(--shadow-3);
    pointer-events: none;
    transition:
      opacity 0.3s var(--ease),
      visibility 0.3s;
  }
  .toast::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--on-dark-muted);
  }
  .toast[data-kind="ok"]::before {
    background: var(--mint);
  }
  .toast[data-kind="error"]::before {
    background: var(--danger-dark);
  }
  .toast.faded {
    opacity: 0;
    visibility: hidden;
  }
  body[data-view="auth"] .toast {
    left: 50%;
    translate: -50% 0;
  }
  body[data-view="plans"] .toast {
    bottom: 84px;
  }
  @media (max-width: 760px) {
    .toast,
    body[data-view="auth"] .toast,
    body[data-view="plans"] .toast {
      left: 12px;
      right: 12px;
      translate: none;
      bottom: calc(12px + env(safe-area-inset-bottom));
      max-width: none;
    }
  }
}

/* ------------------------------------------------------------ components */
@layer components {
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--paper);
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition:
      background 0.15s var(--ease),
      border-color 0.15s var(--ease),
      color 0.15s var(--ease),
      transform 0.1s;
  }
  .btn:active:not(:disabled) {
    transform: translateY(1px);
  }
  .btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
  }
  .btn.primary,
  .btn.dark {
    background: var(--graphite);
    color: #fff;
  }
  .btn.primary .icon,
  .btn.dark .icon {
    color: var(--mint);
  }
  .btn.primary:hover:not(:disabled),
  .btn.dark:hover:not(:disabled) {
    background: var(--graphite-3);
  }
  .btn.mint {
    background: var(--mint);
    color: var(--graphite);
  }
  .btn.mint:hover:not(:disabled) {
    background: color-mix(in oklab, var(--mint) 86%, white);
  }
  .btn.quiet {
    background: transparent;
    color: var(--ink);
  }
  .btn.quiet:hover:not(:disabled) {
    background: color-mix(in oklab, var(--ink) 7%, transparent);
  }
  .btn.ghost {
    background: transparent;
    border-color: var(--graphite-edge);
    color: var(--on-dark);
  }
  .btn.ghost:hover:not(:disabled) {
    border-color: var(--on-dark-muted);
    background: var(--graphite-3);
  }
  .btn.ghost-light {
    background: var(--paper);
    border-color: var(--line);
    color: var(--ink);
    box-shadow: var(--shadow-1);
  }
  .btn.ghost-light:hover:not(:disabled) {
    border-color: var(--line-strong);
  }
  .btn.small {
    min-height: 32px;
    padding: 0 12px;
    font-size: var(--fs-sm);
    border-radius: var(--r-xs);
  }
  .btn.icon-btn {
    width: 40px;
    padding: 0;
  }
  .btn.small.icon-btn {
    width: 32px;
  }
  .btn.block {
    width: 100%;
    min-height: 48px;
  }
  .btn.danger {
    color: var(--danger);
  }
  .btn.danger-solid {
    background: var(--danger);
    color: #fff;
  }
  .btn.danger-solid:hover {
    background: color-mix(in oklab, var(--danger) 85%, black);
  }
  @media (pointer: coarse) {
    .btn,
    .btn.small {
      min-height: 44px;
    }
    .btn.small.icon-btn,
    .btn.icon-btn {
      width: 44px;
    }
  }
  .file-btn {
    position: relative;
    overflow: hidden;
  }
  .file-btn:focus-within {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }
  .file-btn input,
  .file-item input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
  }

  /* fields */
  .field {
    display: grid;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--ink);
  }
  .field input,
  .field select,
  .field textarea,
  .filter,
  .inspector input:not([type="radio"]),
  .inspector select,
  .inspector textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-strong);
    background: var(--paper);
    font-size: var(--fs-md);
    font-weight: 500;
    color: var(--ink);
    transition:
      border-color 0.15s,
      box-shadow 0.15s;
  }
  .field textarea,
  .inspector textarea {
    resize: vertical;
    field-sizing: content;
    min-height: 72px;
    max-height: 240px;
    line-height: 1.45;
  }
  .field input:focus,
  .field select:focus,
  .field textarea:focus,
  .filter:focus,
  .inspector input:focus,
  .inspector select:focus,
  .inspector textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--mint) 75%, transparent);
  }
  .field.compact select {
    min-height: 40px;
    padding-block: 6px;
  }
  .field.dark {
    color: var(--on-dark-muted);
  }
  .field.dark input,
  .field.dark textarea,
  .stage .filter {
    background: var(--graphite);
    border-color: var(--graphite-edge);
    color: var(--on-dark);
  }
  .field.dark input:focus,
  .field.dark textarea:focus,
  .stage .filter:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--mint) 25%, transparent);
  }
  ::placeholder {
    color: color-mix(in oklab, currentColor 55%, transparent);
  }

  /* page header shared by Library / gallery / Practice */
  .page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: calc(var(--pad) + 4px) var(--pad) 18px;
  }
  .page-title {
    display: grid;
    gap: 2px;
    margin-right: auto;
  }
  .page-title h1 {
    font-size: var(--fs-xl);
  }
  .page-stats {
    color: var(--muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    padding-bottom: 10px;
  }
  .count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--pill);
    background: var(--stone);
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--muted);
  }

  /* status belts: 1–3 tape stripes, readable without colour */
  .belt {
    display: inline-block;
    position: relative;
    width: 26px;
    height: 8px;
    border-radius: 2px;
    background: var(--ink);
    flex: none;
    vertical-align: middle;
  }
  .belt::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 4px;
    width: calc(var(--n, 1) * 4px - 1.5px);
    background: repeating-linear-gradient(90deg, #fff 0 2.5px, transparent 2.5px 4px);
  }
  .belt.s1 {
    --n: 1;
  }
  .belt.s2 {
    --n: 2;
  }
  .belt.s3 {
    --n: 3;
  }

  /* menus (Popover API, anchored to invoker) */
  .menu {
    margin: 0;
    inset: auto;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block, flip-inline;
    min-width: 220px;
    max-width: 300px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-2);
    opacity: 1;
    transition:
      opacity 0.14s,
      translate 0.14s var(--ease),
      display 0.14s allow-discrete,
      overlay 0.14s allow-discrete;
    translate: 0 4px;
  }
  .menu:popover-open {
    translate: 0 6px;
  }
  @starting-style {
    .menu:popover-open {
      opacity: 0;
      translate: 0 0;
    }
  }
  .rail .menu {
    position-area: right span-top;
    translate: 8px 0;
  }
  .menu-item {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-xs);
    background: none;
    text-align: left;
    font-size: var(--fs-md);
    font-weight: 500;
    cursor: pointer;
  }
  .menu-item:hover,
  .menu-item:focus-within {
    background: var(--mineral);
  }
  .menu-item.danger {
    color: var(--danger);
  }
  .menu-item[aria-checked] {
    justify-content: space-between;
  }
  .menu-item[aria-checked]::after {
    content: "Off";
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--muted);
  }
  .menu-item[aria-checked="true"]::after {
    content: "On";
    color: var(--mint-deep);
  }
  .menu hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 6px 4px;
  }
  .menu-title {
    padding: 8px 12px 0;
    font-weight: 700;
    overflow-wrap: anywhere;
  }
  .menu-note {
    padding: 2px 12px 8px;
    font-size: var(--fs-xs);
    color: var(--muted);
  }

  /* dialogs */
  .dialog {
    margin: auto;
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 24px;
    border: 0;
    border-radius: var(--r-lg);
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-3);
    opacity: 1;
    scale: 1;
    transition:
      opacity 0.18s var(--ease),
      scale 0.18s var(--ease),
      display 0.18s allow-discrete,
      overlay 0.18s allow-discrete;
  }
  .dialog.wide {
    width: min(560px, calc(100vw - 24px));
  }
  @starting-style {
    .dialog[open] {
      opacity: 0;
      scale: 0.97;
    }
  }
  .dialog::backdrop {
    background: rgb(17 22 21 / 0.5);
    backdrop-filter: blur(3px);
  }
  .dialog h2 {
    font-size: 1.25rem;
  }
  .dialog form {
    display: grid;
    gap: 16px;
  }
  #ask-body {
    color: var(--muted);
  }
  .dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }
  .dialog-actions {
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
    justify-content: flex-start;
  }
  .source-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    border-radius: var(--r-md);
    background: var(--mineral);
  }
  .source-tabs button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }
  .source-tabs [aria-selected="true"] {
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-1);
  }
  .dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 26px 16px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-md);
    background: var(--mineral);
    text-align: center;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }
  .dropzone:focus-within {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }
  .dropzone.over {
    border-color: var(--ink);
    background: color-mix(in oklab, var(--mint) 22%, var(--mineral));
  }
  .dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
  }
  progress {
    width: 100%;
    height: 8px;
    accent-color: var(--ink);
  }

  .list-empty {
    color: var(--muted);
    font-size: var(--fs-sm);
    padding: 12px 4px;
  }
  .kind-tag,
  .tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--stone);
    color: var(--ink);
    white-space: nowrap;
  }
  .dirty-tag {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--warn-dark);
  }
  .empty-mark {
    width: 44px;
    height: 44px;
    color: currentColor;
    opacity: 0.9;
  }
}

/* --------------------------------------------------------------- library */
@layer library {
  #library {
    container: library / inline-size;
  }
  .film-room {
    display: grid;
    grid-template-columns: minmax(184px, 208px) minmax(0, 1fr);
    gap: 20px;
    padding: 0 var(--pad) var(--pad);
    align-items: start;
  }

  /* bin: thumbnail-led collection */
  .bin {
    display: grid;
    gap: 12px;
    position: sticky;
    top: 16px;
  }
  .bin-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 0;
  }
  .bin-head h2 {
    font-size: var(--fs-md);
  }
  .consent {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: var(--r-md);
    background: var(--paper);
    border: 1px solid var(--line);
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .consent strong {
    display: block;
    color: var(--ink);
  }
  .consent-actions {
    display: flex;
    gap: 6px;
  }
  .bin-list {
    display: grid;
    gap: 8px;
  }
  .media-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .bin-open {
    display: grid;
    gap: 8px;
    width: 100%;
    padding: 6px 6px 10px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition:
      background 0.16s var(--ease),
      box-shadow 0.16s var(--ease);
  }
  .bin-open:hover {
    background: var(--paper);
    box-shadow: var(--shadow-1);
  }
  .bin-open[aria-current="true"] {
    background: var(--graphite);
    color: var(--on-dark);
    box-shadow: var(--shadow-2);
    --ring: var(--mint);
  }
  .bin-open[aria-current="true"] .bin-meta {
    color: var(--on-dark-muted);
  }
  .thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: var(--r-xs);
    overflow: hidden;
    background:
      radial-gradient(120% 90% at 20% 0%, #2c3632 0%, transparent 60%),
      linear-gradient(160deg, #1d2522, #0d1110);
    color: var(--on-dark-muted);
  }
  .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .thumb .glyph {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    fill: currentColor;
    opacity: 0.85;
  }
  .thumb[data-kind="youtube"] .glyph {
    color: #ff5a4f;
  }
  .thumb-label {
    position: absolute;
    left: 6px;
    top: 5px;
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--on-dark-muted);
  }
  .thumb-dur {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgb(0 0 0 / 0.72);
    color: #fff;
    font-family: var(--mono);
    font-size: 10.5px;
  }
  .bin-open[aria-current="true"] .thumb {
    outline: 2px solid var(--mint);
    outline-offset: -2px;
  }
  .bin-text {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 0 4px;
  }
  .bin-title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
  }
  .bin-meta {
    font-size: var(--fs-xs);
    color: var(--muted);
    font-weight: 500;
  }
  .media-row .more {
    position: absolute;
    right: 11px;
    top: 11px;
    width: 32px;
    min-height: 32px;
    border-radius: 8px;
    background: rgb(17 22 21 / 0.72);
    color: #fff;
    backdrop-filter: blur(4px);
    --ring: var(--mint);
  }
  .media-row .more:hover {
    background: var(--graphite);
  }
  .shelf-empty {
    padding: 18px 14px;
    border: 1.5px dashed var(--line);
    border-radius: var(--r-md);
    color: var(--muted);
    font-size: var(--fs-sm);
  }
  .quota {
    padding: 4px;
    font-size: 11px;
    color: var(--muted);
  }

  /* stage: the cinematic dark viewer */
  .stage {
    container: stage / inline-size;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    border-radius: var(--r-lg);
    background: var(--graphite);
    color: var(--on-dark);
    box-shadow: var(--shadow-3);
    overflow: hidden;
    min-width: 0;
  }
  .stage-main {
    display: grid;
    gap: 12px;
    padding: 16px;
    align-content: start;
    min-width: 0;
  }
  .stage-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    min-height: 32px;
  }
  .stage-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-right: auto;
  }
  .stage-head h2 {
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .stage .kind-tag {
    background: var(--graphite-3);
    color: var(--on-dark-muted);
  }
  .stage-meta {
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
  }
  .viewer:empty {
    display: none;
  }
  .viewer {
    display: grid;
    gap: 8px;
  }
  .viewer video,
  .viewer iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 62dvh;
    border: 0;
    border-radius: var(--r-md);
    background: #000;
  }
  .source-link {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--on-dark);
    text-underline-offset: 3px;
    min-height: 36px;
    padding: 0 2px;
  }
  .stage-empty {
    display: grid;
    justify-items: start;
    gap: 10px;
    padding: clamp(28px, 6cqi, 64px) clamp(20px, 5cqi, 56px);
    min-height: 340px;
    align-content: center;
    border-radius: var(--r-md);
    background:
      radial-gradient(80% 120% at 100% 0%, color-mix(in oklab, var(--mint) 14%, transparent), transparent 60%),
      repeating-linear-gradient(90deg, transparent 0 47px, rgb(255 255 255 / 0.035) 47px 48px),
      var(--graphite-2);
    --mark-dot: var(--mint);
  }
  .stage-empty h3 {
    font-size: clamp(1.25rem, 1rem + 1cqi, 1.75rem);
  }
  .stage-empty p {
    max-width: 46ch;
    color: var(--on-dark-muted);
  }
  .stage-help {
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
  }
  .stage.no-film .reference {
    display: none;
  }
  .stage.no-film {
    grid-template-columns: minmax(0, 1fr);
  }
  .stage-help:empty {
    display: none;
  }

  /* timeline / reference rail under the player */
  .timeline {
    display: grid;
    gap: 4px;
  }
  .timeline-track {
    --lanes: 1;
    position: relative;
    height: calc(14px + var(--lanes) * 22px);
    border-radius: var(--r-sm);
    background:
      repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgb(255 255 255 / 0.06) calc(10% - 1px) 10%),
      var(--graphite-2);
    border: 1px solid var(--graphite-line);
    cursor: pointer;
    touch-action: none;
  }
  .strip-seg {
    position: absolute;
    top: calc(7px + var(--lane, 0) * 22px);
    left: calc(var(--a) * 100%);
    width: max(6px, calc((var(--b) - var(--a)) * 100%));
    height: 18px;
    padding: 0 6px;
    border: 0;
    border-left: 2px solid var(--mint);
    border-radius: 3px 5px 5px 3px;
    background: color-mix(in oklab, var(--mint) 22%, transparent);
    color: var(--on-dark);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .strip-seg:hover {
    background: color-mix(in oklab, var(--mint) 38%, transparent);
  }
  .strip-seg[aria-current="true"] {
    background: var(--mint);
    color: var(--graphite);
  }
  .strip-draft {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: calc(var(--a, 0) * 100%);
    width: calc((var(--b, 0) - var(--a, 0)) * 100%);
    border: 1.5px dashed color-mix(in oklab, var(--mint) 80%, white);
    border-radius: 6px;
    background: color-mix(in oklab, var(--mint) 8%, transparent);
    pointer-events: none;
  }
  .strip-head {
    position: absolute;
    top: -3px;
    bottom: -3px;
    left: calc(var(--t, 0) * 100%);
    width: 2px;
    margin-left: -1px;
    background: #fff;
    border-radius: 2px;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4);
  }
  .strip-head::before {
    content: "";
    position: absolute;
    top: -3px;
    left: -4px;
    width: 10px;
    height: 6px;
    border-radius: 2px;
    background: #fff;
  }
  .timeline-scale {
    display: flex;
    justify-content: space-between;
    font-size: 10.5px;
    color: var(--on-dark-muted);
  }

  .transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  .tbtn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--graphite-line);
    background: var(--graphite-2);
    color: var(--on-dark);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
  }
  .tbtn:hover:not(:disabled) {
    background: var(--graphite-3);
    border-color: var(--graphite-edge);
  }
  .tbtn.toggle[aria-pressed="true"] {
    background: var(--mint);
    color: var(--graphite);
    border-color: var(--mint);
  }
  .tbtn.accent {
    border-color: color-mix(in oklab, var(--mint) 60%, transparent);
    color: var(--mint);
  }
  .tbtn.accent:hover {
    background: color-mix(in oklab, var(--mint) 12%, var(--graphite-2));
  }
  .playhead-time {
    margin-inline: auto;
    padding: 0 8px;
    font-size: var(--fs-md);
    color: var(--on-dark);
    letter-spacing: 0.02em;
  }

  /* reference column: composer + segment list */
  .reference {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-top: 1px solid var(--graphite-line);
    background: color-mix(in oklab, var(--graphite-2) 55%, var(--graphite));
    min-width: 0;
  }
  @container library (min-width: 1180px) {
    .stage {
      grid-template-columns: minmax(0, 1fr) clamp(288px, 26cqi, 340px);
    }
    .reference {
      border-top: 0;
      border-left: 1px solid var(--graphite-line);
      contain: size;
      overflow: auto;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: var(--graphite-edge) transparent;
    }
  }
  .composer {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: var(--r-md);
    background: var(--graphite-2);
    border: 1px solid var(--graphite-edge);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--mint) 7%, transparent);
  }
  .composer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .composer-head h3,
  .segments-head h3 {
    font-size: var(--fs-md);
    font-weight: 700;
  }
  .marks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .mark {
    display: grid;
    gap: 6px;
    padding: 8px;
    border-radius: var(--r-sm);
    background: var(--graphite);
  }
  .mark legend {
    float: left;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--on-dark-muted);
  }
  .timecode-btn {
    justify-self: start;
    padding: 0 2px;
    border: 0;
    background: none;
    color: var(--on-dark);
    cursor: pointer;
    border-radius: 6px;
  }
  .timecode-btn .timecode {
    font-size: 1.25rem;
    font-weight: 500;
  }
  .mark-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 4px;
  }
  .sec-field input {
    width: 100%;
    min-height: 34px;
    padding: 4px 6px;
    border-radius: 7px;
    border: 1px solid var(--graphite-edge);
    background: var(--graphite-2);
    color: var(--on-dark);
    font-family: var(--mono);
    font-size: var(--fs-sm);
  }
  .sec-field input:focus {
    outline: 2px solid var(--mint);
    outline-offset: 0;
  }
  .nudge {
    min-width: 34px;
    min-height: 34px;
    padding: 0 4px;
    border-radius: 7px;
    border: 1px solid var(--graphite-edge);
    background: transparent;
    color: var(--on-dark);
    font-family: var(--mono);
    font-size: 11.5px;
    cursor: pointer;
  }
  .nudge:hover {
    background: var(--graphite-3);
  }
  .clip-length {
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
  }
  .clip-length.bad {
    color: var(--danger-dark);
  }
  .composer-actions {
    display: flex;
    gap: 8px;
  }
  .composer-actions .mint {
    flex: 1;
  }

  .segments {
    display: grid;
    gap: 10px;
    align-content: start;
  }
  .segments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .seg-toggle {
    display: inline-flex;
    padding: 3px;
    border-radius: var(--r-sm);
    background: var(--graphite);
    border: 1px solid var(--graphite-line);
  }
  .seg-toggle button {
    min-height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--on-dark-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    cursor: pointer;
  }
  .seg-toggle [aria-pressed="true"] {
    background: var(--graphite-3);
    color: var(--on-dark);
  }
  .seg-toggle button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
  }
  .stage .filter {
    min-height: 38px;
    font-size: var(--fs-sm);
  }
  .clip-list {
    display: grid;
    gap: 2px;
  }
  .clip-row {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto auto;
    gap: 4px 10px;
    align-items: start;
    padding: 8px 6px 8px 8px;
    border-radius: var(--r-sm);
    transition: background 0.15s;
  }
  .clip-row:hover {
    background: var(--graphite-2);
  }
  .clip-row[aria-current="true"] {
    background: var(--graphite-3);
  }
  .clip-row[aria-current="true"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 2px;
    border-radius: 2px;
    background: var(--mint);
  }
  .clip-row .play {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 9px;
    background: var(--graphite-3);
    color: var(--mint);
    border: 0;
  }
  .clip-row .play:hover {
    background: var(--mint);
    color: var(--graphite);
  }
  .clip-main {
    display: grid;
    gap: 2px;
    min-width: 0;
  }
  .clip-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    overflow-wrap: anywhere;
  }
  .clip-sub {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--on-dark-muted);
  }
  .clip-sub .timecode {
    color: var(--on-dark);
  }
  .clip-notes {
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
  }
  .clip-row .btn.quiet {
    color: var(--on-dark-muted);
    min-height: 32px;
    padding: 0 8px;
  }
  .clip-row .btn.quiet:hover {
    background: var(--graphite-3);
    color: var(--on-dark);
  }
  .stage .list-empty {
    color: var(--on-dark-muted);
  }

  @container library (max-width: 760px) {
    .film-room {
      grid-template-columns: minmax(0, 1fr);
      gap: 24px;
    }
    .bin {
      position: static;
      order: 2;
    }
    .bin-list {
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    .stage {
      margin-inline: calc(var(--pad) * -0.5);
      border-radius: var(--r-md);
    }
    .stage-main,
    .reference {
      padding: 12px;
    }
    .page-stats {
      display: none;
    }
  }
}

/* ---------------------------------------------------------------- plans */
@layer plans {
  /* gallery */
  .gallery {
    padding-bottom: var(--pad);
  }
  .plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr));
    gap: 18px;
    padding: 0 var(--pad);
  }
  .plan-card {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    gap: 0;
  }
  .plan-open {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 3;
    gap: 0;
    width: 100%;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--paper);
    text-align: left;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition:
      box-shadow 0.2s var(--ease),
      translate 0.2s var(--ease),
      border-color 0.2s;
  }
  .plan-open:hover {
    box-shadow: var(--shadow-2);
    translate: 0 -2px;
    border-color: var(--line-strong);
  }
  .plan-open[aria-current="true"] {
    border-color: var(--ink);
  }
  .mini {
    position: relative;
    aspect-ratio: 16 / 8.5;
    background:
      radial-gradient(circle at 1px 1px, #c9cdc5 1px, transparent 1.4px) 0 0 / 14px 14px,
      var(--mineral);
    border-bottom: 1px solid var(--line);
  }
  .mini svg {
    width: 100%;
    height: 100%;
  }
  .mini .m-edge {
    stroke: var(--muted);
    stroke-width: 1.6;
    fill: none;
    opacity: 0.7;
  }
  .mini .m-pos {
    fill: var(--paper);
    stroke: #b9beb6;
    stroke-width: 1.2;
  }
  .mini .m-tech {
    fill: var(--graphite);
  }
  .mini .m-tech-bar {
    fill: var(--mint);
  }
  .mini-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .plan-name {
    padding: 14px 16px 4px;
    font-weight: 700;
    font-size: var(--fs-md);
    line-height: 1.3;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
  }
  .plan-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 0 16px 14px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--muted);
    align-self: end;
  }
  .plan-meta .badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: var(--pill);
    background: var(--graphite);
    color: var(--mint);
  }
  .plan-meta .badge.warn {
    background: var(--warn-bg);
    color: var(--warn);
  }
  .gallery-empty {
    display: grid;
    justify-items: start;
    gap: 10px;
    margin: 0 var(--pad) 18px;
    padding: clamp(24px, 4vw, 48px);
    border-radius: var(--r-lg);
    background:
      radial-gradient(circle at 1px 1px, #c9cdc5 1px, transparent 1.4px) 0 0 / 18px 18px,
      var(--paper);
    border: 1px solid var(--line);
  }
  .gallery-empty h2 {
    font-size: 1.5rem;
  }
  .gallery-empty p {
    max-width: 52ch;
    color: var(--muted);
  }

  /* editor: canvas-first, floating chrome */
  .editor {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    background: var(--mineral-2);
  }
  .canvas-stage,
  .canvas-viewport {
    position: absolute;
    inset: 0;
  }
  .canvas-viewport {
    overflow: hidden;
    touch-action: none;
    outline: none;
  }
  #canvas {
    width: 100%;
    height: 100%;
    user-select: none;
    cursor: grab;
  }
  #canvas:active {
    cursor: grabbing;
  }
  #canvas.connecting,
  #canvas.connecting .node {
    cursor: crosshair;
  }
  .canvas-empty {
    position: absolute;
    left: 50%;
    top: 46%;
    translate: -50% -50%;
    padding: 14px 20px;
    border-radius: var(--r-md);
    background: var(--paper);
    border: 1px dashed var(--line-strong);
    color: var(--muted);
    font-weight: 600;
    pointer-events: none;
  }

  .editor-head {
    position: absolute;
    z-index: 5;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    pointer-events: none;
  }
  .head-cluster {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: var(--r-md);
    background: color-mix(in oklab, var(--paper) 92%, transparent);
    backdrop-filter: blur(12px) saturate(1.2);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
    min-width: 0;
  }
  .plan-cluster {
    flex: 0 1 auto;
  }
  .plan-ident {
    display: grid;
    min-width: 0;
    padding-right: 2px;
  }
  .plan-title {
    width: clamp(200px, 30vw, 440px);
    min-height: 30px;
    padding: 2px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -0.015em;
    text-overflow: ellipsis;
  }
  .plan-title:hover {
    background: var(--mineral);
  }
  .plan-title:focus {
    outline: none;
    background: var(--paper);
    border-color: var(--ink);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--mint) 75%, transparent);
  }
  .plan-counts {
    padding: 0 9px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .switcher {
    position: relative;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    color: var(--muted);
    flex: none;
  }
  .switcher:hover {
    background: var(--mineral);
    color: var(--ink);
  }
  .switcher:focus-within {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
  }
  .switcher select {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
  }
  .switcher .icon {
    pointer-events: none;
  }
  .save-state {
    padding: 0 8px;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
  }
  .save-state[data-dirty="true"] {
    color: var(--warn);
  }
  .save-state[data-dirty="true"]::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 7px;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 1px;
  }
  #save-plan[data-dirty="false"] {
    background: var(--stone);
    color: var(--muted);
  }

  .conflict {
    position: absolute;
    z-index: 6;
    top: 80px;
    left: 14px;
    max-width: min(540px, calc(100% - 28px));
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--warn-bg);
    border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
    box-shadow: var(--shadow-2);
    font-size: var(--fs-sm);
  }
  .conflict-actions {
    display: flex;
    gap: 6px;
  }
  .connect-hint {
    position: absolute;
    z-index: 6;
    top: 80px;
    left: 50%;
    translate: -50% 0;
    max-width: min(620px, calc(100% - 28px));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-radius: var(--r-md);
    background: var(--graphite);
    color: var(--on-dark);
    font-size: var(--fs-sm);
    box-shadow: var(--shadow-3);
    --ring: var(--mint);
  }
  .pulse {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--mint) 60%, transparent);
    animation: pulse 1.6s infinite;
  }
  @keyframes pulse {
    70% {
      box-shadow: 0 0 0 9px transparent;
    }
  }

  .dock {
    position: absolute;
    z-index: 5;
    left: 50%;
    bottom: 16px;
    translate: -50% 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-radius: 18px;
    background: var(--graphite);
    color: var(--on-dark);
    box-shadow: var(--shadow-3);
    max-width: calc(100% - 28px);
  }
  .dock-group {
    display: flex;
    align-items: center;
    gap: 2px;
  }
  .dock-group + .dock-group {
    padding-left: 5px;
    margin-left: 1px;
    border-left: 1px solid var(--graphite-line);
  }
  .dbtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--on-dark);
    font-size: var(--fs-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
  }
  .dbtn:hover {
    background: var(--graphite-3);
  }
  .dbtn.icon-only {
    padding: 0 11px;
  }
  .dbtn[aria-pressed="true"] {
    background: var(--graphite-3);
    color: var(--mint);
  }
  .dbtn.active {
    background: var(--mint);
    color: var(--graphite);
  }
  .dock-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .swatch {
    width: 14px;
    height: 11px;
    border-radius: 3px;
    flex: none;
  }
  .swatch.pos {
    background: var(--paper);
  }
  .swatch.tech {
    background: var(--graphite);
    box-shadow:
      inset 3px 0 0 var(--mint),
      inset 0 0 0 1px var(--graphite-edge);
  }
  .zoom-level {
    min-width: 46px;
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
  }

  .legend {
    position: absolute;
    z-index: 4;
    right: 14px;
    bottom: 20px;
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--r-sm);
    background: color-mix(in oklab, var(--paper) 85%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
  }
  .legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .editor:has(#inspector:not([hidden])) .legend {
    display: none;
  }

  .inspector {
    position: absolute;
    z-index: 5;
    top: 80px;
    right: 14px;
    width: var(--insp-w);
    max-height: calc(100% - 80px - 84px);
    overflow: auto;
    overscroll-behavior: contain;
    display: grid;
    gap: 14px;
    align-content: start;
    padding: 14px 16px 16px;
    border-radius: var(--r-lg);
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-3);
    scrollbar-width: thin;
  }
  .inspector.collapsed {
    gap: 0;
    padding-bottom: 14px;
  }
  .inspector.collapsed > :not(.inspector-head) {
    display: none;
  }
  .inspector-head {
    position: sticky;
    top: -14px;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: -14px -16px 0;
    padding: 12px 10px 10px 16px;
    background: color-mix(in oklab, var(--paper) 94%, transparent);
    backdrop-filter: blur(6px);
  }
  .inspector-head .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--pill);
    font-size: var(--fs-xs);
    font-weight: 700;
    background: var(--mineral);
    color: var(--ink);
  }
  .inspector-head .chip.kind-technique {
    background: var(--graphite);
    color: var(--mint);
  }
  .inspector-head .chip.kind-edge {
    background: transparent;
    border: 1px dashed var(--line-strong);
  }
  .inspector-head .head-title {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .inspector .field {
    gap: 5px;
  }
  .inspector input[data-field="title"] {
    font-size: var(--fs-lg);
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .opts {
    display: grid;
    gap: 6px;
  }
  .opts legend {
    float: left;
    margin-bottom: 6px;
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .opts-row {
    clear: both;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 3px;
    padding: 3px;
    border-radius: var(--r-sm);
    background: var(--mineral);
  }
  .opts label {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 38px;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
  }
  .opts.belts label {
    min-height: 50px;
  }
  .opts input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
  }
  .opts label:has(:checked) {
    background: var(--paper);
    color: var(--ink);
    box-shadow: var(--shadow-1), inset 0 0 0 1px var(--ink);
  }
  .opts label:has(:focus-visible) {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
  }
  .pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .pair.xy input {
    min-height: 36px;
    font-family: var(--mono);
    font-size: var(--fs-sm);
  }
  .insp-section {
    display: grid;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .sub-title {
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .attached {
    display: grid;
    gap: 4px;
  }
  .attached-chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: 4px 4px 4px 4px;
    border-radius: var(--r-sm);
    background: var(--mineral);
  }
  .attached-chip .chip-title {
    font-size: var(--fs-sm);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .attached-chip .timecode {
    font-size: 11px;
    color: var(--muted);
  }
  .attached-chip .play {
    background: var(--graphite);
    color: var(--mint);
  }
  .picker {
    position: relative;
  }
  .picker label {
    display: grid;
    gap: 5px;
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .picker-list {
    position: absolute;
    z-index: 3;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 240px;
    overflow: auto;
    padding: 4px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow-2);
  }
  .option {
    display: grid;
    gap: 1px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
  }
  .option[aria-selected="true"],
  .option:hover {
    background: var(--mineral);
  }
  .opt-title {
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .opt-meta,
  .picker-empty {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .picker-empty {
    padding: 8px 10px;
  }
  .inline-player:empty {
    display: none;
  }
  .inspector .inline-player:not(:empty) {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-radius: var(--r-md);
    background: var(--graphite);
    color: var(--on-dark);
    --ring: var(--mint);
  }
  .inspector .inline-player video,
  .inspector .inline-player iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border: 0;
    border-radius: var(--r-sm);
    background: #000;
  }
  .delete-item {
    justify-self: start;
  }
  .inspector-help {
    display: grid;
    gap: 6px;
  }

  /* list view: the accessible outline */
  .outline {
    position: absolute;
    z-index: 3;
    top: 80px;
    bottom: 84px;
    left: 14px;
    right: 14px;
    overflow: auto;
    padding: 18px;
    border-radius: var(--r-lg);
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
  }
  .editor:has(#inspector:not([hidden], .collapsed)) .outline {
    right: calc(var(--insp-w) + 28px);
  }
  .outline-list {
    display: grid;
    gap: 10px;
    max-width: 760px;
  }
  .outline-node {
    display: grid;
    gap: 4px;
  }
  .outline-btn {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--paper);
    text-align: left;
    cursor: pointer;
    font-weight: 600;
  }
  .node-technique > .outline-btn {
    background: var(--graphite);
    color: var(--on-dark);
    border-color: var(--graphite);
    --ring: var(--mint);
  }
  .node-technique > .outline-btn .belt {
    background: var(--graphite-edge);
  }
  .outline-btn[aria-current="true"] {
    box-shadow:
      0 0 0 2px var(--ink),
      0 0 0 6px color-mix(in oklab, var(--mint) 70%, transparent);
  }
  .outline-btn.source {
    outline: 2px dashed var(--ink);
    outline-offset: 2px;
  }
  .kind {
    font-size: 10.5px;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .node-technique .kind {
    color: var(--mint);
  }
  .o-title {
    overflow-wrap: anywhere;
  }
  .outline-edges {
    display: grid;
    gap: 2px;
    margin-left: 22px;
    padding-left: 14px;
    border-left: 2px solid var(--line);
  }
  .outline-edge {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    width: 100%;
    min-height: 40px;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--r-sm);
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: var(--fs-sm);
  }
  .outline-edge:hover {
    background: var(--mineral);
  }
  .outline-edge[aria-current="true"] {
    background: var(--mineral);
    box-shadow: inset 0 0 0 1.5px var(--ink);
  }
  .outline-edge .icon {
    color: var(--muted);
  }
  .o-reaction {
    font-weight: 600;
  }
  .o-target {
    color: var(--muted);
  }

  /* SVG canvas */
  .canvas-bg {
    fill: var(--mineral-2);
  }
  .mat {
    fill: #f7f7f3;
    stroke: #d6d9d1;
    stroke-width: 1;
  }
  .dot {
    fill: #c8ccc3;
  }
  .edge .line {
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.75;
    stroke-linecap: round;
  }
  .edge.status-learning .line {
    stroke-dasharray: 0.5 6;
    stroke-width: 2.4;
  }
  .edge.status-drilling .line {
    stroke-dasharray: 9 6;
  }
  .edge.status-in-my-game .line {
    stroke-width: 2.25;
  }
  .edge .halo {
    fill: none;
    stroke: transparent;
    stroke-width: 9;
    stroke-linecap: round;
  }
  .edge .hit {
    fill: none;
    stroke: transparent;
    stroke-width: 18;
    cursor: pointer;
  }
  .edge.selected .line {
    stroke: var(--ink);
    stroke-width: 2.6;
  }
  .edge.selected .halo {
    stroke: color-mix(in oklab, var(--mint) 85%, transparent);
  }
  .edge:hover .line {
    stroke: var(--ink);
  }
  .arrowhead {
    fill: var(--muted);
  }
  .arrowhead.on {
    fill: var(--ink);
  }
  .edge .pill {
    fill: var(--paper);
    stroke: #c9cec5;
    stroke-width: 1;
    cursor: pointer;
    filter: drop-shadow(0 1px 1.5px rgb(17 22 21 / 0.08));
  }
  .edge .pill-text {
    fill: var(--ink);
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
  }
  .edge .tick {
    fill: #d5d9d0;
  }
  .edge .tick.on {
    fill: var(--ink);
  }
  .edge.selected .pill {
    fill: var(--ink);
    stroke: var(--ink);
  }
  .edge.selected .pill-text {
    fill: #fff;
  }
  .edge.selected .tick.on {
    fill: var(--mint);
  }
  .edge.selected .tick {
    fill: var(--graphite-edge);
  }
  .edge:focus-visible {
    outline: none;
  }
  .edge:focus-visible .pill {
    stroke: var(--ink);
    stroke-width: 2.5;
  }

  .node {
    cursor: pointer;
    outline: none;
  }
  .node .shape {
    fill: var(--paper);
    stroke: #cfd3cb;
    stroke-width: 1;
    filter: drop-shadow(0 2px 4px rgb(17 22 21 / 0.08)) drop-shadow(0 8px 18px rgb(17 22 21 / 0.06));
    transition: stroke 0.15s;
  }
  .node:hover .shape {
    stroke: var(--line-strong);
  }
  .node .ring {
    fill: none;
    stroke: transparent;
    stroke-width: 2.5;
  }
  .node .halo {
    fill: none;
    stroke: transparent;
    stroke-width: 7;
  }
  .node.selected .ring,
  .node:focus-visible .ring {
    stroke: var(--ink);
  }
  .node.selected .halo {
    stroke: color-mix(in oklab, var(--mint) 85%, transparent);
  }
  .node.source .ring {
    stroke: var(--ink);
    stroke-dasharray: 6 4;
  }
  .node .bar {
    fill: var(--ink);
  }
  .node .meta {
    fill: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }
  .node .title {
    fill: var(--ink);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
  }
  .node .foot {
    fill: var(--muted);
    font-size: 11px;
    font-weight: 600;
  }
  .node .belt-bar {
    fill: var(--ink);
  }
  .node .tape {
    fill: #fff;
  }
  .node .clip-dot {
    fill: var(--mint-deep);
  }
  .node-technique .shape {
    fill: var(--graphite);
    stroke: var(--graphite);
  }
  .node-technique:hover .shape {
    stroke: var(--graphite-edge);
  }
  .node-technique .bar {
    fill: var(--mint);
  }
  .node-technique .title {
    fill: var(--on-dark);
  }
  .node-technique .meta {
    fill: var(--mint);
  }
  .node-technique .foot {
    fill: var(--on-dark-muted);
  }
  .node-technique .belt-bar {
    fill: #000;
    stroke: var(--graphite-edge);
    stroke-width: 1;
  }
  .node-technique .clip-dot {
    fill: var(--mint);
  }

  @media (max-width: 1099px) {
    .legend {
      display: none;
    }
    .plan-title {
      width: clamp(200px, 38vw, 400px);
    }
  }

  /* phones: stacked, nothing floats over content */
  @media (max-width: 760px) {
    .editor {
      height: auto;
      overflow: visible;
      display: flex;
      flex-direction: column;
      gap: 10px;
      padding: 12px 12px 24px;
      background: var(--mineral);
    }
    .editor-head {
      position: static;
      order: 1;
      flex-direction: column;
      align-items: stretch;
      gap: 8px;
    }
    .head-cluster {
      box-shadow: var(--shadow-1);
    }
    .plan-ident {
      flex: 1;
    }
    .plan-title {
      width: 100%;
      min-height: 40px;
    }
    .save-cluster {
      justify-content: flex-end;
    }
    .save-cluster .save-state {
      margin-right: auto;
    }
    .conflict,
    .connect-hint {
      position: static;
      order: 2;
      translate: none;
      max-width: none;
    }
    .dock {
      position: static;
      order: 3;
      translate: none;
      max-width: none;
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 4px;
      border-radius: var(--r-md);
    }
    .dock-group:first-child {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
    }
    .dock-group + .dock-group {
      padding-left: 0;
      margin-left: 0;
      border-left: 0;
    }
    .dock-group.zoom {
      justify-content: flex-end;
      padding-left: 6px;
      border-left: 1px solid var(--graphite-line);
    }
    .dock .dbtn {
      justify-content: center;
      padding: 0 10px;
      min-height: 44px;
    }
    .canvas-stage {
      position: relative;
      order: 4;
      inset: auto;
    }
    .canvas-viewport {
      position: relative;
      height: 58dvh;
      min-height: 340px;
      border-radius: var(--r-lg);
      border: 1px solid var(--line);
      background: var(--mineral-2);
    }
    .outline {
      position: static;
      padding: 12px;
      box-shadow: var(--shadow-1);
    }
    .editor:has(#inspector:not([hidden], .collapsed)) .outline {
      right: auto;
    }
    .editor > * {
      min-width: 0;
    }
    .inspector {
      position: static;
      order: 5;
      width: auto;
      max-height: none;
      box-shadow: var(--shadow-2);
    }
    .inspector-head {
      position: static;
    }
  }
}

/* -------------------------------------------------------------- practice */
@layer practice {
  #practice {
    container: practice / inline-size;
    padding-bottom: var(--pad);
  }
  .practice-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    padding: calc(var(--pad) + 4px) var(--pad) 14px;
  }
  .practice-setup {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 10px;
    border-radius: var(--r-lg);
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
  }
  .practice-setup .field {
    min-width: min(240px, 100%);
    flex: 1 1 200px;
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  .practice-setup .field select {
    max-width: 320px;
    color: var(--ink);
    font-weight: 600;
  }
  .source-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 var(--pad) 12px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--paper);
    border: 1px solid var(--line);
    font-size: var(--fs-sm);
  }
  .source-note[data-kind="draft"] {
    background: var(--warn-bg);
    border-color: color-mix(in oklab, var(--warn) 35%, transparent);
  }
  .source-note .note-tag {
    font-weight: 700;
  }
  .source-note[data-kind="draft"] .note-tag {
    color: var(--warn);
  }
  .source-note .help {
    flex: 1 1 260px;
  }

  /* breadcrumb route */
  .trail {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 calc(var(--pad) - 14px) 18px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 3px 14px;
    mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 14px), transparent);
  }
  .trail-step {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
  }
  .trail-reaction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 6px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--muted);
    max-width: 22ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .trail-reaction .icon {
    width: 12px;
    height: 12px;
    flex: none;
  }
  .trail-node {
    max-width: 28ch;
    min-height: 34px;
    padding: 0 12px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: var(--paper);
    font-size: var(--fs-sm);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }
  .trail-node:hover {
    border-color: var(--line-strong);
  }
  .trail-node[aria-current="step"] {
    background: var(--graphite);
    color: #fff;
    border-color: var(--graphite);
  }

  .study {
    display: grid;
    gap: 18px;
    padding: 0 var(--pad);
    grid-template-columns: minmax(0, 1fr);
  }
  @container practice (min-width: 900px) {
    .study {
      grid-template-columns: minmax(0, 1fr) clamp(320px, 30cqi, 400px);
      align-items: start;
    }
    .next {
      position: sticky;
      top: 16px;
    }
  }
  .study-step {
    display: grid;
    gap: 14px;
    min-width: 0;
    outline: none;
  }
  .step-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
  }
  .step-num {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(3.5rem, 2rem + 4vw, 5.5rem);
    line-height: 0.8;
    letter-spacing: -0.01em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
  }
  .step-id {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding-bottom: 2px;
  }
  .step-kicker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .step-kicker .status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
  }
  .step-title {
    font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem);
    letter-spacing: -0.025em;
    overflow-wrap: anywhere;
  }
  .via {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--paper);
    border: 1px solid var(--line);
  }
  .via .eyebrow {
    flex: none;
  }
  .via-title {
    font-weight: 700;
  }
  .via .notes {
    flex-basis: 100%;
    color: var(--muted);
    font-size: var(--fs-sm);
  }
  .study-stage {
    display: grid;
    gap: 12px;
    padding: 12px;
    border-radius: var(--r-lg);
    background: var(--graphite);
    color: var(--on-dark);
    box-shadow: var(--shadow-3);
  }
  .study-stage .inline-player {
    display: grid;
    gap: 10px;
  }
  .study-stage video,
  .study-stage iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 58dvh;
    border: 0;
    border-radius: var(--r-md);
    background: #000;
  }
  .inline-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 2px 4px 0;
  }
  .inline-head strong {
    flex: 1 1 14ch;
  }
  .inline-head strong {
    font-weight: 600;
    font-size: var(--fs-md);
    overflow-wrap: anywhere;
  }
  .inline-head .timecode {
    font-size: var(--fs-xs);
    color: var(--on-dark-muted);
    white-space: nowrap;
  }
  .inline-controls {
    display: flex;
    gap: 6px;
  }
  .stage-none {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    min-height: 200px;
    padding: 24px;
    border-radius: var(--r-md);
    background:
      repeating-linear-gradient(90deg, transparent 0 47px, rgb(255 255 255 / 0.035) 47px 48px),
      var(--graphite-2);
    text-align: center;
    color: var(--on-dark-muted);
    font-size: var(--fs-sm);
  }
  .stage-none strong {
    color: var(--on-dark);
    font-size: var(--fs-md);
  }
  .step-clips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .clip-play {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--r-sm);
    border: 1px solid var(--graphite-line);
    background: var(--graphite-2);
    color: var(--on-dark);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
  }
  .clip-play .icon {
    color: var(--mint);
  }
  .clip-play .chip-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .clip-play .timecode {
    font-size: 11px;
    color: var(--on-dark-muted);
    white-space: nowrap;
  }
  .clip-play:hover {
    border-color: var(--graphite-edge);
    background: var(--graphite-3);
  }
  .clip-play[aria-current="true"] {
    background: var(--mint);
    color: var(--graphite);
    border-color: var(--mint);
  }
  .clip-play[aria-current="true"] .icon,
  .clip-play[aria-current="true"] .timecode {
    color: var(--graphite);
  }
  .step-notes {
    padding: 2px 2px 0;
    max-width: 70ch;
    color: var(--ink);
    white-space: pre-line;
    overflow-wrap: anywhere;
  }

  .next {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: var(--r-lg);
    background: var(--paper);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
  }
  .next:empty {
    display: none;
  }
  .next-title {
    font-size: 1.25rem;
  }
  .tiles {
    display: grid;
    gap: 8px;
  }
  .tile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "key reaction go" "key target go";
    align-items: center;
    gap: 2px 14px;
    width: 100%;
    min-height: 72px;
    padding: 12px 14px;
    border: 1px solid var(--graphite);
    border-radius: var(--r-md);
    background: var(--graphite);
    color: var(--on-dark);
    text-align: left;
    cursor: pointer;
    transition:
      translate 0.16s var(--ease),
      box-shadow 0.16s var(--ease),
      border-color 0.16s;
  }
  .tile:hover {
    translate: 0 -1px;
    border-color: var(--mint);
    box-shadow: var(--shadow-2);
  }
  .tile kbd {
    grid-area: key;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: 0;
    background: var(--mint);
    color: var(--graphite);
    font-size: var(--fs-sm);
    font-weight: 500;
    opacity: 1;
  }
  .tile-reaction {
    grid-area: reaction;
    font-weight: 700;
    font-size: var(--fs-md);
    overflow-wrap: anywhere;
  }
  .tile-target {
    grid-area: target;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-sm);
    color: var(--on-dark-muted);
    min-width: 0;
  }
  .tile-target span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tile-target .icon {
    width: 13px;
    height: 13px;
  }
  .tile .go {
    grid-area: go;
    width: 18px;
    height: 18px;
    color: var(--mint);
  }
  .practice-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .practice-empty {
    display: grid;
    justify-items: start;
    gap: 10px;
    margin: 0 var(--pad);
    padding: clamp(24px, 4vw, 44px);
    border-radius: var(--r-lg);
    background: var(--graphite);
    color: var(--on-dark);
    --ring: var(--mint);
    --mark-dot: var(--mint);
  }
  .practice-empty:empty {
    display: none;
  }
  .practice-empty h2 {
    font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  }
  .practice-empty p {
    max-width: 56ch;
    color: var(--on-dark-muted);
  }

  @media (max-width: 760px) {
    .practice-head {
      padding-top: 18px;
    }
    .practice-head .page-title h1 {
      font-size: 1.3rem;
    }
    .practice-setup {
      width: 100%;
    }
    .practice-setup .field select {
      max-width: none;
    }
    .practice-setup .btn {
      flex: 1 1 100%;
    }
    .step-num {
      font-size: 3.25rem;
    }
    .study-stage {
      margin-inline: calc(var(--pad) * -0.5);
      border-radius: var(--r-md);
      padding: 8px;
    }
    .tile {
      min-height: 64px;
    }
  }
}

/* ----------------------------------------------------------------- auth */
@layer auth {
  .auth {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr);
    min-height: 100dvh;
  }
  .auth-poster {
    position: relative;
    display: grid;
    align-content: space-between;
    gap: 24px;
    padding: clamp(28px, 5vw, 64px);
    background:
      radial-gradient(70% 60% at 85% 15%, color-mix(in oklab, var(--mint) 16%, transparent), transparent 70%),
      repeating-linear-gradient(90deg, transparent 0 63px, rgb(255 255 255 / 0.04) 63px 64px),
      repeating-linear-gradient(0deg, transparent 0 63px, rgb(255 255 255 / 0.04) 63px 64px),
      var(--graphite);
    color: var(--on-dark);
    overflow: hidden;
    --mark-dot: var(--mint);
  }
  .auth-mark {
    width: 48px;
    height: 48px;
  }
  .auth-word {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(5rem, 3rem + 9vw, 12rem);
    line-height: 0.82;
    letter-spacing: -0.01em;
    text-transform: uppercase;
  }
  .auth-tag {
    max-width: 36ch;
    hyphens: none;
    font-size: var(--fs-lg);
    color: var(--on-dark-muted);
  }
  .auth-panel {
    display: grid;
    place-items: center;
    padding: 32px 24px;
  }
  .auth-card {
    width: min(400px, 100%);
    display: grid;
    gap: 20px;
  }
  .auth-card h1 {
    font-size: 2rem;
  }
  .auth-lede {
    margin-top: -14px;
    color: var(--muted);
  }
  .auth-card form {
    display: grid;
    gap: 14px;
  }
  .auth-card form h2 {
    font-size: 1.25rem;
  }
  .auth-foot {
    font-size: var(--fs-xs);
    color: var(--muted);
  }
  @media (max-width: 760px) {
    .auth {
      grid-template-columns: minmax(0, 1fr);
      grid-template-rows: auto 1fr;
    }
    .auth-poster {
      grid-template-columns: auto 1fr;
      align-items: center;
      gap: 14px;
      padding: 20px 20px 22px;
    }
    .auth-mark {
      width: 36px;
      height: 36px;
    }
    .auth-word {
      font-size: 3.25rem;
    }
    .auth-word br {
      display: none;
    }
    .auth-tag {
      grid-column: 1 / -1;
      font-size: var(--fs-sm);
    }
    .auth-panel {
      place-items: start center;
      padding: 24px 20px;
    }
    .auth-card {
      gap: 16px;
    }
    .auth-card h1 {
      font-size: 1.5rem;
    }
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      transition-duration: 0.01ms !important;
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      scroll-behavior: auto !important;
    }
  }
}
