@import url('./fonts/slate-fonts.css');

:root {
  color-scheme: dark;
  --bg: #17191c;
  --panel: #22252a;
  --line: #50555e;
  --ink: #f4f5f7;
  --muted: #b5bdc9;
  --accent: #dce7f5;
  --action-ink: #171b21;
  --plate-bg: #111316;
  --plate-ink: #f9fafc;
  --rule: #707883;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edeff2;
  --panel: #fff;
  --line: #aeb5bf;
  --ink: #191d23;
  --muted: #515b69;
  --accent: #253346;
  --action-ink: #fff;
  --plate-bg: #fff;
  --plate-ink: #111316;
  --rule: #8993a1;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, .themes label { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .episode-input:focus-within, .themes input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.editor {
  --editor-mono: "Reddit Mono", ui-monospace, monospace;
  --editor-orange: #f47b20;
  --editor-teal: #77c9bc;
  --editor-gold: #e2ac54;
  --editor-field: #191b1f;
  max-width: 1120px;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  font-family: "Reddit Sans Condensed", system-ui, sans-serif;
}
[data-theme="light"] .editor {
  --editor-teal: #246f65;
  --editor-field: #fafaf9;
}
.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 14px;
  padding: 0 0 16px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: clamp(12px, 3vw, 24px); min-width: 0; }
.editor-logo { display: block; width: clamp(78px, 19vw, 136px); height: auto; flex: none; }
.editor h1 {
  margin: 0;
  padding-inline-start: clamp(11px, 2.5vw, 22px);
  border-inline-start: 1px solid var(--line);
  font-size: clamp(1.8rem, 6vw, 3.25rem);
  line-height: 1;
  letter-spacing: -.025em;
  text-transform: uppercase;
  font-family: "Anton", "Reddit Sans Condensed", sans-serif;
  font-weight: 400;
}
.editor-toolbar { display: grid; justify-items: end; gap: 7px; }
#offline { color: var(--muted); font: 600 .875rem/1.25 var(--editor-mono); }
#offline.ready { color: var(--editor-teal); }
.themes {
  display: flex;
  gap: 0;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}
