/* ==========================================================================
   Focus Tube — Design System
   --------------------------------------------------------------------------
   YouTube Theme: crisp black (#0f0f0f), pure white (#ffffff), and iconic
   YouTube red (#cc0000 / #d90000 / #ff0000). Dark theme is primary; the light
   theme is a clean white-and-black YouTube counterpart.

   Theme:    <html data-theme="dark|light">   (applied pre-paint in index.html)
   Layout:   mobile  <640px  bottom tab bar
             tablet   640–1023px  centred column
             desktop  >=1024px fixed sidebar + wide content grid

   Contents
     01. Tokens (colour, type, space, motion)
     02. Reset & base
     03. Typography
     04. Layout shell (topbar / sidebar / bottom nav)
     05. Primitives (buttons, cards, pills, badges, progress, forms)
     06. Screens: Login, Today, Plan, Watch, Stats, Settings, Search
     07. Overlays: modal, toast, skeleton
     08. Responsive breakpoints
     09. Motion preferences
   ========================================================================== */

/* ==========================================================================
   01. Tokens
   ========================================================================== */

:root {
  /* -- Type --------------------------------------------------------------- */
  --font-sans: "Inter var", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono",
    Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;

  /* -- Space (4px grid, fluid where it helps) ------------------------------ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --gutter: clamp(16px, 4vw, 40px);

  /* -- Radii -------------------------------------------------------------- */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* -- Motion ------------------------------------------------------------- */
  --dur-instant: 90ms;
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 340ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* -- Layout ------------------------------------------------------------- */
  --sidebar-w: 248px;
  --content-w: 760px;
  --wide-w: 1180px;
  --topbar-h: 60px;
  --tabbar-h: 64px;
}

/* -- Dark theme (primary) -------------------------------------------------- */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f0f0f;
  --bg-veil: #0f0f0f;
  --surface: #181818;
  --surface-raised: #212121;
  --surface-sunken: #121212;
  --surface-hover: #272727;
  --surface-active: #333333;
  --surface-glass: rgba(15, 15, 15, 0.84);

  --border: #272727;
  --border-strong: #3d3d3d;
  --border-focus: #ff3b3b;

  --text: #f1f1f1;
  --text-2: #aaaaaa;
  --text-3: #8a8a8a;
  --text-inverse: #0f0f0f;

  --accent: #d90000;
  --accent-hover: #ff1a1a;
  --accent-quiet: rgba(255, 0, 0, 0.14);
  --accent-line: rgba(255, 59, 59, 0.36);
  --accent-ink: #ffffff;
  --accent-2: #ff0000;

  --study: #ff4e45;
  --study-quiet: rgba(255, 78, 69, 0.14);
  --skill: #e5e5e5;
  --skill-quiet: rgba(255, 255, 255, 0.10);
  --fun: #ff9980;
  --fun-quiet: rgba(255, 153, 128, 0.14);

  --success: #4ade80;
  --success-quiet: rgba(74, 222, 128, 0.13);
  --warning: #ff4e45;
  --warning-quiet: rgba(255, 78, 69, 0.14);
  --danger: #ff4e45;
  --danger-quiet: rgba(255, 78, 69, 0.14);

  /* On dark surfaces the base colours already clear AA on their tinted plates */
  --study-ink: #ff4e45;
  --skill-ink: #e5e5e5;
  --fun-ink: #ff9980;
  --success-ink: #4ade80;
  --warning-ink: #ff4e45;
  --danger-ink: #ff4e45;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 26px -12px rgba(0, 0, 0, 0.72);
  --shadow-lg: 0 28px 60px -20px rgba(0, 0, 0, 0.88);
  --scrim: rgba(0, 0, 0, 0.75);
}

