:root {
    --bg: #0f2a17; --bg2: #06140a; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #effbf1; --muted: #bfe0c6; --accent: #8ce99a; --accent-ink: #072010; --field: rgba(255,255,255,.08);
    --soft: rgba(140,233,154,.15); --good: #8ce99a; --warn: #ffc078; --warn-bg: rgba(255,192,120,.14); --bad: #ffa8a8; --water: #74c0fc;
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #f1faf2; --bg2: #d9f0dd; --card: #fff; --line: #c4e3ca; --ink: #102615; --muted: #3f5c45;
            --accent: #237a3b; --accent-ink: #fff; --field: #f9fef9; --soft: #e2f5e5; --good: #2b8a3e; --warn: #b45309; --warn-bg: #fff1dc; --bad: #c92a2a; --water: #1971c2; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #f1faf2; --bg2: #d9f0dd; --card: #fff; --line: #c4e3ca; --ink: #102615; --muted: #3f5c45;
            --accent: #237a3b; --accent-ink: #fff; --field: #f9fef9; --soft: #e2f5e5; --good: #2b8a3e; --warn: #b45309; --warn-bg: #fff1dc; --bad: #c92a2a; --water: #1971c2; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #0f2a17; --bg2: #06140a; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #effbf1; --muted: #bfe0c6; --accent: #8ce99a; --accent-ink: #072010; --field: rgba(255,255,255,.08);
    --soft: rgba(140,233,154,.15); --good: #8ce99a; --warn: #ffc078; --warn-bg: rgba(255,192,120,.14); --bad: #ffa8a8; --water: #74c0fc;
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-main, .col-side { display: contents; }
.app > .topbar, .app > .back { order: 0; }
.app > header, .warn-box { order: 1; }
.summary { order: 2; }
.add { order: 3; }
.list { order: 4; }
.trip { order: 5; }
.settings { order: 6; }
.app > .faq { order: 7; }
.app > footer { order: 8; }
/* first use: the form straight under the title */
.app.setup .add { order: 2; }
.app.setup .summary { order: 3; }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .7rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label, legend, .label-like { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
input[type=text], input[type=search], input[type=date], input[type=time], select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
select { -webkit-appearance: auto; appearance: auto; }
input[type=date] { -webkit-appearance: auto; appearance: auto; }
textarea { resize: vertical; line-height: 1.4; min-height: 84px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
select option { color: #111; background: #fff; }
input:focus-visible, button:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
.hint { margin: .45rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.hint:empty { display: none; }
[hidden] { display: none !important; }
.warn-box { margin: 0 0 .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--warn-bg); border-left: 5px solid var(--warn); font-weight: 600; }

/* buttons */
.primary, .secondary, .danger { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .8rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.secondary { border: 1px solid var(--line); background: var(--field); color: var(--ink); font-weight: 600; }
.secondary.small { width: auto; min-height: 44px; padding: 0 .85rem; font-size: .92rem; margin: 0; }
.danger { border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; margin-top: .9rem; }
button:disabled { opacity: .45; cursor: default; }
.link { display: block; min-height: 44px; margin-top: .3rem; padding: 0 .1rem; border: 0; background: none; color: var(--accent); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; }
.err { margin: .4rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.err:empty { margin: 0; }
.msg { margin: 0; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.msg.show { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: .2rem 0 .8rem; padding: .5rem .75rem; border-radius: 12px; background: var(--soft); color: var(--ink); }
.msg .undo { min-height: 40px; padding: 0 .9rem; border: 1px solid var(--accent); border-radius: 10px; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.settings .msg.show { margin: .8rem 0 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.row-btns > * { flex: 1 1 9rem; width: auto; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: .4rem; }
.tool-grid .wide { grid-column: 1 / -1; }
.settings .tool-grid + label { margin-top: 1.1rem; }
.settings select + .tool-grid { margin-top: 1rem; }

/* today */
.summary { border: 2px solid var(--accent); }
.next-label { margin: 0; color: var(--muted); font-weight: 700; font-size: .95rem; }
.next { margin: .1rem 0 0; font-size: 1.25rem; font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; color: var(--warn); }
.next.ok { color: var(--accent); margin-top: 0; }
.next-left { margin: .45rem 0 0; font-size: 1rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.sum-empty { margin: 0; color: var(--muted); }
.water-all { margin-top: .8rem; }
.feed-due { margin: .6rem 0 0; padding: .45rem .7rem; border-radius: 12px; background: var(--soft); font-weight: 700; overflow-wrap: anywhere; }
fieldset.season { border: 0; margin: .4rem 0 0; padding: 0; min-width: 0; }
fieldset.season legend { margin: .9rem 0 .4rem; }

/* the list */
.empty { margin: 0; color: var(--muted); }
.group { margin-top: .9rem; }
.group:first-of-type { margin-top: 0; }
.g-h { margin: .2rem 0 .55rem; font-size: 1rem; color: var(--accent); }
.g-h.warn { color: var(--warn); }
.g-hint { margin: -.2rem 0 .55rem; }
details.archive summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.box-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.box-list:empty { display: none; }
.box { border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: .65rem .8rem .7rem; background: var(--field); min-width: 0; transition: box-shadow .3s; }
.box.now { border-left-color: var(--water); }
.box.late { border-left-color: var(--warn); }
.box.gone { border-left-color: var(--line); }
.box.flash { box-shadow: 0 0 0 3px var(--accent); }
.box-top { display: flex; justify-content: space-between; align-items: baseline; gap: .2rem .6rem; flex-wrap: wrap; }
.box-name { margin: 0; font-size: 1.08rem; overflow-wrap: anywhere; min-width: 0; }
.box-sub { margin: .1rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.box-note { margin: .35rem 0 0; font-size: .9rem; white-space: pre-line; overflow-wrap: anywhere; }
.st { margin: .35rem 0 0; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.st.now { color: var(--water); }
.st.late { color: var(--warn); }
.st.done { color: var(--muted); font-weight: 600; }
.feed { margin: .15rem 0 0; font-size: .93rem; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.feed.due { color: var(--ink); }
.box-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.mini { flex: 1 1 4.5rem; min-height: 44px; padding: 0 .6rem; border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--accent); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; min-width: 0; }
.mini.strong { flex-basis: 7rem; color: var(--ink); background: var(--soft); }
.mini.bad { color: var(--bad); }

/* the form */
.add #form { margin: 0; }
.add #form > label:first-child { margin-top: 0; }
.opt { min-width: 0; }
.inline { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.inline input { width: 5.5rem; flex: none; text-align: center; }
.inline.grow input { flex: 1 1 auto; width: auto; text-align: left; }
.inline.grow .small { flex: none; min-height: 48px; }
.unit { color: var(--muted); font-weight: 600; font-size: .92rem; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; }
.pair label { margin-top: .9rem; }
.preview { margin: 1rem 0 0; padding: .55rem .75rem; border-radius: 12px; background: var(--soft); font-weight: 600; overflow-wrap: anywhere; }
.preview:empty { display: none; }
.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.chip { min-height: 40px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--accent); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; }
label.check { display: flex; align-items: center; gap: .55rem; min-height: 44px; margin: .8rem 0 0; color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; }
label.check input { width: 1.2rem; height: 1.2rem; flex: none; margin: 0; accent-color: var(--accent); }
.edit-only { margin-top: .6rem; }
.edit-only .danger { margin-top: 0; }
.seg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .4rem; }
.seg label { display: flex; align-items: center; gap: .45rem; margin: 0; min-height: 48px; padding: .35rem .65rem; border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink); font-weight: 600; font-size: .92rem; cursor: pointer; line-height: 1.25; }
.seg label:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.seg input { margin: 0; flex: none; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

/* going away */
.trip .hint.top { margin: -.3rem 0 0; }
.trip .pair { margin-top: -.1rem; }
#trip-out { margin-top: 1rem; }
.trip-text { margin: 0 0 .7rem; padding: .7rem .8rem; border-radius: 12px; background: var(--field); border: 1px solid var(--line); font: inherit; font-size: .95rem; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 26rem; overflow: auto; }
.trip .msg.show { margin: .8rem 0 0; }
#trip-empty { margin-top: .8rem; }

/* place filter */
.places { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .8rem; }
.place { min-height: 40px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; max-width: 100%; overflow-wrap: anywhere; }
.place[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tool-grid.gap { margin-top: 1rem; }
input[type=time] { display: block; width: 100%; min-width: 0; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 12px; }

@media print {
    body { background: #fff; color: #000; padding: 0; display: block; }
    .app { width: 100%; display: block; }
    .back, .topbar, header .sub, .add, .trip, .settings, .faq, footer, .msg, .places, .box-btns, .archive, fieldset.season, .theme-toggle, .help-btn, .water-all { display: none !important; }
    .card, .box { border-color: #999; background: #fff; break-inside: avoid; }
    .st, .st.now, .st.late, .g-h, .g-h.warn, .box-sub, .next, .feed { color: #000; }
    body.print-trip .app > *:not(.col-side), body.print-trip .col-main, body.print-trip .col-side > *:not(.trip) { display: none !important; }
    body.print-trip .trip { display: block !important; border: 0; padding: 0; }
    body.print-trip .trip > *:not(#trip-out), body.print-trip #trip-out .tool-grid { display: none !important; }
    body.print-trip .trip-text { max-height: none; overflow: visible; border: 0; background: #fff; color: #000; font-size: 13pt; }
}

/* questions */
.faq { margin-top: 1.2rem; }
.faq details { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .5rem; background: var(--card); }
.faq summary { cursor: pointer; padding: .75rem .9rem; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0; padding: 0 .9rem .8rem; color: var(--muted); }
footer { margin-top: 1.4rem; text-align: center; font-size: .9rem; }
footer a { color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }

/* narrow phones */
@media (max-width: 420px) {
    .card { padding: 1rem .8rem; }
    .box { padding: .6rem .65rem .65rem; }
    .tool-grid { grid-template-columns: minmax(0, 1fr); }
    .row-btns > * { flex-basis: 100%; }
    .inline.grow { flex-wrap: wrap; }
    .trip .pair { grid-template-columns: minmax(0, 1fr); }
    .inline.grow .small { flex: 1 1 100%; }
    h1 { font-size: 1.5rem; }
}
@media (max-width: 360px) {
    .topbar .theme-toggle { padding: 0; width: 44px; justify-content: center; }
    .topbar .theme-toggle span { display: none; }
    .pair { grid-template-columns: minmax(0, 1fr); }
    .inline:not(.grow) { flex-wrap: wrap; }
}

/* laptops and desktops: today and the plants on the left, the form, trip and tools on the right */
@media (min-width: 900px) {
    .app { width: min(1140px, 100%); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .col-main, .col-side { display: block; min-width: 0; }
    .app > .topbar { grid-row: 1; }
    .app > header { grid-row: 2; }
    .app > .warn-box { grid-row: 3; }
    .app > .col-main { grid-column: 1; grid-row: 4; }
    .app > .col-side { grid-column: 2; grid-row: 4; }
    .app > .faq { grid-row: 5; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.3rem; }
    .next { font-size: 1.45rem; }
}