.themes label { position: relative; }
.themes label + label { border-inline-start: 1px solid var(--line); }
.themes input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.themes span { display: grid; place-items: center; width: 36px; height: 36px; }
.themes svg { width: 19px; height: 19px; }
.themes input:checked + span { background: var(--editor-gold); color: #1c160c; }
.workspace { display: grid; gap: 16px; }
#form { display: grid; gap: 16px; align-content: start; min-width: 0; }
.editor-panel {
  display: grid;
  gap: 13px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.editor-panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--editor-teal);
  font: 800 .875rem/1.2 var(--editor-mono);
  letter-spacing: .035em;
  text-transform: uppercase;
}
.editor-panel h2::after { content: ""; flex: 1; height: 2px; background: currentColor; }
.crew-fields, .shoot-fields { display: grid; gap: 12px; grid-template-columns: minmax(90px, .65fr) minmax(0, 1.35fr); }
.crew-fields { grid-template-columns: minmax(104px, 1fr) minmax(0, 1.15fr); }
.editor label { display: block; font-weight: 750; font-size: .9375rem; }
.editor input:not([type="radio"]), .editor textarea, .editor select, .episode-input {
  width: 100%;
  min-height: 44px;
  display: block;
  margin-top: 5px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--editor-field);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
}
.editor :is(input, textarea)::placeholder, .optional { color: var(--muted); opacity: 1; }
#camera, .extra-camera-id, #episode, #code, .episode-input { font-family: var(--editor-mono); }
.editor :is(button, input, textarea, select):focus-visible,
.editor .episode-input:focus-within,
.editor .themes input:focus-visible + span { outline-color: var(--editor-teal); }
.optional { margin-inline-start: .25em; font-size: .875rem; font-weight: 500; }
textarea { resize: vertical; }
#custom-unit-field[hidden], #camera-color-field[hidden], .extra-camera-color[hidden] { display: none; }
.camera-controls { display: flex; align-items: center; gap: 4px; }
#camera-limit { margin: 0; color: var(--muted); font-size: .875rem; }
.editor .common-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; cursor: pointer; }
.editor .common-toggle input { width: 18px; min-height: 0; height: 18px; margin: 0; padding: 0; accent-color: var(--editor-teal); }
#extra-cameras { display: grid; gap: 8px; }
.extra-camera { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.extra-camera-color { grid-row: 2; grid-column: 1 / -1; }
.extra-camera > button { grid-row: 1; grid-column: 2; }
.camera-button { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); background: var(--editor-field); color: var(--ink); font-weight: 750; }
#add-camera, #camera-limit { margin-top: 9px; }
.help-field { position: relative; min-width: 0; }
.field-name { display: flex; align-items: center; flex-wrap: wrap; min-height: 32px; }
.help-field:has(> .help-button) .field-name { padding-inline-end: 32px; }
.help-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: inherit; }
.help-field > .help-button { position: absolute; top: 0; right: 0; width: 32px; height: 32px; }
.help-button > span { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid currentColor; border-radius: 50%; font: 750 13px/1 "Reddit Mono", monospace; }
.editor .help-button { color: var(--editor-teal); }
.field-help {
  width: min(410px, calc(100% - 36px));
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 4px solid #4da698;
  background: var(--panel);
  color: var(--ink);
  font-family: "Reddit Sans Condensed", system-ui, sans-serif;
}
.install-help { max-height: calc(100% - 32px); overflow: auto; overscroll-behavior: contain; }
.install-help img { display: block; width: 88px; height: auto; margin-bottom: 14px; }
.install-help ol { margin: 12px 0 16px; padding-inline-start: 23px; }
.install-help li { padding-inline-start: 3px; }
.install-help li + li { margin-top: 6px; }
.field-help::backdrop { background: #0009; }
.field-help h2 { margin: 0; font: 800 1rem/1.3 "Reddit Mono", monospace; text-transform: uppercase; }
.field-help p { margin: 12px 0; }
#help-example { padding: 9px 10px; border-inline-start: 3px solid #e2ac54; background: var(--bg); }
.field-help button { width: 100%; min-height: 44px; border: 0; background: #f47b20; color: #201207; font-weight: 800; }
.select-control { position: relative; display: block; }
.select-control select { appearance: none; padding-inline-end: 28px; }
.camera-color-control select { padding-inline-start: 38px; }
.select-control::after {
  content: "";
  position: absolute;
  right: 14px;
  top: calc(50% - 5px);
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
#camera-color-swatch {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #6b6e66;
  background: var(--camera-color, #c9cbd2);
  transform: translateY(-50%);
  pointer-events: none;
}
.episode-input { display: flex; align-items: center; padding: 0 0 0 11px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.episode-input #episode {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding-inline-start: 0;
  appearance: none;
  background: transparent;
  border: 0;
  outline: none;
  font-variant-numeric: inherit;
}
#preview { aspect-ratio: 16 / 9; outline: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.actions { position: sticky; bottom: 0; padding: 12px 0 max(6px, env(safe-area-inset-bottom)); background: var(--bg); margin-top: 5px; }
.show { min-height: 52px; width: 100%; background: var(--editor-orange); color: #201207; border: 0; border-radius: 2px; font: 850 1.0625rem/1 var(--editor-mono); text-transform: uppercase; }
.actions p { text-align: center; margin: 6px 0 0; color: var(--muted); font-size: .875rem; }
@media (max-width: 530px) {
  .editor-toolbar { display: contents; }
  .themes { grid-column: 2; grid-row: 1; justify-self: end; }
  #offline { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
}
@media (min-width: 760px) {
  .editor { padding-inline: 28px; }
  .workspace { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; }
  .actions { position: static; max-width: 440px; }
}
#slate {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
}
:root:fullscreen #slate { height: 100%; }
#board {
  container-type: size;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding-block: max(8px, env(safe-area-inset-top), env(safe-area-inset-bottom));
  padding-inline: max(8px, env(safe-area-inset-left), env(safe-area-inset-right));
  border: 0;
  background: #000;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
#board:focus { outline: none; }
body:has(dialog[open]) { overflow: hidden; }
/* The slate face uses board-relative units so the preview and camera view share a layout. */
.plate {
  --board: #fff;
  --ink-on-board: #080808;
  --ghost: #ebebeb;
  --mono: "Reddit Mono", ui-monospace, monospace;
  --condensed: "Reddit Sans Condensed", "Arial Narrow", sans-serif;
  --credit: "Anton", "Arial Narrow", sans-serif;
  container-type: size;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--board);
  color: var(--ink-on-board);
  font: 800 1rem/1 var(--mono);
  font-variant-numeric: tabular-nums slashed-zero;
  text-transform: uppercase;
}
[data-theme="dark"] .plate { --board: #111214; --ink-on-board: #f7f7f7; --ghost: #252629; }
#board .plate {
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
}
.slate-sticks {
  position: relative;
  height: 3.65cqh;
  overflow: hidden;
  background: #232021;
}
.slate-sticks::before {
  content: "";
  position: absolute;
  inset: 0 8% 0 24%;
  transform: skewX(-44deg);
  background: linear-gradient(90deg, #08732f 0 12.5%, #ebc612 12.5% 25%, #084aab 25% 37.5%, #c31220 37.5% 50%, #dedfe1 50% 62.5%, #a3a4a4 62.5% 75%, #6f7070 75% 87.5%, #403936 87.5%);
}
.slate-face {
  position: relative;
  isolation: isolate;
  display: grid;
  height: 96.35cqh;
  padding: 1.35cqh 2.45cqw 1.5cqh;
  grid-template-rows: 5fr 30fr 5fr 12fr .85fr 34fr 5fr;
  gap: .7cqh;
}
.watermark {
  position: absolute;
  z-index: -1;
  inset: 14% 2.4% 13%;
  display: grid;
  place-items: center;
  color: var(--ghost);
  font: 900 1rem/.9 var(--condensed);
  white-space: nowrap;
  pointer-events: none;
}
.watermark span { display: block; max-width: 100%; }
.slate-ruler {
  display: flex;
  align-items: center;
  gap: 1.55cqw;
  font-size: min(2.42cqw, 4.35cqh);
  white-space: nowrap;
}
.slate-ruler-centered { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.slate-ruler-left, .slate-ruler-right { display: flex; align-items: center; gap: inherit; min-width: 0; }
.slate-ruler-centered > * { grid-row: 1; }
.slate-ruler-centered > span { grid-column: 2; }
.slate-ruler-left { grid-column: 1; }
.slate-ruler-right { grid-column: 3; }
.slate-ruler-centered:has([data-note-label][hidden]) { column-gap: 0; }
.slate-ruler-centered:has([data-note-label][hidden]) > div { column-gap: 1.55cqw; }
.slate-ruler i, .slate-divider { background: currentColor; border-radius: 100px; }
.slate-ruler i { flex: 1; height: max(1px, .82cqh); }
.slate-divider { align-self: center; height: max(1px, .82cqh); }
.identifiers, .slate-details, .slate-credits { display: grid; min-height: 0; min-width: 0; }
.identifiers { grid-template-columns: minmax(0, 39fr) minmax(0, 61fr); gap: 2cqw; }
.slate-details { grid-template-columns: minmax(0, 20fr) minmax(0, 60fr) minmax(0, 20fr); gap: 1.5cqw; }
.slate-value { display: grid; align-items: center; min-width: 0; min-height: 0; }
.slate-value > * { display: block; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.episode-value { font-weight: 900; letter-spacing: -.065em; line-height: .88; }
.scene-value { text-align: right; font: 900 1rem/.9 var(--condensed); white-space: pre-wrap; }
.action-value { text-align: center; font: 900 1rem/.92 var(--condensed); white-space: pre-wrap; }
.action-value > span { transform: translateY(calc(-1 * clamp(1px, 1cqh, 4px))); }
.camera-list { display: grid; grid-auto-rows: minmax(0, 1fr); min-width: 0; min-height: 0; gap: .25cqh .65cqw; }
.camera-list.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.camera-value, .unit-value { font-weight: 900; line-height: .94; }
.camera-value { white-space: nowrap; }
.unit-value { text-align: right; }
[data-unit="main"] { color: #313e77; }
[data-unit="second"] { color: #825800; }
[data-unit="progress"] { color: #28684e; }
[data-theme="dark"] [data-unit="main"] { color: #a8b9ff; }
[data-theme="dark"] [data-unit="second"] { color: #f0bd56; }
[data-theme="dark"] [data-unit="progress"] { color: #83d4ac; }
[data-camera-color="red"] { --camera-color: #fa5945; --camera-text: #db160d; }
[data-camera-color="blue"] { --camera-color: #67b2ff; --camera-text: #005de8; }
[data-camera-color="green"] { --camera-color: #65d77c; --camera-text: #08732f; }
[data-camera-color="yellow"] { --camera-color: #ffe056; --camera-text: #806300; }
[data-camera-color="purple"] { --camera-color: #c0a4ff; --camera-text: #7040c4; }
[data-camera-color="pink"] { --camera-color: #ff9cd8; --camera-text: #a91e68; }
[data-camera-color="orange"] { --camera-color: #ffab57; --camera-text: #a84c00; }
[data-camera-color="gray"] { --camera-color: #c9cbd2; --camera-text: #545962; }
[data-camera-color="lavender"] { --camera-color: #e1d5fa; --camera-text: #745b9a; }
[data-camera-color="magenta"] { --camera-color: #a52379; --camera-text: #a52379; --camera-text-dark: #ff84cf; }
[data-camera-color="teal"] { --camera-color: #087171; --camera-text: #087171; --camera-text-dark: #76d4d4; }
[data-camera-color="tan"] { --camera-color: #d7bd9d; --camera-text: #795d3d; }
[data-camera-color="brown"] { --camera-color: #69432e; --camera-text: #69432e; --camera-text-dark: #dc9e7d; }
[data-camera-color="charcoal"] { --camera-color: #32343a; --camera-text: #32343a; --camera-text-dark: #a5a9b2; }
[data-camera-color="white"] { --camera-color: #fff; --camera-text: #444; }
.camera-value span { color: var(--camera-text, currentColor); }
[data-theme="dark"] .camera-value span { color: var(--camera-text-dark, var(--camera-color, currentColor)); }
.slate-credits {
  grid-template-columns: minmax(0, 1fr) minmax(0, .86fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 66fr) minmax(0, 34fr);
  column-gap: 1.25cqw;
}
.credit {
  display: grid;
  align-self: center;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  height: 58%;
  font: 400 min(2.5cqw, 4.5cqh)/1 var(--credit);
  color: #4da698;
}
.credit .slate-value { color: #f47b20; line-height: 1; }
.director { grid-area: 1 / 1; }
.dp { grid-area: 1 / 3; text-align: right; }
.show-logo { grid-area: 1 / 2 / 3 / 3; place-self: center; width: 100%; height: 94%; object-fit: contain; }
.date-value { grid-area: 2 / 1; align-items: end; }
.clock-value { grid-area: 2 / 3; align-items: end; text-align: right; }
.plate [hidden] { display: none; }
