:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #111;
  color: #f5f5f5;
}

.app {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

h1 {
  margin: 0 0 16px;
  font-size: 28px;
}

h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid #555;
  border-radius: 10px;
  font-size: 16px;
  background: #111;
  color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

#saveKeyButton,
#changeKeyButton,
#refreshEventsButton,
#closeSnapshotViewerButton,
#downloadSnapshotButton,
#enableNotificationsButton,
#simulateCallButton {
  background: #3a3a3a;
  color: #fff;
}

#openDoorButton {
  background: #d84040;
  color: #fff;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status {
  margin-top: 12px;
  color: #cfcfcf;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.sectionHeader {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.sectionHeader h2 {
  margin: 0;
}

.sectionHeader button {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.eventsList {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.eventCard {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #151515;
  border: 1px solid #333;
  border-radius: 12px;
}

.eventMeta {
  display: grid;
  gap: 4px;
}

.eventTitle {
  font-size: 15px;
  font-weight: 700;
}

.eventTime {
  color: #cfcfcf;
  font-size: 14px;
}

.eventSnapshotButton {
  display: block;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
}

.eventSnapshot {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  background: #000;
}

.eventNoSnapshot {
  padding: 12px;
  background: #202020;
  border-radius: 10px;
  color: #cfcfcf;
  font-size: 14px;
}

.snapshotViewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.82);
}

.snapshotViewerPanel {
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
  background: #1c1c1c;
  border: 1px solid #333;
  border-radius: 16px;
}

.snapshotViewerImage {
  display: block;
  width: 100%;
  max-height: calc(100vh - 180px);
  margin-top: 12px;
  object-fit: contain;
  background: #000;
  border-radius: 12px;
}

.snapshotViewerActions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

@media (min-width: 720px) {
  .actions {
    grid-template-columns: 1fr 1fr;
  }

  #accessCard .actions {
    grid-template-columns: 1fr;
  }

  .eventCard {
    grid-template-columns: 220px 1fr;
    align-items: start;
  }

  .eventMeta {
    order: 2;
  }

  .eventSnapshotButton,
  .eventNoSnapshot {
    order: 1;
  }
}