/* Riggle app — "the stage".
 *
 * Every screen here is either a face you are inspecting or a list of faces,
 * so the room stays dark and quiet and the model plates are the only things
 * that carry light. The accent palette is not decorative: it is the exact
 * grease-pencil set the marking canvas draws with (mark.js), so a colour
 * means the same thing in the chrome as it does on the face — yellow is the
 * lip boundary and "you are mid-task", green is the lower lip and "done",
 * red is the inside-mouth seed and "this failed".
 *
 * The brand gradient is spent in exactly one place: the primary button.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  /* the room */
  --ink-900: #0B0912;   /* page ground */
  --ink-850: #100D18;   /* sunken wells */
  --ink-800: #14111C;   /* recessed surfaces: inputs, rails */
  --ink-700: #1A1624;   /* raised surfaces: cards */
  --ink-600: #221D30;   /* hover / active fills */
  --line:    #2B2537;   /* hairlines */
  --line-2:  #3A3350;   /* emphasised hairlines */

  /* ink */
  --paper:     #EFECF6;
  --paper-dim: #948EA8;
  --paper-faint: #6A6480;

  /* marks — mark.js draws the face with these exact values */
  --mark-boundary: #FFD60A;  /* lip polygon   → working, attention */
  --mark-inside:   #FF453A;  /* mouth seed    → failed, destructive */
  --mark-upper:    #64D2FF;  /* upper lip     → input, informational */
  --mark-lower:    #30D158;  /* lower lip     → ready, success */
  --mark-eye:      #FF9F0A;  /* eye centres   → warnings */

  /* brand — button and logo only */
  --brand-a: #FF4D8D;
  --brand-b: #8B5CFF;

  --r-sm: 5px;
  --r-md: 10px;
  --r-lg: 14px;

  --display: "Outfit", system-ui, -apple-system, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --shadow-plate: 0 18px 40px -22px rgba(0, 0, 0, .95);

  /* native controls (checkboxes, scrollbars, the video control bar) follow
   * this — without it they render as light-mode widgets on a dark page */
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink-900);
  color: var(--paper);
  font: 400 15px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 22px 72px;
}

/* --------------------------------------------------------------- typography */

h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 31px;
  line-height: 1.15;
  letter-spacing: -.022em;
  margin: 0 0 8px;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -.012em;
  margin: 0;
}

.sub {
  color: var(--paper-dim);
  margin: 0;
  max-width: 62ch;
}

.page-head { margin-bottom: 30px; }

/* section headings carry a pencil rule in the boundary colour */
.section {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 44px 0 16px;
}
.section::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.section .count {
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
  color: var(--paper-faint);
  text-transform: uppercase;
}

/* anything measured is set in mono */
.mono, .meta {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .01em;
  color: var(--paper-dim);
}

.label {
  font: 500 10px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--paper-faint);
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  height: 60px;
  background: rgba(11, 9, 18, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.nav a {
  position: relative;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--paper-dim);
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--paper); background: var(--ink-700); }
.nav a.is-active { color: var(--paper); }
/* the active page is underlined like a pencil mark on the plate */
.nav a.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--mark-boundary);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* the token chip is quiet: no gradient, it is a readout not a button */
.chip-tokens {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--ink-800);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-dim);
  transition: border-color .15s, color .15s;
}
.chip-tokens strong { font-size: 13px; font-weight: 600; color: var(--paper); }
.chip-tokens:hover { border-color: var(--mark-boundary); color: var(--paper); }

/* below this the brand + nav + wallet + sign-out cannot share one line, so the
 * nav drops to its own row and scrolls sideways rather than overflowing */
@media (max-width: 760px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 8px 14px;
  }
  .nav {
    order: 3;
    width: 100%;
    margin-right: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 6px 10px; white-space: nowrap; }
  .topbar-right { margin-left: auto; }
  main { padding: 24px 16px 56px; }
  h1 { font-size: 26px; }
  .section { margin-top: 34px; }
}

.linkish {
  background: none;
  border: 0;
  padding: 7px 4px;
  font: 500 14px var(--body);
  color: var(--paper-dim);
  cursor: pointer;
}
.linkish:hover { color: var(--mark-inside); }

