body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #111827;
  color: #e5e7eb;
}

header {
  padding: 24px;
  background: #020617;
  border-bottom: 1px solid #1f2937;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: grid;
  gap: 10px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-link {
  color: #94a3b8;
  text-decoration: none;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.header-link:hover {
  color: #e2e8f0;
  border-color: #475569;
}

.header-link.is-active {
  color: #f8fafc;
  border-color: #64748b;
  background: #1e293b;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

main {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-section {
  display: grid;
  gap: 16px;
}

.page-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

h1,
h2 {
  margin: 0 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card,
.clip-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 16px;
}

.metric {
  font-size: 28px;
  font-weight: 700;
}

.label {
  color: #9ca3af;
  font-size: 14px;
}

.status-good {
  color: #bbf7d0;
  background: #064e3b;
  border: 1px solid #047857;
  padding: 12px;
  border-radius: 10px;
}

.status-muted {
  color: #cbd5e1;
  background: #334155;
  padding: 12px;
  border-radius: 10px;
}

.recording-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  font-size: 13px;
  color: #cbd5e1;
}

.recording-line-active {
  color: #bbf7d0;
}

.recording-line-idle {
  color: #94a3b8;
}

.recording-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: currentColor;
  opacity: 0.5;
}

.recording-line-active .recording-dot {
  opacity: 1;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.clips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.clips-panel-body {
  display: grid;
  gap: 16px;
}

.clips-panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.clips-summary {
  color: #cbd5e1;
  font-size: 13px;
}

.clips-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

.clips-page-indicator {
  color: #94a3b8;
  font-size: 12px;
  min-width: 76px;
  text-align: center;
}

.clips-page-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.clips-page-btn:hover:not(:disabled) {
  background: #1e293b;
}

.clips-page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.timelapse-section {
  margin-top: 28px;
  display: grid;
  gap: 16px;
}

.timelapse-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.timelapse-section-copy {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 13px;
}

.timelapse-panel {
  display: grid;
  gap: 16px;
}

.timelapse-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.timelapse-filter-label {
  color: #94a3b8;
  font-size: 12px;
}

.timelapse-day-select {
  min-width: 180px;
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 10px;
}

.timelapse-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.timelapse-page-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.timelapse-page-btn:hover:not(:disabled) {
  background: #1e293b;
}

.timelapse-page-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.timelapse-page-indicator {
  color: #94a3b8;
  font-size: 12px;
  min-width: 76px;
  text-align: center;
}

.timelapse-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.timelapse-summary-card,
.timelapse-card {
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 14px;
  padding: 14px;
}

.timelapse-summary-label {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  margin-bottom: 8px;
}

.timelapse-summary-value {
  display: block;
  color: #f8fafc;
  font-size: 28px;
  line-height: 1;
}

.timelapse-summary-detail {
  display: block;
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.timelapse-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.timelapse-thumb-link {
  display: block;
}

.timelapse-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #020617;
}

.timelapse-card-meta {
  display: grid;
  gap: 4px;
  margin-top: 12px;
}

.timelapse-card-meta strong {
  color: #f8fafc;
  font-size: 14px;
}

.timelapse-card-meta span {
  color: #94a3b8;
  font-size: 12px;
  overflow-wrap: anywhere;
}

video {
  width: 100%;
  margin-top: 12px;
  border-radius: 10px;
  background: #000;
}

.clip-thumb {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  max-height: 160px;
  display: block;
}

.clip-thumb-button {
  width: 100%;
  padding: 0;
  margin-top: 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: inherit;
}

.clip-thumb-missing {
  width: 100%;
  height: 80px;
  border-radius: 8px;
  background: #374151;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 13px;
}

.clip-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.clip-action-link,
.clip-delete-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.clip-action-link:hover,
.clip-delete-btn:hover:not(:disabled) {
  background: #1e293b;
}

.clip-delete-btn {
  color: #fecaca;
  border-color: #7f1d1d;
}

.clip-delete-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.clip-meta {
  display: grid;
  gap: 2px;
  font-size: 13px;
  color: #cbd5e1;
}

.clip-meta strong {
  color: #f9fafb;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.clip-meta span {
  color: #94a3b8;
  font-size: 12px;
}

.clip-subtitle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 18px;
}

.clip-duration {
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.clip-log-btn {
  margin-left: auto;
  background: transparent;
  color: #93c5fd;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}

.clip-log-btn:hover {
  background: #1e293b;
}

.clip-events {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 16px;
}

.clip-event-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
}

.clip-event-person {
  color: #f8fafc;
}

.clip-event-pet {
  color: #fde68a;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #020617;
  border: 1px solid #374151;
  padding: 12px;
  border-radius: 10px;
  color: #d1d5db;
}

a {
  color: #93c5fd;
}

.live-view {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 0;
  background: #000;
  display: block;
}

.viewer-frame {
  width: 100%;
  max-width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.viewer-media {
  margin-top: 0;
}

.clip-thumb-button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
  border-radius: 10px;
}

.preview-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.preview-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-on {
  background: #064e3b;
  border: 1px solid #047857;
  color: #bbf7d0;
}

.preview-off {
  background: #3f1d1d;
  border: 1px solid #7f1d1d;
  color: #fecaca;
}

.preview-toggle {
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.preview-toggle:hover {
  background: #1e293b;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vw, 24px);
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(80vh, 900px);
  overflow: auto;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.viewer-modal-card {
  width: min(1120px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: clamp(10px, 1.8vw, 16px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.modal-close-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

.viewer-modal-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.viewer-modal-title {
  margin: 0;
  text-align: center;
  min-width: 0;
}

.viewer-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.viewer-nav-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

.viewer-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.clip-log-list {
  display: grid;
  gap: 10px;
}

.clip-log-entry {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 10px 12px;
}

.clip-log-entry-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #f8fafc;
  font-size: 13px;
  margin-bottom: 4px;
}

.clip-log-entry-meta {
  color: #94a3b8;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.clip-log-entry-items {
  color: #cbd5e1;
  font-size: 12px;
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .header-bar {
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .timelapse-section-header {
    align-items: stretch;
  }

  .timelapse-pagination {
    margin-left: 0;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .viewer-modal-card {
    width: min(100vw - 16px, 1120px);
    max-height: calc(100vh - 16px);
    padding: 10px;
  }

  .viewer-modal-title {
    font-size: 15px;
  }

  .viewer-nav-btn,
  .modal-close-icon {
    width: 34px;
    height: 34px;
  }
}
