:root {
  color-scheme: light;
  --ink: #252823;
  --muted: #73776e;
  --line: #dcded7;
  --paper: #f3f3ee;
  --card: #fbfcf9;
  --accent: #344031;
  --accent-soft: #dfe6d8;
  --dark: #20241f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(130, 151, 121, .16), transparent 35%),
    var(--paper);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  height: 76px;
  padding: 0 clamp(22px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--dark);
  color: #f5f7f1;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid #8b9983;
  border-radius: 50%;
  font: 600 19px/1 Georgia, serif;
}

.brand strong { display: block; letter-spacing: .14em; font-size: 15px; }
.brand small { display: block; margin-top: 4px; color: #aeb6a8; font-size: 9px; letter-spacing: .16em; }

.device-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #c7cec2;
  font-size: 13px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #899583;
  box-shadow: 0 0 0 4px rgba(137, 149, 131, .14);
}

.device-state.online .state-dot { background: #a8c795; box-shadow: 0 0 0 4px rgba(168, 199, 149, .14); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 60px; }

.intro, .section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.intro { margin-bottom: 38px; }

.eyebrow {
  margin: 0 0 9px;
  color: #65705f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .19em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font: 500 clamp(34px, 6vw, 57px)/1.05 Georgia, "Songti SC", serif; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font: 500 26px/1.2 Georgia, "Songti SC", serif; }
h3 { margin-bottom: 8px; font-size: 18px; }
.description { margin-bottom: 0; color: var(--muted); line-height: 1.7; }

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 17px;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.refresh-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh-button.loading svg { animation: spin .7s linear infinite; }
.refresh-button:focus-visible, .latest-image-button:focus-visible, .photo-card:focus-visible { outline: 3px solid #9aad8e; outline-offset: 3px; }

.latest-panel {
  margin-bottom: 50px;
  padding: clamp(18px, 3vw, 30px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.latest-panel .section-heading { margin-bottom: 20px; }
.section-heading time, .photo-count { color: var(--muted); font-size: 13px; }

.latest-image-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  background: #171a16;
  border: 0;
  border-radius: 6px;
  cursor: zoom-in;
}

.latest-image-button img {
  display: block;
  width: 100%;
  max-height: 600px;
  object-fit: contain;
}

.history-section > .section-heading { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding-top: 20px; }

.photo-card {
  padding: 0;
  overflow: hidden;
  color: inherit;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}

.photo-card:hover { transform: translateY(-2px); border-color: #afb5aa; }
.photo-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #e3e4df; }
.photo-card-meta { display: flex; justify-content: space-between; gap: 10px; padding: 13px 14px; color: var(--muted); font-size: 12px; }
.photo-card-meta strong { color: var(--ink); font-size: 12px; font-weight: 600; }

.empty-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; width: 62px; height: 62px; margin: 0 auto 20px; place-items: center; color: #717b6b; background: var(--accent-soft); border-radius: 50%; }
.empty-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.empty-state p { max-width: 430px; margin: 0 auto; line-height: 1.7; }
.error-message { margin-top: 20px; padding: 14px 16px; color: #7d302b; background: #f5e5e2; border: 1px solid #e8c8c3; border-radius: 6px; }

.viewer { width: min(1000px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: hidden; color: #f3f4ef; background: #161915; border: 1px solid #454c42; border-radius: 9px; }
.viewer::backdrop { background: rgba(16, 18, 15, .82); backdrop-filter: blur(4px); }
.viewer img { display: block; width: 100%; max-height: calc(100vh - 105px); object-fit: contain; }
.viewer-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; color: #fff; background: rgba(0,0,0,.62); border: 1px solid rgba(255,255,255,.25); border-radius: 50%; cursor: pointer; font: 300 27px/1 sans-serif; }
.viewer-meta { display: flex; justify-content: space-between; padding: 15px 18px; color: #bac1b6; font-size: 13px; }
.viewer-meta a { color: #e4eadf; }

footer { min-height: 70px; padding: 0 clamp(22px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: #858a81; border-top: 1px solid var(--line); font-size: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .site-header { height: 68px; }
  .brand small { display: none; }
  main { width: min(100% - 28px, 620px); padding-top: 38px; }
  .intro { align-items: center; }
  .description { max-width: 250px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

@media (max-width: 480px) {
  .device-state span:last-child { display: none; }
  .refresh-button { padding: 0 13px; }
  .photo-grid { grid-template-columns: 1fr; }
  .latest-panel { padding: 13px; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
