* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #f4f7f2; color: #1f2d1f; line-height: 1.5; }
.site-header { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem max(1rem, calc((100% - 64rem) / 2 + 1rem)); background: #fff; border-bottom: 1px solid #d9e3d4; }
.site-name { display: flex; align-items: center; color: inherit; text-decoration: none; }
.site-name img { display: block; height: 40px; width: auto; }
@media (max-width: 399px) { .site-name img { height: 30px; } }
@media (max-width: 379px) { .site-name img { height: 26px; } }
.site-nav .button, .site-nav a { white-space: nowrap; }
.inline-form { margin: 0; }
.page { max-width: 32rem; margin: 0 auto; padding: 1.5rem 1rem; }
.form { display: flex; flex-direction: column; gap: 0.5rem; }
.form input { width: 100%; max-width: 100%; padding: 0.65rem 0.75rem; font: inherit; border: 1px solid #b7c7b0; border-radius: 0.4rem; background: #fff; }
.form .button { margin-top: 0.75rem; width: auto; }
.button { padding: 0.65rem 1rem; font: inherit; color: #fff; background: #2f6b3a; border: 0; border-radius: 0.4rem; cursor: pointer; }
.button-link { padding: 0.35rem 0.5rem; color: #2f6b3a; background: none; text-decoration: underline; }
.alert { padding: 0.65rem 0.75rem; color: #7a1f1f; background: #fbe9e9; border: 1px solid #e4b4b4; border-radius: 0.4rem; }

/* Layout */
.site-header { flex-wrap: wrap; gap: 0.5rem; }
.site-header { flex-wrap: nowrap; }
.site-nav { display: flex; align-items: center; gap: 0.5rem; }
a.button-small, .button-small { padding: 0.4rem 0.7rem; font-size: 0.9rem; color: #fff; }
.page { max-width: 64rem; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; }
a { color: #2f6b3a; }
.notice { padding: 0.65rem 0.75rem; color: #1f4d29; background: #e6f3e6; border: 1px solid #b7d9b7; border-radius: 0.4rem; }

/* Forms */
.form select, .form textarea, .filters input, .filters select { width: 100%; padding: 0.65rem 0.75rem; font: inherit; border: 1px solid #b7c7b0; border-radius: 0.4rem; background: #fff; }
.form { max-width: 32rem; }
.form input[type="file"] { padding: 0.4rem 0; border: 0; background: none; }
.form label { font-weight: 500; margin-top: 0.4rem; }
.form fieldset { margin: 0.4rem 0 0; padding: 0.5rem 0.75rem 0.75rem; border: 1px solid #d9e3d4; border-radius: 0.4rem; }
.row-fields { display: flex; gap: 0.75rem; }
.row-fields legend { padding: 0 0.25rem; }
.row-fields label { flex: 1; margin-top: 0; }
.row-fields label span { display: block; font-size: 0.85rem; color: #4d614d; }
.row-fields input { width: 100%; }
.hint { font-size: 0.85rem; color: #4d614d; }
.field-error { font-size: 0.9rem; color: #7a1f1f; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.button-danger { color: #8a2222; }
a.button { display: inline-block; text-decoration: none; }
a.button-link { text-decoration: underline; }

/* Collection */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; min-height: 0; overflow: hidden; }
.filters label span { display: block; font-size: 0.85rem; color: #4d614d; }
.filter-wide, .filter-actions { grid-column: 1 / -1; }
.filter-actions { display: flex; align-items: center; gap: 1rem; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.title-row h1 { margin: 0; min-width: 0; }
.filter-toggle { display: inline-flex; align-items: center; gap: 0.4rem; flex: none; white-space: nowrap; padding: 0.45rem 0.75rem; color: #2f6b3a; background: #fff; border: 1px solid #b7c7b0; }
a.filter-toggle { display: inline-flex; }
.filter-toggle.is-active { color: #fff; background: #2f6b3a; border-color: #2f6b3a; }
.filter-toggle .icon { flex: none; }
.filters[hidden] { display: none; }
/* Smooth expand/collapse: grid row 0fr -> 1fr; transitions are enabled by JS (.filters-ready) after the first frame. */
.filters-panel { display: grid; grid-template-rows: 0fr; opacity: 0; margin-bottom: 0; }
.filters-panel.is-open { grid-template-rows: 1fr; opacity: 1; margin-bottom: 1rem; }
.filters-panel.filters-ready { transition: grid-template-rows 250ms ease, opacity 200ms ease, margin-bottom 250ms ease; }
/* A small, user-triggered expand: kept under reduced motion, only gentler (same grid-template-rows transition, 180ms, ease-out). */
@media (prefers-reduced-motion: reduce) { .filters-panel.filters-ready { transition: grid-template-rows 180ms ease-out; } }
.count-reset { margin-left: 0.5rem; font-size: 0.9rem; }
.count { color: #4d614d; margin: 0 0 0.75rem; }
.empty { text-align: center; padding: 2rem 0; }
.plant-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.plant-card { background: #fff; border: 1px solid #d9e3d4; border-radius: 0.5rem; overflow: hidden; display: flex; flex-direction: column; }
.plant-card > a { color: inherit; text-decoration: none; }
.plant-thumb { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #eef3ea; }
.plant-thumb-empty { display: flex; align-items: center; justify-content: center; color: #7a8d7a; font-size: 0.85rem; }
.plant-name { display: block; padding: 0.5rem 0.6rem 0.25rem; font-weight: 600; overflow-wrap: anywhere; }
.plant-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; padding: 0 0.6rem 0.6rem; font-size: 0.85rem; color: #4d614d; }
.tag { padding: 0 0.4rem; background: #e6f3e6; border-radius: 0.3rem; }
.tag-status { background: #f3ece0; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; padding: 0 0.4rem 0.4rem; }

/* Plant page */
.plant-cover { display: block; width: 100%; max-width: 32rem; height: auto; border-radius: 0.5rem; }
.gallery { list-style: none; margin: 0.75rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gallery img { display: block; width: 5rem; height: 5rem; object-fit: cover; border-radius: 0.4rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 1rem 0; max-width: 40rem; }
.facts dt { color: #4d614d; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Select with an add button, and the add dialog */
.select-row { display: flex; align-items: center; gap: 0.5rem; }
.select-row select { flex: 1; min-width: 0; }
.select-row .button { margin-top: 0; flex: none; }
.dialog { width: calc(100% - 2rem); max-width: 24rem; padding: 1rem; border: 1px solid #b7c7b0; border-radius: 0.5rem; background: #fff; color: inherit; }
.dialog::backdrop { background: rgba(31, 45, 31, 0.5); }
.dialog-title { margin: 0 0 0.5rem; }
.dialog .form-actions { margin-top: 0.5rem; }

@media (min-width: 40rem) {
    .plant-grid { grid-template-columns: repeat(4, 1fr); }
    .filters { grid-template-columns: repeat(4, 1fr) ; }
    .filter-wide { grid-column: 1 / -1; }
}

/* Header gear and checkbox rows */
.icon-link { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; color: #2f6b3a; border-radius: 0.4rem; }
.icon-link:hover, .icon-link:focus-visible { background: #e6f3e6; }
.form input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; padding: 0; accent-color: #2f6b3a; flex: none; }
.form label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; margin-top: 0.6rem; }
.form .field-error, .form .hint { margin: 0; }

/* Sign-in page: white base, a flowing plant-coloured ribbon behind a centred card, thin guide lines (CSS only). */
body.page-login { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: #fff; position: relative; overflow-x: clip; }
body.page-login::before, body.page-login::after { content: ""; position: fixed; top: 4rem; bottom: 0; width: 1px; background: rgba(31, 45, 31, 0.08); z-index: 1; pointer-events: none; }
body.page-login::before { left: max(1rem, calc((100% - 1080px) / 2)); }
body.page-login::after { right: max(1rem, calc((100% - 1080px) / 2)); }
.login-bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; background: radial-gradient(60% 50% at 85% 0%, rgba(214, 240, 190, 0.55), transparent 70%), #fff; }
.login-bg::before, .login-bg::after { content: ""; position: absolute; left: -25%; width: 150%; transform-origin: center; }
.login-bg::before {
    top: 30%; height: 42%; transform: rotate(-16deg) skewX(-14deg); border-radius: 50% 45% 55% 40% / 60% 50% 50% 45%; filter: blur(14px); opacity: 0.9;
    background:
        radial-gradient(40% 90% at 78% 70%, #f2b79a 0%, rgba(242, 183, 154, 0) 70%),
        radial-gradient(35% 80% at 55% 30%, #c8ee6a 0%, rgba(200, 238, 106, 0) 70%),
        linear-gradient(95deg, #2f9e6b 0%, #4cc08a 25%, #9fdc5c 48%, #3fb8a5 72%, #1f8a8a 100%);
}
.login-bg::after {
    top: 52%; height: 22%; transform: rotate(-16deg) skewX(-14deg); border-radius: 60% 40% 50% 50% / 50% 60% 40% 50%; filter: blur(22px); opacity: 0.55;
    background: linear-gradient(100deg, rgba(31, 138, 138, 0) 5%, #63c7a8 30%, #d7f07a 55%, #f4c3a6 80%, rgba(244, 195, 166, 0) 100%);
}
.login-header, .login-main, .login-footer { position: relative; z-index: 2; }
.login-header { display: flex; align-items: center; height: 4rem; padding: 0 max(1rem, calc((100% - 1080px) / 2)); background: rgba(255, 255, 255, 0.75); border-bottom: 1px solid rgba(31, 45, 31, 0.1); }
.login-header .site-name img { height: 48px; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.login-card { width: 100%; max-width: 440px; padding: 2.5rem; background: #fff; border-radius: 8px; box-shadow: 0 18px 40px -12px rgba(31, 61, 39, 0.25), 0 6px 16px rgba(31, 45, 31, 0.1), 0 0 0 1px rgba(31, 45, 31, 0.05); }
.login-card h1 { margin: 0 0 1.5rem; font-size: 1.5rem; line-height: 1.25; }
.login-card .alert { margin: 0 0 1rem; }
.login-card .form { max-width: none; gap: 0.35rem; }
.login-card .form label { margin-top: 0.6rem; }
.login-card .form label.check { margin-top: 0.9rem; }
.login-card .form .button { width: 100%; margin-top: 1.25rem; padding: 0.8rem 1rem; font-weight: 600; border-radius: 6px; }
.login-footer { padding: 1rem max(1rem, calc((100% - 1080px) / 2)) 1.5rem; text-align: left; font-size: 0.85rem; color: #4d614d; }
@media (max-width: 40rem) {
    body.page-login::before, body.page-login::after { display: none; }
}
@media (max-width: 30rem) {
    .login-card { padding: 1.5rem 1.25rem; }
}

/* PIN boxes: square one-digit inputs, four at first, growing to twelve */
.form .pin-group { margin: 0.4rem 0 0; padding: 0; border: 0; min-width: 0; }
.pin-group legend { padding: 0; margin-bottom: 0.4rem; font-weight: 500; }
.pin-group legend.visually-hidden { margin: -1px; padding: 0; }
.pin-boxes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.form .pin-boxes input { flex: 0 0 calc((100% - 40px) / 6); width: calc((100% - 40px) / 6); min-width: 0; max-width: 48px; aspect-ratio: 1 / 1; padding: 0; font-size: 1.5rem; font-weight: 600; text-align: center; }
.pin-group noscript input { width: 100%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Dialog close button, secondary button, list pages */
.dialog { position: relative; }
.dialog-x { position: absolute; top: 0.4rem; right: 0.4rem; width: 2rem; height: 2rem; padding: 0; font-size: 1.5rem; line-height: 1; color: #4d614d; background: none; border: 0; border-radius: 0.4rem; cursor: pointer; }
.dialog-title { padding-right: 2rem; }
.dialog .form-actions { flex-wrap: wrap; gap: 0.5rem 1rem; }
.dialog .button-secondary { color: #2f6b3a; background: #e6f3e6; }
.inline-row { display: flex; align-items: center; gap: 0.5rem; }
.inline-row input { flex: 1; min-width: 0; }
.dir-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.dir-list li { background: #fff; border: 1px solid #d9e3d4; border-radius: 0.5rem; padding: 0.6rem; }
.dir-list input { padding: 0.5rem 0.6rem; font: inherit; border: 1px solid #b7c7b0; border-radius: 0.4rem; }
.dir-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 0.4rem; font-size: 0.9rem; color: #4d614d; }
.plant-group { margin: 0 0 1.5rem; }
.plant-group h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
