:root {
  --ink: #0d1f30;
  --night: #153450;
  --paper: #eceff2;
  --card: #ffffff;
  --text: #14283b;
  --muted: #5a6c7d;
  --line: #d0d9e1;
  --signal: #f5a524;
  --signal-ink: #2b1d00;
  --ok: #1e9e6a;
  --off: #94a3b0;
  --alert: #c93a3a;
  --focus: #1b6fd1;
  --solid: #0d1f30;
  --solid-text: #ffffff;
  --radius: 16px;
  --nav-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #08121b;
    --card: #11263a;
    --text: #e6edf3;
    --muted: #93a6b8;
    --line: #234058;
    --focus: #6aa8f5;
    --solid: #f5a524;
    --solid-text: #2b1d00;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--text); line-height: 1.45; min-height: 100vh; min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- papan jaga: jam ---- */
.board {
  color: #f4f7fa;
  padding: max(16px, env(safe-area-inset-top)) 0 0;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, var(--ink), var(--night));
}
.board-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.board .site { font-size: 1.05rem; font-weight: 700; margin: 0; letter-spacing: .01em; }
.board .sub { margin: 2px 0 0; font-size: .86rem; color: #a9bccd; }
.pulse { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 99px; background: rgba(255,255,255,.08); font-size: .78rem; font-weight: 600; color: #d6e2ec; }
.pulse::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; animation: beat 2.4s ease-in-out infinite; }
@keyframes beat { 50% { opacity: .35; } }
.clock-time { display: flex; align-items: baseline; gap: .35em; margin-top: 16px; font-variant-numeric: tabular-nums; line-height: .95; }
.clock-time .hm { font-size: clamp(4rem, 23vw, 8.4rem); font-weight: 800; letter-spacing: -.035em; }
.clock-time .ss { font-size: clamp(1.7rem, 8vw, 3.2rem); font-weight: 700; color: var(--signal); }
.clock-time .tz { font-size: .85rem; color: #a9bccd; margin-left: auto; align-self: flex-end; font-weight: 600; }
.clock-date { margin-top: 8px; font-size: 1.05rem; color: #dbe5ee; }
.clock-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 16px 0 0; border-top: 1px solid rgba(255,255,255,.13); }
.clock-stats div { padding: 12px 8px 14px 0; }
.clock-stats div + div { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.13); }
.clock-stats dd { margin: 0; font-size: 1.4rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.clock-stats dt { font-size: .78rem; color: #a9bccd; text-wrap: balance; }

.ticker { background: var(--signal); color: var(--signal-ink); font-weight: 600; font-size: .92rem; overflow: hidden; white-space: nowrap; }
.ticker span { display: inline-block; padding: 8px 0 8px 100%; animation: tick 30s linear infinite; }
@keyframes tick { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) {
  .ticker { white-space: normal; }
  .ticker span { padding: 8px 16px; animation: none; }
  .pulse::before { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---- navigasi: bar bawah di HP, tab atas di layar lebar ---- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .wrap { display: flex; padding: 0 6px; }
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); padding: 6px 4px; color: var(--muted); text-decoration: none;
  font-size: .76rem; font-weight: 600; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 26%; right: 26%; height: 3px; border-radius: 0 0 3px 3px; background: var(--signal); }
.tab.hidden { display: none; }
main { padding: 18px 0 calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); }
@media (min-width: 720px) {
  .nav { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); padding-bottom: 0; }
  .nav .wrap { padding: 0 16px; gap: 4px; justify-content: flex-start; }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 8px; min-height: 52px; padding: 0 18px; font-size: .95rem; }
  .tab svg { width: 20px; height: 20px; }
  .tab[aria-current="page"]::before { top: auto; bottom: -1px; left: 12px; right: 12px; height: 3px; border-radius: 3px 3px 0 0; }
  main { padding: 24px 0 48px; }
}

h2 { font-size: 1.2rem; margin: 0 0 4px; }
h3 { margin: 0; }
.hint { color: var(--muted); font-size: .92rem; margin: 0 0 14px; }
.pagehead { margin-bottom: 16px; }