.inline { display: inline; }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* a visible border always: the default fill sits on cards of the same
   * colour, where a fill-only button disappears */
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 17px;
  font: 600 14px/1 var(--body);
  color: var(--paper);
  background: var(--ink-600);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: #2A2440; border-color: #4A4268; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; }

/* the one place the brand gradient appears */
.btn--primary {
  background: linear-gradient(112deg, var(--brand-a), var(--brand-b));
  color: #0B0912;
  border-color: transparent;
}
.btn--primary:hover { filter: brightness(1.09); border-color: transparent; }
.btn--primary[disabled]:hover { filter: none; }

.btn--quiet { background: transparent; border-color: var(--line-2); color: var(--paper-dim); }
.btn--quiet:hover { background: var(--ink-700); color: var(--paper); }

/* Sign-in buttons. Each carries its provider's own colour and mark, so no door
 * looks more recommended than another, and the hover is a shade rather than a
 * flip — these are the first buttons a stranger sees, and a button that
 * inverts under the cursor reads as a glitch. */
.btn--provider { color: #fff; border-color: transparent; }
.btn--discord { background: #5865F2; }
.btn--discord:hover { background: #4752C4; border-color: transparent; }
.btn--google { background: var(--ink-600); border-color: var(--line-2); }
.btn--google:hover { background: #2A2440; border-color: #4A4268; }
/* flex-shrink:0 — a flex item with no intrinsic size and a viewBox will
 * otherwise take the whole button. */
.provider-icon { height: 16px; flex: 0 0 auto; }

.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
}

.cards { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); }

.well {
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
}

/* --------------------------------------------------------------- messages */

.messages {
  list-style: none;
  margin: 0 auto;
  padding: 14px 22px 0;
  width: 100%;
  max-width: 1120px;
}
.msg {
  padding: 10px 15px;
  border-radius: var(--r-sm);
  background: var(--ink-700);
  border-left: 3px solid var(--line-2);
  margin-bottom: 8px;
  font-size: 14px;
}
.msg.error { border-left-color: var(--mark-inside); }
.msg.success { border-left-color: var(--mark-lower); }
.msg.warning { border-left-color: var(--mark-eye); }

.errbox {
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mark-inside);
  border-radius: var(--r-sm);
  padding: 14px 16px;
}
.warnbox {
  background: var(--ink-850);
  border-left: 3px solid var(--mark-eye);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  color: var(--paper-dim);
  font-size: 13.5px;
}
.warnbox ul { margin: 6px 0 0; padding-left: 18px; }
.warnbox li + li { margin-top: 3px; }

.form-error { color: var(--mark-inside); font-size: 13px; min-height: 1em; }

/* ------------------------------------------------------------------ status */

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--paper-dim);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.status--ready { color: var(--mark-lower); }
.status--failed { color: var(--mark-inside); }
.status--marking { color: var(--mark-boundary); }
.status--working { color: var(--mark-eye); }
/* only the genuinely-in-flight state pulses */
.status--working::before { animation: pulse 1.6s ease-in-out infinite; }

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

/* ------------------------------------------------------------------ plates */

/* A plate is a model on a lit stage. IN plates hold the flat front render
 * (transparent PNG, so the stage shows through); OUT plates hold the rigged
 * result, which the renderer hands us on its own grey. That difference is
 * doing work — the still dark plate reads as "before", the lit grey one as
 * "after" — so it is kept rather than normalised away. */
.plate {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--ink-800);
}

