/*
  The interface is black and white so it never competes with the footage. One
  colour is allowed, and only on notes: tungsten, the amber of a film light,
  marks where notes sit (on the timeline, on a clip's note strip, in counts of
  open notes). Elevation is lightness alone: black ground, #111 panels, #1c1c1c
  inside them, no shadows on anything at rest. Dark is the default because
  review happens next to graded images; light is a choice in Settings.
*/
:root {
  --bg: #000000;
  --panel: #111111;
  --raised: #1c1c1c;
  --hover: #242424;
  --line: #1f1f1f;
  --line-strong: #3d3d3d;
  --text: #ffffff;
  --text-2: #b4b4b4;
  --text-3: #949494;
  --invert: #ffffff;
  --on-invert: #000000;
  --focus: #ffffff;
  --letterbox: #000000;
  --shadow: 0 16px 40px rgb(0 0 0 / .6);
  /* Tungsten: notes and marks only. Never on buttons, tabs or navigation. */
  --accent: #f2b33d;
  --accent-soft: #2b2414;
  --on-accent: #000000;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  /* Archivo's narrow widths echo slate lettering and end-credit type; display use only. */
  --display: "Archivo", var(--font);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-pill: 999px;
  --control: 36px;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f4f4f4;
  --raised: #e9e9e9;
  --hover: #e2e2e2;
  --line: #e4e4e4;
  --line-strong: #b5b5b5;
  --text: #0a0a0a;
  --text-2: #555555;
  --text-3: #6b6b6b;
  --invert: #0a0a0a;
  --on-invert: #fafafa;
  --focus: #000000;
  --shadow: 0 16px 40px rgb(0 0 0 / .12);
  --accent: #9a5b00;
  --accent-soft: #fbedd3;
  --on-accent: #ffffff;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

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

[hidden] { display: none !important; }

/* ---------- Shutter's signatures, shared by every page ---------- */

@property --sweep {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* Changing page is a shutter turn: the next page wipes in with a rotary sweep, like the logo's blade. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: none; }
::view-transition-new(root) {
  animation: shutter-turn .42s cubic-bezier(.65, 0, .35, 1) both;
  -webkit-mask-image: conic-gradient(from 135deg, #000 var(--sweep), transparent 0);
  mask-image: conic-gradient(from 135deg, #000 var(--sweep), transparent 0);
}
@keyframes shutter-turn { from { --sweep: 0deg; } to { --sweep: 360deg; } }

/* Selected text reads like a film negative. */
::selection { background: var(--text); color: var(--bg); }

/* Viewfinder frame lines: "this is a shot". Put .frame-corners on any positioned box. */
.frame-corners::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 2;
  pointer-events: none;
  --c: rgb(255 255 255 / .9);
  --l: 14px;
  --w: 1.5px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) top left / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) top right / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) bottom left / var(--w) var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--w),
    linear-gradient(var(--c), var(--c)) bottom right / var(--w) var(--l);
  background-repeat: no-repeat;
}

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

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 14px; background: var(--invert); color: var(--on-invert);
  border-radius: var(--r-sm); text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  font: 12px/1 var(--mono);
  text-align: center;
  padding: 3px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
  background: var(--raised);
}

/* Logo: lowercase wordmark, heavy and extra wide, set tight against a solid mark. */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
}
.logo svg { width: 21px; height: 21px; flex: none; }
.logo span {
  font: 900 21px/1 var(--display);
  font-stretch: 125%;
  letter-spacing: -0.035em;
  padding-bottom: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control);
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  background: var(--raised);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .12s ease;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }

/* The one primary on a screen: inverted, white on black. */
.btn-primary { background: var(--invert); color: var(--on-invert); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--invert) 82%, var(--bg)); }

.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-lg { --control: 46px; padding: 0 22px; font-size: 16px; }
.btn-sm { --control: 30px; padding: 0 12px; font-size: 13px; }

.link {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  cursor: pointer;
  font-weight: 520;
}
.link:hover { text-decoration-color: currentColor; }

/* Fields */
input, select, textarea {
  background: var(--raised);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  min-height: var(--control);
  padding: 5px 12px;
  transition: border-color .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--text-3); }
::placeholder { color: var(--text-3); }

select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 11px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

