/* Galeana Cams — design tokens + components. Light/dark via [data-theme] or system. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --card2: #faf9f7;
  --ink: #1b1a18;
  --muted: #75716b;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e4f5f2;
  --line: #e8e6e2;
  --danger: #b91c1c;
  --shadow: 0 1px 3px rgb(28 25 23 / .07), 0 4px 16px rgb(28 25 23 / .05);
  --radius: 18px;
  --skeleton: linear-gradient(100deg, #ebe9e5 40%, #f5f3ef 50%, #ebe9e5 60%);
}
[data-theme="dark"] {
  --bg: #101413;
  --card: #1a201e;
  --card2: #171d1b;
  --ink: #eeece8;
  --muted: #98a29e;
  --accent: #34c3b0;
  --accent-ink: #06211d;
  --accent-soft: #14332f;
  --line: #262e2b;
  --danger: #f87171;
  --shadow: 0 1px 3px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  --skeleton: linear-gradient(100deg, #1c2321 40%, #232b28 50%, #1c2321 60%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101413;
    --card: #1a201e;
    --card2: #171d1b;
    --ink: #eeece8;
    --muted: #98a29e;
    --accent: #34c3b0;
    --accent-ink: #06211d;
    --accent-soft: #14332f;
    --line: #262e2b;
    --danger: #f87171;
    --shadow: 0 1px 3px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
    --skeleton: linear-gradient(100deg, #1c2321 40%, #232b28 50%, #1c2321 60%);
  }
}

html { font-size: 17px; }
html[data-text="large"] { font-size: 20px; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; display: flex; flex-direction: column; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
header .logo { width: 22px; height: 22px; color: var(--accent); }
.status { display: flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.ok { color: var(--accent); }
.status.ok .dot { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.status.err { color: var(--danger); }
.status.err .dot { background: var(--danger); }

main { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 24px; -webkit-overflow-scrolling: touch; }

/* ---------- skeletons ---------- */
.skel { border-radius: var(--radius); background: var(--skeleton); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -80% 0; } }

/* ---------- cameras ---------- */
.cam-grid { display: grid; gap: 16px; grid-template-columns: 1fr; max-width: 900px; margin: 0 auto; }
@media (min-width: 700px) { .cam-grid { grid-template-columns: 1fr 1fr; } }
.cam-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left; padding: 0; display: block; width: 100%;
  transition: transform .12s ease;
}
.cam-card:active { transform: scale(.985); }
.cam-card .frame { position: relative; }
.cam-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: var(--card2); }
.cam-card .frame::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgb(0 0 0 / .38), transparent 42%);
}
.cam-card .cam-label {
  position: absolute; left: 14px; bottom: 10px; z-index: 1;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  text-shadow: 0 1px 6px rgb(0 0 0 / .5);
}
.cam-card .cam-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; color: var(--muted); font-size: .85rem;
}
.cam-card .cam-foot svg { width: 17px; height: 17px; }

