/* Two checklists in one page: a sticky header holds the title, a 2-tab menu
     (shopping list / hospital bag) and the active tab's progress summary.
     Each tab keeps its own interaction model and its own saved state:
     shopping = buy / no-buy budget planning, hospital bag = packed toggle. */
  :root {
    --bg: #F7F3EC; --surface: #FFFFFF; --surface-muted: #EFE7D9; --border: #E3D7C4;
    --text: #3B3530; --text-muted: #8C7E70; --accent: #A99B8C; --accent-weak: #DCCFC1;
    --sage: #B7C8B5;  --sage-ink: #42523F;
    --blush: #E8C8C5; --blush-ink: #6B433F;
    --blue: #C9DCE8;  --blue-ink: #37536A;
    --lav: #D9D1E8;   --lav-ink: #534A6E;
    --radius: 14px;
    --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-body: "Noto Sans Thai", "Noto Sans", -apple-system, "Segoe UI", sans-serif;
    color-scheme: light;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #221D18; --surface: #2B2520; --surface-muted: #342D26; --border: #473E34;
      --text: #F2EAE0; --text-muted: #B3A493; --accent: #CBBCAB; --accent-weak: #4A4038;
      --sage: #6E8A6C;  --sage-ink: #E4EEE2;
      --blush: #B9807B; --blush-ink: #FAEAE7;
      --blue: #6F94AD;  --blue-ink: #E9F1F6;
      --lav: #9A8CB8;   --lav-ink: #F0EBF8;
      color-scheme: dark;
    }
  }

  * { box-sizing: border-box; }
  html { scroll-padding-top: env(safe-area-inset-top, 0px); }
  body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; }
  body::before {
    content: ""; position: fixed; inset: 0 0 auto;
    height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg);
  }
  [hidden] { display: none !important; }
  .wrap {
    max-width: 640px; margin: 0 auto;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  }

  /* ---------- header + tab menu ---------- */
  header.top {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
    background: var(--bg);
    padding-block: 8px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
  }
  .brand { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
  .wordmark {
    font-family: var(--font-display); font-weight: 700; font-size: 20px;
    letter-spacing: 0.01em; margin-top: 2px; text-wrap: balance;
  }

  .tabs {
    margin-top: 10px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    padding: 4px;
    background: var(--surface-muted);
    border-radius: 12px;
  }
  .tab {
    appearance: none; border: 0; cursor: pointer;
    font: inherit; color: var(--text-muted);
    background: transparent;
    border-radius: 9px;
    padding: 8px 6px;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    min-width: 0;
  }
  .tab svg { width: 16px; height: 16px; flex-shrink: 0; }
  .tab .t-label { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tab .t-count {
    font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
    padding: 1px 7px; border-radius: 999px; background: var(--bg); color: var(--text-muted);
  }
  .tab[aria-selected="true"] {
    background: var(--surface); color: var(--text);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 14%, transparent);
  }
  .tab[aria-selected="true"] .t-count { background: var(--sage); color: var(--sage-ink); }
  .tab[data-tab="hospital-bag"][aria-selected="true"] .t-count { background: var(--blush); color: var(--blush-ink); }
  .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

  .summary { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
  .summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
  .summary-row .label { color: var(--text-muted); }
  .summary-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
  .summary-row .value.lead-sage { font-size: 15px; color: var(--sage-ink); }
  .summary-row .value.lead-blush { font-size: 15px; color: var(--blush-ink); }
  .summary-row .value.done { color: var(--sage-ink); }
  .bar-track { height: 7px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
  .bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }
  .missing-note { font-size: 11.5px; color: var(--text-muted); }

  /* ---------- intro ---------- */
  .intro {
    font-size: 13px; line-height: 1.65;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; margin-bottom: 14px;
    display: flex; flex-direction: column; gap: 6px;
  }
  .intro .muted { color: var(--text-muted); font-size: 12px; }

  /* ---------- category cards ---------- */
  .categories { display: flex; flex-direction: column; gap: 12px; }
  details.cat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  details.cat > summary {
    list-style: none; cursor: pointer; padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
  }
  details.cat > summary::-webkit-details-marker { display: none; }
  details.cat > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .cat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .cat-icon svg { width: 18px; height: 18px; }
  .cat-title { flex: 1; min-width: 0; }
  .cat-title .name { font-weight: 600; font-size: 15px; }
  .cat-title .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
  .chevron {
    width: 11px; height: 11px;
    border-right: 1.6px solid var(--text-muted); border-bottom: 1.6px solid var(--text-muted);
    transform: rotate(-45deg); transition: transform 0.2s ease; flex-shrink: 0; margin-right: 2px;
  }
  details.cat[open] > summary .chevron { transform: rotate(45deg); }

  .items { border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .item {
    padding: 10px; display: flex; flex-direction: column; gap: 6px;
    background: var(--bg); border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px);
    min-width: 0; transition: opacity 0.2s ease;
  }
  .item-name { font-size: 13px; font-weight: 500; line-height: 1.35; }
  .item.skipped .item-name { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border); }
  .item.packed { opacity: 0.62; }
  .item.packed .item-name { text-decoration: line-through; text-decoration-color: var(--accent); }

  .pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; line-height: 1.6; }
  .pill-must  { background: var(--sage); color: var(--sage-ink); }
  .pill-later { background: var(--blue); color: var(--blue-ink); }
  .pill-nice  { background: var(--lav);  color: var(--lav-ink); }
  .pill-hosp  { background: var(--blue); color: var(--blue-ink); }

  .item-note {
    display: flex; gap: 6px; align-items: flex-start;
    font-size: 11.5px; font-style: italic; line-height: 1.5;
    background: var(--surface-muted); border-left: 2px solid var(--accent);
    border-radius: 0 8px 8px 0; padding: 7px 9px;
  }
  .item-note svg { width: 12px; height: 12px; flex-shrink: 0; margin-top: 2px; opacity: 0.6; }

  .item-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: auto; }
  .item-price { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .item-price.unset { font-weight: 400; color: var(--text-muted); font-size: 10.5px; }
  .actions { display: flex; align-items: center; gap: 5px; }

  .icon-btn {
    appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
    width: 28px; height: 28px; border-radius: 999px; padding: 0; cursor: pointer; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .icon-btn svg { width: 13px; height: 13px; }
  .icon-btn.buy  { border-color: var(--sage);  color: var(--sage-ink);  background: color-mix(in srgb, var(--sage) 22%, var(--surface)); }
  .icon-btn.buy.active  { background: var(--sage);  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sage) 35%, transparent); }
  .icon-btn.skip { border-color: var(--blush); color: var(--blush-ink); background: color-mix(in srgb, var(--blush) 22%, var(--surface)); }
  .icon-btn.skip.active { background: var(--blush); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blush) 35%, transparent); }

  .pack-btn {
    appearance: none; display: inline-flex; align-items: center; gap: 5px;
    font: inherit; font-size: 11.5px; font-weight: 600;
    padding: 5px 10px 5px 7px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--sage); color: var(--sage-ink);
    background: color-mix(in srgb, var(--sage) 22%, var(--surface));
  }
  .pack-btn svg { width: 13px; height: 13px; }
  .pack-btn.active { background: var(--sage); box-shadow: 0 0 0 2px color-mix(in srgb, var(--sage) 35%, transparent); }

  /* shop link: the revenue tap target — dark square, same in both tabs */
  .link-btn {
    width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--bg); background: var(--text); border: 1px solid var(--text);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--text) 30%, transparent);
  }
  .link-btn svg { width: 15px; height: 15px; }
  .link-btn:active { transform: scale(0.94); }
  .icon-btn:focus-visible, .pack-btn:focus-visible, .link-btn:focus-visible, .reset:focus-visible, .next-link:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
  }

  /* ---------- tab footer + next-tab nudge ---------- */
  .next-link {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 16px; padding: 14px 16px;
    background: var(--surface); border: 1px dashed var(--accent); border-radius: var(--radius);
    color: var(--text); text-decoration: none; cursor: pointer; width: 100%;
    font: inherit; text-align: left;
  }
  .next-link .nl-small { font-size: 11.5px; color: var(--text-muted); }
  .next-link .nl-big { font-size: 14px; font-weight: 600; margin-top: 2px; }
  .next-link .arrow { font-size: 18px; color: var(--text-muted); }

  .tab-foot { text-align: center; margin-top: 18px; font-size: 11.5px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 8px; line-height: 1.6; }
  .reset {
    appearance: none; font: inherit; font-size: 11.5px; color: var(--text-muted);
    background: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; cursor: pointer;
  }
  .reset.confirm { color: var(--blush-ink); border-color: var(--blush); background: color-mix(in srgb, var(--blush) 25%, transparent); }
  footer.site { text-align: center; margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }
  footer.site .sig { font-family: var(--font-display); font-size: 13px; color: var(--text); margin-top: 4px; }

  @media (max-width: 380px) {
    .items { gap: 8px; padding: 10px; }
    .item { padding: 8px; }
    .tab .t-label { font-size: 12.5px; }
  }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

  /* multi-page additions: tabs are now links between pages */
  a.tab { text-decoration: none; }
  a.tab[aria-current="page"] { background: var(--surface); color: var(--text);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 14%, transparent); }
  a.tab[aria-current="page"] .t-count { background: var(--sage); color: var(--sage-ink); }
  a.tab[data-tab="hospital-bag"][aria-current="page"] .t-count { background: var(--blush); color: var(--blush-ink); }
  a.brand { text-decoration: none; display: inline-block; }
  a.next-link { box-sizing: border-box; }
  /* home hub */
  .hub { display: flex; flex-direction: column; gap: 12px; }
  .hub-card { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
  .hub-card .cat-icon { width: 44px; height: 44px; border-radius: 12px; }
  .hub-card .cat-icon svg { width: 22px; height: 22px; }
  .hub-card .h-title { font-weight: 600; font-size: 16px; }
  .hub-card .h-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.55; }
  .hub-card .t-count { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-muted); color: var(--text-muted); vertical-align: 2px; margin-left: 4px; }
  .hub-card .arrow { margin-left: auto; font-size: 18px; color: var(--text-muted); }
  .hub-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
