:root {
  --bg: #111418;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --card: #1c2026;
  --line: #2d333b;
  --open: #2e9d5b;
  --stop: #d9a21b;
  --close: #d0453b;
  --accent: #4b8bf5;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", sans-serif;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
}
main { max-width: 560px; margin: 0 auto; padding: 16px 0 32px; }
h1 { font-size: 28px; margin: 40px 0 24px; text-align: center; }
h2 { font-size: 18px; margin: 0; }
button {
  font: inherit; color: var(--fg); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer;
}
button:disabled { opacity: .35; cursor: not-allowed; }
button.primary { width: 100%; background: var(--accent); border: 0; padding: 16px; font-size: 18px; }
label { display: block; margin-bottom: 16px; color: var(--muted); }
input {
  display: block; width: 100%; margin-top: 6px; font: inherit; color: var(--fg);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.msg { min-height: 1.5em; color: var(--muted); text-align: center; }
.msg.error { color: #ff8a80; }

.video-box {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border-radius: 14px; overflow: hidden;
}
.video-box video-stream, .video-box video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-overlay {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 6px;
  background: rgba(0,0,0,.6); font-size: 13px; color: var(--muted);
}
.video-overlay.live { color: #8be28b; }

.status-row { display: flex; justify-content: space-between; align-items: center; margin: 12px 0; font-size: 14px; }
.pill { padding: 2px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.pill.on { color: #8be28b; }
.pill.off { color: #ff8a80; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 8px; align-items: center; }
.ctl { font-size: 24px; font-weight: 600; padding: 28px 0; border: 0; border-radius: 16px; }
.ctl.open { background: var(--open); }
.ctl.stop { background: var(--stop); color: #1b1b1b; }
.ctl.close { background: var(--close); }
.ctl.armed { outline: 3px solid #fff; font-size: 14px; white-space: pre-line; line-height: 1.3; }

/* 稍後開：圓形按鈕，外圈是倒數進度 */
.ctl.later {
  position: relative; aspect-ratio: 1; padding: 0; border-radius: 50%;
  background: transparent; color: var(--open); font-size: 15px;
}
.ctl.later span { position: relative; font-variant-numeric: tabular-nums; }
.ctl.later .ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--open); opacity: .35; }
.ring .bar { stroke: var(--open); stroke-linecap: round; stroke-dasharray: 289.03; stroke-dashoffset: 289.03; transition: stroke-dashoffset .5s linear; }
.ctl.later.pending { color: var(--fg); font-size: 18px; }
.ctl.later.pending .track { opacity: .2; }

.later-picker {
  margin-top: 12px; padding: 12px; border-radius: 14px; background: var(--card);
  border: 1px solid var(--line); text-align: center;
}
.later-picker div { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

nav { display: flex; gap: 8px; justify-content: center; margin-top: 28px; }
header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.log, .keys { list-style: none; padding: 0; margin: 0 0 16px; }
.log li, .keys li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log .t { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.log .bad { color: #ff8a80; }
.log .sub { display: block; color: var(--muted); font-size: 12px; }
.keys li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.keys .sub { display: block; color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 14px; }
code { background: var(--card); padding: 1px 6px; border-radius: 4px; }

#invite-box { margin-top: 16px; text-align: center; }
#invite-qr { width: 220px; height: 220px; background: #fff; border-radius: 12px; padding: 8px; }
.invite-link { display: flex; gap: 8px; margin-top: 12px; }
.invite-link input { margin: 0; font-size: 12px; }
