/* The join page (docs/design/WATCH-IN-YOUR-BROWSER.md "Look"): Decky's palette (Android Theme.kt), the system
   font (nothing fetched), 44-px targets, light and dark by the system's choice; Watching is always dark. */

:root {
  --ink: #1e1a33;
  --ink-2: #423c5e;
  --ink-3: #5e5878;
  --ground: #f6f3ff;
  --card: #ffffff;
  --well: #f3f0fc;
  --line: rgba(30, 26, 51, 0.12);
  --purple: #7c4dff;
  --purple-deep: #5b2fd9;
  --pink: #ff5ca8;
  --cyan: #12c6e3;
  --coral: #e85a38;
  --focus: #7c4dff;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f4f1fb;
    --ink-2: #cdc7e2;
    --ink-3: #a9a2c4;
    --ground: #15122a;
    --card: #231f3b;
    --well: #1b1832;
    --line: rgba(255, 255, 255, 0.09);
    --purple: #9d7bff;
    --purple-deep: #7c4dff;
    --coral: #ff8f73;
    --focus: #9d7bff;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 400px;
  margin-top: 6vh;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(30, 26, 51, 0.06), 0 12px 32px rgba(30, 26, 51, 0.08);
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--purple); margin-bottom: 14px; }
.brand .icon { width: 20px; height: 20px; fill: var(--purple); stroke: none; }

h1 { font-size: 24px; line-height: 1.2; margin: 0 0 2px; letter-spacing: -0.01em; }
.sub { margin: 0 0 12px; color: var(--ink-2); min-height: 1.45em; }

label { margin-top: 10px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.optional { font-weight: 400; color: var(--ink-3); }

.field {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--well);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
}
.field:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.field[readonly] { opacity: 0.7; }
.letters { text-transform: uppercase; letter-spacing: 0.18em; font-weight: 700; max-width: 9.5em; font-variant-numeric: tabular-nums; }
.digits { letter-spacing: 0.3em; font-weight: 700; font-variant-numeric: tabular-nums; max-width: 11em; }

.help { margin: 4px 0 0; font-size: 14px; color: var(--ink-3); }

button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.primary {
  margin-top: 20px;
  min-height: 50px;
  border: 0;
  border-radius: var(--radius);
  background: var(--purple);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.primary:hover:not(:disabled) { background: var(--purple-deep); }
.primary:disabled { opacity: 0.55; cursor: default; }

.secondary {
  min-height: 44px;
  margin-top: 12px;
  padding: 0 18px;
  align-self: flex-start;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}
.secondary:hover { background: var(--well); }

.outcome:empty { display: none; }
.outcome { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--coral) 10%, var(--card)); display: flex; flex-direction: column; }
.outcome-text { margin: 0; font-weight: 600; }
.outcome-hint { margin: 4px 0 0; color: var(--ink-2); font-size: 15px; }

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.waiting { display: flex; align-items: center; gap: 12px; margin: 18px 0 8px; font-size: 18px; font-weight: 600; }
.pulse { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--purple); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(0.8); opacity: 0.5; } 50% { transform: scale(1.15); opacity: 1; } }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Watching: always dark ── */

.stage { position: fixed; inset: 0; background: #000; color: #f4f1fb; display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none; }
.pictures { flex: 1; display: flex; min-height: 0; }
.pictures .picture { position: relative; flex: 1; min-width: 0; min-height: 0; }
.pictures.two { gap: 2px; }
@media (orientation: portrait) { .pictures.two { flex-direction: column; } }
.picture video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; pointer-events: none; }
.picture .ink-echo { position: absolute; pointer-events: none; }
.stage.drawing .picture { cursor: crosshair; }

.bar {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(15, 12, 31, 0.85), rgba(15, 12, 31, 0));
  transition: opacity 0.25s ease;
}
.stage.idle .bar { opacity: 0; pointer-events: none; }
.bar-text { flex: 1; min-width: 0; }
.bar-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-status { font-size: 13px; color: #cdc7e2; min-height: 1.2em; }
.bar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bar-btn, .tool, .tb-btn {
  min-height: 44px; min-width: 44px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 12px;
  background: rgba(35, 31, 59, 0.82); color: #f4f1fb; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.bar-btn:hover:not(:disabled), .tool:hover, .tb-btn:hover { background: rgba(66, 60, 94, 0.95); }
.bar-btn:disabled { opacity: 0.6; cursor: default; }
.bar-btn.leave { background: rgba(232, 90, 56, 0.9); border-color: transparent; }
@media (max-width: 760px) { .bar-btn .label, .tool .label, .tb-btn:not(.stop) .label { display: none; } .bar-btn, .tool, .tb-btn { padding: 0 10px; } }

.ink-toolbar {
  position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px;
  background: rgba(21, 18, 42, 0.92); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 18px;
  max-width: calc(100vw - 24px); overflow-x: auto;
}
.ink-toolbar .tool[aria-pressed="true"] { background: var(--purple); border-color: transparent; }
.ink-toolbar .sep { width: 1px; align-self: stretch; margin: 6px 2px; background: rgba(255, 255, 255, 0.16); }
.swatch { width: 18px; height: 18px; border-radius: 50%; margin: 0 6px 0 8px; flex: none; border: 2px solid #fff; }

.toast {
  position: absolute; left: 50%; top: 84px; transform: translate(-50%, -8px); opacity: 0;
  padding: 10px 16px; border-radius: 12px; background: rgba(35, 31, 59, 0.95); color: #f4f1fb; font-weight: 600;
  transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.shown { opacity: 1; transform: translate(-50%, 0); }

.back-soon {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: rgba(0, 0, 0, 0.55); text-align: center; padding: 24px;
}
.back-soon[hidden] { display: none; }
.back-title { font-size: 22px; font-weight: 700; }
.back-detail { color: #cdc7e2; max-width: 30em; }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .pulse, .spinner { animation: none; }
  .bar, .toast { transition: none; }
}