/* -- Light theme (YouTube clean white, black & red) ------------------------ */

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f9f9f9;
  --bg-veil: #f2f2f2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #f2f2f2;
  --surface-hover: #e5e5e5;
  --surface-active: #d9d9d9;
  --surface-glass: rgba(255, 255, 255, 0.88);

  --border: #e5e5e5;
  --border-strong: #cccccc;
  --border-focus: #cc0000;

  --text: #0f0f0f;
  --text-2: #606060;
  --text-3: #6b6b6b;
  --text-inverse: #ffffff;

  --accent: #cc0000;
  --accent-hover: #b30000;
  --accent-quiet: rgba(204, 0, 0, 0.09);
  --accent-line: rgba(204, 0, 0, 0.28);
  --accent-ink: #ffffff;
  --accent-2: #ff0000;

  --study: #cc0000;
  --study-quiet: rgba(204, 0, 0, 0.09);
  --skill: #0f0f0f;
  --skill-quiet: rgba(15, 15, 15, 0.08);
  --fun: #606060;
  --fun-quiet: rgba(96, 96, 96, 0.10);

  --success: #0d7a3e;
  --success-quiet: rgba(13, 122, 62, 0.10);
  --warning: #cc0000;
  --warning-quiet: rgba(204, 0, 0, 0.08);
  --danger: #cc0000;
  --danger-quiet: rgba(204, 0, 0, 0.09);

  /* Badge text sits on a tinted plate, which lifts the effective background and
     costs contrast. These inks are darker than --study/--skill/--fun so the
     tinted badges still clear 4.5:1 on any surface. */
  --study-ink: #a30000;
  --skill-ink: #0f0f0f;
  --fun-ink: #404040;
  --success-ink: #095c2e;
  --warning-ink: #a30000;
  --danger-ink: #a30000;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 30px 60px -24px rgba(0, 0, 0, 0.24);
  --scrim: rgba(0, 0, 0, 0.38);
}

/* ==========================================================================
   02. Reset & base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: normal;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(
      70rem 32rem at 12% -12%,
      color-mix(in srgb, var(--accent) 9%, transparent),
      transparent 60%
    ),
    radial-gradient(
      52rem 30rem at 100% 0%,
      color-mix(in srgb, var(--accent-2) 6%, transparent),
      transparent 55%
    );
}

img,
svg,
video,
iframe {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

.hidden {
  display: none !important;
}

/*
 * The nav is a sibling of .chrome rather than a child: a backdrop-filtered
 * ancestor becomes the containing block for fixed children, which broke
 * `position: fixed; bottom: 0` on phones. The trade-off is that the chrome
 * toggle no longer reaches it, so app.js hides the nav directly (and it starts
 * hidden in the markup to avoid a flash before the first route resolves).
 */

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--text-2);
}

.dim {
  color: var(--text-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   03. Typography
   ========================================================================== */

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* Shared icon sizing (JS sets class on a 24x24 viewBox svg) */
.icon-xs {
  width: 14px;
  height: 14px;
  flex: none;
}
.icon-sm {
  width: 17px;
  height: 17px;
  flex: none;
}
.icon-md {
  width: 22px;
  height: 22px;
  flex: none;
}
.icon-lg {
  width: 28px;
  height: 28px;
  flex: none;
}

/* ==========================================================================
   04. Layout shell
   ========================================================================== */

.shell {
  min-height: 100dvh;
  display: flow-root;
}

/*
 * Chrome lives in a single wrapper. On phones/tablets it is a sticky topbar;
 * from 1024px the wrapper becomes the fixed sidebar column and the topbar
 * inside it is no longer a bar.
 */
.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar {
  min-width: 0;
  flex: 1 1 auto;
}

.topbar-inner {
  height: var(--topbar-h);
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: var(--text-md);
  min-height: 44px;
  padding-right: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  flex: none;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 24%, transparent);
}

.brand-mark svg,
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

/* Show only the icon and label representing the theme the button will switch to */
:root[data-theme="dark"] .icon-moon,
:root[data-theme="light"] .icon-sun,
:root[data-theme="dark"] .theme-label-dark,
:root[data-theme="light"] .theme-label-light {
  display: none;
}

.theme-label {
  display: none;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions [data-theme-toggle] {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}

.topbar-actions [data-theme-toggle] svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.topbar-actions [data-theme-toggle]:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.signout {
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  gap: 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 500;
}

.signout:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
  background: var(--danger-quiet);
}

.topbar-user {
  display: none;
  font-size: var(--text-sm);
  color: var(--text-2);
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Bottom tab bar (mobile) ---- */

.bottom-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 45;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border-radius: var(--radius-md);
  color: var(--text-3);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.nav-item:hover {
  color: var(--text);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-quiet);
}

.nav-icon {
  width: 21px;
  height: 21px;
}

/* ---- Main content column ---- */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--space-5) var(--gutter)
    calc(var(--tabbar-h) + var(--space-7) + env(safe-area-inset-bottom, 0px));
}