.plate__stage {
  position: relative;
  aspect-ratio: 1;
  background: radial-gradient(ellipse 62% 52% at 50% 42%, #292338 0%, #14111C 72%);
}
/* media is taken out of flow: a grid/flow child sized 100% fights the stage's
 * aspect-ratio and wins, which silently squares off every plate */
.plate__stage img,
.plate__stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.plate__stage video[data-hover-play] { cursor: pointer; }

/* registration ticks — a viewport habit, not decoration: they mark the frame
 * the pipeline measured the face against */
.plate__stage::after {
  content: "";
  position: absolute;
  inset: 9px;
  pointer-events: none;
  --t: var(--line-2);
  background:
    linear-gradient(var(--t), var(--t)) 0 0 / 11px 1px no-repeat,
    linear-gradient(var(--t), var(--t)) 0 0 / 1px 11px no-repeat,
    linear-gradient(var(--t), var(--t)) 100% 0 / 11px 1px no-repeat,
    linear-gradient(var(--t), var(--t)) 100% 0 / 1px 11px no-repeat,
    linear-gradient(var(--t), var(--t)) 0 100% / 11px 1px no-repeat,
    linear-gradient(var(--t), var(--t)) 0 100% / 1px 11px no-repeat,
    linear-gradient(var(--t), var(--t)) 100% 100% / 11px 1px no-repeat,
    linear-gradient(var(--t), var(--t)) 100% 100% / 1px 11px no-repeat;
}

.plate__tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(11, 9, 18, .8);
  backdrop-filter: blur(6px);
  font: 600 10px/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.plate__tag--in { color: var(--mark-upper); box-shadow: inset 0 0 0 1px rgba(100, 210, 255, .35); }
.plate__tag--out { color: var(--mark-lower); box-shadow: inset 0 0 0 1px rgba(48, 209, 88, .35); }

.plate__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  background: var(--ink-800);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--paper-dim);
}
/* a long upload name must truncate, not stretch the plate */
.plate__foot > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plate__foot > span:last-child { flex: none; }

.plate__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--paper-faint);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* ------------------------------------------------- signature: the plate pair */

/* IN ·····> OUT. The connector carries the five marking colours, because the
 * five clicks are literally what turned the left plate into the right one. */
.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.pair__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--paper-faint);
}
.pair__dots { display: flex; gap: 4px; }
.pair__dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c);
  display: block;
}
.pair__arrow { font-size: 15px; line-height: 1; color: var(--line-2); }
.pair__note {
  font: 500 9px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
  .pair__link { flex-direction: row; }
  .pair__arrow { transform: rotate(90deg); }
}

/* ------------------------------------------------------------- model cards */

.model {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--ink-700);
  padding: 16px;
  transition: border-color .18s, transform .18s;
}
.model:hover { border-color: var(--line-2); }
.model + .model { margin-top: 14px; }

.model__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.model__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -.01em;
}
.model__title:hover { color: var(--mark-boundary); }

.models-list { display: grid; gap: 14px; }

/* the small pair used in a list row: fixed-width plates so a long list stays
 * scannable instead of turning into a column of posters */
.pair--compact {
  grid-template-columns: minmax(0, 248px) auto minmax(0, 248px);
  justify-content: start;
  gap: 14px;
}
@media (max-width: 640px) {
  .pair--compact { grid-template-columns: minmax(0, 248px); }
}

/* ------------------------------------------------------------- upload dock */

.dock {
  position: relative;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--ink-800);
  padding: 30px 24px;
  text-align: center;
  transition: border-color .18s, background .18s;
}
.dock.is-hot { border-color: var(--mark-boundary); background: var(--ink-700); }
.dock__title { font-family: var(--display); font-weight: 600; font-size: 17px; }
.dock__hint { color: var(--paper-dim); font-size: 13.5px; margin: 6px 0 16px; }
.dock input[type=file] { display: none; }
.dock__file {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--mark-boundary);
  min-height: 1.2em;
  margin-top: 12px;
}
/* the chosen file is over MAX_UPLOAD_MB: the same line, saying no. It carries
   a sentence rather than a filename, so it also stops being monospaced. */
.dock__file.is-bad {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mark-inside);
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}
.dock__terms {
  margin-top: 14px;
  font: 500 11px/1.5 var(--mono);
  letter-spacing: .04em;
  color: var(--paper-faint);
}

/* ------------------------------------------------------------- marking bay */

.bay {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 316px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) { .bay { grid-template-columns: 1fr; } }

#markCanvasWrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 10px;
  overflow: hidden;
  background: radial-gradient(ellipse 62% 52% at 50% 42%, #292338 0%, #14111C 72%);
  /* cap the WIDTH, never the height: the canvas element box has to stay square
   * or mark.js's client->canvas pixel conversion drifts */
  max-width: min(100%, 74vh);
}
#markCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--r-md);
  cursor: crosshair;
  touch-action: none;
}

