:root {
  color-scheme: light;
  --cream: #fffaf0;
  --paper: #fffefb;
  --ink: #344158;
  --muted: #59667a;
  --orange: #c14a28;
  --orange-deep: #a83d31;
  --yellow: #ffd86f;
  --mint: #8fd9c4;
  --sky: #8ecdf4;
  --lavender: #b8a5ef;
  --line: #eee6d8;
  --shadow: 0 16px 45px rgba(94, 78, 58, .11);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--cream); font-size: 16px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 4%, rgba(255, 216, 111, .42) 0 70px, transparent 72px),
    radial-gradient(circle at 95% 15%, rgba(142, 205, 244, .3) 0 95px, transparent 97px),
    linear-gradient(180deg, #fff7e4 0, #f6fbff 50%, #fffaf2 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

button, input, select { min-height: 48px; font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: #5477a8; text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(142, 205, 244, .75);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.site-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.08rem; font-weight: 850; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 15px; background: #fff; box-shadow: 0 8px 22px rgba(126, 101, 62, .12); font-size: 1.35rem; }
.ghost-button { min-height: 42px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .82); color: var(--muted); font-weight: 750; }

.welcome-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; padding: 27px 30px; border: 1px solid rgba(255, 255, 255, .9); border-radius: 28px; background: linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(255, 249, 226, .94)); box-shadow: var(--shadow); }
.welcome-card h1 { margin: 7px 0 5px; font-size: clamp(1.55rem, 4vw, 2.3rem); line-height: 1.2; }
.eyebrow { margin: 0; color: #9a472c; font-size: .84rem; font-weight: 850; letter-spacing: .04em; }
.muted { color: var(--muted); }
.welcome-card .muted { max-width: 710px; margin: 0; }
.sun { display: grid; place-items: center; width: 92px; height: 92px; border-radius: 29px; background: linear-gradient(145deg, #fff3b1, #ffd66c); box-shadow: 0 12px 30px rgba(235, 176, 62, .24); font-size: 3.15rem; transform: rotate(4deg); }

.content-card { margin-top: 18px; padding: 22px; border: 1px solid rgba(255, 255, 255, .96); border-radius: 28px; background: rgba(255, 254, 251, .95); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.heading-copy { display: flex; align-items: center; gap: 12px; min-width: 0; }
.section-heading h2 { margin: 0; font-size: 1.2rem; line-height: 1.25; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.section-icon { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; border-radius: 15px; background: #e5f5ff; font-size: 1.35rem; }
.section-icon.lavender { background: #f0eaff; }
.live-badge, .soft-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; font-size: .75rem; font-weight: 900; white-space: nowrap; }
.live-badge { color: #a83d31; background: #fff0ed; }
.live-badge i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(220, 102, 85, .15); }
.live-badge.history { color: #735fb1; background: #f1edff; }
.live-badge.history i { display: none; }
.soft-badge { color: #735fb1; background: #f1edff; }

.video-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; border-radius: 20px; background: #151d29; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
/* The camera publishes 1280x960 without a display-aspect marker, while the
   official viewer presents this feed as widescreen. Fill the 16:9 frame in
   CSS so every source pixel (including the timestamp and class label) remains
   visible, without adding a server-side scale/crop step or latency. */
.player { display: block; width: 100%; height: 100%; background: #111; object-fit: fill; }
.player-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 5px; padding: 28px; color: var(--ink); background: linear-gradient(145deg, #edf8ff, #fff8de); text-align: center; }
.player-empty strong { font-size: 1.15rem; }
.player-empty > span:not(.empty-mascot):not(.loading-dots) { color: var(--muted); font-size: .88rem; }
.empty-mascot { margin-bottom: 4px; font-size: 3.1rem; }
.loading-dots { display: flex; gap: 6px; margin-top: 9px; }
.loading-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); animation: bounce 1.2s infinite; }
.loading-dots i:nth-child(2) { animation-delay: .15s; }
.loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
.tap-play { position: absolute; left: 50%; bottom: 20px; min-height: 44px; padding: 9px 16px; border-radius: 999px; color: #fff; background: rgba(168, 61, 49, .96); box-shadow: 0 8px 22px rgba(0, 0, 0, .2); font-weight: 850; transform: translateX(-50%); white-space: nowrap; }

.timeline-panel { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: #f7f9fc; }
.timeline-copy { display: grid; min-width: 140px; }
.timeline-copy span { color: var(--muted); font-size: .74rem; }
.timeline-copy strong { font-size: .88rem; }
.timeline-panel input { width: 100%; margin: 0; accent-color: var(--orange); touch-action: pan-y; }
.live-button { padding: 10px 14px; border-radius: 14px; color: #a83d31; background: #fff0ed; font-weight: 850; white-space: nowrap; }
.history-player-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 15px; border-radius: 18px; background: #f7f4ff; }
.history-player-controls p { margin: 0; color: var(--muted); font-size: .86rem; }

.history-fields { display: grid; grid-template-columns: minmax(190px, .34fr) 1fr; gap: 22px; padding: 18px; border-radius: 20px; background: #faf8ff; }
.history-fields label, .field-title { display: flex; flex-direction: column; gap: 8px; color: #66738a; font-size: .84rem; font-weight: 800; }
.select-wrap { position: relative; margin-top: 8px; }
.select-wrap::after { position: absolute; top: 50%; right: 14px; color: #8e7bbf; content: "⌄"; font-size: 1.2rem; pointer-events: none; transform: translateY(-56%); }
select { width: 100%; padding: 0 42px 0 14px; border: 1px solid #e4dcf6; border-radius: 14px; color: var(--ink); background: #fff; font-size: 1rem; font-weight: 750; appearance: none; }
.hour-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 8px; }
.hour-chip { display: grid; gap: 1px; min-height: 58px; padding: 8px; border: 1px solid #e7e1f4; border-radius: 14px; color: var(--ink); background: #fff; text-align: left; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.hour-chip strong { font-size: .95rem; }
.hour-chip small { overflow: hidden; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.hour-chip.selected { border-color: #a996e6; background: #eee9ff; box-shadow: 0 0 0 3px rgba(184, 165, 239, .16); transform: translateY(-1px); }
.history-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; }
.history-action p { margin: 0; font-size: .86rem; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; padding: 11px 19px; border-radius: 15px; color: #fff; background: linear-gradient(135deg, var(--orange), var(--orange-deep)); box-shadow: 0 8px 18px rgba(242, 122, 79, .24); font-weight: 850; }
.primary-button span { margin-left: 8px; }
.link-button { min-height: 48px; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.login-card { width: min(430px, 100%); padding: 32px; border: 1px solid rgba(255, 255, 255, .96); border-radius: 30px; background: rgba(255, 254, 251, .96); box-shadow: var(--shadow); text-align: center; }
.mascot { display: grid; place-items: center; width: 86px; height: 86px; margin: 0 auto 14px; border-radius: 28px; background: linear-gradient(145deg, #fff0ca, #ffd890); box-shadow: 0 12px 26px rgba(221, 167, 74, .18); font-size: 2.8rem; }
.login-card h1 { margin: 8px 0 5px; font-size: 1.75rem; }
.login-card > .muted { margin: 0 0 22px; }
.login-card form { display: grid; gap: 12px; text-align: left; }
.login-card label { color: #657188; font-size: .88rem; font-weight: 800; }
.login-card input[type="password"] { width: 100%; padding: 0 15px; border: 1px solid #eadfd2; border-radius: 15px; color: var(--ink); background: #fff; }
.full-button { width: 100%; }
.privacy-note { margin: 18px 0 0; padding-top: 15px; border-top: 1px dashed var(--line); color: var(--muted); font-size: .78rem; }
.form-error { padding: 10px 12px; border-radius: 12px; color: #a83d31; background: #fff0ed; font-weight: 700; }

@media (max-width: 720px) {
  .site-shell { padding-top: 12px; }
  .topbar { margin-bottom: 14px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
  .ghost-button { min-height: 40px; padding: 7px 12px; font-size: .82rem; }
  .welcome-card { padding: 21px 20px; border-radius: 23px; }
  .welcome-card .muted { font-size: .88rem; }
  .sun { width: 68px; height: 68px; border-radius: 22px; font-size: 2.35rem; }
  .content-card { padding: 15px; border-radius: 23px; }
  .section-heading { margin-bottom: 13px; }
  .video-frame { border-radius: 15px; }
  .timeline-panel { grid-template-columns: 1fr auto; gap: 9px; padding: 11px; }
  .timeline-copy { min-width: 0; }
  .timeline-panel input { grid-column: 1 / -1; grid-row: 2; min-height: 36px; }
  .live-button { grid-column: 2; grid-row: 1; }
  .history-fields { grid-template-columns: 1fr; gap: 16px; padding: 14px; }
  .hour-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .history-action { align-items: stretch; flex-direction: column; }
  .history-action .primary-button { width: 100%; }
  .history-player-controls { align-items: stretch; flex-direction: column; }
  .history-player-controls .live-button { width: 100%; }
  .login-card { padding: 26px 20px; border-radius: 25px; }
}

@media (max-width: 390px) {
  .welcome-card { grid-template-columns: 1fr; }
  .sun { display: none; }
  .hour-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-heading h2 { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-dots i { animation: none; }
  .hour-chip { transition: none; }
}