.app-main:has(.watch-layout),
.app-main:has(.stats-wide),
.app-main:has(.notes-wide) {
  max-width: var(--wide-w);
}

/* Focus mode: login and watch hide chrome entirely */
.shell.is-focus-mode .app-main {
  padding-bottom: var(--space-7);
}

.screen-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.screen-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.screen-title {
  font-size: var(--text-2xl);
  letter-spacing: -0.03em;
}

.screen-sub {
  margin-top: 2px;
  color: var(--text-2);
  font-size: var(--text-base);
}

.section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.row-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
}

/* ==========================================================================
   05. Primitives
   ========================================================================== */

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 550;
  letter-spacing: -0.006em;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-instant) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-quiet);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
  width: 34px;
  min-height: 34px;
}

.btn-block {
  width: 100%;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 640ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
}

/* ---- Cards & surfaces ---- */

.card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card-pad-lg {
  padding: var(--space-5);
}

/* ---- Banners ---- */

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-base);
  line-height: 1.5;
}

.banner svg {
  flex: none;
  margin-top: 2px;
}

.banner-warn {
  border-color: color-mix(in srgb, var(--warning) 32%, transparent);
  background: var(--warning-quiet);
}

.banner-warn svg {
  color: var(--warning);
}

.banner-danger {
  border-color: color-mix(in srgb, var(--danger) 32%, transparent);
  background: var(--danger-quiet);
}

.banner-danger svg {
  color: var(--danger);
}

.banner-info {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.banner-info svg {
  color: var(--accent);
}

/* ---- Pills & badges ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.pill-neutral {
  background: var(--surface-sunken);
  color: var(--text-2);
}

.pill-accent {
  background: var(--accent-quiet);
  border-color: var(--accent-line);
  color: var(--accent);
}

.pill-warn {
  background: var(--warning-quiet);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  color: var(--warning);
}

.pill-full {
  background: var(--danger-quiet);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.pill-ok {
  background: var(--success-quiet);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: var(--text-xs);
  font-weight: 550;
  letter-spacing: 0.005em;
  text-transform: capitalize;
  white-space: nowrap;
}

.badge-study {
  background: var(--study-quiet);
  color: var(--study-ink);
}
.badge-skill {
  background: var(--skill-quiet);
  color: var(--skill-ink);
}
.badge-fun {
  background: var(--fun-quiet);
  color: var(--fun-ink);
}
.badge-planned {
  background: var(--surface-sunken);
  border-color: var(--border);
  color: var(--text-2);
}
.badge-progress {
  background: var(--accent-quiet);
  color: var(--accent);
}
.badge-done {
  background: var(--success-quiet);
  color: var(--success-ink);
}
.badge-emergency {
  background: var(--warning-quiet);
  color: var(--warning-ink);
}

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

.progress-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}

.progress-fill.done {
  background: var(--success);
}

.progress-fill.warn {
  background: var(--warning);
}

.progress-fill.danger {
  background: var(--danger);
}

/* ---- Forms ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.label svg {
  color: var(--accent);
  flex: none;
}

.input,
.textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: var(--text-base);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.55;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}

.hint {
  font-size: var(--text-sm);
  color: var(--text-3);
  line-height: 1.5;
}

.char-counter {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.char-counter.is-valid {
  color: var(--success);
}

/* ---- Segmented control ---- */

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.seg-btn {
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-weight: 550;
  text-transform: capitalize;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.seg-btn.active[data-cat="study"] {
  color: var(--study);
}
.seg-btn.active[data-cat="skill"] {
  color: var(--skill);
}
.seg-btn.active[data-cat="fun"] {
  color: var(--fun);
}

.segmented-compact .seg-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--text-xs);
}

/* ---- Switch ---- */

.switch-btn {
  position: relative;
  width: 48px;
  min-height: 32px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-sunken);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
  flex: none;
}

.switch-btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-thumb {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}

.switch-btn.is-on .switch-thumb {
  transform: translateX(18px);
}

/* ---- Empty states ---- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.empty-illustration-wrap {
  display: grid;
  place-items: center;
  width: 128px;
  height: 84px;
  margin-bottom: var(--space-1);
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.empty-illustration {
  width: 88px;
  height: 58px;
  flex: none;
  color: var(--text-2);
}

.empty-state h2,
.empty-state h3 {
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
}

.empty-state p {
  max-width: 38ch;
  color: var(--text-2);
  font-size: var(--text-base);
}

.empty-state .btn {
  margin-top: var(--space-2);
}

.empty-meta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-4);
  width: 100%;
  max-width: 420px;
  border-top: 1px solid var(--border);
}

.empty-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-2);
}

.empty-meta-chip strong {
  color: var(--text);
  font-weight: 600;
}

/* ==========================================================================
   06. Screens
   ========================================================================== */

