:root {
  color-scheme: light;
  --ink: #253228;
  --muted: #657267;
  --panel: rgba(255, 251, 235, 0.95);
  --line: #d9c99d;
  --leaf: #4f8f50;
  --leaf-dark: #2f6539;
  --berry: #d94b4b;
  --water: #4b93bd;
  --sun: #e3a944;
  --shadow: 0 16px 40px rgba(54, 38, 21, 0.16);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #b8dcc1;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.modal-open { overflow: hidden; }
.visitor-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(86vw, 380px);
  min-height: 92px;
  padding: 18px 20px;
  border: 2px solid rgba(255,248,218,.82);
  background: rgba(37,50,40,.9);
  color: #fff9df;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transform: translate(-50%, -46%) scale(.96);
  opacity: 0;
  pointer-events: none;
}
.visitor-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: opacity .28s ease, transform .28s ease;
}
.visitor-toast.is-hiding {
  opacity: 0;
  transform: translate(-50%, -46%) scale(.96);
  transition: opacity .8s ease, transform .8s ease;
}
.visitor-toast__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: url("./assets/favicon.svg") center / contain no-repeat;
  font-size: 1.7rem;
  line-height: 1;
}
.visitor-toast__icon.has-flag {
  background: none;
}
.visitor-toast strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  text-align: center;
}
button, input, select { font: inherit; }
button { color: inherit; }
.app-shell {
  min-height: 100vh;
  padding-bottom: 42px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(184,220,193,.94) 62%), url("./assets/farm-background.png") top center / cover no-repeat fixed;
}
.hero {
  position: relative;
  min-height: 320px;
  padding: 22px clamp(16px, 4vw, 54px) 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.hero__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(34,52,35,.62), rgba(34,52,35,.12) 62%), linear-gradient(180deg, rgba(255,250,220,.2), rgba(32,50,31,.08));
  pointer-events: none;
}
.topbar, .hero__content, .dashboard {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand, .status-pill, .day-card {
  border: 2px solid rgba(255,248,218,.74);
  background: rgba(37,50,40,.76);
  color: #fff9df;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.brand { height: 56px; display: inline-flex; align-items: center; gap: 10px; padding: 10px 14px; font-weight: 900; }
.brand__mark {
  width: 22px; height: 22px; flex: 0 0 auto; image-rendering: pixelated;
  background: url("./assets/favicon.svg") center / contain no-repeat;
}
.topbar__status { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.status-pill, .gallery-button, .bgm-button { height: 56px; display: inline-flex; align-items: center; gap: 9px; padding: 9px 12px; }
.gallery-button, .bgm-button { border: 2px solid rgba(255,248,218,.74); background: rgba(255,246,216,.92); color: var(--leaf-dark); box-shadow: var(--shadow); cursor: pointer; font-weight: 900; }
.bgm-button { min-width: 92px; }
.bgm-button span { width: 22px; height: 22px; display: grid; place-items: center; border: 2px solid #d3b96b; background: #fff2bf; color: #795b15; font-weight: 900; }
.bgm-button.is-on span { border-color: #85c98e; background: #e4f5d7; color: var(--leaf-dark); }
.bgm-button.is-blocked span { border-color: #e3a944; background: #fff2bf; color: #795b15; }
.gallery-button span { width: 22px; height: 22px; display: grid; place-items: center; border: 2px solid #d3b96b; background: #fff2bf; color: #795b15; }
.gallery-button:hover, .gallery-button:focus-visible, .bgm-button:hover, .bgm-button:focus-visible { outline: 0; transform: translateY(-1px); box-shadow: 0 18px 40px rgba(54,38,21,.22); }
.status-pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #e5bf54; box-shadow: 0 0 0 0 rgba(229,191,84,.6); animation: pulse 1.8s infinite; }
.hero__content { display: grid; grid-template-columns: minmax(0, 1fr) 180px; align-items: end; gap: 28px; color: #fff9df; }
.eyebrow { margin: 0 0 8px; color: #f2cf74; font-size: .78rem; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; max-width: 780px; font-size: clamp(2.5rem, 7vw, 5.25rem); line-height: 1; letter-spacing: 0; text-shadow: 0 4px 18px rgba(0,0,0,.28); }
.hero__copy { max-width: 620px; margin-bottom: 0; color: #fff4cc; font-size: 1.08rem; line-height: 1.7; }
.day-card { min-height: 132px; padding: 16px; display: grid; gap: 7px; align-content: center; }
.day-card span, .day-card small { color: #ffe8a6; }
.day-card strong { font-size: 1.35rem; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .9fr); align-items: start; gap: 18px; margin-top: 24px; margin-bottom: 42px; }
.panel { min-width: 0; border: 2px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); padding: 18px; }
.camera-panel { grid-row: auto; }
.panel__header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel h2 { margin: 0; font-size: 1.18rem; line-height: 1.25; }
.icon-button { width: 42px; height: 42px; flex: 0 0 auto; border: 2px solid var(--line); border-radius: 8px; background: #fff6d8; color: var(--leaf-dark); cursor: pointer; font-weight: 900; }
.camera-frame { position: relative; aspect-ratio: 16 / 9; min-height: 220px; border: 3px solid #7d5d3f; border-radius: 8px; overflow: hidden; background: #2d4b35; }
.camera-media { width: 100%; height: 100%; display: block; border: 0; object-fit: cover; background: #111; }
.water-button { position: absolute; right: 14px; bottom: 14px; z-index: 2; min-width: 72px; height: 46px; border: 3px solid #d7f0ff; border-radius: 999px; background: linear-gradient(180deg,#e9f8ff,#85c9ef); color: #155c7d; box-shadow: 0 10px 22px rgba(20,68,83,.3); cursor: pointer; display: grid; place-items: center; font-weight: 900; }
.water-button:hover, .water-button:focus-visible { outline: 0; transform: translateY(-1px); box-shadow: 0 12px 28px rgba(20,68,83,.38); }
.water-button:disabled { cursor: wait; opacity: .76; transform: none; }
.water-progress { margin-top: 12px; border: 2px solid #b9dcee; border-radius: 8px; background: #eefaff; padding: 10px; }
.water-progress__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: #225a70; }
.water-progress__top strong { color: #0d5e86; }
.water-progress__track { height: 12px; border: 2px solid #85c9ef; border-radius: 999px; overflow: hidden; background: #d7f0ff; }
.water-progress__track span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg,#4b93bd,#74d0f1); transition: width .25s linear; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric { min-width: 0; min-height: 132px; border: 2px solid #ead9aa; border-radius: 8px; background: #fffdf1; padding: 14px; display: grid; align-content: start; gap: 8px; text-align: left; }
.metric-button { width: 100%; cursor: pointer; }
.metric-button:hover, .metric-button:focus-visible { border-color: var(--leaf); box-shadow: 0 0 0 3px rgba(79,143,80,.18); outline: 0; }
.metric small { color: var(--muted); }
.metric strong { font-size: 1.22rem; overflow-wrap: anywhere; }
.metric__icon { width: 24px; height: 24px; border-radius: 6px; display: inline-block; }
.metric__icon.sun { background: var(--sun); box-shadow: inset 0 0 0 5px #ffd978; }
.metric__icon.water { background: var(--water); border-radius: 50% 50% 50% 8px; transform: rotate(45deg); }
.metric__icon.temp { background: linear-gradient(#d94b4b 0 62%, #fffdf1 62%); border: 2px solid #b53434; }
.metric__icon.leaf { background: var(--leaf); border-radius: 100% 8px; }
meter { width: 100%; height: 10px; }
@media (max-width: 560px) {
  .dashboard { width: min(100% - 20px, 1180px); gap: 12px; }
  .panel { padding: 14px; }
  .panel__header { align-items: flex-start; }
  .camera-frame { min-height: 190px; }
  .metric-grid { grid-template-columns: 1fr; }
}




.chart-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; }
.chart-modal[hidden] { display: none !important; }
.chart-modal__backdrop { position: absolute; inset: 0; background: rgba(26,38,29,.58); backdrop-filter: blur(5px); }
.chart-modal__content { position: relative; z-index: 1; width: min(760px, 100%); max-height: min(720px, calc(100vh - 36px)); overflow: auto; }
.chart-modal__actions { display: inline-flex; align-items: center; gap: 8px; }
.chart-wrap { height: clamp(260px, 48vh, 420px); border: 2px solid #ead9aa; border-radius: 8px; background: #fffdf1; padding: 10px; }
#airChart { width: 100%; height: 100%; display: block; }
.chart-badge { border: 2px solid #d3b96b; border-radius: 8px; background: #fff2bf; color: #795b15; padding: 8px 10px; font-weight: 900; }
.chart-status { margin: 0; color: var(--muted); line-height: 1.6; }
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgba(229,191,84,0); } 100% { box-shadow: 0 0 0 0 rgba(229,191,84,0); } }
@media (max-width: 900px) {
  .hero { min-height: 280px; padding: 16px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar__status { flex-direction: column; align-items: stretch; }
  .brand, .status-pill, .gallery-button, .bgm-button { width: 100%; }
  .hero__content, .dashboard { grid-template-columns: 1fr; }
  .day-card { width: min(100%, 240px); }
  .dashboard { margin-top: 18px; }
}


.gallery-modal { position: fixed; inset: 0; z-index: 22; display: grid; place-items: center; padding: 18px; }
.gallery-modal[hidden] { display: none !important; }
.gallery-modal__backdrop { position: absolute; inset: 0; background: rgba(26,38,29,.62); backdrop-filter: blur(5px); }
.gallery-modal__content { position: relative; z-index: 1; width: min(960px, 100%); max-height: min(780px, calc(100vh - 36px)); overflow: auto; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.gallery-photo { margin: 0; border: 2px solid #ead9aa; border-radius: 8px; overflow: hidden; background: #fffdf1; }
.gallery-photo img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #2d4b35; }
.gallery-photo figcaption { padding: 10px 12px; color: var(--leaf-dark); font-weight: 900; }
.gallery-empty { margin: 0; color: var(--muted); line-height: 1.6; }

@media (max-width: 760px) {
  .visitor-toast {
    width: calc(100vw - 36px);
    min-height: 84px;
    padding: 15px 16px;
    border-width: 1px;
  }

  .visitor-toast strong {
    font-size: .86rem;
  }

  .app-shell {
    padding-bottom: 20px;
    background-attachment: scroll;
    background-position: top center;
  }

  .hero {
    min-height: 210px;
    padding: 12px 12px 20px;
  }

  .hero__shade {
    background: linear-gradient(180deg, rgba(34,52,35,.72), rgba(34,52,35,.18));
  }

  .topbar,
  .hero__content,
  .dashboard {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .brand {
    height: 44px;
    padding: 8px 10px;
    font-size: .96rem;
  }

  .brand__mark {
    width: 18px;
    height: 18px;
    background-size: contain;
  }

  .topbar__status {
    display: grid;
    grid-template-columns: 82px 82px minmax(0, 1fr);
    gap: 8px;
  }

  .gallery-button,
  .bgm-button,
  .status-pill {
    width: 100%;
    height: 40px;
    padding: 7px 9px;
    border-width: 1px;
    box-shadow: 0 8px 22px rgba(54,38,21,.12);
    font-size: .9rem;
  }

  .gallery-button span,
  .bgm-button span {
    width: 18px;
    height: 18px;
    border-width: 1px;
  }

  .status-pill {
    justify-content: flex-start;
  }

  .pulse {
    width: 8px;
    height: 8px;
  }

  .hero__content {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    margin-top: 20px;
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: .68rem;
  }

  h1 {
    margin-bottom: 6px;
    font-size: clamp(2rem, 12vw, 3.15rem);
    line-height: .98;
  }

  .hero__copy {
    font-size: .86rem;
    line-height: 1.3;
  }

  .day-card {
    width: 100%;
    min-height: 46px;
    min-width: 0;
    padding: 9px 10px;
    gap: 8px;
    border-width: 1px;
    box-shadow: 0 8px 22px rgba(54,38,21,.12);
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    align-content: center;
    justify-self: stretch;
  }

  .day-card strong {
    min-width: 0;
    font-size: 1rem;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .day-card span,
  .day-card small {
    font-size: .76rem;
    white-space: nowrap;
  }

  .dashboard {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 12px;
    margin-bottom: 22px;
  }

  .panel {
    padding: 10px;
    border-width: 1px;
    box-shadow: 0 10px 24px rgba(54,38,21,.12);
  }

  .panel__header {
    margin-bottom: 9px;
  }

  .panel h2 {
    font-size: 1rem;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-width: 1px;
  }

  .camera-frame {
    min-height: 0;
    border-width: 2px;
    border-radius: 8px;
  }

  .water-button {
    right: 10px;
    bottom: 10px;
    min-width: 58px;
    height: 38px;
    border-width: 2px;
    font-size: .9rem;
  }

  .water-progress {
    margin-top: 8px;
    padding: 8px;
    border-width: 1px;
  }

  .water-progress__top {
    margin-bottom: 6px;
    font-size: .86rem;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    min-height: 92px;
    padding: 10px;
    gap: 5px;
    border-width: 1px;
  }

  .metric__icon {
    width: 18px;
    height: 18px;
    border-radius: 5px;
  }

  .metric small {
    font-size: .76rem;
  }

  .metric strong {
    font-size: 1rem;
  }

  meter {
    height: 8px;
  }

  .gallery-modal,
  .chart-modal {
    padding: 8px;
    align-items: stretch;
  }

  .gallery-modal__content,
  .chart-modal__content {
    width: 100%;
    max-height: calc(100vh - 16px);
    align-self: center;
    padding: 12px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chart-wrap {
    height: min(58vh, 360px);
    padding: 6px;
    border-width: 1px;
  }

  .chart-badge {
    padding: 6px 8px;
    border-width: 1px;
    font-size: .82rem;
  }

  .chart-status,
  .gallery-empty,
  .gallery-photo figcaption {
    font-size: .86rem;
  }
}

@media (max-width: 380px) {
  .topbar__status {
    grid-template-columns: 70px 70px minmax(0, 1fr);
  }

  .day-card {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 3px;
    min-height: 76px;
  }

  .day-card strong {
    text-align: left;
    white-space: normal;
  }

  .metric-grid {
    gap: 6px;
  }

  .metric {
    min-height: 86px;
    padding: 8px;
  }
}