/* the step rail: numbering is honest here, this really is a fixed sequence */
.rail { list-style: none; margin: 0 0 16px; padding: 0; }
.rail li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--paper-faint);
  transition: color .15s, background .15s;
}
.rail li .n {
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid currentColor;
  font: 600 10px/1 var(--mono);
}
.rail li.is-active {
  color: var(--paper);
  background: var(--ink-800);
  box-shadow: inset 2px 0 0 var(--mark-boundary);
}
.rail li.is-done { color: var(--mark-lower); }
.rail li.is-done .n { background: var(--mark-lower); border-color: var(--mark-lower); color: #0B0912; }

.zoombar { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.zoombar .zoombtn { padding: 6px 11px; font-size: 15px; line-height: 1; }
#markZoomLabel {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper-dim);
  min-width: 40px;
  text-align: center;
}

.hint { color: var(--paper-dim); font-size: 12.5px; line-height: 1.55; margin: 12px 0 0; }
.hint b { color: var(--paper); font-weight: 600; }
/* base `a` is colour:inherit, so a link inside dim copy needs saying out loud */
.hint a { color: var(--mark-upper); text-decoration: underline; text-underline-offset: 2px; }
.hint a:hover { color: var(--paper); }

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--ink-800);
  font: 500 11px var(--mono);
  color: var(--paper-dim);
}

/* --------------------------------------------------------------- results */

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) { .result { grid-template-columns: 1fr; } }

/* the preview renders at 512² — a full-column plate just upscales it */
.result .plate { max-width: min(100%, 58vh); }

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.strip figure { margin: 0; }
.strip img {
  width: 100%;
  display: block;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--ink-800);
}
.strip figcaption {
  margin-top: 5px;
  font: 500 11px/1 var(--mono);
  color: var(--paper-dim);
  text-align: center;
  letter-spacing: .02em;
}

/* ------------------------------------------------------------- file rows */

.files { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line);
         border-radius: var(--r-md); overflow: hidden; }
