/* Nebari — design tokens. Brand green #2D5336 from the logo; black, white and greys around it. */
@font-face { font-family: "Geist"; src: url("/fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f5f3;
  --surface-3: #eceeeb;
  --ink: #0d0f0d;
  --ink-2: #2a2f2b;
  --muted: #6a726b;
  --line: #e6e9e5;
  --brand: #2d5336;
  --brand-hover: #234229;
  --brand-ink: #2d5336;
  --brand-soft: #e8efe9;
  --on-brand: #ffffff;
  --danger: #c0392b;
  --danger-soft: #fbeae7;
  --warn: #a86b12;
  --warn-soft: #fbf1df;
  --overlay: rgba(10, 12, 10, .5);
  --glass: rgba(255, 255, 255, .82);
  --shadow-sm: 0 1px 2px rgba(13, 15, 13, .05);
  --shadow: 0 1px 2px rgba(13, 15, 13, .04), 0 8px 24px rgba(13, 15, 13, .06);
  --shadow-lg: 0 24px 64px rgba(13, 15, 13, .18);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --nav: #4c7b58;
  --nav-ink: #ffffff;
  --tabbar-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d0b;
    --surface: #131613;
    --surface-2: #1a1e1a;
    --surface-3: #222722;
    --ink: #eef1ee;
    --ink-2: #cdd3cd;
    --muted: #8b948c;
    --line: #252a25;
    --brand: #2d5336;
    --brand-hover: #386743;
    --brand-ink: #8fc49b;
    --brand-soft: #1a271d;
    --nav: #3b6347;
    --danger: #ef7b6c;
    --danger-soft: #2c1714;
    --warn: #e2a64b;
    --warn-soft: #2a2112;
    --overlay: rgba(0, 0, 0, .6);
    --glass: rgba(19, 22, 19, .8);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d0b;
  --surface: #131613;
  --surface-2: #1a1e1a;
  --surface-3: #222722;
  --ink: #eef1ee;
  --ink-2: #cdd3cd;
  --muted: #8b948c;
  --line: #252a25;
  --brand: #2d5336;
  --brand-hover: #386743;
  --brand-ink: #8fc49b;
  --brand-soft: #1a271d;
  --nav: #3b6347;
  --danger: #ef7b6c;
  --danger-soft: #2c1714;
  --warn: #e2a64b;
  --warn-soft: #2a2112;
  --overlay: rgba(0, 0, 0, .6);
  --glass: rgba(19, 22, 19, .8);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
.when, .stat b, .facts dd, .tl-meta, .money { font-variant-numeric: tabular-nums; }
.ico { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--nav); color: var(--nav-ink); padding-top: env(safe-area-inset-top); box-shadow: 0 1px 0 rgba(0, 0, 0, .06); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--nav-ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand b { font-size: 19px; font-weight: 650; letter-spacing: -.03em; display: block; line-height: 1.2; }
.brand small { display: block; font-size: 11.5px; color: rgba(255, 255, 255, .75); font-weight: 450; }
.mainnav { display: flex; gap: 2px; background: rgba(0, 0, 0, .14); padding: 4px; border-radius: 999px; }
.mainnav a { display: flex; align-items: center; gap: 7px; color: rgba(255, 255, 255, .82); font-weight: 550; font-size: 14px; padding: 7px 14px; border-radius: 999px; }
.mainnav a:hover { color: #fff; text-decoration: none; }
.mainnav a.on { color: var(--brand); background: #fff; box-shadow: var(--shadow-sm); }
.mainnav .ico { width: 17px; height: 17px; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; border: none; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; flex-shrink: 0; }
.icon-btn:hover { background: rgba(255, 255, 255, .24); }
.topbar #new-btn { background: var(--brand); box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); }
.topbar #new-btn:hover { background: var(--brand-hover); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 56px; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 999px; padding: 9px 16px; font-weight: 550; font-size: 14px; cursor: pointer; background: var(--brand); color: var(--on-brand); white-space: nowrap; line-height: 1.2; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--brand-hover); text-decoration: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { background: var(--brand-soft); border-color: var(--brand-ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: 13px; font-weight: 550; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; background: var(--surface); outline: none; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236a726b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-ink) 18%, transparent); }
textarea { min-height: 84px; resize: vertical; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 16px; }

/* ---------- Page heads, stats ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; letter-spacing: -.035em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--surface-2); border-radius: var(--r); padding: 16px 18px; }
.stat b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.alert b { color: var(--danger); }
.stat.due b { color: var(--warn); }
.section-title { font-size: 18px; margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-title .count { font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 2px 8px; }
.section-title .count.red { background: var(--danger-soft); color: var(--danger); }
.section-title .count.amber { background: var(--warn-soft); color: var(--warn); }
.section-title .right { margin-left: auto; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 550; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge .ico { width: 13px; height: 13px; }
.badge.green { background: var(--brand-soft); color: var(--brand-ink); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.dark { background: var(--ink); color: var(--bg); }
.badge.outline { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* ---------- Lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row.link { cursor: pointer; }
.row.link:hover { background: var(--surface-2); }
.row .main { flex: 1; min-width: 0; }
.row .main b { font-weight: 600; }
.row .main small { display: block; color: var(--muted); font-size: 13px; }
.row .when { font-size: 13px; font-weight: 550; white-space: nowrap; color: var(--muted); }
.row .when.late { color: var(--danger); }
.row .when.now { color: var(--warn); }
.row.off { opacity: .5; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chip-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); flex-shrink: 0; }
.chip-ico.red { background: var(--danger-soft); color: var(--danger); }
.chip-ico.amber { background: var(--warn-soft); color: var(--warn); }
.chip-ico.dark { background: var(--ink); color: var(--bg); }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.search { position: relative; flex: 1; min-width: 200px; }
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 40px; border-radius: 999px; background: var(--surface-2); border-color: transparent; }
.toolbar select { width: auto; min-width: 190px; border-radius: 999px; }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 999px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: none; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 550; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Photo cards (trees, pots) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.pcard { position: relative; display: block; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 4 / 5; background: var(--surface-2); color: #fff; box-shadow: var(--shadow); isolation: isolate; }
.pcard:hover { text-decoration: none; }
.pcard > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.pcard:hover > img { transform: scale(1.04); }
.pcard .ph { position: absolute; inset: 0; display: grid; place-items: center; background: var(--brand-soft); }
.pcard .ph img { width: 42%; opacity: .22; }
.pcard .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .25) 0%, transparent 28%, transparent 50%, rgba(0, 0, 0, .78) 100%); }
.pcard .top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.pcard .top .badge { background: rgba(0, 0, 0, .45); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.pcard .top .badge.red { background: rgba(192, 57, 43, .9); }
.pcard .top .badge.amber { background: rgba(168, 107, 18, .92); }
.pcard .bottom { position: absolute; left: 16px; right: 16px; bottom: 14px; }
.pcard h3 { font-size: 20px; letter-spacing: -.025em; text-shadow: 0 1px 12px rgba(0, 0, 0, .3); }
.pcard .sub { font-size: 13.5px; opacity: .85; margin-top: 1px; }
.pcard .sub i { font-style: italic; }
.pcard.noimg { color: var(--ink); }
.pcard.noimg .shade { display: none; }
.pcard.noimg .top .badge { background: var(--surface); color: var(--ink-2); }
.pcard.retired > img { filter: grayscale(1); }
.pcard.retired { opacity: .85; }

.empty { text-align: center; padding: 56px 24px; color: var(--muted); background: var(--surface-2); border-radius: var(--r-lg); }
.empty > img { width: 72px; margin: 0 auto 14px; opacity: .5; }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 19px; }
.empty p { max-width: 460px; margin: 0 auto 16px; }

/* ---------- Detail page (tree / pot) ---------- */
.hero { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--brand-soft); aspect-ratio: 16 / 7; max-height: 480px; width: 100%; margin-bottom: 26px; color: #fff; }
.hero > img.bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .35) 0%, transparent 30%, transparent 45%, rgba(0, 0, 0, .75) 100%); pointer-events: none; }
.hero .ph { position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer; }
.hero .ph img { width: 120px; opacity: .2; }
.hero.noimg { color: var(--ink); }
.hero.noimg .shade { display: none; }
.hero .bar { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 8px; }
.hero .round { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .4); color: #fff; border: none; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hero.noimg .round { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.hero .round:hover { background: rgba(0, 0, 0, .6); text-decoration: none; }
.hero.noimg .round:hover { background: var(--surface-2); }
.hero .title { position: absolute; left: 24px; right: 24px; bottom: 20px; pointer-events: none; }
.hero h1 { font-size: 40px; letter-spacing: -.04em; line-height: 1.05; text-shadow: 0 2px 20px rgba(0, 0, 0, .25); }
.hero .sub { font-size: 16px; opacity: .9; margin-top: 4px; }
.hero .sub i { font-style: italic; }
.hero .title .badges { margin-top: 10px; }
.hero .title .badge { background: rgba(255, 255, 255, .18); color: #fff; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.hero.noimg .title .badge { background: var(--surface); color: var(--ink-2); }
.hero.retired > img.bg { filter: grayscale(1); }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.aside { position: sticky; top: 84px; display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 .btn { text-transform: none; letter-spacing: 0; }
.facts { display: grid; gap: 9px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.facts div:last-child { border-bottom: none; padding-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; text-align: right; }
.notes { white-space: pre-wrap; color: var(--ink-2); font-size: 14.5px; margin: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 4px; border-radius: 999px; margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1; background: none; border: none; padding: 8px 14px; font-weight: 550; font-size: 14px; color: var(--muted); cursor: pointer; border-radius: 999px; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tab.active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.tab .count { font-size: 11.5px; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 6px; line-height: 18px; min-width: 18px; }
.tab-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.tab-head h2 { font-size: 20px; }

.banner { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; border-radius: var(--r); padding: 14px 18px; margin-bottom: 18px; background: var(--ink); color: var(--bg); }
.banner b { font-size: 17px; }
.banner.soft { background: var(--brand-soft); color: var(--ink); }
.banner.soft b { color: var(--brand-ink); }
.banner.warn { background: var(--warn-soft); color: var(--ink); }
.banner.warn b { color: var(--warn); }
.banner .btn-ghost { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 30%, transparent); }

/* Timeline */
.timeline { position: relative; padding-left: 34px; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.tl-year { font-size: 22px; font-weight: 650; letter-spacing: -.03em; margin: 24px 0 12px -34px; background: var(--bg); position: relative; padding: 2px 0; }
.tl-year:first-child { margin-top: 0; }
.tl-item { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 15px; margin-bottom: 12px; }
.tl-dot { position: absolute; left: -35px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); border: 3px solid var(--bg); }
.tl-dot .ico { width: 12px; height: 12px; stroke-width: 2.4; }
.tl-dot.dark { background: var(--ink); color: var(--bg); }
.tl-dot.red { background: var(--danger-soft); color: var(--danger); }
.tl-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-item h4 { margin: 3px 0 2px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.tl-item p { margin: 4px 0 0; white-space: pre-wrap; color: var(--ink-2); font-size: 14.5px; }
.tl-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 10px; }
.tl-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.photo { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); cursor: zoom-in; aspect-ratio: 1; }
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.photo:hover img { transform: scale(1.04); }
.photo .date { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; font-size: 12.5px; font-weight: 550; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.photo .star { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(6px); }

/* Records (repots / health) */
.rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 15px 16px; margin-bottom: 10px; display: flex; gap: 14px; align-items: flex-start; }
.rec .main { flex: 1; min-width: 0; }
.rec h4 { margin: 0; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rec dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 9px 0 0; font-size: 14px; }
.rec dt { color: var(--muted); }
.rec dd { margin: 0; white-space: pre-wrap; }
.rec .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; }
.pot-box { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 8px; }
.card .pot-box { border: none; padding: 0; margin: 0; }
.pot-box .thumb { width: 72px; height: 56px; border-radius: 10px; background: var(--brand-soft); overflow: hidden; flex-shrink: 0; display: grid; place-items: center; color: var(--brand-ink); }
.pot-box .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pot-box .main { flex: 1; min-width: 0; }
.pot-box .main b { color: var(--ink); }
.pot-box .main small { color: var(--muted); display: block; font-size: 13px; }
.seal { display: flex; gap: 12px; align-items: center; }
.seal img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; cursor: zoom-in; }

/* ---------- Modal / bottom sheet ---------- */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: 100%; max-width: 600px; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal.wide { max-width: 1100px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: 12px 22px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.x { background: var(--surface-2); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.x:hover { color: var(--ink); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes up { from { transform: translateY(100%); } }

.actions-sheet { display: grid; gap: 6px; }
.actions-sheet button { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: none; background: var(--surface-2); padding: 12px 14px; border-radius: var(--r); cursor: pointer; font-weight: 550; font-size: 15px; }
.actions-sheet button:hover { background: var(--surface-3); }
.actions-sheet button small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }

.upload-list { display: grid; gap: 10px; margin-top: 12px; }
.upload-item { display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: start; background: var(--surface-2); border-radius: var(--r); padding: 10px; }
.upload-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; }
.upload-item .err { color: var(--danger); font-size: 13px; }
.drop { display: block; border: 1.5px dashed var(--line); border-radius: var(--r); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; transition: all .15s; font-weight: 450; }
.drop:hover, .drop.over { border-color: var(--brand-ink); background: var(--brand-soft); color: var(--brand-ink); }
.drop .ico { width: 28px; height: 28px; margin: 0 auto 6px; display: block; }

.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.months label { margin: 0; }
.months input { display: none; }
.months span { display: block; text-align: center; padding: 8px 0; background: var(--surface-2); border-radius: 8px; font-size: 12.5px; cursor: pointer; font-weight: 600; color: var(--muted); }
.months input:checked + span { background: var(--brand); color: #fff; }
.freq { display: grid; grid-template-columns: 1fr 90px 1fr; gap: 8px; }
.tree-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; max-height: 210px; overflow-y: auto; background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; }

/* Viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: #050605; display: flex; flex-direction: column; color: #fff; animation: fade .15s; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.viewer-top { display: flex; align-items: center; gap: 8px; padding: 12px 16px; flex-wrap: wrap; }
.viewer-top .title { flex: 1; min-width: 150px; }
.viewer-top .title small { color: #9aa49b; display: block; }
.viewer .x { background: rgba(255, 255, 255, .12); color: #fff; }
.viewer-img { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; padding: 0 64px 18px; touch-action: pan-y; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255, 255, 255, .1); border: none; color: #fff; width: 46px; height: 46px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.nav:hover { background: rgba(255, 255, 255, .2); }
.nav.prev { left: 10px; } .nav.next { right: 10px; }
.viewer .btn-ghost { background: rgba(255, 255, 255, .08); color: #e6ebe6; border-color: transparent; }
.viewer .btn-ghost:hover { background: rgba(255, 255, 255, .16); }
.viewer .btn-danger { color: #ff9c8f; border-color: transparent; background: rgba(255, 120, 100, .1); }
.viewer .badge { background: rgba(255, 255, 255, .14); color: #fff; }

/* Compare */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compare figure { margin: 0; }
.compare img { width: 100%; max-height: 70vh; object-fit: contain; background: #050605; border-radius: var(--r); }
.compare figcaption { margin-top: 8px; font-weight: 600; }
.compare figcaption small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.slider-wrap { position: relative; overflow: hidden; border-radius: var(--r); background: #050605; user-select: none; touch-action: none; aspect-ratio: 4 / 3; }
.slider-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.slider-wrap .after { position: absolute; inset: 0; }
.slider-wrap .handle { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; transform: translateX(-1px); cursor: ew-resize; }
.slider-wrap .handle span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; color: #2d5336; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); }

/* Toast */
.toast { position: fixed; bottom: calc(24px + var(--tabbar-h) + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 80; box-shadow: var(--shadow-lg); animation: fade .2s; max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); color: #fff; }

/* Footer (backups) */
.foot { max-width: 1200px; margin: 0 auto; padding: 18px 24px calc(40px + var(--tabbar-h) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 13px; color: var(--muted); }
.foot .hint { flex-basis: 100%; margin: 0; overflow-wrap: anywhere; }

/* Mobile tab bar + floating button (hidden on desktop) */
.tabbar, .fab { display: none; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--surface-2); padding: 16px; }
.login form { background: var(--surface); border-radius: var(--r-lg); padding: 32px 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); text-align: center; }
.login img { width: 84px; margin: 0 auto; }
.login h1 { font-size: 28px; letter-spacing: -.04em; margin: 12px 0 2px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login label { text-align: left; }
.login .error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 8px 0; }

/* Collapsible cards (tree/pot sheet on the side) */
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h3 { margin-bottom: 0; }
details.card[open] > summary h3 { margin-bottom: 12px; }
details.card > summary .chev { transition: transform .2s; }
details.card[open] > summary .chev { transform: rotate(180deg); }
.detail > .aside { grid-column: 2; grid-row: 1; }
.detail > .content { grid-column: 1; grid-row: 1; min-width: 0; }

/* ---------- Tablet ---------- */
@media (max-width: 980px) {
  .detail { grid-template-columns: 1fr; gap: 18px; }
  .detail > .aside, .detail > .content { grid-column: auto; grid-row: auto; }
  .aside { position: static; grid-template-columns: 1fr 1fr; align-items: start; }
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  :root { --tabbar-h: 64px; }
  .topbar-inner { padding: 10px 16px; gap: 12px; }
  .brand img { width: 30px; height: 30px; }
  .brand small { display: none; }
  .topbar .mainnav, .topbar #new-btn { display: none; }
  main { padding: 18px 16px 28px; }
  .page-head h1 { font-size: 28px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; gap: 0; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .aside { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pcard { border-radius: var(--r); }
  .pcard h3 { font-size: 16px; }
  .pcard .sub { font-size: 12.5px; }
  .pcard .bottom { left: 12px; right: 12px; bottom: 10px; }
  .pcard .top { top: 8px; left: 8px; right: 8px; }
  .pcard .top .badge { font-size: 11px; padding: 2px 7px; }
  .hero { aspect-ratio: 1 / 1; max-height: 62vh; border-radius: 0; margin: -18px -16px 18px; width: calc(100% + 32px); }
  .hero h1 { font-size: 30px; }
  .hero .title { left: 18px; right: 18px; bottom: 16px; }
  .quick { display: none; }
  .tab { flex: none; padding: 8px 12px; font-size: 13.5px; }
  .compare { grid-template-columns: 1fr; }
  .months { grid-template-columns: repeat(6, 1fr); }
  .freq { grid-template-columns: 1fr 1fr; }
  .freq > :first-child { grid-column: 1 / -1; }
  .toolbar select { width: 100%; }
  .row { flex-wrap: wrap; padding: 12px 14px; }
  .row .row-actions { width: 100%; padding-left: 52px; }
  .rec { flex-direction: column; }
  .rec .side { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .viewer-img { padding: 0 0 12px; }
  .viewer .nav { display: none; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .photo { border-radius: 6px; }
  .photo .date { font-size: 11px; padding: 14px 6px 5px; }

  /* Sheets slide up from the bottom */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 22px 22px 0 0; max-height: 94vh; display: flex; flex-direction: column; animation: up .25s cubic-bezier(.2, .8, .2, 1); }
  .modal-head { padding: 18px 18px 4px; position: relative; }
  .modal-head::before { content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 4px; background: var(--line); }
  .modal-body { overflow-y: auto; padding: 10px 18px 16px; }
  .modal-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .modal-foot .left { flex-basis: 100%; order: 3; margin: 0; }

  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--nav); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: rgba(255, 255, 255, .7); font-size: 11.5px; font-weight: 550; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.on { color: #fff; }
  .tabbar a.on .ico { stroke-width: 2.3; }
  .tabbar .ico { width: 23px; height: 23px; }
  .fab { display: grid; place-items: center; position: fixed; z-index: 45; right: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--brand); color: #fff; border: 3px solid #fff; box-shadow: 0 10px 28px rgba(45, 83, 54, .45); cursor: pointer; }
  .fab .ico { width: 26px; height: 26px; stroke-width: 2.2; }
}
