/* Pflanzwerk – Oberfläche. Dunkle, kontrastreiche Schrift (keine blassen Grautöne). */
:root {
  color-scheme: light;
  --bg: #f3f6f1;
  --surface: #ffffff;
  --surface-2: #eaf1e6;
  --line: #cdd9c8;
  --text: #0f1a12;
  --text-2: #24382a;         /* Sekundärtext: dunkelgrün statt grau */
  --brand: #2f7d32;
  --brand-2: #1f5e22;
  --brand-soft: #dcefd9;
  --accent: #0d6efd;
  --water: #1565c0;
  --water-soft: #dbe9fb;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --alarm: #b3261e;
  --alarm-soft: #fde2df;
  --ok: #1e7b34;
  --frost: #0b5cad;
  --frost-soft: #dcecff;
  --shadow: 0 1px 2px rgba(20, 40, 20, .08), 0 2px 8px rgba(20, 40, 20, .06);
  --radius: 14px;
  --nav-h: 64px;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1511; --surface: #172019; --surface-2: #1e2b21; --line: #2e4033;
    --text: #f2f7f0; --text-2: #d3e3d1; --brand: #5cb85f; --brand-2: #86d388; --brand-soft: #1f3a22;
    --water: #6fa8f0; --water-soft: #1a2b44; --warn: #f0b048; --warn-soft: #3a2c10; --alarm: #ff8a80; --alarm-soft: #3d1a17;
    --ok: #6fd48a; --frost: #8cc4ff; --frost-soft: #16304d; --shadow: 0 1px 2px rgba(0,0,0,.4);
    --series-1: #3987e5; --series-2: #d95926;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1511; --surface: #172019; --surface-2: #1e2b21; --line: #2e4033;
  --text: #f2f7f0; --text-2: #d3e3d1; --brand: #5cb85f; --brand-2: #86d388; --brand-soft: #1f3a22;
  --water: #6fa8f0; --water-soft: #1a2b44; --warn: #f0b048; --warn-soft: #3a2c10; --alarm: #ff8a80; --alarm-soft: #3d1a17;
  --ok: #6fd48a; --frost: #8cc4ff; --frost-soft: #16304d; --shadow: 0 1px 2px rgba(0,0,0,.4);
  --series-1: #3987e5; --series-2: #d95926;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .3rem 0 .6rem; }
small, .small { font-size: .86rem; color: var(--text-2); }
.muted { color: var(--text-2); }
img { max-width: 100%; }

/* ---------- Grundgerüst */
#app { display: flex; min-height: 100vh; }
nav.side { display: none; }
main { flex: 1; min-width: 0; padding: 16px 16px calc(var(--nav-h) + 24px); max-width: 1100px; margin: 0 auto; width: 100%; }
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 50;
}
nav.bottom a, nav.side a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--text-2); font-size: .72rem; font-weight: 600;
}
nav.bottom a .ico { font-size: 1.35rem; line-height: 1; }
nav a.active { color: var(--brand-2); }
nav.bottom a.active .ico { transform: scale(1.1); }
@media (min-width: 900px) {
  nav.bottom { display: none; }
  nav.side {
    display: flex; flex-direction: column; gap: 4px; width: 210px; padding: 18px 10px; position: sticky; top: 0; height: 100vh;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  nav.side .logo { font-weight: 800; font-size: 1.25rem; padding: 4px 12px 16px; color: var(--brand-2); }
  nav.side a { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: .95rem; }
  nav.side a.active { background: var(--brand-soft); }
  main { padding: 24px 28px 40px; }
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 10px; }
.stack > * + * { margin-top: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card.flat { box-shadow: none; }
.card.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.card.alarm { background: var(--alarm-soft); border-color: color-mix(in srgb, var(--alarm) 40%, transparent); }
.card.frost { background: var(--frost-soft); border-color: color-mix(in srgb, var(--frost) 40%, transparent); }
.section-title { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); margin: 20px 0 8px; }

/* ---------- Bedienelemente */
button, .btn {
  font: inherit; font-weight: 650; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 40px;
}
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] button.primary, :root[data-theme="dark"] .btn.primary { color: #07140a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { color: #07140a; } }
button.water { background: var(--water); border-color: var(--water); color: #fff; }
button.danger { color: var(--alarm); border-color: color-mix(in srgb, var(--alarm) 50%, transparent); }
button.ghost { background: transparent; border-color: transparent; }
button.small { min-height: 32px; padding: 5px 10px; font-size: .88rem; }
button:disabled { opacity: .55; cursor: default; }
button.icon { min-width: 40px; justify-content: center; padding: 6px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-height: 42px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--brand); }
label { display: block; font-weight: 650; font-size: .92rem; margin: 10px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), minmax(0, 1fr))); }
.form .full { grid-column: 1 / -1; }
.hint { font-size: .85rem; color: var(--text-2); margin-top: 3px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; min-height: 36px; }
.seg button.on { background: var(--brand-soft); color: var(--brand-2); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.chip.ok { background: var(--brand-soft); color: var(--ok); }
.chip.water { background: var(--water-soft); color: var(--water); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.alarm { background: var(--alarm-soft); color: var(--alarm); }
.chip.frost { background: var(--frost-soft); color: var(--frost); }

/* ---------- Listen */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item .t { font-weight: 700; }
.item .s { font-size: .88rem; color: var(--text-2); }
.thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 1.6rem; flex: none; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.plant-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-decoration: none; color: inherit; padding: 0; overflow: hidden; }
.plant-card .pic { height: 150px; background: var(--surface-2); display: grid; place-items: center; font-size: 3.2rem; }
.plant-card .pic img { width: 100%; height: 100%; object-fit: cover; }
.plant-card .body { padding: 0 14px 14px; }
.plant-card:hover { border-color: var(--brand); }

/* ---------- Kennzahlen, Wetter */
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile .v { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.tile .l { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.days { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.day { text-align: center; border-radius: 12px; padding: 8px 4px; background: var(--surface-2); font-size: .85rem; }
.day .wd { font-weight: 800; }
.day .ic { font-size: 1.5rem; }
.day .tx { font-weight: 800; }
.day .tn { color: var(--text-2); font-weight: 650; }
.day.frost { background: var(--frost-soft); outline: 2px solid color-mix(in srgb, var(--frost) 55%, transparent); }
.day .rain { color: var(--water); font-weight: 700; }

.gauge { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.gauge > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--water); }
.gauge .band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ok) 25%, transparent); }
.gauge .needle { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--text); border-radius: 2px; }