.file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--ink-700);
  font-size: 13.5px;
}
.file__kind {
  flex: none;
  width: 34px;
  font: 600 9px/1 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.file__kind--in { color: var(--mark-upper); }
.file__kind--out { color: var(--mark-lower); }
.file__name { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.file__size { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--paper-faint); white-space: nowrap; }
.file__act { flex: none; }
.file--missing .file__name { color: var(--paper-faint); }

/* narrow: the filename gets its own line rather than being squeezed into a
 * 100px column between the kind chip and the download button */
@media (max-width: 560px) {
  .file { flex-wrap: wrap; row-gap: 9px; }
  .file__name { order: -1; flex: 1 0 100%; }
}

/* ----------------------------------------------------------------- tables */

/* the ledger is the one genuinely wide block; it scrolls in its own box rather
 * than wrapping every timestamp onto three lines */
.table-scroll { overflow-x: auto; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.ledger th,
table.ledger td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
table.ledger th {
  font: 500 10px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
table.ledger td { font-family: var(--mono); font-size: 12px; color: var(--paper-dim); }
table.ledger td.reason { color: var(--paper); }
table.ledger tr:last-child td { border-bottom: 0; }
.delta-pos { color: var(--mark-lower); }
.delta-neg { color: var(--paper-dim); }

/* ------------------------------------------------------------------ plans */

.plan { display: flex; flex-direction: column; }
.plan__name { font-family: var(--display); font-weight: 600; font-size: 16px; }
.plan__price {
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -.02em;
  margin: 8px 0 2px;
}
.plan__tokens { color: var(--paper-dim); font-size: 13px; margin-bottom: 18px; flex: 1; }
.plan--current { border-color: var(--mark-lower); }

/* ----------------------------------------------------------------- account */

.acct { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .acct { grid-template-columns: 1fr; } }

.kv { display: grid; gap: 11px; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.kv dt { font: 500 10px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--paper-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; text-align: right; overflow-wrap: anywhere; }

.prefs { display: grid; gap: 14px; justify-items: start; }
.check { display: flex; gap: 10px; align-items: start; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--brand-a); flex: none; }
.check span { font-size: 13.5px; line-height: 1.55; color: var(--paper-dim); }

.balance {
  font-family: var(--display);
  font-weight: 700;
  font-size: 42px;
  letter-spacing: -.03em;
  line-height: 1;
}
.balance span { font-size: 15px; font-weight: 500; color: var(--paper-dim); margin-left: 8px; letter-spacing: 0; }

/* ------------------------------------------------------------------ forms */

input[type=text],
input[type=email],
input[type=password],
textarea,
select {
  width: 100%;
  padding: 10px 13px;
  font: 400 14px var(--body);
  color: var(--paper);
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 8px;
}
/* textarea inherits monospace and select inherits the platform control unless
   both are said out loud — the contact form is the first place either appears. */
textarea { resize: vertical; min-height: 140px; line-height: 1.55; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%238C8799' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand-b);
}
form p { margin: 0 0 13px; }
form label { display: block; font-size: 13px; color: var(--paper-dim); margin-bottom: 5px; }
form label[for$="remember"] { display: inline; margin-left: 6px; }
input[type=checkbox] { accent-color: var(--brand-a); }
.errorlist { list-style: none; margin: 6px 0 0; padding: 0; color: var(--mark-inside); font-size: 13px; }

.auth-card { max-width: 400px; margin: 7vh auto; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* ------------------------------------------------------------------ empty */

.empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  text-align: center;
  color: var(--paper-dim);
}
.empty strong { display: block; color: var(--paper); font-family: var(--display); font-size: 17px; margin-bottom: 6px; }

/* ------------------------------------------------------------ legal prose */

/* The only long-form reading surface in the app. Measure is capped at ~68ch
   and headings keep the display face, so it reads as Riggle rather than as a
   pasted document. */
.prose { max-width: 68ch; }
.prose h2 {
  font-size: 17px;
  margin: 34px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.prose h3 { font-family: var(--display); font-size: 14px; font-weight: 600; margin: 22px 0 8px; }
.prose p, .prose li { color: var(--paper-dim); line-height: 1.68; }
.prose p { margin: 0 0 12px; }
.prose strong { color: var(--paper); font-weight: 600; }
.prose ul { margin: 0 0 12px; padding-left: 20px; }
.prose li + li { margin-top: 7px; }
.prose a { color: var(--mark-upper); }
.prose a:hover { color: var(--paper); }
.prose .kv--wide dd { text-align: left; max-width: 46ch; font-family: var(--body); font-size: 13.5px; color: var(--paper-dim); }
.prose .kv--wide > div { align-items: start; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 16px; }

/* ------------------------------------------------------------- destructive */

/* Deleting is a disclosure, never a button sitting next to Download. */
.danger { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 16px; }
.danger summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--paper-faint);
  width: fit-content;
}
.danger summary:hover { color: var(--mark-inside); }
.danger .sub { max-width: 56ch; }
.btn--danger { border-color: var(--mark-inside); color: var(--mark-inside); background: transparent; }
.btn--danger:hover { background: var(--mark-inside); color: #0B0912; }

/* ----------------------------------------------------------------- footer */

footer {
  border-top: 1px solid var(--line);
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--paper-faint);
}
footer a:hover { color: var(--paper); }
.footlinks { display: flex; flex-wrap: wrap; gap: 16px; }

/* ----------------------------------------------------------------- motion */

/* plates arrive in order down the page — one orchestrated moment, no more */
@media (prefers-reduced-motion: no-preference) {
  .model, .card, .dock { animation: rise .5s cubic-bezier(.2, .7, .3, 1) backwards; }
  .models-list > *:nth-child(2) { animation-delay: .05s; }
  .models-list > *:nth-child(3) { animation-delay: .1s; }
  .models-list > *:nth-child(n+4) { animation-delay: .15s; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------------------- ops
 *
 * The staff dashboard. Same room, same marks: green is a number moving the
 * way we want, red is one moving the other way, and the boundary yellow is
 * reserved for "somebody is stuck here" — exactly what it means on a face.
 * Nothing on this page is decorative; every colour is a verdict.
 *
 * All of it is namespaced (.ops-*, .stat, .funnel, .cond*, .person, .tag)
 * because it shares a stylesheet with the customer-facing screens and must
 * not reach into them.
 */

.ops-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px 15px;
}
.stat__label {
  margin: 0;
  font: 500 10px/1.5 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.stat__now {
  margin: 4px 0 2px;
  font: 600 30px/1.1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}
.stat__delta {
  margin: 0;
  font: 500 12px/1.5 var(--mono);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}
.delta--good { color: var(--mark-lower); }
.delta--bad  { color: var(--mark-inside); }
.delta--flat { color: var(--paper-faint); }
.stat__pct { opacity: .8; }
.stat__prev { color: var(--paper-faint); font-size: 11px; margin-left: auto; }
.stat__note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--paper-faint);
}

/* The daily strip is the same numbers as the weekly one and must read as the
 * same instrument - so it is the same tile, sized down rather than restyled.
 * Today's counts are small and a 30px numeral makes a 1 look like an event;
 * the week above it keeps the loud type, because that is the strip that is
 * actually claiming a trend. */
.ops-stats--day { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ops-stats--day .stat { padding: 10px 12px 12px; background: var(--ink-800); }
.ops-stats--day .stat__now { font-size: 22px; margin: 3px 0 2px; }
.ops-stats--day .stat__delta { font-size: 11px; }
.ops-stats--day .stat__note { margin-top: 6px; font-size: 11px; }

/* ----------------------------------------------------------- the funnel */

.funnel { display: grid; gap: 1px; background: var(--line);
          border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.funnel__row {
  display: grid;
  grid-template-columns: 180px minmax(60px, 1fr) 56px 60px 92px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--ink-700);
  font-size: 13.5px;
}
.funnel__label { color: var(--paper); }
.funnel__bar {
  height: 8px;
  border-radius: 99px;
  background: var(--ink-850);
  overflow: hidden;
}
.funnel__bar i { display: block; height: 100%; background: var(--mark-upper); border-radius: 99px; }
/* the last rung is the only one that is revenue, so it gets the ready colour */
.funnel__row--last .funnel__bar i { background: var(--mark-lower); }
.funnel__row--last .funnel__label { color: var(--mark-lower); font-weight: 600; }
.funnel__n { font: 600 16px var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.funnel__pct { font: 400 12px var(--mono); color: var(--paper-dim); text-align: right;
               font-variant-numeric: tabular-nums; }
.funnel__lost { font: 400 11.5px var(--mono); color: var(--mark-inside); text-align: right; }
.funnel__note {
  grid-column: 1 / -1;
  margin-top: -2px;
  font-size: 11.5px;
  color: var(--paper-faint);
}
@media (max-width: 720px) {
  .funnel__row { grid-template-columns: 1fr 52px 56px; }
  .funnel__bar { grid-column: 1 / -1; order: 3; }
  .funnel__lost { grid-column: 1 / -1; order: 4; text-align: left; }
}

/* ------------------------------------------------------------ the money */

.payer { margin-bottom: 12px; padding: 0; overflow: hidden; }
.payer__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-600);
}
.payer__who { font: 600 14px var(--mono); }
.payer__bought { font-size: 12.5px; color: var(--paper-dim); }
.payer__unspent {
  margin-left: auto;
  font: 600 12.5px var(--mono);
  color: var(--mark-boundary);
}
.payer__spent { margin-left: auto; font-size: 12.5px; color: var(--paper-faint); }

/* -------------------------------------------------------- the conditions */

table.conds td.cond__note { white-space: normal; min-width: 260px;
                            font-family: var(--body); font-size: 12.5px; }
tr.cond--blocking td.reason { color: var(--mark-inside); font-weight: 600; }

.unknowns { display: grid; gap: 10px; }
.unknown {
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-left: 2px solid var(--mark-eye);
  border-radius: var(--r-sm);
  padding: 11px 14px;
}
.unknown__head {
  margin: 0 0 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--paper-dim);
}
.unknown__when { margin-left: auto; color: var(--paper-faint); }
.unknown__line {
  margin: 0;
  font: 400 11.5px/1.6 var(--mono);
  color: var(--paper);
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------- stuck cards */

.stuckcard { padding: 16px 18px; }
.stuckcard--loud { border-color: var(--line-2); box-shadow: inset 2px 0 0 var(--mark-boundary); }
.stuckcard__n {
  margin: 6px 0 0;
  font: 600 28px/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.stuckcard__blurb { margin: 8px 0 12px; font-size: 12px; line-height: 1.5; color: var(--paper-faint); }
.stuckcard__row {
  margin: 0 0 4px;
  display: flex;
  gap: 9px;
  font: 400 11.5px var(--mono);
  color: var(--paper-dim);
}
.stuckcard__file { margin-left: auto; overflow-wrap: anywhere; text-align: right; }
.stuckcard__more { margin: 6px 0 0; font-size: 11.5px; color: var(--paper-faint); }

/* ---------------------------------------------------------- the people */

.people { display: grid; gap: 10px; }
.person {
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 16px;
}
.person--pays { border-color: var(--mark-lower); }
.person__head {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--paper-dim);
}
.person__who { font: 600 13px var(--mono); color: var(--paper); }
.person__n { margin-left: auto; font: 400 11.5px var(--mono); color: var(--paper-faint); }
.person__empty { margin: 8px 0 0; font-size: 12.5px; color: var(--paper-faint); }

.jobline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}
.jobline__id { font-size: 11.5px; color: var(--paper-faint); }
.jobline__name { color: var(--paper-dim); overflow-wrap: anywhere; }
.jobline__marks { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--ink-800);
  font: 500 10.5px/1.5 var(--mono);
  color: var(--paper-dim);
  white-space: nowrap;
}
.tag--bad  { border-color: var(--mark-inside); color: var(--mark-inside); }
.tag--good { border-color: var(--mark-lower); color: var(--mark-lower); }
.tag--pays { border-color: var(--mark-lower); background: var(--mark-lower); color: var(--ink-900); }