/* ---- Login ---- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.login-card {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--accent) 35%, transparent);
}

.login-mark-icon {
  width: 100%;
  height: 100%;
  display: block;
}

.login-title {
  font-size: var(--text-3xl);
  letter-spacing: -0.04em;
}

.login-promise {
  color: var(--text-2);
  font-size: var(--text-md);
  margin-top: -8px;
}

.login-btn {
  margin-top: var(--space-2);
}

.login-points {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.login-point {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--text-2);
  text-align: left;
}

.login-point svg {
  color: var(--accent);
  flex: none;
}

.login-footer {
  font-size: var(--text-xs);
  color: var(--text-3);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.theme-fab {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 50;
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
}

.theme-fab svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.theme-fab:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

/* ---- Today: hero ---- */

.today-hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.hero-top {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.hero-figure {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-track {
  stroke: var(--surface-sunken);
}

.progress-ring-fill {
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out);
}

.hero-figure-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.05;
}

.hero-figure-value strong {
  font-size: var(--text-xl);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.hero-figure-value span {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.hero-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.hero-headline {
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.hero-meta {
  color: var(--text-2);
  font-size: var(--text-base);
}

.hero-cta {
  margin-top: var(--space-1);
  align-self: flex-start;
}

/* Budget bar: one segment per queued video */
.budget-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
  height: 6px;
}

.budget-segment {
  height: 100%;
  min-width: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.budget-segment-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}

.budget-segment.is-done .budget-segment-fill {
  background: var(--success);
}

.budget-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-2);
}

.budget-legend b {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 550;
}

/* ---- Today: video cards ---- */

.video-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.video-card {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.video-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.video-card.is-done {
  background: var(--surface-sunken);
}

.video-card.is-done .video-thumb {
  opacity: 0.55;
}

.video-card.is-done .video-title {
  color: var(--text-2);
}

.video-thumb-wrap {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  aspect-ratio: 16 / 9;
}

.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease-out);
}

.video-card:hover .video-thumb {
  transform: scale(1.03);
}

.video-thumb-progress {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.42);
}

.video-thumb-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.video-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.video-title {
  font-size: var(--text-base);
  font-weight: 550;
  line-height: 1.35;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.video-channel {
  font-size: var(--text-sm);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  flex-wrap: wrap;
}

/* Lazy-loaded notes panel spans the whole card */
.video-panel {
  grid-column: 1 / -1;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.video-actions .btn-icon {
  flex: none;
}

.video-actions .btn:first-child {
  flex: 1;
}

.calm-toggle-btn {
  margin-top: var(--space-2);
}

/* ---- Today: revisions (recall cards) ---- */

.recall-list {
  display: grid;
  gap: var(--space-3);
}

.recall-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.recall-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.recall-title {
  font-size: var(--text-base);
  font-weight: 550;
  line-height: 1.35;
}

.recall-quote {
  padding: var(--space-3) var(--space-4);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-quiet);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.6;
}

.recall-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Revision stage indicator: 1d / 7d / 30d */
.stage-track {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.stage-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--text-3);
  font-family: var(--font-mono);
}

.stage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-sunken);
}

.stage-item.is-reached .stage-dot {
  border-color: var(--accent);
  background: var(--accent-quiet);
}

.stage-item.is-current .stage-dot {
  background: var(--accent);
}

.stage-item.is-current {
  color: var(--accent);
}

/* ---- Calm "all done" state ---- */

.calm-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, var(--surface), var(--surface-sunken));
  text-align: center;
}

.calm-check-svg {
  width: 64px;
  height: 64px;
}

.calm-check-circle {
  stroke: var(--accent);
  fill: none;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
  animation: draw-ring 900ms var(--ease-out) forwards;
}

.calm-check-tick {
  stroke: var(--accent);
  fill: none;
  stroke-dasharray: 32;
  stroke-dashoffset: 32;
  animation: draw-ring 500ms var(--ease-out) 620ms forwards;
}

@keyframes draw-ring {
  to {
    stroke-dashoffset: 0;
  }
}