/* Signed-in shell: dashboard, settings */
.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.appnav { display: flex; gap: 4px; }
.appnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 540;
}
.appnav a:hover { color: var(--text); background: var(--hover); }
.appnav a[aria-current="page"] { color: var(--text); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--invert);
  color: var(--on-invert);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.user-slot { min-width: 32px; min-height: 32px; display: grid; place-items: center; }

.avatar {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 13px;
  font-weight: 650;
}

.preview-banner {
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  font-size: 13px;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.page-title {
  margin: 0;
  font: 800 clamp(26px, 3vw, 32px)/1.05 var(--display);
  font-stretch: 88%;
  letter-spacing: -0.015em;
}

.page-sub { margin: 8px 0 0; color: var(--text-2); max-width: 64ch; }

/* Open notes: the one number in colour, anywhere it appears. */
.note-count {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none;
  min-height: 22px; padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.note-count::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.note-count.is-zero { background: var(--raised); color: var(--text-2); }
.note-count.is-zero::before { display: none; }

/* Blocking states: loading, error */
.gate {
  min-height: 60vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.gate h1, .gate h2 { margin: 0; font-size: 20px; }
.gate p { margin: 0; max-width: 48ch; color: var(--text-2); }

/* The loader is the logo's shutter: a ring with a half-disc blade turning at 24 frames a second. */
.spinner {
  position: relative;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--text);
}
.spinner::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: conic-gradient(var(--text) 0 180deg, transparent 0);
  animation: spin 1s steps(24) infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--invert);
  color: var(--on-invert);
  box-shadow: var(--shadow);
  font-weight: 550;
}
.toast .link { color: var(--on-invert); text-decoration-color: currentColor; }

/* Dialogs */
.sheet {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--raised);
  color: var(--text);
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgb(0 0 0 / .6); }
/* Fields inside a dialog sit one step darker than it, so they never vanish into it. */
.sheet input:not([type="checkbox"]):not([type="radio"]):not(.switch), .sheet select, .sheet textarea { background-color: var(--panel); }
.sheet h2 { margin: 0 0 8px; font-size: 17px; }
.sheet p { margin: 0; color: var(--text-2); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 720px) {
  :root { --control: 44px; }
  .appbar { gap: 12px; padding: 0 16px; }
  .appbar .logo span { display: none; }
  .appnav a { min-height: 44px; }
  .page { padding: 28px 16px 64px; }
  .preview-banner { padding: 8px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  /* A loader still has to show work is happening: slow, stepped turns. */
  .spinner::before { animation: spin 4s steps(8) infinite !important; }
}

/* Signed-in shell with a sidebar: Reviews, Friends, Settings */
/* One ground for the sidebar and the page, split by a single rule. The page you're on is
   marked by brightness alone: its label goes from grey to white. */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }
.shell-main { min-width: 0; }

.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding-left: 8px; margin-bottom: 14px; }

.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  text-decoration: none;
  font-weight: 550;
  transition: color .15s ease, background-color .15s ease;
}
.rail-item:hover { color: var(--text); background: var(--panel); }
.rail-item[aria-current="page"] { color: var(--text); }
.rail-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 2px; border-radius: 0 2px 2px 0; background: var(--text); }
.rail-item svg { width: 18px; height: 18px; flex: none; }
.rail-item .badge { margin-left: auto; }
/* New review: the screen's one primary, a white pill at the top of the rail. */
.rail-new {
  justify-content: center;
  min-height: 40px;
  margin-bottom: 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--invert);
  cursor: pointer;
  color: var(--on-invert);
  font-weight: 650;
}
.rail-new:hover { background: color-mix(in srgb, var(--invert) 85%, var(--bg)); color: var(--on-invert); }
.rail-new .disc { display: grid; place-items: center; flex: none; }
.rail-new .disc svg { width: 16px; height: 16px; }

.rail-recents { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 22px; }
.rail-label { margin: 0 0 6px; padding: 0 10px; color: var(--text-3); font-size: 12px; font-weight: 550; }
.recents { list-style: none; margin: 0; padding: 0; overflow: hidden auto; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 0; }
.rec {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
}
.rec:hover { background: var(--panel); color: var(--text); }
.rec-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Open notes on a clip: the one number worth seeing at a glance, in the notes' colour. */
.rec-open { flex: none; min-width: 20px; padding: 0 7px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; line-height: 18px; font-variant-numeric: tabular-nums; text-align: center; }
.rec-none { padding: 4px 10px; color: var(--text-3); font-size: 13px; }

