:root {
  color-scheme: light;
  --ink: #172a29;
  --muted: #647573;
  --paper: #f0f4f2;
  --panel: #ffffff;
  --line: #dce5e1;
  --deep: #203937;
  --lime: #d9f36a;
  --lime-strong: #b7d93f;
  --coral: #e56d56;
  --success: #25815e;
  --warning: #a9523c;
  --shadow: 0 16px 46px rgba(27, 56, 49, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--paper); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(135deg, rgba(50, 88, 75, 0.025) 0 1px, transparent 1px 12px);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(37, 129, 94, 0.38); outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; padding: env(safe-area-inset-top) 34px env(safe-area-inset-bottom); }
.topbar, .page-content, .page-footer { width: min(100%, 1392px); margin-inline: auto; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(23, 42, 41, 0.11); }
.dashboard-mode { height: 100%; overflow: hidden; }
.dashboard-mode .app-shell { height: 100vh; height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.dashboard-mode .topbar { flex: 0 0 76px; }
.dashboard-mode .page-content { min-height: 0; flex: 1 1 auto; display: flex; overflow: hidden; padding: 18px 0 10px; }
.dashboard-mode .dashboard { width: 100%; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; }
.dashboard-mode .page-heading { flex: 0 0 auto; margin-bottom: 0; }
.dashboard-mode .dashboard-tabs { flex: 0 0 38px; }
.dashboard-mode .dashboard-page, .dashboard-mode .history-page { width: 100%; min-height: 0; flex: 1 1 auto; }
.dashboard-mode .dashboard-page { display: flex; }
.dashboard-mode .dashboard-grid { width: 100%; min-height: 0; flex: 1 1 auto; }
.dashboard-mode .camera-panel { min-height: 0; display: flex; flex-direction: column; }
.dashboard-mode .video-frame { min-height: 0; flex: 1 1 auto; aspect-ratio: auto; }
.dashboard-mode .camera-footer { flex: 0 0 28px; min-height: 28px; }
.dashboard-mode .feed-panel { min-height: 0; }
.dashboard-mode .dashboard-error { flex: 0 0 auto; margin: 0; }
.dashboard-tabs { display: flex; align-items: stretch; gap: 5px; border-bottom: 1px solid var(--line); }
.dashboard-tab { position: relative; min-width: 88px; padding: 0 13px 9px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.dashboard-tab::after { position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; background: transparent; content: ""; }
.dashboard-tab:hover { color: var(--ink); }
.dashboard-tab.is-active { color: var(--ink); }
.dashboard-tab.is-active::after { background: var(--coral); }
.history-page { display: flex; flex-direction: column; padding: 10px 0 0; }
.history-page-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 0 2px 14px; }
.history-page-heading h2 { margin: 4px 0 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 24px; font-weight: 600; }
.history-today { color: var(--muted); font-size: 12px; white-space: nowrap; }
.history-today strong { color: var(--ink); font-size: 18px; font-variant-numeric: tabular-nums; }
.history-page-list { min-height: 0; flex: 1 1 auto; padding: 0 3px; }
.history-page-list .history-entry { min-height: 40px; padding: 7px 3px; }
.history-page-list .history-when strong { min-width: 54px; }
.history-page-list .history-when strong, .history-page-list .history-when time, .history-page-list .history-status { font-size: 12px; }
.history-page-list .history-empty { padding: 14px 0; font-size: 12px; }
.wordmark { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 12px; font-weight: 850; letter-spacing: 1.25px; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; background: var(--coral); border-radius: 10px 10px 10px 3px; transform: rotate(-3deg); }
.brand-mark img { width: 21px; height: 21px; filter: brightness(0) invert(1); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.connection-badge { min-height: 32px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.62); color: var(--muted); font-size: 12px; font-weight: 700; }
.status-dot, .live-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #98a7a3; }
.connection-badge.is-ready .status-dot, .live-badge .live-dot { background: #72bc63; box-shadow: 0 0 0 3px rgba(114,188,99,.17); }
.connection-badge.is-issue .status-dot { background: var(--coral); }
.connection-badge.is-checking .status-dot { animation: pulse 1.3s ease-in-out infinite; }

.page-content { padding: 30px 0 20px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 19px; }
.eyebrow { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 1.35px; line-height: 1.4; }
h1, h2, p { margin-top: 0; }
h1, h2 { color: var(--ink); }
.page-heading h1, .auth-copy h1 { margin: 5px 0 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 37px; font-weight: 600; line-height: 1.1; }
.icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; transition: background .18s ease, transform .18s ease; }
.icon-button:hover { background: #f7faf8; transform: translateY(-1px); }
.icon-button img { width: 18px; height: 18px; }
.refresh-button img { transition: transform .4s ease; }
.refresh-button.is-refreshing img { transform: rotate(180deg); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(320px, .82fr); align-items: stretch; gap: 18px; }
.camera-panel, .feed-panel { min-width: 0; overflow: hidden; border: 1px solid rgba(23,42,41,.08); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.camera-panel { padding: 14px; }
.camera-heading { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 12px; }
.camera-name { min-width: 0; display: flex; align-items: center; gap: 9px; }
.camera-name > img { width: 17px; height: 17px; }
.camera-name h2 { overflow: hidden; margin: 0; font-size: 14px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #dfe9dc; border-radius: 4px; background: #f4faef; color: #387446; font-size: 9px; font-weight: 850; letter-spacing: 1.2px; }
.live-badge .live-dot { width: 6px; height: 6px; }
.live-badge.is-connecting { border-color: #e8dfbf; background: #fbf8eb; color: #816a31; }
.live-badge.is-connecting .live-dot { background: #c59d42; box-shadow: 0 0 0 3px rgba(197,157,66,.16); }
.live-badge.is-offline { border-color: #efc7bd; background: #fff3ef; color: #964b39; }
.live-badge.is-offline .live-dot { background: var(--coral); box-shadow: 0 0 0 3px rgba(229,109,86,.15); }
.video-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; background: #132120; border-radius: 4px; }
.video-frame video { width: 100%; height: 100%; display: block; background: #132120; object-fit: contain; }
.video-frame.has-error video { visibility: hidden; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 11px; color: #f5f7f5; text-align: center; }
.camera-placeholder p { margin: 0; color: #d0d9d5; font-size: 13px; }
.camera-placeholder .text-button { color: var(--lime); }
.camera-placeholder .text-button:hover { color: #ffffff; }
.placeholder-mark { width: 45px; height: 45px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; background: rgba(255,255,255,.06); }
.placeholder-mark img { width: 21px; height: 21px; filter: brightness(0) invert(1); }
.camera-footer { min-height: 39px; display: flex; align-items: end; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.camera-footer > span { display: inline-flex; align-items: center; gap: 7px; }
.privacy-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 5px; border: 0; background: transparent; color: var(--deep); font-size: 12px; font-weight: 700; cursor: pointer; }
.text-button:hover { color: var(--success); }
.text-button img { width: 15px; height: 15px; }

.feed-panel { display: flex; flex-direction: column; padding: 21px; }
.feed-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.feed-panel-heading h2 { margin: 4px 0 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 25px; font-weight: 600; line-height: 1.15; }
.feed-state { display: inline-flex; align-items: center; gap: 7px; color: var(--success); font-size: 11px; font-weight: 750; white-space: nowrap; }
.feed-state-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--success); }
.feed-state.is-issue { color: var(--warning); }
.feed-state.is-issue .feed-state-dot { background: var(--coral); }
.feed-state.is-checking { color: var(--muted); }
.feed-state.is-checking .feed-state-dot { background: #c59d42; animation: pulse 1.3s ease-in-out infinite; }
.today-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 20px 0 11px; color: var(--muted); font-size: 12px; }
.today-summary strong { color: var(--ink); font-family: "Iowan Old Style", Georgia, serif; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.primary-button, .secondary-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 17px; border: 0; border-radius: 5px; font-size: 14px; font-weight: 800; cursor: pointer; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.primary-button { background: var(--lime); color: #1d3129; }
.primary-button:hover:not(:disabled) { background: #c9e64c; transform: translateY(-1px); }
.primary-button:disabled { background: #e3e9e5; color: #87918d; cursor: not-allowed; }
.primary-button img { width: 18px; height: 18px; }
.feed-button { width: 100%; min-height: 52px; justify-content: center; font-size: 15px; }
.feed-button img { width: 20px; height: 20px; }
.feed-feedback { min-height: 19px; margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; text-align: center; }
.feed-feedback.is-warning { color: var(--warning); }
.history-section { min-height: 0; flex: 1 1 auto; margin-top: 7px; padding-top: 10px; border-top: 1px solid var(--line); }
.history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.history-heading h3 { margin: 0; color: var(--ink); font-size: 11px; font-weight: 750; }
.history-timezone { color: #85928e; font-size: 9px; }
.feed-history { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.history-entry { min-height: 29px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 1px; border-bottom: 1px solid #edf1ef; }
.history-when { min-width: 0; display: flex; align-items: baseline; gap: 9px; }
.history-when strong { min-width: 41px; color: var(--ink); font-size: 10px; font-weight: 700; }
.history-when time, .history-status { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.history-status { font-weight: 650; text-align: right; }
.history-sent .history-status { color: var(--success); }
.history-uncertain .history-status { color: var(--warning); }
.history-empty { padding: 7px 0; color: #85928e; font-size: 10px; }

.activity-bar { display: flex; align-items: center; gap: 22px; margin-top: 15px; padding: 13px 17px; border: 1px solid rgba(23,42,41,.07); border-radius: 6px; background: rgba(255,255,255,.7); }
.activity-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.activity-icon { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; }
.activity-icon img { width: 15px; height: 15px; }
.activity-item > span:last-child { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-label { color: #82908c; font-size: 8px; font-weight: 800; letter-spacing: 1.05px; }
.activity-item strong { overflow: hidden; color: var(--ink); font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.activity-divider { width: 1px; height: 27px; background: var(--line); }
.dashboard-error { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #efc7bd; border-radius: 5px; background: #fff5f1; color: #8c4533; font-size: 12px; }
.page-footer { display: flex; justify-content: space-between; padding: 10px 0 18px; color: #879490; font-size: 9px; font-weight: 700; letter-spacing: .8px; }

.auth-view { width: min(100%, 470px); margin: clamp(35px, 9vh, 92px) auto 60px; padding: clamp(23px, 5vw, 38px); border: 1px solid rgba(23,42,41,.09); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.auth-copy h1 { margin-top: 8px; font-size: 36px; }
.auth-copy p { margin: 10px 0 25px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-form { display: grid; gap: 9px; }
.auth-form label { margin-top: 7px; color: #3b504d; font-size: 11px; font-weight: 750; }
.auth-form input { width: 100%; min-height: 48px; padding: 0 13px; border: 1px solid #cfdad5; border-radius: 4px; background: #fbfcfb; color: var(--ink); }
.auth-form input:focus { border-color: #5b9275; }
.field-hint { margin: 0 0 6px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.form-error { margin: 3px 0; color: var(--warning); font-size: 12px; line-height: 1.45; }
.auth-submit { width: 100%; margin-top: 12px; }
.auth-submit img { width: 16px; height: 16px; }

.center-state { min-height: min(65vh, 500px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; color: var(--muted); text-align: center; }
.center-state p { margin: 0; font-size: 13px; }
.center-state h1 { margin: 0; font-family: "Iowan Old Style", Georgia, serif; font-size: 27px; font-weight: 600; }
.unavailable-state p { max-width: 280px; line-height: 1.55; }
.unavailable-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: #e1e9e5; }
.unavailable-icon img { width: 23px; height: 23px; }
.loader { width: 24px; height: 24px; border: 2px solid #d4dfda; border-top-color: var(--success); border-radius: 50%; animation: spin .75s linear infinite; }

.feed-dialog { width: min(calc(100% - 32px), 410px); max-width: none; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink); }
.feed-dialog::backdrop { background: rgba(15, 32, 29, .57); backdrop-filter: blur(3px); }
.dialog-card { position: relative; display: flex; flex-direction: column; align-items: center; padding: 30px 25px 24px; border: 1px solid rgba(23,42,41,.1); border-radius: 7px; background: var(--panel); text-align: center; box-shadow: 0 22px 70px rgba(0,0,0,.2); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 35px; height: 35px; border-color: transparent; background: transparent; }
.dialog-close img { width: 17px; height: 17px; }
.dialog-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 50%; background: #eef4dd; }
.dialog-icon img { width: 23px; height: 23px; }
.dialog-card h2 { margin: 7px 0 7px; font-family: "Iowan Old Style", Georgia, serif; font-size: 26px; font-weight: 600; }
.dialog-card > p { max-width: 280px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.dialog-actions { width: 100%; display: grid; grid-template-columns: 1fr 1.2fr; gap: 9px; margin-top: 24px; }
.dialog-actions .primary-button, .dialog-actions .secondary-button { min-height: 47px; font-size: 12px; }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary-button:hover { background: #f4f7f5; }

@keyframes pulse { 50% { opacity: .38; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 1100px) {
  .page-content { padding-top: 37px; }
  .dashboard-grid { grid-template-columns: minmax(0, 1.8fr) minmax(340px, .78fr); gap: 20px; }
  .feed-panel { padding: 24px 25px; }
  .portion-summary { margin-top: 32px; }
}

@media (max-width: 850px) {
  .app-shell { padding-inline: 18px; }
  .topbar { height: 64px; }
  .dashboard-mode .topbar { flex-basis: 64px; }
  .dashboard-mode .page-content { padding: 10px 0 7px; }
  .dashboard-mode .dashboard { gap: 7px; }
  .dashboard-mode .page-heading h1 { font-size: 31px; }
  .dashboard-mode .dashboard-tabs { flex-basis: 34px; }
  .dashboard-mode .dashboard-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 7px; }
  .dashboard-mode .camera-panel { padding: 10px; }
  .dashboard-mode .camera-heading { min-height: 30px; padding-bottom: 7px; }
  .dashboard-mode .feed-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; align-items: center; gap: 3px 12px; padding: 8px 12px; }
  .dashboard-mode .feed-panel-heading { grid-column: 1; grid-row: 1; }
  .dashboard-mode .feed-panel-heading .eyebrow { display: none; }
  .dashboard-mode .feed-panel-heading h2 { margin: 0; font-size: 19px; }
  .dashboard-mode .feed-state { display: none; }
  .dashboard-mode .today-summary { grid-column: 2; grid-row: 1; margin: 0; gap: 7px; font-size: 10px; }
  .dashboard-mode .today-summary strong { font-size: 19px; }
  .dashboard-mode .feed-button { grid-column: 1 / -1; grid-row: 2; min-height: 42px; }
  .dashboard-mode .feed-feedback { display: none; }
  .dashboard-mode .history-page { padding-top: 5px; }
  .dashboard-mode .history-page-heading { padding-bottom: 9px; }
  .dashboard-mode .history-page-list .history-entry { min-height: 34px; }
}

@media (max-width: 430px) {
  .app-shell { padding-inline: 12px; }
  .topbar { height: 59px; }
  .dashboard-mode .topbar { flex-basis: 59px; }
  .dashboard-mode .page-content { padding-top: 7px; padding-bottom: 5px; }
  .dashboard-mode .dashboard { gap: 6px; }
  .dashboard-mode .page-heading h1 { font-size: 27px; }
  .dashboard-mode .eyebrow { font-size: 8px; }
  .dashboard-mode .dashboard-grid { gap: 6px; }
  .dashboard-mode .camera-name h2 { font-size: 12px; }
  .dashboard-mode .camera-footer { flex-basis: 23px; min-height: 23px; font-size: 9px; }
  .dashboard-mode .fullscreen-button { font-size: 10px; }
  .dashboard-mode .feed-panel { padding: 7px 10px; }
  .dashboard-mode .feed-panel-heading h2 { font-size: 17px; }
  .dashboard-mode .today-summary { gap: 5px; font-size: 9px; }
  .dashboard-mode .today-summary strong { font-size: 17px; }
  .dashboard-mode .feed-button { min-height: 39px; font-size: 13px; }
  .dashboard-mode .history-page-heading h2 { font-size: 21px; }
  .dashboard-mode .history-today { font-size: 10px; }
  .dashboard-mode .history-today strong { font-size: 16px; }
}

@media (max-width: 850px) and (max-height: 700px) {
  .dashboard-mode .dashboard-grid { grid-template-rows: minmax(0, 1fr) auto; }
  .dashboard-mode .history-entry:nth-child(n + 4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}