.calm-done-title {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}

.calm-done-sub {
  color: var(--text-2);
  max-width: 42ch;
}

/* ---- Locked / limit states ---- */

.locked-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

.locked-state h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}

.locked-state p {
  max-width: 46ch;
  color: var(--text-2);
}

.locked-icon-wrap {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.locked-icon-wrap.is-warn {
  background: var(--warning-quiet);
  border-color: transparent;
  color: var(--warning);
}

/* ---- Plan ---- */

.plan-capacity {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.plan-capacity-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.plan-capacity-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.plan-capacity-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-2);
}

.plan-capacity-meta strong {
  color: var(--text);
  font-weight: 600;
}

.plan-slot-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 6px;
}

.plan-slot-pip {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  transition:
    background-color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.plan-slot-pip.is-filled {
  background: var(--accent);
  border-color: var(--accent);
}

.plan-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.plan-panel .segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  gap: 4px;
  padding: 4px;
}

.plan-panel .seg-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.plan-field-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.plan-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 500;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.plan-tool-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.plan-submit-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-shortcut-hint {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-3);
}

.plan-pills {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.plan-paste-box {
  min-height: 104px;
}

.preview-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.preview-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.preview-card.is-invalid {
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: var(--danger-quiet);
}

.preview-thumb,
.preview-thumb-placeholder {
  width: 76px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-hover);
}

.preview-thumb-placeholder {
  display: grid;
  place-items: center;
  color: var(--danger);
}

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.preview-url {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-ok {
  font-size: var(--text-xs);
  color: var(--success);
}

.preview-err {
  font-size: var(--text-xs);
  color: var(--danger);
}

.paste-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paste-result-ok,
.paste-result-err {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.paste-result-ok {
  color: var(--success);
}

.paste-result-err {
  color: var(--danger);
}

.paste-result-ok svg,
.paste-result-err svg {
  margin-top: 3px;
  flex: none;
}

/* Queue rows */

.queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.queue-item {
  display: grid;
  grid-template-columns: auto 96px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

.queue-item.is-dragging {
  opacity: 0.45;
}

.queue-item.is-drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-quiet);
}

.queue-thumb {
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-sunken);
}

.queue-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.queue-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.drag-handle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 40px;
  color: var(--text-3);
  cursor: grab;
  border-radius: var(--radius-sm);
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  color: var(--text-2);
  background: var(--surface-hover);
}

.reorder-group {
  display: flex;
  align-items: center;
}

/* ---- Watch ---- */

.watch-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.watch-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.watch-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.watch-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.player-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

.player-shell iframe,
.player-mount,
.player-mount > div {
  width: 100%;
  height: 100%;
  border: 0;
}

.player-shell:fullscreen,
.player-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: 0;
}

/* Fullscreen-only floating quick-note controls (invisible in small frame) */
.fs-note-fab,
.fs-note-popover,
.fs-note-toast {
  display: none;
}

.player-shell:fullscreen .fs-note-fab,
.player-shell:-webkit-full-screen .fs-note-fab {
  position: absolute;
  right: 22px;
  bottom: 64px;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.player-shell:fullscreen .fs-note-fab.is-dragging,
.player-shell:-webkit-full-screen .fs-note-fab.is-dragging {
  cursor: grabbing;
  transform: scale(1.08);
  transition: none;
}

.player-shell:fullscreen .fs-note-fab:hover,
.player-shell:-webkit-full-screen .fs-note-fab:hover {
  background: var(--accent-hover);
  transform: scale(1.06);
}

.player-shell:fullscreen .fs-note-popover.is-open,
.player-shell:-webkit-full-screen .fs-note-popover.is-open {
  position: absolute;
  right: 22px;
  bottom: 124px;
  z-index: 31;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 44px));
  padding: 14px;
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: fade-in var(--dur-fast) var(--ease-out) both;
}

.fs-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fs-note-input {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text);
  min-height: 76px;
}

.fs-note-input::placeholder {
  color: var(--text-3);
}