/* a rung that does not nest in the one above has no drop-off to report */
.funnel__row--last .funnel__lost { color: var(--paper-faint); }

/* stuck-card rows are three fields in a narrow column: let the filename take
 * what is left and clip, rather than breaking "BigBossAnimation.glb" across
 * two lines mid-word */
.cards.grid-3 { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
.stuckcard__row > span { white-space: nowrap; }
.stuckcard__file {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
}

/* the payer ledger mixes purchases with jobs, so the columns need pinning or
 * each row sets its own and nothing lines up down the card */
.payer table.ledger td:first-child { width: 120px; }
.payer table.ledger td.reason { width: 40%; white-space: normal; }
.payer table.ledger td:nth-child(3) { width: 110px; }

/* ------------------------------------------------- one job, from three sides
 *
 * The staff autopsy page (/ops/jobs/<id>/). Three plates side by side, in the
 * order the question is always asked: what riggle showed them, what they marked
 * on it, what came out. They are the same construction as the customer's
 * .plate - a square stage with the media taken out of flow - because they are
 * the same pictures, and a render that looks different here than it does to the
 * person who is complaining about it is worse than no page at all.
 */

.autopsy {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.plate-fig {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--ink-850);
  padding: 12px;
  min-width: 0;
}
.plate-fig__title {
  margin: 0 0 9px;
  font: 500 10px/1.5 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--paper-faint);
}

