/* Margin pages (sign-in, dashboard, new critique, invites). Same paper, ink
   and red margin line as the landing page, so the product feels like the
   page that sold it. */
:root {
  --paper: #f6f1e7;
  --paper-2: #efe8da;
  --card: #fffdf8;
  --ink: #1d1a16;
  --ink-2: #4a443b;
  --ink-3: #857c6f;
  --rule: #d9cfbd;
  --red: #c8361f;          /* the margin line: the one loud colour */
  --red-soft: #c8361f14;
  --blue: #2a5bd7;
  --blue-soft: #2a5bd714;
  --green: #2e8a4f;
  --stage: #15161a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --margin-x: clamp(24px, 6vw, 96px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16171b;
    --paper-2: #1c1d22;
    --card: #202127;
    --ink: #efe9dd;
    --ink-2: #c3bbad;
    --ink-3: #8f887c;
    --rule: #34353c;
    --red: #ff6a4d;
    --red-soft: #ff6a4d1f;
    --blue: #7aa2ff;
    --blue-soft: #7aa2ff1f;
    --green: #5cc283;
    --stage: #0b0c0e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh;
}
/* The signature motif: a notebook margin line down the whole page. */
body.paper::before {
  content: ""; position: fixed; top: 0; bottom: 0; left: var(--margin-x);
  width: 1.5px; background: var(--red); opacity: .55; pointer-events: none; z-index: 0;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code, pre { font-family: var(--mono); font-size: 13.5px; }
code { background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }

.wrap {
  position: relative; z-index: 1; max-width: 1180px;
  padding-left: calc(var(--margin-x) + clamp(18px, 3vw, 40px)); padding-right: clamp(18px, 4vw, 56px); padding-bottom: 80px;
}

/* -------------------------------------------------------------- top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 24px 0; }
.logo { font: 600 26px/1 var(--serif); letter-spacing: -.01em; text-decoration: none; display: flex; align-items: baseline; gap: 2px; }
.logo i { width: 9px; height: 9px; background: var(--red); border-radius: 50%; display: inline-block; transform: translateY(-1px); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; color: var(--ink-2); }
.nav-who { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border-radius: 999px; padding: 10px 18px; font: 600 15px/1 var(--sans); text-decoration: none;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink); white-space: nowrap;
}
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.solid:hover:not(:disabled) { background: var(--red); border-color: var(--red); }
.btn.ghost:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
.btn.rec { background: var(--red); border-color: var(--red); color: #fff; }
.btn.rec:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .4; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
.link-btn:hover { color: var(--red); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* ----------------------------------------------------------- type, hero */
.eyebrow { font: 12.5px/1 var(--mono); color: var(--red); text-transform: uppercase; letter-spacing: .14em; margin-bottom: 18px; }
.hero-sm { padding: 36px 0 28px; max-width: 760px; }
.hero-sm h1, .h-page { font: 500 clamp(36px, 5.2vw, 64px)/1.02 var(--serif); letter-spacing: -.02em; margin: 0 0 18px; }
.h-page { font-size: clamp(32px, 4vw, 48px); margin: 0; }
h1 em { font-style: italic; color: var(--red); }
.lede { font-size: clamp(17px, 1.5vw, 20px); color: var(--ink-2); max-width: 46ch; margin: 0 0 24px; }
.h-sm { font: 600 22px/1.2 var(--serif); margin: 0 0 6px; }
.fine { font-size: 13.5px; color: var(--ink-3); margin: 10px 0 0; }
.loading { color: var(--ink-3); font-style: italic; font-family: var(--serif); font-size: 19px; }

.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 24px 26px;
  box-shadow: 0 1px 0 var(--rule), 0 24px 44px -34px #0005;
}
.card.narrow { max-width: 460px; }