.fs-note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fs-note-hint {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.fs-note-toast:not(.hidden) {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: var(--text-xs);
  font-weight: 600;
  pointer-events: none;
  animation: fade-in var(--dur-fast) var(--ease-out) both;
}

.player-shell:fullscreen .fs-note-toast:not(.hidden),
.player-shell:-webkit-full-screen .fs-note-toast:not(.hidden) {
  top: auto;
  left: auto;
  transform: none;
  right: 82px;
  bottom: 72px;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-5);
  text-align: center;
  background: color-mix(in srgb, #0f0f0f 92%, transparent);
  color: #f1f1f1;
  animation: fade-in var(--dur-base) var(--ease-out) both;
}

.player-overlay h3 {
  font-size: var(--text-lg);
}

.player-overlay p {
  max-width: 42ch;
  color: #aaaaaa;
  font-size: var(--text-base);
}

.watch-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: -6px;
}

.watch-player-markers {
  flex: 1;
  min-width: 0;
}

.watch-player-bar .marker-strip {
  margin-top: 0;
}

/* Timestamp marker strip under the player. The dots stay small visually but
   keep a 32px hit area through the ::after expander. */
.marker-strip {
  position: relative;
  height: 22px;
  margin-top: -8px;
}

.marker-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: transform var(--dur-fast) var(--ease-out);
}

.marker-dot::after {
  content: "";
  position: absolute;
  inset: -11px -9px;
}

.marker-dot.is-resume {
  background: var(--success);
}

.marker-dot:hover,
.marker-dot:focus-visible {
  transform: translate(-50%, -50%) scale(1.4);
}

.marker-dot[data-preview]:hover::before,
.marker-dot[data-preview]:focus-visible::before {
  content: attr(data-preview);
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 260px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  z-index: 10;
}

.watch-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.watch-title {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.watch-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.done-btn-with-ring {
  gap: 10px;
}

.done-btn-ring {
  transform: rotate(-90deg);
  flex: none;
}

.done-btn-ring-track {
  stroke: color-mix(in srgb, var(--accent-ink) 28%, transparent);
}

.done-btn-ring-fill {
  stroke: var(--accent-ink);
  transition: stroke-dashoffset var(--dur-slow) var(--ease-out);
}

.watch-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.note-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.note-time {
  min-height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  background: var(--accent-quiet);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.note-time:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.note-body {
  font-size: var(--text-base);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* Watch limit full screen */
.limit-fullscreen {
  display: grid;
  place-items: center;
  min-height: 60dvh;
}

.limit-fullscreen-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  max-width: 440px;
  padding: var(--space-6) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  text-align: center;
}

.limit-fullscreen-card h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}

.limit-fullscreen-card p {
  color: var(--text-2);
}

/* ---- Stats ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.stat-sub {
  font-size: var(--text-sm);
  color: var(--text-2);
}

.chart-wrap {
  width: 100%;
}

.svg-bar-chart {
  width: 100%;
  height: auto;
}

.svg-chart-grid {
  stroke: var(--border);
  stroke-dasharray: 3 5;
}

.svg-chart-axis {
  stroke: var(--border-strong);
}

.svg-chart-bar {
  fill: var(--accent);
}

.svg-chart-bar-empty {
  fill: var(--surface-sunken);
}

.svg-chart-value {
  fill: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
}

.svg-chart-label {
  fill: var(--text-3);
  font-size: 11px;
}

.cat-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cat-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 56px;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.cat-name {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  text-transform: capitalize;
}

.cat-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.cat-swatch.study {
  background: var(--study);
}
.cat-swatch.skill {
  background: var(--skill);
}
.cat-swatch.fun {
  background: var(--fun);
}

.cat-track {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.cat-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease-out);
}

.cat-fill.study {
  background: var(--study);
}
.cat-fill.skill {
  background: var(--skill);
}
.cat-fill.fun {
  background: var(--fun);
}

.cat-value {
  text-align: right;
  color: var(--text-2);
}

.streak-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: var(--space-2);
}

.streak-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.streak-dot.lvl-1 {
  background: var(--accent-quiet);
  border-color: transparent;
}

.streak-dot.lvl-2 {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  border-color: transparent;
}

.streak-dot.lvl-3 {
  background: var(--accent);
  border-color: transparent;
}

.recap-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.recap-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.recap-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recap-row b {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 550;
}

/* ---- Settings ---- */

.settings-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}

.settings-row:first-child {
  padding-top: 0;
}

.settings-row:last-child {
  padding-bottom: 0;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-row-text .label {
  color: var(--text);
  font-size: var(--text-base);
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  flex: none;
}

.stepper-btn {
  width: 32px;
  min-height: 32px;
}

.stepper-value-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0 4px;
}