/* the stage: square, dark, media absolutely placed. See .plate__stage - a
 * child sized 100% in normal flow beats the aspect-ratio and squares the frame */
.plate-fig__img,
.plate-fig__stack,
.plate-fig__empty {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: radial-gradient(ellipse 62% 52% at 50% 42%, #292338 0%, #14111C 72%);
  object-fit: contain;
}
.plate-fig__stack > img,
.plate-fig__over {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
/* the overlay shares the image's box and its aspect ratio, so a point at
 * (512, 775) of the render lands on the same pixel of the picture */
.plate-fig__over { pointer-events: none; }
.plate-fig__over circle { pointer-events: auto; }

.plate-fig__empty {
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  font: 500 12px/1.5 var(--mono);
  color: var(--paper-faint);
  border: 1px dashed var(--line-2);
}

.plate-fig__cap {
  margin: 9px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--paper-faint);
  overflow-wrap: anywhere;
}
.plate-fig__cap--bad { color: var(--mark-inside); }

/* every expression the validator rendered, small - this is a contact sheet,
 * scanned for the one frame that is wrong, not looked at one plate at a time */
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin: 8px 0 20px;
}
.shot { margin: 0; }
.shot img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink-800);
}
.shot figcaption {
  margin-top: 5px;
  font: 500 10px/1.4 var(--mono);
  color: var(--paper-faint);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* a traceback is read, not skimmed: keep the newlines, keep it selectable, and
 * let it scroll in its own box rather than setting the page's width */
.autopsy__pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mark-inside);
  border-radius: var(--r-md);
  font: 400 12px/1.6 var(--mono);
  color: var(--paper-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 340px;
  overflow: auto;
}

/* key/value ledgers - metrics and the row. Left to itself a two-column table
 * at width:100% puts the key at one edge of the page and its value at the
 * other, which is a reading exercise, not a table. */
table.ledger--kv td:first-child { width: 220px; }
table.ledger--kv td.reason { white-space: normal; overflow-wrap: anywhere; }
