:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --surface: #fffdf9;
  --surface-2: #efe7da;
  --ink: #1c2822;
  --muted: #66716b;
  --line: #e2d8c8;
  --brand: #1e5a43;
  --brand-ink: #ffffff;
  --brand-soft: #e2efe8;
  --accent: #b02a33;
  --accent-ink: #ffffff;
  --ok: #1d7448;
  --ok-soft: #dff1e6;
  --danger: #b02a33;
  --shadow: 0 1px 2px rgba(28, 40, 34, .06), 0 4px 14px rgba(28, 40, 34, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1412;
    --surface: #161f1b;
    --surface-2: #1e2924;
    --ink: #e8eee9;
    --muted: #9aa69f;
    --line: #2a3631;
    --brand: #62c294;
    --brand-ink: #0e1412;
    --brand-soft: #1b2e25;
    --accent: #ee6a6f;
    --accent-ink: #1a0b0c;
    --ok: #74d6a0;
    --ok-soft: #183326;
    --danger: #ee6a6f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1412;
  --surface: #161f1b;
  --surface-2: #1e2924;
  --ink: #e8eee9;
  --muted: #9aa69f;
  --line: #2a3631;
  --brand: #62c294;
  --brand-ink: #0e1412;
  --brand-soft: #1b2e25;
  --accent: #ee6a6f;
  --accent-ink: #1a0b0c;
  --ok: #74d6a0;
  --ok-soft: #183326;
  --danger: #ee6a6f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
h1 { font-size: 1.35rem; margin: 0 0 .4rem; }
p { margin: 0 0 .9rem; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.center { text-align: center; padding: 3rem 0; }
.wrap { max-width: 760px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.page { padding-top: 20px; padding-bottom: 96px; }
.stack { display: grid; gap: 10px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: var(--brand-ink);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.tree-body { fill: currentColor; }
.tree-trunk { fill: currentColor; opacity: .75; }
.tree-star { fill: #f2c14e; }
.brand-title { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.brand-sub { font-size: .8rem; opacity: .8; line-height: 1.1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.account { display: flex; align-items: center; gap: 8px; }
.who { font-size: .9rem; font-weight: 600; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid currentColor;
  background: transparent; color: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer; opacity: .9;
}
.topbar .btn-quiet { color: var(--brand-ink); border-color: currentColor; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent;
  padding: 10px 16px; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-lg { padding: 13px 18px; font-size: 1.05rem; }
.btn-sm { padding: 6px 12px; font-size: .9rem; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn:focus-visible, .field:focus-visible, .tab:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.field {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.field-lg { padding: 13px 14px; font-size: 1.05rem; }
.field::placeholder { color: var(--muted); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.narrow { max-width: 460px; margin: 24px auto; }

.tabs {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px 16px; padding: 2px 16px 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font: inherit; font-weight: 600; font-size: .95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 8px 8px 14px; cursor: pointer;
}
.tab .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 22px; padding: 0 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.tab.active .count { background: rgba(255, 255, 255, .22); color: var(--brand-ink); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; font-size: .95rem;
}
.summary { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; margin: 0 2px 12px; }
.summary strong { color: var(--ink); }

.add { margin-bottom: 18px; }
.add-title { font-weight: 700; margin-bottom: 10px; }
.trio { display: grid; grid-template-columns: 1fr 90px 2fr; gap: 10px; }
.mini { display: grid; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.qty { font-size: .8rem; font-weight: 700; color: var(--brand); background: var(--brand-soft); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.progress-line { flex: 1 1 100%; font-size: .9rem; }
.buy-group { display: flex; gap: 8px; align-items: center; }
.qty-pick { width: auto; min-width: 64px; padding: 9px 10px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px;
}
.item-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.item-name { font-weight: 650; overflow-wrap: anywhere; line-height: 1.35; }
.item-name a { color: var(--ink); text-decoration: none; }
.item-name a:hover { text-decoration: underline; }
.store-link { display: inline-block; margin-top: 4px; font-size: .85rem; font-weight: 600; color: var(--brand); text-decoration: none; }
.store-link:hover { text-decoration: underline; }
.note { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.price {
  font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--surface-2); border-radius: 999px; padding: 3px 10px; font-size: .95rem;
}
.item-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.bought-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ok-soft); color: var(--ok); font-weight: 700; font-size: .9rem;
  border-radius: 999px; padding: 5px 12px;
}
.item.done { background: var(--surface-2); box-shadow: none; }
.item.done .item-name a, .item.done .item-name { text-decoration: line-through; color: var(--muted); }
.section-label { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 2px 10px; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

.price-note {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px; font-size: .88rem; color: var(--muted);
}
.deals {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--line); font-size: .88rem;
}
.deals-label { font-weight: 600; color: var(--muted); }
.deal {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink);
  background: var(--ok-soft); border-radius: 999px; padding: 4px 11px; font-weight: 600;
}
.deal strong { color: var(--ok); font-variant-numeric: tabular-nums; }
.deal:hover { text-decoration: underline; }
.deals-best { color: var(--ok); font-weight: 600; }
.deals-best .muted { font-weight: 400; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; z-index: 20;
  background: var(--ink); color: var(--bg); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow);
}

@media (max-width: 560px) {
  .who { display: none; }
  .panel { padding: 18px; }
  .trio { grid-template-columns: 1fr 90px; }
  .trio .mini:last-child { grid-column: 1 / -1; }
  .buy-group { flex: 1 1 100%; }
  .buy-group .btn-accent { flex: 1; padding: 12px 16px; }
  .item-foot .btn-accent { flex: 1 1 100%; padding: 12px 16px; }
  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; overflow: visible; margin: 0 0 16px; padding: 0; }
  .tab { justify-content: space-between; border-radius: 12px; padding: 10px 10px 10px 14px; }
  .brand-sub { display: none; }
}