.rail-foot { display: flex; align-items: center; gap: 10px; padding: 12px 2px 0 6px; margin-top: 8px; border-top: 1px solid var(--line); }
.rail-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  flex: none;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover, .icon-btn[aria-current="page"] { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.mbar, .scrim, .rail-close { display: none; }
.shell .preview-banner { margin: 0; }

/* Collapsed to icons on wide screens. */
@media (min-width: 821px) {
  .shell.rail-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
  .rail-collapsed .rail { align-items: center; }
  .rail-collapsed .rail-top { flex-direction: column; padding: 0; }
  .rail-collapsed .rail .logo span,
  .rail-collapsed .rail-item > span:not(.disc),
  .rail-collapsed .rail-recents,
  .rail-collapsed .rail-name { display: none; }
  .rail-collapsed .rail-recents + .rail-foot { margin-top: auto; }
  .rail-collapsed .rail-item { width: 40px; justify-content: center; padding: 0; }
  .rail-collapsed .rail-new { height: 40px; }
  .rail-collapsed .rail-item[aria-current="page"]::before { left: -12px; }
  .rail-collapsed .rail-foot { flex-direction: column; padding: 10px 0 0; }
  /* A dot stands in for the unread count. */
  .rail-collapsed .rail-item .badge { position: absolute; top: 6px; right: 6px; min-width: 8px; height: 8px; padding: 0; margin: 0; font-size: 0; }
}

/* Phones: a top bar, and the sidebar slides over the page. */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .mbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 4px;
    height: 56px; padding: 0 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .mbar .logo { margin-right: auto; }
  .mbar .icon-btn { width: 44px; height: 44px; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.2, .7, .1, 1), visibility 0s linear .28s;
  }
  .rail-open .rail { transform: none; visibility: visible; box-shadow: var(--shadow); transition: transform .28s cubic-bezier(.2, .7, .1, 1); }
  .rail-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / .5); }
  .rail-toggle { display: none; }
  .rail-close { display: grid; }
  .rail-item, .rec { min-height: 44px; }
  .rail-foot .icon-btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .rail { transition: none !important; }
}

/* The studio's other apps, under the recents. */
.rail-apps { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.rail-app svg { width: 18px; height: 18px; flex: none; }
.rail-collapsed .rail-apps .rail-label { display: none; }

/* Phones: tab bar along the bottom, clear of the home indicator. */
.tabbar { display: none; }
@media (max-width: 820px) {
  .shell { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .mbar { padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .mbar a[href="/review/"] { display: none; }
  .rail { padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset: auto 0 0; z-index: 35;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    position: relative;
    display: grid; justify-items: center; align-content: center; gap: 3px;
    min-height: 52px;
    border-radius: var(--r-md);
    color: var(--text-2);
    text-decoration: none;
    font-size: 11px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--text); }
  .tabbar a:active { background: var(--hover); }
  .tabbar .tab-new svg { width: 30px; height: 30px; padding: 6px; border-radius: 50%; background: var(--invert); color: var(--on-invert); }
  .tabbar .tab-new { gap: 1px; color: var(--text); }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
/* Installed app: the page sits under a see-through status bar. */
@media (min-width: 821px) {
  .standalone .rail { padding-top: max(16px, env(safe-area-inset-top)); }
}

/* On/off switch: a checkbox with role="switch". */
.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 44px; height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background .2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fafafa;
  box-shadow: 0 1px 3px rgb(0 0 0 / .35);
  transition: transform .2s cubic-bezier(.2, .7, .1, 1);
}
.switch:checked { background: var(--invert); }
.switch:checked::after { transform: translateX(18px); background: var(--on-invert); }
.switch:disabled { opacity: .45; cursor: default; }
.switch:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

.suspended-banner {
  padding: 12px 24px;
  background: var(--invert);
  color: var(--on-invert);
  font-weight: 600;
  font-size: 14px;
}

/* Touch screens: no control smaller than a fingertip. */
@media (pointer: coarse) {
  .btn-sm { min-height: 40px; }
  .icon-btn { width: 44px; height: 44px; }
}