/* ---- daftar kamera ---- */
.camgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .camgrid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 900px) { .camgrid { grid-template-columns: repeat(4, 1fr); } }
.camcard {
  position: relative; display: flex; flex-direction: column; justify-content: space-between;
  width: 100%; aspect-ratio: 4 / 3; padding: 12px 13px; text-align: left; cursor: pointer; overflow: hidden;
  border: 0; border-radius: var(--radius); color: #fff;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 4px),
    linear-gradient(160deg, #1b4260, #0d1f30 70%);
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 8px 18px -12px rgba(5, 15, 25, .7);
  transition: transform .15s, box-shadow .15s;
}
.camcard:hover { transform: translateY(-2px); box-shadow: 0 1px 0 rgba(255,255,255,.1) inset, 0 12px 22px -12px rgba(5, 15, 25, .8); }
.camcard:active { transform: scale(.985); }
.camcard .lens { position: absolute; right: -14px; bottom: -14px; width: 74%; color: rgba(255,255,255,.09); }
.camcard .lens svg { width: 100%; height: auto; stroke-width: 1.2; }
.camcard .st { position: relative; align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; background: rgba(0,0,0,.35); font-size: .74rem; font-weight: 600; }
.camcard .nm { position: relative; font-size: 1.02rem; font-weight: 700; line-height: 1.2; text-wrap: balance; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.camcard.is-off { filter: grayscale(.85) brightness(.85); }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #3ddc97; }
.dot.off { background: var(--off); }
.item .dot { background: var(--ok); width: 12px; height: 12px; }
.item .dot.off { background: var(--off); }
.shortcut { display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 600; }
.shortcut svg { width: 26px; height: 26px; flex: none; color: var(--signal); }
.shortcut small { display: block; color: var(--muted); font-weight: 400; font-size: .86rem; }
.shortcut .go { margin-left: auto; }
.shortcut:hover { border-color: var(--signal); }

/* ---- tombol ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 8px 16px; border-radius: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); font-weight: 600; text-decoration: none; color: var(--text);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { border-color: var(--signal); }
.btn.primary { background: var(--solid); border-color: var(--solid); color: var(--solid-text); }
.btn.danger { color: var(--alert); }
.btn.small { min-height: 34px; padding: 4px 11px; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---- pemutar ---- */
.player-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.player-head h2 { margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.player-layout { display: grid; gap: 14px; }
@media (min-width: 900px) { .player-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.video-box { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.video-box video { width: 100%; height: 100%; display: block; background: #000; }
.video-msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; text-align: center; color: #fff; background: rgba(0, 0, 0, .58); }
.live-badge { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 7px; background: var(--alert); color: #fff; font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.live-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.controls .grow { flex: 1; }
.side { display: grid; gap: 8px; align-content: start; }
.side .controls { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; min-height: 44px; padding: 8px 18px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--solid); color: var(--solid-text); }

/* ---- rekaman ---- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.chip { flex: none; scroll-snap-align: start; min-height: 44px; padding: 6px 15px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); font-weight: 600; cursor: pointer; text-align: center; line-height: 1.2; }
.chip small { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--solid-text); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .8; }
.step { margin: 18px 0 8px; font-size: .95rem; font-weight: 700; display: flex; align-items: baseline; gap: 10px; }
.step span { font-weight: 400; color: var(--muted); font-size: .86rem; }
.dateline { display: flex; gap: 8px; align-items: center; margin: 8px 0 14px; }
.dateline input { max-width: 190px; }
.hours { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (min-width: 600px) and (max-width: 899px) { .hours { grid-template-columns: repeat(12, 1fr); } }
.rec-layout { display: grid; gap: 0; }
.rec-box.idle { display: none; }
.rec-side .step:first-child { margin-top: 12px; }
@media (min-width: 900px) {
  .rec-layout { grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
  .rec-box.idle { display: block; }
  .rec-side { order: 2; } .rec-side .step:first-child { margin-top: 0; }
  .rec-side .chips { flex-wrap: wrap; overflow: visible; margin: 0; padding-inline: 0; }
  .rec-layout .clips { grid-template-columns: repeat(2, 1fr); }
}
.hour {
  position: relative; min-height: 58px; padding: 8px 2px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; cursor: default;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 6px;
}
.hour i { display: block; width: 62%; height: 5px; border-radius: 3px; background: var(--line); font-style: normal; }
.hour.has { background: var(--card); color: var(--text); cursor: pointer; border-color: color-mix(in srgb, var(--signal) 55%, var(--line)); }
.hour.has i { background: var(--signal); }
.hour.has:hover { border-color: var(--signal); }
.hour[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--solid-text); }
.hour[aria-pressed="true"] i { background: var(--solid-text); }
.clips { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.clip { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; text-align: left; font-variant-numeric: tabular-nums; }
.clip svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.clip b { font-size: 1.02rem; }
.clip small { color: var(--muted); margin-left: auto; }
.clip[aria-pressed="true"] { border-color: var(--signal); box-shadow: inset 0 0 0 1px var(--signal); }
.clip[aria-pressed="true"] svg { color: var(--signal); }
.now-playing { margin: 10px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.now-playing strong { flex: 1; min-width: 0; }
.rec-box { margin-top: 6px; }

/* ---- form umum ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: .92rem; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=number], textarea, select {
  width: 100%; min-height: 44px; padding: 8px 12px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px;
}
textarea { min-height: 96px; resize: vertical; }
.msg { margin: 10px 0 0; font-size: .92rem; }
.msg.err { color: var(--alert); }
.msg.ok { color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.empty p { margin: 0 0 12px; }
#view > form.card { max-width: 440px; margin: 8px auto; }

/* ---- kegiatan & galeri ---- */
.acts { display: grid; gap: 14px; }
@media (min-width: 720px) { .acts { grid-template-columns: repeat(2, 1fr); align-items: start; } }
.act { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.act img { width: 100%; display: block; max-height: 360px; object-fit: cover; }
.act .in { padding: 14px 16px 16px; }
.act time { color: var(--muted); font-size: .86rem; }
.act h3 { margin: 2px 0 6px; font-size: 1.1rem; }
.act p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid button { padding: 0; border: 0; background: var(--line); aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.grid button:hover img { transform: scale(1.05); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(5, 1fr); gap: 8px; } }
dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; }
dialog.lightbox::backdrop { background: rgba(0, 0, 0, .92); }
.lb { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; color: #fff; }
.lb img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.lb .row { display: flex; gap: 8px; }
.lb .btn { background: #1b2f44; color: #fff; border-color: #35506b; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px calc(var(--nav-h) + 12px); }
@media (min-width: 720px) { footer { padding-bottom: 28px; } }

/* ---- admin ---- */
.wrap.wide { max-width: 980px; }
.admin-top { display: flex; align-items: center; gap: 10px; padding: 14px 0; }
.admin-top h1 { font-size: 1.1rem; margin: 0; flex: 1; }
.warn { background: #fff4d6; color: #5a3f00; border: 1px solid #f0cf7a; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; }
.list { display: grid; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.item .top { display: flex; align-items: center; gap: 10px; }
.item .top strong { flex: 1; overflow-wrap: anywhere; }
.item form { margin-top: 8px; }
.row2 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumb { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumb .cap { padding: 6px 8px; font-size: .82rem; color: var(--muted); min-height: 2.4em; overflow-wrap: anywhere; }
.thumb .btn { width: calc(100% - 16px); margin: 0 8px 8px; }
details summary { cursor: pointer; font-weight: 600; margin-top: 10px; }
code { background: var(--paper); padding: 1px 5px; border-radius: 5px; font-size: .85em; overflow-wrap: anywhere; }
pre.out { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .82rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; }

/* ---- daftar kamera (hanya nama, video baru dibuka saat diklik) ---- */
.camlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .camlist { grid-template-columns: repeat(2, 1fr); } }
.cambtn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; min-height: 64px; padding: 12px 14px 12px 16px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--signal); border-radius: var(--radius);
  font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: transform .12s, border-color .12s;
}
.cambtn:hover { border-color: var(--signal); }
.cambtn:active { transform: scale(.99); }
.cambtn .dot { background: var(--ok); width: 11px; height: 11px; }
.cambtn .dot.off { background: var(--off); }
.cambtn .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cambtn .state { font-size: .82rem; font-weight: 500; color: var(--muted); }
.cambtn .go { color: var(--muted); display: flex; }
.cambtn .go svg { width: 20px; height: 20px; }
.cambtn.is-off { border-left-color: var(--off); color: var(--muted); }
.about p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.contact { margin-bottom: 4px; }
.contact small { display: block; color: var(--muted); font-weight: 600; }
footer p { margin: 0 0 4px; }

/* Wizard rekaman (admin) */
.mode.on { border-color: var(--signal) !important; background: #fff9ec; }
.mode input { margin-top: 4px; flex: none; }
.card h3 { margin: 22px 0 6px; font-size: 1.02rem; color: var(--night); }
.card h3:first-child { margin-top: 0; }
.pickrow .btn { min-height: 40px; }
.card .actions + h3, .card .actions ~ div > h3:first-child { margin-top: 26px; }