/* ---------- activity ---------- */
.filters { max-width: 900px; margin: 0 auto 14px; display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .92rem;
  cursor: pointer;
  min-height: 40px;
}
.chip.sel { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

.event-list { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.day-head { font-size: .85rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 10px 2px 0; }
.event-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  text-align: left; width: 100%;
}
.event-card:active { transform: scale(.99); }
.event-card img { width: 122px; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; background: var(--card2); flex-shrink: 0; }
.event-card .ev-what { font-weight: 700; font-size: 1.02rem; }
.event-card .ev-where { color: var(--muted); margin-top: 2px; font-size: .92rem; }
.event-card .ev-when { color: var(--accent); font-weight: 700; margin-top: 6px; font-size: .92rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; font-size: 1rem; line-height: 1.5; }

/* ---------- tab bar ---------- */
nav {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  border: 0; background: none;
  padding: 10px 0 8px;
  font-size: .78rem; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  position: relative;
  min-height: 54px;
}
.tab svg { width: 24px; height: 24px; }
.tab.sel { color: var(--accent); }
.badge {
  position: absolute; top: 5px; right: calc(50% - 32px);
  background: #dc2626; color: #fff;
  font-size: .68rem; font-weight: 700;
  border-radius: 999px; padding: 2px 7px;
}

/* ---------- buttons ---------- */
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 14px;
  padding: 14px 26px; font-size: 1rem; font-weight: 700;
  cursor: pointer; min-height: 48px;
}
.btn-primary:disabled { opacity: .55; }
.btn-ghost {
  background: none; border: 0; color: var(--muted);
  padding: 14px 18px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.btn-pill {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent-ink); background: var(--accent);
  text-decoration: none; font-weight: 700;
  padding: 12px 20px; border-radius: 999px; font-size: .95rem;
  border: 0; cursor: pointer;
}
.btn-pill.alt { background: rgb(255 255 255 / .14); color: #fff; }
.btn-pill svg { width: 18px; height: 18px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: #0b0a09; display: flex; flex-direction: column; }
.overlay-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 16px; color: #fff; font-weight: 600; font-size: 1.05rem;
  padding-top: max(12px, env(safe-area-inset-top));
}
.ov-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ov-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-pill {
  background: #dc2626; color: #fff; font-size: .68rem; font-weight: 800;
  letter-spacing: .06em; border-radius: 6px; padding: 3px 7px; flex-shrink: 0;
  animation: livepulse 2s infinite;
}
@keyframes livepulse { 50% { opacity: .55; } }
.btn-close {
  background: rgb(255 255 255 / .14); color: #fff;
  border: 0; border-radius: 50%;
  width: 42px; height: 42px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-close svg { width: 20px; height: 20px; }
.overlay-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 8px; min-height: 0;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.overlay-body video, .overlay-body img, .overlay-body video-stream {
  max-width: 100%; max-height: 100%; width: 100%; border-radius: 8px;
}
video-stream { display: block; flex: 1; min-height: 0; }
video-stream .info { display: none; } /* hide go2rtc debug mode label */
.player-stage { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.player-stage video, .player-stage img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.player-note { color: #d6d3d1; font-size: .9rem; text-align: center; padding: 0 20px; }
.player-actions { display: flex; gap: 12px; }

/* ---------- gates (login / onboarding) ---------- */
.gate {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 34px 28px;
  display: flex; flex-direction: column; gap: 16px; text-align: center;
}
.gate-icon {
  width: 64px; height: 64px; margin: 0 auto;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 20px; display: flex; align-items: center; justify-content: center;
}
.gate-icon svg { width: 32px; height: 32px; }
.gate-card h2 { font-size: 1.4rem; letter-spacing: -.01em; }
.gate-sub { color: var(--muted); font-size: .95rem; line-height: 1.5; }
.pw-wrap { position: relative; }
.pw-wrap input {
  width: 100%; padding: 14px 52px 14px 16px;
  font-size: 1.05rem; color: var(--ink);
  background: var(--card2); border: 1.5px solid var(--line); border-radius: 14px;
}
.pw-wrap input:focus { border-color: var(--accent); outline: none; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
}
.pw-eye svg { width: 21px; height: 21px; }
.gate-err { color: var(--danger); font-size: .9rem; font-weight: 600; }

/* ---------- onboarding ---------- */
.ob-card {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  max-height: 100%;
}
.ob-body { padding: 34px 28px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.ob-body h2 { font-size: 1.35rem; letter-spacing: -.01em; }
.ob-body p { color: var(--muted); font-size: .97rem; line-height: 1.55; }
.ob-emoji { font-size: 3rem; line-height: 1; }
.ob-foot { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 20px; gap: 10px; }
.ob-dots { display: flex; gap: 7px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.ob-dots i.on { background: var(--accent); }
.ob-lang { display: flex; gap: 12px; justify-content: center; }
.ob-lang button {
  flex: 1; max-width: 150px; padding: 16px 10px; border-radius: 16px;
  border: 1.5px solid var(--line); background: var(--card2);
  font-size: 1rem; font-weight: 700; cursor: pointer;
}
.ob-lang button.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ob-steps { text-align: left; display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.ob-step { display: flex; gap: 12px; align-items: flex-start; }
.ob-step .n {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: .85rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.ob-step div { font-size: .95rem; line-height: 1.5; }
.ob-step small { color: var(--muted); }
.topic-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--card2); border: 1.5px dashed var(--line); border-radius: 14px;
  padding: 10px 10px 10px 14px;
}
.topic-box code { flex: 1; font-size: .82rem; word-break: break-all; text-align: left; color: var(--ink); }
.topic-box button {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 10px; padding: 9px 13px; font-size: .85rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.topic-box button svg { width: 15px; height: 15px; }
.store-links { display: flex; gap: 10px; justify-content: center; }
.store-links a {
  color: var(--accent); font-weight: 700; font-size: .92rem; text-decoration: none;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 16px;
}

/* ---------- settings ---------- */
.settings { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.set-group h3 {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 4px 8px;
}
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px; min-height: 56px;
  border-top: 1px solid var(--line);
}
.set-row:first-child { border-top: 0; }
.set-row .set-label { font-weight: 600; font-size: .98rem; }
.set-row .set-sub { color: var(--muted); font-size: .84rem; margin-top: 2px; }
.set-row.tappable { cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.set-row.tappable:active { background: var(--card2); }
.set-row .row-ico { color: var(--accent); flex-shrink: 0; width: 22px; height: 22px; }
.set-row .danger { color: var(--danger); }
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex-shrink: 0; }
.seg button {
  border: 0; background: none; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font-size: .88rem; font-weight: 600; cursor: pointer;
  min-height: 38px;
}
.seg button.sel { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); font-weight: 700; }
.pill-ok { color: var(--accent); font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 6px; }
.pill-ok svg { width: 16px; height: 16px; }
.pill-warn { color: #b45309; font-weight: 700; font-size: .9rem; }
[data-theme="dark"] .pill-warn { color: #fbbf24; }
.meter { height: 8px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); overflow: hidden; width: 130px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- zone editor ---------- */
.zed-hint {
  color: #d6d3d1; font-size: .88rem; text-align: center;
  padding: 0 18px 8px; line-height: 1.45; min-height: 2.6em;
}
.zed-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 6px; }
.zed-frame { position: relative; max-width: 100%; max-height: 100%; }
.zed-frame img { display: block; max-width: 100%; max-height: 100%; border-radius: 8px; user-select: none; -webkit-user-select: none; }
.zed-frame svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  stroke-width: 0; touch-action: none; border-radius: 8px;
}
.zed-frame polygon { fill: rgb(52 195 176 / .28); stroke: #34c3b0; stroke-width: 2.5; cursor: pointer; }
.zed-frame polygon.sel { fill: rgb(52 195 176 / .42); stroke-width: 3.5; }
.zed-frame polygon.watch { fill: rgb(245 158 11 / .26); stroke: #f59e0b; }
.zed-frame polygon.watch.sel { fill: rgb(245 158 11 / .4); }
.zed-frame polyline { fill: rgb(52 195 176 / .18); stroke: #34c3b0; stroke-width: 2.5; stroke-dasharray: 7 5; }
.zed-frame polyline.watch { fill: rgb(245 158 11 / .16); stroke: #f59e0b; }
.zed-frame circle { fill: #fff; stroke: #0f766e; stroke-width: 3; cursor: grab; }
.zed-frame circle.watch { stroke: #b45309; }
.zed-frame text {
  fill: #fff; font: 700 .85rem -apple-system, sans-serif;
  paint-order: stroke; stroke: rgb(0 0 0 / .55); stroke-width: 3px;
  pointer-events: none;
}
.zed-bar {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 12px 14px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.zed-bar:has(+ .zed-bar) { padding-bottom: 0; }
.zed-bar .btn-pill:disabled { opacity: .45; }
.seg.dark { background: rgb(255 255 255 / .1); border-color: rgb(255 255 255 / .16); }
.seg.dark button { color: #d6d3d1; }
.seg.dark button.sel { background: rgb(255 255 255 / .92); color: #1b1a18; }
.ev-bell { margin-left: 6px; font-size: .85em; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 12px 22px; border-radius: 999px;
  font-size: .92rem; font-weight: 600;
  z-index: 100; box-shadow: var(--shadow);
  max-width: 88vw; text-align: center;
  animation: toastin .2s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }
