:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, Segoe UI, sans-serif;
  --bg: #101820;
  --surface: #18242d;
  --text: #f3f7fa;
  --muted: #a7bac6;
  --border: #2d3d48;
  --image-bg: #090e12;
  --accent: #8bd5e3;
  --button-bg: #243743;
  --good: #82d6ae;
  --bad: #e9b27c;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f6f8;
  --surface: #fff;
  --text: #152632;
  --muted: #536a78;
  --border: #d5e0e6;
  --image-bg: #e2e9ed;
  --accent: #006d81;
  --button-bg: #e9f2f5;
  --good: #006c49;
  --bad: #98520c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
main { width: min(1200px, 100%); margin: 0 auto; padding: 32px 20px 64px; }
.page-header { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 24px; margin-bottom: 34px; }
.brand { display: inline-block; margin-bottom: 20px; color: var(--accent); text-decoration: none; font-size: .77rem; font-weight: 800; letter-spacing: .19em; }
h1 { margin: 0; font-size: clamp(2.15rem, 5vw, 3.2rem); line-height: 1.05; letter-spacing: -.045em; }
.note { margin: 12px 0 0; color: var(--muted); font-size: .95rem; }
.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.language-switch { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.language-switch button { min-width: 42px; padding: 7px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 700; }
.language-switch button[aria-pressed="true"] { background: var(--button-bg); color: var(--text); }
.theme-toggle { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font-size: .82rem; font-weight: 650; }
.section-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; margin-bottom: 14px; color: var(--muted); font-size: .83rem; }
.section-label span:first-child { color: var(--text); font-weight: 750; text-transform: uppercase; letter-spacing: .1em; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr)); gap: 20px; }
.camera-card { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.photo-open { display: block; width: 100%; padding: 0; border: 0; background: var(--image-bg); cursor: zoom-in; }
.photo-open img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: var(--image-bg); }
.info { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 15px 16px; }
h2 { margin: 0; font-size: 1.05rem; }
.location { margin: 5px 0 0; color: var(--muted); font-size: .81rem; }
.status { padding: 5px 8px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.status.online { color: var(--good); }
.status.offline { color: var(--bad); }
.card-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; padding: 0 16px 15px; color: var(--muted); font-size: .82rem; }
.card-footer button { padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--button-bg); color: var(--text); font-size: .82rem; font-weight: 650; }
.source-note { margin: 24px 0 0; color: var(--muted); font-size: .82rem; }
dialog { width: min(980px, calc(100% - 28px)); max-height: min(92vh, 900px); padding: 24px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px #0008; }
dialog::backdrop { background: #071019c9; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: .73rem; font-weight: 800; letter-spacing: .12em; }
.dialog-header h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }
.close-btn { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--button-bg); color: var(--text); font-size: 1.6rem; line-height: 1; }
.dialog-action { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--button-bg); color: var(--text); font-size: .82rem; font-weight: 650; }
.dialog-action:disabled { opacity: .4; cursor: default; }
#history-dialog { width: min(1400px, calc(100% - 28px)); height: min(92dvh, 1000px); max-height: 92dvh; }
#history-dialog[open] { display: flex; flex-direction: column; }
#history-dialog .dialog-header, .history-tools { flex: none; }
.history-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 22px 0 14px; font-size: .86rem; }
.history-tools label { font-weight: 650; }
.history-tools select { min-width: 160px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--button-bg); color: var(--text); }
.timezone { margin-left: auto; color: var(--muted); font-size: .78rem; }
.history-message { min-height: 1.5em; color: var(--muted); }
.history-message:empty { display: none; }
.history-view { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; flex: 1; gap: 12px; }
.history-view[hidden] { display: none; }
.history-browser-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .82rem; }
.history-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 10px; min-height: 0; overflow: auto; align-content: start; padding: 3px; }
.history-list button { position: relative; width: 100%; min-width: 0; aspect-ratio: 4 / 3; align-self: start; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: 8px; background: var(--image-bg); color: #fff; text-align: left; cursor: zoom-in; }
.history-list button[aria-pressed="true"] { border-color: var(--accent); }
.history-list img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.history-list time { position: absolute; left: 5px; bottom: 5px; padding: 3px 6px; border-radius: 5px; background: #000b; font-size: .75rem; }
.history-pagination { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; font-size: .82rem; }
#history-page-prev { justify-self: start; }
#history-page-next { justify-self: end; }
#photo-dialog { width: min(96vw, 1800px); max-width: none; height: 96dvh; max-height: 96dvh; padding: 12px; background: #101820; color: #f3f7fa; }
#photo-dialog[open] { display: flex; flex-direction: column; }
#photo-dialog::backdrop { background: #03080de8; }
.photo-dialog-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 12px; margin-bottom: 10px; }
.photo-dialog-header h2 { min-width: 0; overflow: hidden; font-size: .95rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
#photo-counter { color: #a7bac6; font-size: .85rem; }
#photo-dialog .close-btn { flex: none; color: #f3f7fa; background: #243743; }
#photo-close { grid-column: 4; }
#photo-dialog .dialog-action { color: #f3f7fa; background: #243743; border-color: #46606f; }
#photo-stage { position: relative; flex: 1; min-height: 0; touch-action: pan-y pinch-zoom; }
#photo-large { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; background: #090e12; }
.photo-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 56px; padding: 0; border: 1px solid #ffffff55; border-radius: 9px; background: #101820cc; color: #fff; font-size: 2.4rem; line-height: 1; }
.photo-nav[hidden] { display: none; }
.photo-nav:disabled { opacity: .3; cursor: default; }
.photo-nav-prev { left: 10px; }
.photo-nav-next { right: 10px; }
@media (max-width: 650px) {
  main { padding-top: 23px; }
  .brand { margin-bottom: 14px; }
  .history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .history-tools { margin-top: 16px; }
  .history-tools select { min-width: 0; max-width: calc(100% - 40px); }
  .history-pagination { grid-template-columns: 1fr 1fr; gap: 8px; }
  #history-page-label { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .timezone { margin-left: 0; width: 100%; }
  dialog { padding: 16px; }
  #photo-dialog { width: calc(100% - 12px); padding: 8px; }
  .photo-dialog-header { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  #photo-close { grid-column: 2; grid-row: 1; }
  #photo-history { grid-column: 1; grid-row: 2; justify-self: start; }
  #photo-counter { grid-column: 2; grid-row: 2; }
}
