@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* night */
  --ground: #120f2a;
  --panel: #0b0a1f;
  --panel-2: #1a1638;
  --line: #2c2858;
  --text: #eeecf7;
  --text-dim: #b0b2cf;
  --text-faint: #8a8db3;
  /* light: each colour has one meaning */
  --lantern: #f4b04a;       /* watching / live */
  --lantern-ink: #241603;
  --ember: #ff6a52;         /* movement */
  --brass: #d6c29b;         /* owner controls */
  --glow: 0.10;
  --glow-color: 244 176 74;

  --r-sm: 8px;
  --r: 14px;
  --gap: 16px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: "Onest", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(70rem 36rem at 3rem 0, rgb(var(--glow-color) / var(--glow)), transparent 70%),
    var(--ground);
  transition: --glow 1.2s var(--ease);
  -webkit-font-smoothing: antialiased;
}
@property --glow { syntax: "<number>"; inherits: true; initial-value: 0.10; }

::selection { background: var(--text); color: var(--ground); }
* { scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
input { caret-color: var(--text); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
a { color: var(--text); text-underline-offset: 3px; }
.tnum { font-variant-numeric: tabular-nums; }

/* page states drive the lantern light */
body[data-state="live"], body[data-state="motion"] { --glow: 0.22; }
body[data-state="motion"] { --glow-color: 255 106 82; }
body[data-flare] { --glow: 0.38; }

/* ---------- lantern mark ---------- */
.lamp { width: 22px; height: 26px; flex: none; }
.lamp .frame { fill: none; stroke: var(--brass); stroke-width: 1.5; stroke-linejoin: round; }
.lamp .flame { fill: var(--text-faint); transition: fill .6s var(--ease); }
body[data-state="live"] .lamp .flame { fill: var(--lantern); }
body[data-state="motion"] .lamp .flame { fill: var(--ember); animation: flicker 1s var(--ease) 3; }
@keyframes flicker { 50% { opacity: .55; } }

/* ---------- buttons & inputs ---------- */
button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
  transition: background .2s, border-color .2s, opacity .2s;
}
button:hover:not(:disabled) { background: #221d47; border-color: #3d3874; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button[aria-pressed="true"]:disabled { opacity: .7; }
button.primary {
  background: var(--text);
  color: var(--ground);
  border-color: transparent;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: #fff; }
button.quiet { background: transparent; border-color: transparent; color: var(--text-dim); }
button.quiet:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
button[aria-pressed="true"] { background: #2c2a3a; border-color: var(--brass); color: var(--brass); }
svg.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
input[type="text"], input[type="password"] {
  font: inherit;
  font-size: 16px; /* no zoom on iOS */
  color: var(--text);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  min-height: 46px;
  padding: 0 14px;
  transition: border-color .2s;
}
input:hover { border-color: #3d3874; }
input:focus-visible { outline: 2px solid var(--text-dim); outline-offset: 1px; border-color: var(--text-dim); }
input::placeholder { color: var(--text-faint); }

/* ---------- app shell ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px clamp(16px, 3vw, 32px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: -0.01em; }
.status { color: var(--text-dim); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.status strong { color: var(--text); font-weight: 600; }
body[data-state="live"] .status strong { color: var(--lantern); }
body[data-state="motion"] .status strong { color: var(--ember); }
.account { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 14px; }
.account .who { padding-right: 4px; }
.role { font-size: 12px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; white-space: nowrap; }
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; row-gap: 4px; padding-bottom: 10px; }
  .status { order: 3; width: 100%; }
  .account .who { display: none; }
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  padding: 4px clamp(16px, 3vw, 32px) 32px;
  max-width: 1480px;
  margin: 0 auto;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

/* ---------- video ---------- */
.stage {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  background: #05060d;
  aspect-ratio: var(--ar, 4 / 3);
  width: min(100%, calc((100dvh - 150px) * var(--ar, 4 / 3)));
  margin-inline: auto;
  box-shadow: 0 18px 50px -20px rgb(0 0 0 / .7), 0 0 0 1px var(--line);
}
.stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.snap {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 6px;
  color: #fff; font-size: 13px; text-decoration: none;
  background: rgb(8 10 22 / .62); backdrop-filter: blur(6px);
  padding: 7px 12px; border-radius: 99px; min-height: 34px;
}
.snap:hover { background: rgb(8 10 22 / .8); }
.snap .icon { width: 16px; height: 16px; }
.overlay .dim { color: rgb(255 255 255 / .7); }
.seg.two { grid-template-columns: repeat(2, 1fr); }
.panel h3 small { color: var(--text-faint); font-weight: 400; margin-left: 6px; }
.box {
  position: absolute;
  border: 2px solid var(--ember);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgb(0 0 0 / .45);
  display: none;
  pointer-events: none;
  transition: left .35s var(--ease), top .35s var(--ease), width .35s var(--ease), height .35s var(--ease);
}
.overlay {
  position: absolute; left: 14px; bottom: 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: #fff;
  background: rgb(8 10 22 / .62);
  padding: 6px 10px; border-radius: 99px;
  backdrop-filter: blur(6px);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
body[data-state="live"] .dot { background: var(--lantern); }
body[data-state="motion"] .dot { background: var(--ember); }
.veil {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: 6px; text-align: center;
  color: var(--text-dim); font-size: 14px;
  background: radial-gradient(30rem 16rem at 50% 50%, #12162c, #05060d);
}
.veil strong { color: var(--text); font-size: 17px; font-weight: 600; }
.veil[hidden] { display: none; }
.note { color: var(--text-faint); font-size: 13px; margin: 10px 2px 0; min-height: 1.4em; }
.note.err { color: var(--ember); }

/* ---------- side rail ---------- */
.rail { display: grid; gap: 20px; align-content: start; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
}
.panel h2, .ledger h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; display: flex; justify-content: space-between; align-items: baseline; }
.panel h2 small, .ledger h2 small { font-weight: 400; color: var(--text-faint); font-size: 13px; }
.panel h3 { margin: 14px 0 8px; font-size: 13px; font-weight: 500; color: var(--text-dim); }
.controls { border-color: #3a3346; }
.role.owner { color: var(--brass); border-color: #4a4436; }
.controls button { border-color: #4a4436; }
.controls svg.icon { color: var(--brass); }
.controls button:hover:not(:disabled) { background: #241f2a; border-color: var(--brass); }
.controls h2 { color: var(--brass); }

.pad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 48px); gap: 4px; justify-content: center; }
.pad button { padding: 0; display: grid; place-items: center; min-height: 0; }
.pad .home { color: var(--brass); }
.hint { text-align: center; font-size: 12px; color: var(--text-faint); margin: 8px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 6px; }
.row.presets button { min-width: 44px; padding: 0; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: #2c2a3a; color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.check input { appearance: none; margin: 0; width: 18px; height: 18px; border: 1px solid #4a4436; border-radius: 4px; background: var(--ground); display: grid; place-content: center; }
.check input:checked { background: var(--brass); border-color: var(--brass); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--ground); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.danger { margin-top: 18px; width: 100%; color: var(--text-dim); }

/* round log */
.round { list-style: none; margin: 0; padding: 0; }
.round li {
  display: grid; grid-template-columns: 86px 1fr auto; gap: 10px; align-items: baseline;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px;
  transition: opacity .4s;
}
.round li:first-child { border-top: 0; padding-top: 0; }
.round time { color: var(--text); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }
.round .what { color: var(--text-dim); }
.round .dur { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 13px; }
.round li.now .what { color: var(--ember); font-weight: 600; }
.round li.now time { color: var(--ember); }
.round li.stamp { animation: stamp .9s var(--ease); }
@keyframes stamp { from { opacity: 0; filter: blur(3px); transform: scale(1.04); } }
.round .empty { display: block; color: var(--text-faint); border: 0; padding: 4px 0; }

/* ---------- auth pages: the lantern at the gate ---------- */
.auth { min-height: 100dvh; --glow: 0.05; }
.gate { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(400px, .8fr); }

/* the night scene */
.night {
  position: relative; overflow: hidden;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  padding: 48px 32px;
  background: linear-gradient(180deg, #0f0c25 0%, #120f2a 55%, #0a0819 100%);
}
.night::before {  /* the pool of lantern light */
  content: ""; position: absolute; left: 50%; top: 38%;
  width: 70rem; height: 70rem; translate: -50% -50%;
  background: radial-gradient(closest-side, rgb(244 176 74 / .26), rgb(244 176 74 / .09) 40%, transparent 72%);
  opacity: .55; scale: .85;
  transition: opacity 1.4s var(--ease), scale 1.4s var(--ease);
  animation: breathe 7s ease-in-out infinite;
  pointer-events: none;
}
.auth.warm .night::before { opacity: .8; scale: .95; }
.auth.lit .night::before { opacity: 1; scale: 1.15; }
@keyframes breathe { 50% { filter: brightness(1.12); } }
.night > * { position: relative; }
.lantern { width: clamp(120px, 13vw, 168px); height: auto; overflow: visible; }
.lantern .metal { fill: none; stroke: var(--brass); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lantern .pane { fill: rgb(214 194 155 / .05); stroke: var(--brass); stroke-width: 2; }
.lantern .post { stroke: var(--brass); stroke-width: 1; opacity: .45; }
.lantern .flame { fill: #5b4a33; transform-origin: 60px 104px; scale: .7; transition: fill 1s var(--ease), scale 1s var(--ease); }
.lantern .core { fill: #3b3026; transform-origin: 60px 104px; scale: .7; transition: fill 1s var(--ease), scale 1s var(--ease); }
.auth.warm .lantern .flame { fill: #c98a37; scale: .85; }
.auth.warm .lantern .core { fill: #e9c07a; scale: .85; }
.auth.lit .lantern .flame { fill: var(--lantern); scale: 1.05; }
.auth.lit .lantern .core { fill: #fff1d2; scale: 1.05; }
.auth.flicker .lantern .flame { animation: gutter .5s var(--ease) 2; }
@keyframes gutter { 40% { scale: .45; fill: var(--ember); } }
.night .clock { font-size: clamp(48px, 6vw, 84px); font-weight: 500; letter-spacing: -0.03em; line-height: 1; margin-top: 22px; font-variant-numeric: tabular-nums; }
.night .greet { color: var(--text-dim); font-size: 16px; margin: 0; }
.night .credit { position: absolute; left: 32px; top: 28px; display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; }

/* the form sheet */
.sheet {
  display: grid; align-content: center;
  padding: 48px clamp(28px, 5vw, 72px);
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.sheet .inner { width: min(380px, 100%); margin: 0 auto; }
.sheet h1 { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 8px; text-wrap: balance; }
.sheet .lede { color: var(--text-dim); margin: 0 0 32px; }
.sheet form { display: grid; gap: 18px; }
.sheet .field input { background: #07061a; }
.sheet .code { letter-spacing: .06em; }
.pw { position: relative; }
.pw input { width: 100%; padding-right: 72px; }
.pw .reveal { position: absolute; right: 6px; top: 50%; translate: 0 -50%; min-height: 34px; padding: 0 10px; font-size: 13px; }
.pw .reveal[aria-pressed="true"] { background: transparent; border-color: transparent; color: var(--text); }
.sheet .help { font-size: 12px; color: var(--text-faint); }
.sheet .caps { font-size: 12px; color: var(--lantern); }
.sheet .err { color: var(--ember); font-size: 14px; min-height: 1.4em; margin: -4px 0 -6px; }
.sheet button.primary { min-height: 52px; font-size: 16px; }
.sheet .alt { margin: 26px 0 0; color: var(--text-dim); font-size: 14px; }
.sheet .meta { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 12px; }
.sheet .meta svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.sheet .mobile-brand { display: none; }

@media (max-width: 900px) {
  .gate { grid-template-columns: 1fr; }
  .night { min-height: 300px; padding: 36px 20px 28px; }
  .night .credit { display: none; }
  .night .clock { font-size: 44px; margin-top: 12px; }
  .lantern { width: 96px; }
  .sheet { border-left: 0; border-top: 1px solid var(--line); padding: 32px 20px 40px; align-content: start; }
  .sheet .mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 18px; color: var(--text-dim); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.ledger { border-top: 1px solid var(--line); padding: 16px 18px 0; }
/* the lantern's light catches the top rim of the picture (painted above the video) */
.stage::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 1px 0 rgb(var(--glow-color) / calc(var(--glow) * 2)); }
/* disabled controls keep their brass family, just quieter */
.controls button:disabled { opacity: 1; color: var(--text-faint); }
.controls button:disabled svg.icon { opacity: .55; }
.controls .note { margin: -6px 0 12px; }

/* members have no Camera panel to align with: the ledger meets the video edge */
.rail:has(#controls[hidden]) .ledger { padding-inline: 0; }