.stepper-input {
  width: 44px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-size: var(--text-base);
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-input:focus {
  outline: none;
}

.stepper-unit {
  font-size: var(--text-xs);
  color: var(--text-3);
}

.save-status {
  text-align: center;
  min-height: 1.2em;
}

/* ---- Search ---- */

.search-form {
  display: flex;
  gap: var(--space-2);
}

.search-input {
  flex: 1;
}

.search-results {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 768px) {
  .search-results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.notes-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.notes-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.notes-filter-pill {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: var(--text-xs);
  font-weight: 550;
  transition:
    color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.notes-filter-pill:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.notes-filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.note-library-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.note-library-card:hover {
  border-color: var(--border-strong);
}

.note-library-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.note-library-thumb-wrap {
  flex: none;
  width: 72px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.note-library-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.note-library-title-wrap {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.note-library-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-library-title:hover {
  color: var(--accent);
}

.note-library-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-3);
}

.note-library-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-group-count {
  color: var(--text-2);
  font-weight: 550;
}

.note-library-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
}

.note-library-body.is-takeaway,
.note-item-takeaway {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-sunken));
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border));
}

.note-item-takeaway {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
}

.note-time-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--accent-quiet);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

a.note-time-chip:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.note-time-chip.is-takeaway {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.note-library-text {
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-show-more {
  display: flex;
  justify-content: center;
  padding-top: var(--space-2);
}

.notes-toggle-btn {
  border-radius: var(--radius-pill);
  padding: 0 20px;
  gap: 8px;
}

.result-card {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.result-title {
  font-size: var(--text-base);
  font-weight: 550;
  line-height: 1.35;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--text-3);
}

.result-snippet {
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text-2);
}

.result-snippet mark {
  background: var(--accent-quiet);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}

/* ==========================================================================
   07. Overlays
   ========================================================================== */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--space-3);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  background: var(--scrim);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: fade-in var(--dur-fast) var(--ease-out) both;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: sheet-up var(--dur-base) var(--ease-out) both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.modal-title {
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

.confirm-dialog {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.confirm-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-md);
  background: var(--danger-quiet);
  color: var(--danger);
}

.confirm-icon.is-primary {
  background: var(--accent-quiet);
  color: var(--accent);
}

.confirm-message {
  color: var(--text-2);
  font-size: var(--text-base);
  line-height: 1.5;
  padding-top: 2px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sheet-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: sheet-up var(--dur-base) var(--ease-out) both;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.toast-success {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
}

.toast-error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
}

/* Loading skeleton */