/* -------------------------------------------------------------- sign-in */
.signin-form { display: flex; flex-direction: column; gap: 10px; }
.signin-form label { font: 600 13px/1 var(--sans); color: var(--ink-2); }
.signin-form input, .details input, .name-card input {
  width: 100%; font-size: 17px; padding: 12px 14px; border-radius: 9px; border: 1.5px solid var(--rule); background: var(--paper);
}
.signin-form input:focus, .details input:focus, .name-card input:focus { outline: none; border-color: var(--ink); }
.signin-form .btn { margin-top: 6px; align-self: flex-start; }
.code-input { font: 600 28px/1 var(--mono) !important; letter-spacing: .45em; text-align: center; max-width: 280px; }
.sent { margin: 0 0 6px; color: var(--ink-2); }
.signin-alt { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.signin-alt .dot { color: var(--ink-3); }
.form-error { color: var(--red); background: var(--red-soft); border-left: 3px solid var(--red); padding: 9px 12px; border-radius: 0 6px 6px 0; margin: 4px 0; font-size: 14.5px; }
.form-info { color: var(--green); font-size: 14px; margin: 0; }

/* ----------------------------------------------------------- dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 40px; align-items: start; padding-top: 18px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.crit-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.crit { display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--rule); position: relative; }
.crit-link { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 16px 0; text-decoration: none; }
.crit-title { font: 600 20px/1.25 var(--serif); }
.crit-link:hover .crit-title { color: var(--red); }
.crit-meta { font-size: 13.5px; color: var(--ink-3); }
.crit-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font: 600 11px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; padding: 5px 8px; border-radius: 4px; border: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.badge.role-owner { color: var(--red); border-color: var(--red); background: var(--red-soft); }
.badge.role-contributor { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.badge.role-viewer { color: var(--ink-2); }
.badge.status-transcribing, .badge.status-uploading { color: var(--ink-3); border-style: dashed; }
.crit-copy { font-size: 13px; color: var(--ink-3); font-style: italic; }
.badge.template { color: var(--green); border-color: var(--green); }
.badge.expiry { color: var(--ink-3); text-transform: none; letter-spacing: 0; font-weight: 400; }
.empty-state { border-top: 1px solid var(--rule); padding: 36px 0; }
.empty-big { font: italic 26px/1.3 var(--serif); margin: 0 0 6px; }
.empty-state p { color: var(--ink-2); margin: 0; }

.usage { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 20px 22px; position: sticky; top: 20px; }
.usage-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; color: var(--ink-3); font-size: 14px; }
.plan-pill { font: 600 21px/1 var(--serif); color: var(--ink); }
.meter-row { margin: 12px 0; }
.meter-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.meter-label b { font: 600 13px/1.4 var(--mono); color: var(--ink); white-space: nowrap; }
.meter-bar { height: 6px; background: var(--paper-2); border-radius: 3px; overflow: hidden; }
.meter-bar div { height: 100%; background: var(--ink-2); border-radius: 3px; }
.meter-row.full .meter-bar div { background: var(--red); }
.meter-row.full b { color: var(--red); }

.name-card { margin: 8px 0 18px; max-width: 620px; border-left: 3px solid var(--red); }
.name-card p { margin: 0 0 12px; color: var(--ink-2); }
.name-card.bare { margin: 0; max-width: none; border: 0; }
.signin > .fine:first-child { margin: 0 0 16px; }
.inline-form { display: flex; gap: 10px; }
.inline-form input { flex: 1; }

.notice { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 16px 18px; margin: 0 0 20px; border-radius: 10px; background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.notice p { margin: 0 0 4px; color: var(--ink-2); font-size: 14.5px; }
.notice .notice-title { font: 600 18px/1.3 var(--serif); color: var(--ink); margin-bottom: 6px; }
.gutter-mark { font: 600 12px/1.6 var(--mono); color: var(--red); }

/* --------------------------------------------------------- new critique */
.new { padding-top: 10px; }
.new .h-page { margin-bottom: 22px; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.tab {
  background: none; border: 0; border-bottom: 2.5px solid transparent; padding: 10px 18px 12px; margin-bottom: -1px;
  cursor: pointer; font: 600 15px/1 var(--sans); color: var(--ink-3);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); }
.tab-panel { margin-bottom: 22px; }

.rec-stage {
  position: relative; height: clamp(300px, 62vh, 820px); width: 100%; background: var(--stage);
  border-radius: 10px; overflow: hidden; box-shadow: 0 24px 44px -34px #0008;
}
/* The output frame: sized by script to the chosen shape, centred in the stage. */
.rec-frame { position: absolute; outline: 1px solid #ffffff1f; }
.rec-stage.live .rec-frame { outline: 3px solid var(--red); }
.rec-stage.paused .rec-frame { outline: 3px solid #d9a400; }
.rec-frame canvas, .rec-frame .rec-result { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
/* An invisible grab area over the bubble the canvas draws; outlined on hover. */
.cam-handle { position: absolute; z-index: 2; cursor: grab; touch-action: none; border-radius: 10%; }
.cam-handle.round { border-radius: 50%; }
.cam-handle:hover, .cam-handle:active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0006; }
.cam-handle:active { cursor: grabbing; }
/* The camera as its own layer: the live camera shown over the canvas, drawn
   like the player draws it (white rim, soft shadow). --rim is set by script
   so the rim scales with the bubble the way the burned-in one does. */
.cam-handle .cam-live { display: none; }
.cam-handle.layer { background: #222; border-radius: 10%; overflow: hidden; box-shadow: 0 4px 18px #0007; }
.cam-handle.layer.round { border-radius: 50%; }
.cam-handle.layer:hover, .cam-handle.layer:active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0006; }
.cam-handle.layer .cam-live { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cam-handle.layer.mirror .cam-live { transform: scaleX(-1); }
.cam-handle.layer::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 var(--rim, 3px) #ffffffe6;
}
.cam-handle.layer .cam-resize { z-index: 1; }
.cam-resize {
  position: absolute; width: 18px; height: 18px; margin: -9px; border-radius: 50%; cursor: nwse-resize;
  background: #fff; box-shadow: 0 1px 4px #0008; opacity: .9;
}
.cam-handle[data-corner="se"] .cam-resize { left: 92%; top: 92%; }
.cam-handle[data-corner="sw"] .cam-resize { left: 8%; top: 92%; cursor: nesw-resize; }
.cam-handle[data-corner="ne"] .cam-resize { left: 92%; top: 8%; cursor: nesw-resize; }
.cam-handle[data-corner="nw"] .cam-resize { left: 8%; top: 8%; }
.cam-handle.round[data-corner="se"] .cam-resize { left: 85%; top: 85%; }
.cam-handle.round[data-corner="sw"] .cam-resize { left: 15%; top: 85%; }
.cam-handle.round[data-corner="ne"] .cam-resize { left: 85%; top: 15%; }
.cam-handle.round[data-corner="nw"] .cam-resize { left: 15%; top: 15%; }
.stage-pill {
  position: absolute; left: 12px; bottom: 12px; z-index: 3; padding: 5px 10px; border-radius: 999px;
  background: #000a; color: #fff; font: 13px/1.2 var(--sans);
}
.stage-pill kbd { font: 11px var(--mono); background: #fff3; border-radius: 3px; padding: 0 4px; }

/* Crop editor: the raw shared picture with the region being recorded. */
.crop-editor { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; background: var(--stage); }
.crop-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: #e8e2d6; font-size: 13.5px; }
.crop-bar span { flex: 1; }
.crop-bar .btn { padding: 6px 12px; font-size: 13px; border-color: #e8e2d6; color: #e8e2d6; }
.crop-bar .btn.solid { background: #e8e2d6; color: #15161a; }
.crop-bar kbd { font: 11px var(--mono); opacity: .7; }
.crop-area { position: relative; flex: 1; margin: 0 12px 12px; }
.crop-src { position: absolute; overflow: hidden; cursor: crosshair; touch-action: none; }
.crop-video { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-rect { position: absolute; box-shadow: 0 0 0 9999px #000a; outline: 2px solid #fff; cursor: move; }
.crop-handle { position: absolute; width: 16px; height: 16px; margin: -8px; background: #fff; border-radius: 3px; box-shadow: 0 1px 4px #0008; }
.crop-handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle.ne { left: 100%; top: 0; cursor: nesw-resize; }
.crop-handle.sw { left: 0; top: 100%; cursor: nesw-resize; }
.crop-handle.se { left: 100%; top: 100%; cursor: nwse-resize; }

/* Output, framing and camera options under the stage. */
.rec-options { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; align-items: center; margin-top: 16px; }
.rec-options.done { opacity: .5; }
.opt-group { display: contents; }
.opt-label { font: 600 12.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.opt-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.opt-row > .opt-row { margin-right: 10px; }
.opt-btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer; padding: 7px 12px; border-radius: 8px;
  border: 1.5px solid var(--rule); background: var(--card); color: var(--ink-2); font: 600 14px/1 var(--sans);
}
.opt-btn:hover:not(:disabled) { border-color: var(--ink-3); color: var(--ink); }
.opt-btn[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--paper-2); box-shadow: inset 0 0 0 1px var(--ink); }
.opt-btn:disabled { opacity: .45; cursor: default; }
.opt-btn[aria-pressed="true"]:disabled { opacity: .75; }
.opt-btn kbd { font: 11px var(--mono); color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 4px; }
.opt-btn small { font: 11.5px var(--mono); color: var(--ink-3); }
.shape-ico { display: inline-block; height: 16px; max-width: 26px; border: 1.5px solid currentColor; border-radius: 2px; }
.shape-btn[data-shape="9:16"] .shape-ico { height: 18px; }
.out-size { font: 600 13.5px/1 var(--mono); color: var(--ink-2); white-space: nowrap; }
.opt-sep { width: 1px; height: 22px; background: var(--rule); margin: 0 4px; }
.rec-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.rec-timer { font: 600 22px/1 var(--mono); margin-left: auto; font-variant-numeric: tabular-nums; }
.rec-stage.live ~ .rec-controls .rec-timer, .live-timer { color: var(--red); }
.field { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.field select { max-width: 240px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--rule); background: var(--card); }
.meter { width: 70px; height: 6px; background: var(--paper-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--rule); }
.meter div { height: 100%; width: 0; background: var(--green); transition: width 60ms linear; }
.rec-msg { color: var(--red); font-size: 14px; min-height: 1em; margin: 10px 0 0; }
.rec-msg:empty { display: none; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  min-height: 220px; border: 2px dashed var(--rule); border-radius: 12px; background: var(--card); color: var(--ink-3); text-align: center; padding: 20px;
}
.drop:hover, .drop.over { border-color: var(--red); color: var(--ink-2); }
.drop-big { font: 500 26px/1.2 var(--serif); color: var(--ink); }
.upload-preview { display: block; width: 100%; max-height: 50vh; margin-top: 14px; border-radius: 10px; background: var(--stage); }

.teams-panel { max-width: 720px; }
.teams-panel p { color: var(--ink-2); }
.code { background: var(--card); border: 1px solid var(--rule); border-left: 3px solid var(--red); border-radius: 4px 8px 8px 4px; padding: 14px 16px; overflow-x: auto; line-height: 1.6; }

.details { max-width: 720px; display: flex; flex-direction: column; gap: 8px; }
.details label { font: 600 13px/1 var(--sans); color: var(--ink-2); }
.source-info { margin: 2px 0 0; font-size: 14px; color: var(--ink-3); }
.source-info b { color: var(--ink); font-weight: 600; }
.details .notice { margin: 8px 0 0; }
.progress { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.progress-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--paper-2); overflow: hidden; border: 1px solid var(--rule); }
.progress-bar div { height: 100%; width: 0; background: var(--red); transition: width .2s; }
.progress-text { font: 13px/1 var(--mono); color: var(--ink-2); white-space: nowrap; }

/* -------------------------------------------------------------- invite */
.invite-hero { padding-bottom: 20px; }
.invite-from { font-size: 18px; color: var(--ink-2); margin: 0 0 8px; }
.invite-hero h1 { margin-bottom: 12px; }
.invite-hero .lede b { color: var(--red); font-weight: 600; }

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .usage { position: static; order: -1; }
  .crit { flex-direction: column; align-items: flex-start; gap: 0; padding-bottom: 12px; }
  .crit-tags { justify-content: flex-start; }
}

/* Phones: the address and Sign out share the bar with the wordmark instead
   of pushing the page wider than the screen. */
@media (max-width: 600px) {
  .topbar { gap: 12px; }
  .nav-right { gap: 10px; min-width: 0; }
  .nav-who { min-width: 0; flex: 0 1 auto; }
  .nav-right .link-btn { white-space: nowrap; }
}
