:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #16191f;
  --panel-2: #20242d;
  --text: #f2f5f8;
  --muted: #9aa5b1;
  --line: #333946;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #f87171;
  --ok: #34d399;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

html:has(body.frame),
body.frame {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page {
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

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

.brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.brand p,
.muted {
  margin: 0;
  color: var(--muted);
}

.panel {
  margin-top: 24px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.field {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 150px;
  margin: 12px 0 18px;
  padding: 20px;
  color: var(--muted);
  background: #0f1116;
  border: 1px dashed #596273;
  border-radius: 8px;
  text-align: center;
}

.drop-zone strong {
  color: var(--text);
  font-size: 20px;
}

.drop-zone.active {
  border-color: var(--accent);
  background: #102231;
}

.setup-grid {
  display: grid;
  gap: 18px;
}

.setup-panel {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
  background: #fff;
  border-radius: 8px;
}

.qr-code {
  width: min(100%, 280px);
  aspect-ratio: 1;
}

.setup-details h2 {
  margin-top: 0;
}

.url-display {
  overflow-wrap: anywhere;
  padding: 14px;
  color: var(--text);
  background: #0f1116;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

input[type="password"],
input[type="file"],
input[type="number"],
input[type="time"],
input[type="text"],
textarea,
select {
  width: 100%;
  padding: 12px;
  color: var(--text);
  background: #0f1116;
  border: 1px solid var(--line);
  border-radius: 6px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.file-caption-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.file-caption-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.45fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.file-caption-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  margin-top: 18px;
}

.settings-form .field {
  margin: 0;
}

.toggle {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 44px;
  color: var(--text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.system-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.system-actions button {
  justify-content: center;
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.health-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.health-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.health-row > span {
  display: inline-flex;
  justify-content: center;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.health-row.ok > span {
  color: #052117;
  background: var(--ok);
}

.health-row.warn > span {
  color: #241305;
  background: #fbbf24;
}

.health-row div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.health-row strong,
.health-row small {
  overflow-wrap: anywhere;
}

.health-row small {
  color: var(--muted);
}

.health-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.health-details div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  background: #0f1116;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.health-details strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.event-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-row div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.event-row strong,
.event-row time {
  color: var(--text);
  font-size: 14px;
}

.event-row span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2 {
  margin: 0 0 6px;
}

button,
.button {
  min-height: 42px;
  padding: 0 14px;
  color: #041018;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button.secondary,
.button.secondary {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

button.danger,
.button.danger {
  color: var(--danger);
}

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

.message {
  margin-top: 16px;
  color: var(--muted);
  white-space: pre-wrap;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

.frame {
  position: fixed;
  inset: 0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background: #000;
  cursor: none;
  user-select: none;
  touch-action: manipulation;
}

.frame * {
  cursor: none;
}

.slide {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 1200ms ease;
}

.slide.visible {
  opacity: 1;
}

.photo-image,
.backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-orientation: from-image;
}

.photo-image {
  z-index: 2;
  object-fit: contain;
}

.backdrop {
  z-index: 1;
  display: none;
  object-fit: cover;
  filter: blur(32px) brightness(0.62) saturate(1.08);
  transform: scale(1.08);
}

.mode-fill .photo-image {
  object-fit: cover;
}

.mode-blur .backdrop {
  display: block;
}

.mode-blur .photo-image {
  object-fit: contain;
}

.frame-overlay {
  position: fixed;
  inset: 0;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  z-index: 5;
  opacity: 0.78;
}

.overlay-corner {
  position: absolute;
  display: grid;
  gap: 10px;
  max-width: min(70vw, 1200px);
}

.overlay-top-left {
  top: 24px;
  left: 24px;
  justify-items: start;
  text-align: left;
}

.overlay-top-right {
  top: 24px;
  right: 24px;
  justify-items: end;
  text-align: right;
}

.overlay-bottom-left {
  bottom: 20px;
  left: 24px;
  justify-items: start;
  text-align: left;
}

.overlay-bottom-right {
  right: 24px;
  bottom: 20px;
  justify-items: end;
  text-align: right;
}

.overlay-item {
  overflow-wrap: anywhere;
}

.frame-overlay #caption {
  font-size: 24px;
  line-height: 1.25;
}

.frame-overlay #clock {
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
}

.empty-frame {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.frame-message {
  background: #000;
  z-index: 6;
}

.frame-message h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
}

.frame-message p {
  margin: 0;
}

.frame-sleep {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.management-sections {
  display: grid;
  gap: 24px;
  margin-top: 18px;
}

.management-sections h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 16px;
}

.review-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.review-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #050608;
  border-radius: 6px;
}

.review-select {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.review-select span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.caption-editor {
  display: grid;
  gap: 6px;
}

.caption-editor span {
  color: var(--muted);
  font-size: 12px;
}

.caption-editor textarea {
  min-height: 70px;
  font-size: 14px;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .page {
    width: min(100vw - 20px, 920px);
    padding-top: 20px;
  }

  .panel {
    padding: 16px;
  }

  .section-head {
    flex-direction: column;
  }

  .setup-panel {
    grid-template-columns: 1fr;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  .file-caption-row {
    grid-template-columns: 1fr;
  }

  .overlay-corner {
    max-width: calc(100vw - 32px);
  }

  .overlay-top-left {
    top: 16px;
    left: 16px;
  }

  .overlay-top-right {
    top: 16px;
    right: 16px;
  }

  .overlay-bottom-left {
    bottom: 16px;
    left: 16px;
  }

  .overlay-bottom-right {
    right: 16px;
    bottom: 16px;
  }

  .frame-overlay #caption {
    font-size: 18px;
  }

  .frame-overlay #clock {
    font-size: 44px;
  }
}
