*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.35;
  color: #1f2a1f;
  background: linear-gradient(#eaf6ff, #f4fbe9);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}
.card {
  width: 100%;
  max-width: 560px;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
h1 { margin: 4px 0 0; font-size: 1.6rem; }
.subtitle { margin: 0; color: #4a5a4a; font-size: 0.95rem; }
.flower { width: min(60vw, 32dvh, 300px); margin: 0 auto; }
.flower svg { display: block; width: 100%; height: auto; }
.state { margin: 4px 0 0; font-size: 2rem; font-weight: 800; }
.state::before { margin-right: 0.3em; }
[data-look="ok"] .state::before { content: "🌼"; }
[data-look="drying"] .state::before { content: "⚠️"; }
[data-look="thirsty"] .state::before { content: "💧"; }
[data-look="neutral"] .state::before { content: "❔"; }
[data-look="ok"] .state { color: #1f7a1f; }
[data-look="drying"] .state { color: #8a5a00; }
[data-look="thirsty"] .state { color: #a33a1a; }
[data-look="neutral"] .state { color: #4d5660; }
.hint { margin: 0; color: #3a463a; }
.readings { background: #ffffffcc; border-radius: 14px; padding: 12px 14px; text-align: left; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meter-value { font-size: 1.5rem; }
.meter { height: 14px; background: #dde4dd; border-radius: 7px; overflow: hidden; margin: 6px 0; }
.meter-fill { height: 100%; width: 0; background: #3c8fd0; transition: width 0.4s; }
.note { margin: 0; font-size: 0.85rem; color: #5a665a; }
.measured { margin: 8px 0 0; font-weight: 600; }
.error { margin: 8px 0 0; color: #a33a1a; }
.demo { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.demo-controls p { margin: 0 0 6px; }
.demo-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
button {
  font: inherit;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #3a6a3a;
  background: #fff;
  color: #1f2a1f;
  cursor: pointer;
}
button[aria-pressed="true"] { background: #3a6a3a; color: #fff; }
.demo-toggle { border-style: dashed; background: transparent; font-size: 0.95rem; }
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 1;
  width: 100%;
  padding: 10px 12px;
  text-align: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  background: repeating-linear-gradient(45deg, #b0306a, #b0306a 14px, #962659 14px, #962659 28px);
}
body.is-demo .readings { border: 3px dashed #b0306a; }
.chat { background: #ffffffcc; border-radius: 14px; padding: 12px 14px; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.chat[hidden] { display: none; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.chat h2 { margin: 0; font-size: 1.2rem; }
.chat-badge { font-size: 0.8rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #fff1d6; color: #7a4a00; border: 1px solid #d9a441; }
.chat-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-presets button { font-size: 0.9rem; min-height: 40px; padding: 6px 10px; }
.chat-log { max-height: 40dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-msg { max-width: 88%; padding: 8px 10px; border-radius: 12px; font-size: 0.95rem; }
.chat-msg p { margin: 0; white-space: pre-line; }
.chat-user { align-self: flex-end; background: #3a6a3a; color: #fff; }
.chat-bot { align-self: flex-start; background: #eef6e8; }
.chat-tip { align-self: flex-start; background: #fff7e6; border: 1px dashed #d9a441; }
.chat-warn { align-self: stretch; max-width: 100%; color: #7a4a00; background: #fff1d6; font-size: 0.85rem; }
.chat-label { display: block; font-size: 0.75rem; font-weight: 700; color: #5a665a; margin-bottom: 2px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; font: inherit; font-size: 1rem; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 2px solid #9fb59f; }
.chat-form input:disabled, .chat-form button:disabled, .chat-presets button:disabled { opacity: 0.55; cursor: not-allowed; }
.chat-note { margin: 0; font-size: 0.85rem; color: #5a665a; }
.chat-disclaimer { margin: 0; font-size: 0.75rem; color: #5a665a; }
.states { background: #ffffffcc; border-radius: 14px; padding: 12px 10px; }
.states h2 { margin: 0 0 8px; font-size: 1.2rem; }
.states-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.state-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px 8px; border-color: #c9d6c9; position: relative; min-width: 0;
}
.state-card[data-pick="ok"] .state-name { color: #1f7a1f; }
.state-card[data-pick="drying"] .state-name { color: #8a5a00; }
.state-card[data-pick="thirsty"] .state-name { color: #a33a1a; }
.state-card[aria-current="true"] { border-color: #3a6a3a; box-shadow: 0 0 0 2px #3a6a3a; }
.state-card[aria-pressed="true"] { background: #eef6e8; color: #1f2a1f; border-color: #b0306a; box-shadow: 0 0 0 2px #b0306a; }
.state-mini { display: block; width: 100%; max-width: 110px; }
.state-mini svg { display: block; width: 100%; height: auto; }
.state-name { font-size: 0.85rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.state-now { font-size: 0.75rem; font-weight: 700; color: #fff; background: #3a6a3a; border-radius: 999px; padding: 1px 8px; }
.state-now[hidden] { display: none; }
.states-note { margin: 8px 0 0; font-size: 0.85rem; color: #5a665a; }
@media (min-width: 900px) {
  .card { max-width: 900px; display: grid; grid-template-columns: 1fr 1fr; align-items: center; column-gap: 28px; }
  .card header { grid-column: 1 / -1; }
  .flower-area { grid-column: 1; grid-row: 2 / span 2; }
  .readings { grid-column: 2; grid-row: 2; align-self: end; }
  .demo { grid-column: 2; grid-row: 3; align-self: start; }
  .states { grid-column: 1 / -1; grid-row: 4; }
  .state-mini { max-width: 150px; }
  .state-name { font-size: 1rem; }
  .chat { grid-column: 1 / -1; grid-row: 5; }
  .flower { width: min(30vw, 46dvh, 340px); }
}
.stand-link { color: #2a6a3a; font-size: 0.95rem; margin-top: 4px; }
.board { margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: #eef4ec; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.board-status { margin: 0; font-size: 0.95rem; }
.board-connect { font: inherit; padding: 8px 14px; border-radius: 10px; border: 1px solid #3c7a3c; background: #3c7a3c; color: #fff; cursor: pointer; }
.board-connect[hidden] { display: none; }