.skeleton-screen {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.skeleton {
  border-radius: var(--radius-lg);
  background: var(--surface-sunken);
  animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-title {
  width: 180px;
  height: 30px;
  border-radius: var(--radius-sm);
}

.skeleton-card {
  height: 132px;
}

.skeleton-row {
  height: 96px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* ==========================================================================
   08. Responsive
   ========================================================================== */

/* -- Tablet and up -- */
@media (min-width: 640px) {
  .topbar-user {
    display: block;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .video-card {
    grid-template-columns: 168px minmax(0, 1fr);
    align-items: start;
    gap: var(--space-4);
    padding: var(--space-4);
  }

  .video-actions {
    grid-column: 2;
  }

  .video-actions .btn:first-child {
    flex: 0 0 auto;
  }

  .modal-root {
    align-items: center;
  }

  .today-hero {
    padding: var(--space-6);
  }
}

/* -- Desktop: fixed sidebar -- */
@media (min-width: 1024px) {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    align-items: start;
  }

  /* Login and Watch run full width with no chrome column */
  .shell.is-focus-mode {
    display: block;
  }

  .chrome {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 40;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-3) var(--space-4);
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }

  .topbar-inner {
    height: auto;
    max-width: none;
    margin: 0;
    padding: 0 var(--space-2) var(--space-4);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border);
  }

  .brand {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    min-height: 36px;
    padding-right: 0;
  }

  .topbar-meta {
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }

  .topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: none;
    padding: 2px 4px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: -0.01em;
  }

  .topbar-user::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-quiet);
    flex: none;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .topbar-actions [data-theme-toggle] {
    width: 100%;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    gap: 6px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: var(--text-xs);
    font-weight: 500;
    transition:
      color var(--dur-fast) var(--ease-out),
      background-color var(--dur-fast) var(--ease-out),
      border-color var(--dur-fast) var(--ease-out);
  }

  .topbar-actions [data-theme-toggle] svg {
    width: 15px;
    height: 15px;
    flex: none;
  }

  .topbar-actions .theme-label {
    display: inline;
  }

  :root[data-theme="dark"] .topbar-actions .theme-label-dark,
  :root[data-theme="light"] .topbar-actions .theme-label-light {
    display: none;
  }

  .topbar-actions [data-theme-toggle]:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-hover);
  }

  .signout {
    width: 100%;
    height: 34px;
    min-height: 34px;
    padding: 0 10px;
    gap: 6px;
    justify-content: center;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: var(--text-xs);
    font-weight: 500;
    transition:
      color var(--dur-fast) var(--ease-out),
      background-color var(--dur-fast) var(--ease-out),
      border-color var(--dur-fast) var(--ease-out);
  }

  .signout:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 32%, transparent);
    background: var(--danger-quiet);
  }

  /*
   * The nav lives outside .chrome (a backdrop-filtered ancestor would become
   * its containing block and break `position: fixed` on phones). On desktop it
   * is fixed inside the sidebar column so it never scrolls with the page.
   */
  .bottom-nav {
    position: fixed;
    top: calc(var(--space-5) + 36px + var(--space-4) + var(--space-5));
    left: 0;
    bottom: auto;
    right: auto;
    z-index: 41;
    margin-top: 0;
    height: auto;
    width: var(--sidebar-w);
    padding: 0 var(--space-3);
    flex-direction: column;
    gap: 4px;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: 0;
  }

  .nav-item {
    position: relative;
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 13px;
    min-height: 42px;
    padding: 0 var(--space-3);
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--text-2);
    border-radius: var(--radius-md);
  }

  .nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .nav-item.active,
  .nav-item.active:hover {
    background: var(--accent-quiet);
    color: var(--text);
    font-weight: 600;
  }

  .nav-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
  }

  .nav-item.active .nav-icon {
    color: var(--accent);
  }

  .nav-icon {
    width: 19px;
    height: 19px;
    transition: color var(--dur-fast) var(--ease-out);
  }

  .app-main {
    grid-column: 2;
    padding: var(--space-7) var(--gutter) var(--space-8);
    max-width: none;
  }

  .app-main > * {
    max-width: var(--content-w);
    margin-inline: auto;
  }

  .app-main:has(.watch-layout) > *,
  .app-main:has(.stats-wide) > *,
  .app-main:has(.notes-wide) > * {
    max-width: var(--wide-w);
  }

  .toast-container {
    left: calc(50% + (var(--sidebar-w) / 2));
    bottom: var(--space-5);
  }

  .shell.is-focus-mode .toast-container {
    left: 50%;
  }

  .video-card {
    grid-template-columns: 184px minmax(0, 1fr) auto;
    align-items: center;
  }

  .video-actions {
    grid-column: auto;
  }
}

/* -- Watch screen: two columns -- */
@media (min-width: 1100px) {
  .watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(330px, 1fr);
    gap: var(--space-6);
    align-items: start;
  }

  .watch-layout > .watch-top {
    grid-column: 1 / -1;
  }
}

/* -- Small phones: tighten the video card -- */
@media (max-width: 420px) {
  :root {
    --text-2xl: 1.5rem;
    --text-3xl: 1.9rem;
  }

  /* Stack the hero so the ring and the action never fight for width */
  .today-hero {
    padding: var(--space-4);
  }

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .hero-cta {
    width: 100%;
  }

  .video-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .queue-item {
    grid-template-columns: auto minmax(0, 1fr) auto;
    row-gap: var(--space-2);
  }

  .queue-thumb {
    display: none;
  }

  .queue-controls {
    grid-column: 2 / -1;
  }

  .recap-rows {
    grid-template-columns: 1fr;
  }

  .cat-row {
    grid-template-columns: 64px minmax(0, 1fr) 48px;
  }
}

/* ==========================================================================
   09. Motion & print
   ========================================================================== */

.is-tab-hidden *,
.is-tab-hidden *::before,
.is-tab-hidden *::after {
  animation-play-state: paused !important;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: var(--ease-out);
}

::view-transition-group(hero-video) {
  animation-duration: 260ms;
  animation-timing-function: var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .calm-check-circle,
  .calm-check-tick {
    stroke-dashoffset: 0 !important;
  }
}