/* ---------- Gießplan */
.plan { overflow-x: auto; }
.plan table { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: .88rem; }
.plan th, .plan td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.plan th:first-child, .plan td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; padding-right: 10px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.plan td.today, .plan th.today { background: var(--brand-soft); }
.plan .dot { display: inline-block; width: 22px; height: 22px; border-radius: 50%; background: var(--water); color: #fff; line-height: 22px; font-size: .75rem; }
.plan .dot.over { background: var(--alarm); }
.plan .dot.auto { background: transparent; border: 2px solid var(--water); color: var(--water); line-height: 18px; }

/* ---------- Kalender-Balken */
.cal { font-size: .85rem; }
.cal .r { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 8px; padding: 3px 0; }
.cal .bar { position: relative; height: 18px; background: var(--surface-2); border-radius: 6px; }
.cal .seg-i, .cal .seg-o, .cal .seg-p, .cal .seg-h { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; }
.cal .seg-i { background: #b58ad6; } .cal .seg-o { background: #7cb342; } .cal .seg-p { background: #2e7d32; } .cal .seg-h { background: #f29d38; top: 9px; bottom: 1px; }
.cal .todayline { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--alarm); }
.cal .months { display: grid; grid-template-columns: repeat(12, 1fr); font-size: .72rem; font-weight: 700; color: var(--text-2); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; font-weight: 600; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }

/* ---------- Diagramme */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis-t { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.chart .ln { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { fill: color-mix(in srgb, var(--ok) 16%, transparent); }
.chart .xh { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: .82rem; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -110%); }
.chart .tip b { font-size: .95rem; }

/* ---------- Dialoge, Meldungen */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 20, 10, .45); }
dialog .dlg-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
dialog .dlg-b { padding: 14px 16px; overflow: auto; }
dialog .dlg-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
.empty { text-align: center; padding: 26px 10px; color: var(--text-2); }
.empty .big { font-size: 2.6rem; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; gap: 12px; align-items: flex-start; }
.banner .big { font-size: 1.8rem; line-height: 1; }
.timeline { border-left: 3px solid var(--line); margin-left: 10px; padding-left: 14px; }
.timeline .ev { position: relative; padding: 6px 0; }
.timeline .ev::before { content: ""; position: absolute; left: -21px; top: 12px; width: 11px; height: 11px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; cursor: pointer; }
.drop:hover { border-color: var(--brand); }
.previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.previews img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }
.conf { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.conf > span { display: block; height: 100%; background: var(--brand); }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 88%; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand-soft); }
.msg.assistant { align-self: flex-start; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .93rem; }
.kv dt { font-weight: 700; } .kv dd { margin: 0; }
.login { max-width: 380px; margin: 12vh auto; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: var(--surface-2); border-radius: 6px; padding: 1px 5px; overflow-wrap: anywhere; }
pre { padding: 10px; overflow-x: auto; white-space: pre-wrap; }
details summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--line); }
.status-dot.on { background: var(--ok); } .status-dot.off { background: var(--alarm); }
.running { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (max-width: 520px) {
  h1 { font-size: 1.3rem; }
  .cal .r { grid-template-columns: 96px 1fr; }
  .hide-sm { display: none; }
}
