:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1d2622;
  --muted: #667069;
  --line: #e0dccf;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe4;
  --warn: #9a5b00;
  --warn-soft: #fbeccb;
  --danger: #a3372b;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14201c;
    --surface: #1b2a25;
    --ink: #edf1ec;
    --muted: #a0aca5;
    --line: #2c3d36;
    --accent: #52c3a3;
    --accent-ink: #0b1a15;
    --accent-soft: #23463b;
    --warn: #f0be67;
    --warn-soft: #3d3118;
    --danger: #ff8d7e;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { width: min(640px, 100%); margin: 0 auto; padding: 20px 16px 72px; }

header.top { display: flex; align-items: center; gap: 12px; padding: 8px 0 18px; }
.logo { width: 36px; height: 36px; flex: none; }
header .grow { flex: 1; min-width: 0; }
h1 { font-size: 21px; margin: 0; letter-spacing: -.02em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 2px 0 14px; }
.tab { min-height: 44px; padding: 0 4px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card .sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.extension-card { margin-top: 24px; }
.extension-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.extension-actions a { display: inline-flex; align-items: center; text-decoration: none; }
.extension-help { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.extension-help code { color: var(--ink); }

.add-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.add-form.custom { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
select, input[type="text"], input[type="search"] { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.btn { min-height: 44px; padding: 0 18px; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.quiet { border-color: var(--line); background: transparent; color: var(--ink); }
.btn.danger { border-color: var(--line); background: transparent; color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.form-msg { margin: 10px 0 0; font-size: 13px; color: var(--danger); min-height: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 999px; background: var(--accent-soft); font-size: 14px; }
.chip b { font-weight: 700; }
.chip button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }
.chip button:hover { background: rgb(0 0 0 / 8%); }

.search { margin-bottom: 12px; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 10px 2px; border: 0; background: transparent; text-align: left; }
li.row { border-bottom: 1px solid var(--line); }
.vendor { min-width: 0; }
.vendor .name { display: block; font-weight: 650; }
.vendor .note { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.result { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.size { font-size: 20px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.size.empty { color: var(--muted); font-weight: 500; font-size: 14px; }
.tag { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.tag.yours { background: var(--accent); color: var(--accent-ink); }
.tag.guess { background: var(--accent-soft); color: var(--accent); }
.alt { font-size: 12px; color: var(--muted); }

.panel { padding: 4px 2px 18px; display: grid; gap: 14px; }
.callout { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; line-height: 1.45; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.panel .set { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.stepper { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stepper .label { flex: 1; min-width: 140px; font-size: 14px; }
.stepper button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: transparent; font-size: 20px; }
.panel .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty-state { padding: 20px 4px; color: var(--muted); font-size: 14px; text-align: center; }
.foot { margin: 22px 4px 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.foot button { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
.foot-links { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 440px) {
  .add-form { grid-template-columns: 1fr 1fr; }
  .add-form .btn { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: .01ms !important; } }
