:root {
  color-scheme: dark;
  --ground: oklch(0.16 0.008 262);
  --sheet: oklch(0.205 0.01 262);
  --sheet-hover: oklch(0.24 0.012 262);
  --ink: oklch(0.94 0.006 262);
  --ink-muted: oklch(0.68 0.012 262);
  --ink-faint: oklch(0.5 0.012 262);
  --line: oklch(0.3 0.012 262);
  --accent: oklch(0.74 0.12 235);
  --accent-strong: oklch(0.82 0.1 235);
  --accent-ink: oklch(0.18 0.03 240);
  --danger: oklch(0.7 0.16 25);
  --danger-strong: oklch(0.78 0.14 25);
  --warn: oklch(0.8 0.13 80);
  --ok: oklch(0.75 0.13 150);
  --ease-ui: cubic-bezier(0.23, 1, 0.32, 1);
  --dur-feedback: 110ms;
  --dur-state: 160ms;
  --dur-reveal: 300ms;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 20px; --s5: 32px; --s6: 56px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--ground);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }

button, .button {
  font: inherit; font-weight: 550; font-size: 0.9375rem;
  height: 36px; padding: 0 14px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-state) var(--ease-ui), border-color var(--dur-state) var(--ease-ui), transform var(--dur-feedback) var(--ease-ui);
  -webkit-tap-highlight-color: transparent;
}
button:active, .button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: default; }
button:disabled:active { transform: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.quiet { background: transparent; border-color: transparent; color: var(--ink-muted); padding: 0 8px; }
button.danger { color: var(--danger); }
@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled), .button:hover { background: var(--sheet-hover); }
  button.primary:hover:not(:disabled), .button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
  button.quiet:hover:not(:disabled) { background: var(--sheet); color: var(--ink); }
}
button:focus { outline: none; }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid color-mix(in oklch, var(--accent) 45%, transparent); outline-offset: 0; }

input[type=text], input[type=password] {
  font: inherit; height: 38px; padding: 0 12px; border-radius: 7px; width: 100%;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--line);
  transition: border-color var(--dur-state) var(--ease-ui);
}
input:focus { outline: none; border-color: var(--ink-faint); }
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }

/* Layout */
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s4) var(--s3); max-width: 1180px; margin: 0 auto; }
.brand { font-weight: 650; letter-spacing: -0.01em; font-size: 1.0625rem; text-decoration: none; display: flex; align-items: center; gap: var(--s2); }
.brand svg { width: 22px; height: 22px; }
main { max-width: 1180px; margin: 0 auto; padding: 0 var(--s4) var(--s6); }

/* Library */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s5) var(--s4); margin-top: var(--s3); }
.item { display: block; text-decoration: none; color: inherit; -webkit-tap-highlight-color: transparent; }
.thumb { aspect-ratio: 16 / 9; border-radius: 10px; background: var(--sheet); overflow: hidden; position: relative; transition: transform var(--dur-state) var(--ease-ui); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badge { position: absolute; left: 8px; bottom: 8px; font-size: 0.75rem; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: oklch(0.12 0.01 262 / 0.75); color: var(--ink); }
a.item:active .thumb { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { a.item:hover .thumb { transform: scale(1.015); } }
.item h3 { margin: var(--s2) 0 0; font-size: 0.9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--ink-muted); font-size: 0.8125rem; margin-top: 2px; }
.status { display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.dot.work { background: var(--accent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.track { height: 1px; background: var(--line); margin-top: var(--s2); position: relative; overflow: hidden; }
.track > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width var(--dur-reveal) var(--ease-ui); }
.actions { display: flex; gap: var(--s2); margin-top: var(--s2); flex-wrap: wrap; }
.actions button { height: 32px; font-size: 0.875rem; }
.empty { color: var(--ink-muted); padding: var(--s6) 0; max-width: 460px; }
.empty h2 { color: var(--ink); font-size: 1.125rem; margin: 0 0 var(--s2); }

/* Notice (one-off messages under the header) */
.notice { max-width: 1180px; margin: 0 auto var(--s3); padding: var(--s3) var(--s4); }
.notice > div { background: var(--sheet); border-radius: 10px; padding: var(--s3) var(--s4); }
.notice h2 { font-size: 1rem; margin: 0 0 var(--s1); }
.notice p { margin: 0; color: var(--ink-muted); }
.notice ol { margin: var(--s2) 0 0; padding-left: 1.2em; color: var(--ink-muted); }
.notice .actions { margin-top: var(--s3); }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); }
.login form { width: min(340px, 100%); display: grid; gap: var(--s3); }
.login h1 { font-size: 1.25rem; margin: 0 0 var(--s2); display: flex; align-items: center; gap: var(--s2); }
.login h1 svg { width: 26px; height: 26px; flex: none; color: var(--accent); }
.login .err { color: var(--danger); font-size: 0.875rem; min-height: 1.3em; margin: 0; }

/* Watch */
.watch { max-width: 1180px; }
.stage { aspect-ratio: 16 / 9; background: oklch(0.1 0.006 262); border-radius: 12px; overflow: hidden; }
.stage video { width: 100%; height: 100%; display: block; }
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s4); margin-top: var(--s4); flex-wrap: wrap; }
.title-row h1 { font-size: 1.375rem; margin: 0; letter-spacing: -0.01em; }
.title-row .sub { color: var(--ink-muted); margin-top: 2px; }
.xr { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; height: 36px; }
.seg button { border: 0; border-radius: 0; height: 34px; background: transparent; color: var(--ink-muted); font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: color-mix(in oklch, var(--accent) 16%, var(--sheet)); color: var(--accent-strong); }
.readout { display: grid; grid-template-columns: minmax(140px, 160px) 1fr; gap: 6px var(--s4); margin-top: var(--s5); font-size: 0.875rem; }
.readout dt { color: var(--ink-muted); }
.readout dd { margin: 0; }
.manage { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px dashed var(--line); display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.share-url { font-size: 0.8125rem; color: var(--ink-muted); word-break: break-all; flex-basis: 100%; }
.xr-note { color: var(--ink-muted); font-size: 0.8125rem; margin-top: var(--s2); }
kbd { font: inherit; font-weight: 600; color: var(--ink); }

.files { max-width: 640px; padding: var(--s5) var(--s4); }
.files li { margin: var(--s3) 0; font-size: 1.125rem; }

@media (max-width: 560px) {
  .top { padding: var(--s3) var(--s3) var(--s2); }
  main { padding: 0 var(--s3) var(--s6); }
  .grid { grid-template-columns: 1fr; gap: var(--s4); }
  .readout { grid-template-columns: 120px 1fr; }
  .stage { border-radius: 0; margin: 0 calc(var(--s3) * -1); }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; } }
