/* Forecast Studio - calm, mobile-first, light and dark. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --ink: #17181b;
  --ink-2: #4b4f57;
  --muted: #80848c;
  --line: #e6e6e1;
  --accent: #5b6cff;
  --accent-ink: #ffffff;
  --accent-soft: #eceeff;
  --ok: #1a8f5a;
  --ok-soft: #e4f5ec;
  --warn: #b26a00;
  --warn-soft: #fdf1df;
  --bad: #c2362f;
  --bad-soft: #fbe7e5;
  --shadow: 0 1px 2px rgb(16 18 24 / .04), 0 8px 24px rgb(16 18 24 / .06);
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 46px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e2229;
    --ink: #eceef2;
    --ink-2: #b9bec8;
    --muted: #868c97;
    --line: #262a32;
    --accent: #8a96ff;
    --accent-ink: #0f1115;
    --accent-soft: #1f2340;
    --ok: #4fc58b;
    --ok-soft: #13271e;
    --warn: #e8a64a;
    --warn-soft: #2a2114;
    --bad: #ff8a80;
    --bad-soft: #2c1717;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 760px; margin: 0 auto; padding: 20px 16px calc(120px + env(safe-area-inset-bottom)); outline: none; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 16px; margin: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.hide { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--accent) url("icon.svg") center / cover; }
.bar-actions { display: flex; align-items: center; gap: 10px; position: relative; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--accent-soft); color: var(--accent); font-weight: 700; cursor: pointer;
}
.menu {
  position: absolute; right: 0; top: 48px; min-width: 220px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.menu a, .menu button {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.menu-who { padding: 6px 12px 10px; margin: 0 0 6px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); word-break: break-all; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-tight { padding: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }

/* ---------- forms ---------- */
label, .label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; min-height: var(--tap);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 140px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 38px; }
input[type="range"] { padding: 0; background: none; border: 0; min-height: 32px; accent-color: var(--accent); }
.code-input { font-size: 28px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 560px) { .fields-2 { grid-template-columns: 1fr 1fr; } }

/* segmented control */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; cursor: pointer; }
.switch input { appearance: none; width: 50px; height: 30px; min-height: 0; padding: 0; border-radius: 99px; background: var(--line); border: 0; position: relative; flex: none; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.switch strong { display: block; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-quiet { background: none; border-color: transparent; color: var(--ink-2); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

/* sticky action bar */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.actionbar-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.actionbar-inner .btn-primary { flex: 1; }

/* ---------- status ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-live { background: var(--accent-soft); color: var(--accent); }
.chip-live::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.mode-switch { margin-top: 12px; max-width: 320px; }
.steps { display: flex; gap: 6px; margin: 14px 0 20px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps span.done { background: var(--accent); }
.steps span.now { background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%); background-size: 200% 100%; animation: slide 1.6s linear infinite; }
@keyframes slide { from { background-position: 100% 0; } to { background-position: 0 0; } }
.step-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.working { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 16px; gap: 14px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; background: var(--surface-2); color: var(--ink-2); }
.note-warn { background: var(--warn-soft); color: var(--warn); }
.note-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- lists ---------- */
.videos { display: grid; gap: 12px; }
.video-item { display: flex; gap: 14px; align-items: center; padding: 14px; color: inherit; }
.video-item:hover { border-color: var(--muted); }
.thumb { width: 64px; height: 64px; flex: none; border-radius: 12px; background: var(--surface-2) center / cover; display: grid; place-items: center; color: var(--muted); }
.thumb svg { width: 22px; height: 22px; }
.video-item .meta { min-width: 0; flex: 1; }
.video-item h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 48px 20px; }
.empty .art { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px; background: var(--accent-soft) url("icon.svg") center / 44px no-repeat; }

/* ---------- media ---------- */
video, audio { width: 100%; display: block; }
video { border-radius: 12px; background: #000; aspect-ratio: 16 / 9; }
video.vertical { aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; width: auto; max-width: 100%; }
.script-text { white-space: pre-wrap; font-size: 17px; line-height: 1.65; }

/* scenes */
.scene { padding: 16px; }
.scene-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.scene-num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; margin-right: 8px; }
.quote { font-size: 15px; color: var(--ink-2); border-left: 3px solid var(--accent-soft); padding: 2px 0 2px 12px; margin: 0 0 12px; }
details { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 12px; }
summary { cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 36px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 20px; color: var(--muted); }
details[open] summary::after { content: "−"; }
details > *:not(summary) { margin-top: 10px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--surface-2); cursor: pointer; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo[aria-pressed="true"] { border-color: var(--accent); }
.photo[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: grid; place-items: center; font-weight: 700; }
.photo-row { display: flex; gap: 6px; }
.photo-row img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }

.join { display: flex; align-items: center; gap: 12px; margin: 10px 4px; }
.join::before { content: ""; width: 2px; align-self: stretch; min-height: 30px; background: var(--line); border-radius: 2px; margin-left: 13px; }
.join select { width: auto; flex: 1; min-height: 40px; padding-top: 8px; padding-bottom: 8px; font-size: 15px; }
.join .muted { white-space: nowrap; }

.takes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.takes button { min-height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.takes button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth .brand { justify-content: center; font-size: 20px; margin-bottom: 26px; }
.auth .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.qr { width: 200px; height: 200px; margin: 6px auto; display: block; background: #fff; border-radius: 12px; padding: 8px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: .06em; text-align: center; word-break: break-all; background: var(--surface-2); padding: 10px; border-radius: 10px; user-select: all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 15px; }
.codes span { background: var(--surface-2); border-radius: 8px; padding: 8px; text-align: center; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  max-width: min(520px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 15px; box-shadow: var(--shadow);
}
#toast.bad { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
