:root {
  color-scheme: dark;
  --bg: #141715; --panel: #1d211f; --raised: #252b27; --ink: #f0f4f1; --muted: #a4b1a8; --line: #343d37;
  --brand: #8bd4ac; --brand-2: #95cbd5; --ok: #6dc593; --warn: #edbf72; --danger: #f0a29b;
}
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
html { scroll-padding-top: 100px; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 17px; line-height: 1.35; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.app-shell { max-width: 900px; margin: auto; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; min-height: 94px; padding: 18px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.site-heading { flex: 1; min-width: 0; }
.eyebrow { color: var(--brand); margin-bottom: 5px; font-size: 11px; font-weight: 750; text-transform: uppercase; }
.topbar-actions { display: flex; gap: 5px; }
.icon-button { width: 42px; height: 42px; flex: 0 0 42px; display: inline-grid; place-items: center; border: 0; border-radius: 6px; color: var(--ink); background: transparent; padding: 8px; }
.icon-button:hover { background: var(--raised); }
.icon-button.is-refreshing svg { animation: refresh-spin 1s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
.close-button { font-size: 28px; font-weight: 350; }
.feed-status-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 26px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); min-height: 49px; }
.status-button { display: inline-flex; align-items: center; gap: 9px; background: none; border: none; padding: 3px 0; color: var(--muted); font-size: 12px; }
.status-button svg { width: 15px; height: 15px; }
.relay-state, .event-state { display: inline-flex; align-items: center; gap: 7px; }
.status-dot, .severity-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 7px; }
.status-dot.ok, .severity-dot.info { background: var(--ok); }
.status-dot.pending, .severity-dot.warning { background: var(--warn); }
.status-dot.danger, .severity-dot.critical, .severity-dot.error { background: var(--danger); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; min-height: 76px; padding: 18px 26px; }
.section-heading h2 { font-size: 15px; }
.section-heading p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.history-toggle, .filter-button, .event-details-button, .history-image-button { color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 5px; padding: 8px 12px; min-height: 36px; font-size: 12px; }
.history-toggle:hover, .filter-button.active { background: var(--raised); color: var(--ink); }
.timeline-event { margin: 0; padding: 20px 26px 22px; border-top: 1px solid var(--line); background: var(--panel); min-width: 0; }
.event-heading { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; width: 100%; padding: 0; border: 0; text-align: left; color: var(--ink); background: none; align-items: start; }
.controller-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #237e55; color: #effff6; font-size: 20px; font-weight: 500; }
.event-controller { display: block; font-size: 15px; font-weight: 700; margin: 0 0 3px; }
.alert-copy, .history-copy { min-width: 0; }
.alert-copy strong, .history-copy strong { display: block; font-size: 15px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.alert-copy small, .history-copy small { display: block; font-size: 13px; line-height: 1.55; margin-top: 5px; color: var(--muted); overflow-wrap: anywhere; }
.event-heading time { font-size: 12px; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.event-footer, .history-meta { margin-left: 54px; }
.event-media { margin-top: 15px; }
.event-footer { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 11px; color: var(--muted); }
.event-details-button { border: 0; padding: 4px 0 4px 12px; min-height: 30px; color: var(--brand-2); }
.photo-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.photo-previews > :only-child { grid-column: 1 / -1; }
.photo-open { display: block; width: 100%; aspect-ratio: 16 / 9; position: relative; padding: 0; background: #101311; border: 0; border-radius: 3px; overflow: hidden; cursor: zoom-in; }
.photo-open img, .attachment-open img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.legacy-photo-panel { margin: 0; min-width: 0; }
.legacy-photo-panel figcaption { padding-top: 5px; color: var(--muted); font-size: 11px; }
.legacy-photo-clip { position: absolute; inset: 0; margin: auto; width: calc(100% * 45 / 49); overflow: hidden; }
.legacy-photo-crop img { height: 200%; object-fit: fill; }
.legacy-photo-bottom img { top: -100%; }
.photo-pending { position: absolute; inset: 0; display: grid; place-items: center; background: #171b18; color: var(--muted); border: 1px solid var(--line); font-size: 13px; padding: 20px; text-align: center; }
.photo-caption { display: flex; flex-wrap: wrap; gap: 5px 12px; font-size: 11px; color: var(--muted); padding-top: 8px; }
.history-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); padding-top: 12px; }
.filter-row { display: flex; gap: 8px; padding: 0 26px 18px; flex-wrap: wrap; }
.attachment-delivery { min-width: 0; }
.attachment-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.attachment-retry { color: var(--muted); background: none; border: 0; width: 32px; height: 32px; font-size: 20px; }
.attachment-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.attachment-slot { margin: 8px 0; min-width: 0; }
.attachment-slot:only-child { grid-column: 1 / -1; }
.attachment-slot figcaption { display: grid; gap: 4px; margin-bottom: 8px; overflow-wrap: anywhere; font-size: 12px; }
.attachment-slot figcaption span, .attachment-status { font-size: 11px; color: var(--muted); line-height: 1.5; }
.attachment-slot .attachment-status { min-height: 1.5em; }
.attachment-open, .attachment-empty { width: 100%; aspect-ratio: 16 / 9; position: relative; padding: 0; border: 0; border-radius: 3px; background: #101311; overflow: hidden; }
.attachment-open { display: block; cursor: zoom-in; }
.attachment-empty { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.attachment-warning { color: var(--warn); font-size: 12px; line-height: 1.5; margin-top: 6px; overflow-wrap: anywhere; }
.empty-state { padding: 65px 24px; text-align: center; color: var(--muted); font-size: 14px; }
.empty-state span { display: block; margin-bottom: 12px; }
.notice { margin: 0; padding: 12px 26px; color: var(--brand-2); background: #1a2927; font-size: 13px; line-height: 1.5; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.notice.error { color: var(--danger); background: #30221f; }
dialog { color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0; max-width: calc(100% - 24px); }
dialog::backdrop { background: rgba(0, 0, 0, .78); }
.utility-dialog { width: 620px; max-height: calc(100dvh - 32px); }
.dialog-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.connection-panel, .status-panel { padding: 20px; }
.connection-form, .identity-card, .invite-card { display: grid; gap: 14px; }
.identity-card { padding-top: 20px; }
.identity-card p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.connection-form.lab-fallback label, .connection-form.lab-fallback button { display: none; }
label { display: grid; gap: 7px; font-size: 12px; color: var(--muted); }
input { width: 100%; min-height: 42px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; color: var(--ink); }
.action-button, .connection-form button { min-height: 40px; padding: 9px 14px; border: 1px solid #4e8765; border-radius: 5px; color: #f7fff9; background: #285d40; font-weight: 650; font-size: 13px; }
.action-button.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.connection-form button.connected { background: none; border: 0; padding: 0; min-height: 0; text-align: left; color: var(--brand); }
.connection-status { color: var(--brand); font-size: 12px; }
.connection-status.error { color: var(--danger); }
.client-version { color: var(--muted); font-size: 11px; margin-top: 24px; }
.storage-settings { display: grid; gap: 10px; padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.storage-settings p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.status-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.status-card, .meta-item { min-width: 0; }
.status-card span, .meta-item span { display: block; font-size: 11px; color: var(--muted); }
.status-card strong, .meta-item strong { display: block; font-size: 13px; font-weight: 550; margin-top: 5px; overflow-wrap: anywhere; }
.controller-list { display: grid; padding: 10px; gap: 6px; }
.controller-item { display: grid; gap: 6px; background: transparent; border: 0; text-align: left; color: var(--ink); padding: 16px; border-radius: 4px; }
.controller-item.active { background: var(--raised); box-shadow: inset 3px 0 var(--brand); }
.controller-item span { color: var(--muted); font-size: 12px; }
.snapshot-panel { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; display: grid; gap: 14px; }
.snapshot-copy p:last-child { color: var(--muted); font-size: 13px; margin-top: 8px; }
.snapshot-preview img { width: 100%; max-height: 250px; object-fit: contain; display: block; }
.snapshot-open-button { border: 0; background: #101311; padding: 0; width: 100%; }
.snapshot-empty { color: var(--muted); font-size: 12px; }
.image-dialog { width: 1340px; max-height: calc(100dvh - 32px); }
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px,1fr); }
.viewer-media { min-width: 0; background: #0b0d0c; }
.viewer-viewport { height: min(68dvh, 680px); min-height: 260px; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); place-items: center; overflow: hidden; position: relative; touch-action: none; }
.viewer-viewport img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; display: block; user-select: none; }
#viewerStatus { position: absolute; padding: 24px; color: var(--muted); font-size: 13px; text-align: center; }
.viewer-controls { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); min-height: 60px; background: #191d1b; }
.image-bar { display: grid; grid-template-columns: 42px 42px minmax(0, 1fr) 58px; align-items: center; gap: 6px; padding: 6px 10px 0; background: #191d1b; border-top: 1px solid var(--line); }
.image-bar .icon-button { font-size: 24px; }
.image-bar-caption { display: grid; gap: 3px; min-width: 0; padding-inline: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
#viewerPosition { font-variant-numeric: tabular-nums; }
.viewer-save-status { min-height: 24px; padding: 2px 14px 6px; color: var(--brand-2); font-size: 11px; line-height: 16px; background: #191d1b; overflow-wrap: anywhere; }
.viewer-controls output { width: 55px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; }
.pixel-button { height: 42px; min-width: 42px; border: 0; background: none; color: var(--ink); font-size: 13px; border-radius: 5px; }
.fullscreen-button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 5px; padding: 8px 10px; color: var(--ink); background: transparent; font-size: 12px; }
.fullscreen-button:hover { background: var(--raised); }
.fullscreen-return { position: absolute; z-index: 2; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); background: #191d1bd9; color: #fff; }
.image-dialog.image-only { position: fixed; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; overflow: hidden; background: #000; }
.image-only .viewer-header, .image-only .detail-panel, .image-only .viewer-controls, .image-only .viewer-cameras, .image-only .image-bar, .image-only .viewer-save-status { display: none; }
.image-only .viewer-layout { display: block; height: 100%; }
.image-only .viewer-media { height: 100%; background: #000; }
.image-only .viewer-viewport, .viewer-viewport:fullscreen { width: 100%; height: 100%; min-height: 0; background: #000; }
.viewer-viewport:fullscreen { height: 100dvh; }
#viewerDimensions { font-size: 11px; color: var(--muted); margin-left: 8px; }
.viewer-cameras { display: flex; gap: 8px; padding: 12px; flex-wrap: wrap; }
.camera-button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 5px; padding: 8px 12px; font-size: 12px; }
.camera-button[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }
.detail-panel { min-width: 0; border-left: 1px solid var(--line); }
.detail-header { padding: 24px 22px 14px; }
.detail-message { padding: 0 22px 20px; font-size: 14px; line-height: 1.6; color: #ced8d1; overflow-wrap: anywhere; }
.detail-panel .attachment-delivery { margin: 0 22px 20px; }
.detail-panel .attachment-grid { grid-template-columns: 1fr; }
.detail-panel .attachment-slot { display: none; }
.snapshot-placeholder { margin: 0 22px 20px; padding: 14px 0; border-block: 1px solid var(--line); display: grid; gap: 8px; }
.snapshot-placeholder span { font-size: 12px; color: var(--muted); }
.meta-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px 14px; padding: 0 22px 24px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 22px 24px; }
.action-status, .success-panel { margin: 0 22px 20px; font-size: 13px; line-height: 1.5; color: var(--brand); }
.success-panel { display: grid; gap: 8px; }
@media (max-width: 760px) {
  .viewer-layout { grid-template-columns: 1fr; }
  .detail-panel { border-left: 0; border-top: 1px solid var(--line); }
  .viewer-viewport { height: 51dvh; }
  .attachment-grid, .photo-previews { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .topbar { min-height: 80px; padding: 12px 10px; gap: 9px; }
  h1 { font-size: 20px; }
  .eyebrow { font-size: 10px; }
  .topbar-actions { gap: 0; }
  .feed-status-bar { padding: 10px 16px; gap: 10px; font-size: 11px; }
  .section-heading { padding: 16px; min-height: 74px; }
  .timeline-event { padding: 18px 14px; }
  .event-heading { grid-template-columns: 34px minmax(0,1fr) auto; gap: 10px; }
  .controller-avatar { width: 34px; height: 34px; font-size: 18px; }
  .event-controller, .alert-copy strong, .history-copy strong { font-size: 14px; }
  .event-heading time { font-size: 11px; }
  .alert-copy small, .history-copy small { font-size: 12px; }
  .event-footer, .history-meta { margin-left: 44px; }
  .event-media :is(.photo-open, .attachment-open, .attachment-empty) { aspect-ratio: 4 / 3; }
  .event-media img.feed-photo-fill { object-fit: cover; }
  .event-media .legacy-photo-clip { inset: 50% 0 auto; width: 100%; aspect-ratio: 1280 / 784; transform: translateY(-50%); }
  .filter-row { padding-inline: 16px; }
  .image-dialog { max-width: 100%; width: 100%; max-height: 100dvh; height: 100dvh; border: 0; border-radius: 0; margin: 0; }
  .viewer-header { padding: 12px 14px; }
  .viewer-header h2 { font-size: 15px; }
  .viewer-viewport { height: 47dvh; min-height: 210px; }
  .viewer-controls { gap: 3px; }
  #viewerDimensions { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
