@import url('./tokens.css');

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs)/1.45 var(--font); -webkit-font-smoothing: antialiased; font-synthesis: none; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.01em; }
h3 { font-size: var(--fs); font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
img { display: block; max-width: 100%; }
svg { display: block; }
ol, ul { list-style: none; margin: 0; padding: 0; }
s { color: var(--muted); text-decoration-thickness: 1px; }
kbd { font: inherit; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: color-mix(in srgb, var(--green) 25%, transparent); }
.num, .price, td, .tnum { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -40px; z-index: 100; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: var(--r); }
.skip:focus { top: 8px; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.fine { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.icon { width: 16px; height: 16px; flex-shrink: 0; }
[data-icon] { display: inline-flex; flex-shrink: 0; }
.noscript { padding: 24px; text-align: center; }

/* ---------- Controls ---------- */
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r); color: var(--ink-2); transition: background var(--t) var(--ease), color var(--t); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm .icon { width: 14px; height: 14px; }
.ghost-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; transition: background var(--t) var(--ease), color var(--t); white-space: nowrap; }
.ghost-btn:hover { background: var(--hover); color: var(--ink); }
.ghost-btn .icon { width: 14px; height: 14px; }
.ghost-btn.strong { color: var(--ink); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
.ghost-btn.strong:hover { background: var(--hover); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; padding: 4px 0; }
.link-btn:hover { color: var(--ink); }
.link-btn .icon { width: 14px; height: 14px; color: var(--muted); }
.link-btn.strong { color: var(--green); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--r); background: var(--ink); color: var(--bg); font-weight: 700; font-size: var(--fs-sm); transition: opacity var(--t); }
.btn:hover { opacity: .88; }
.btn.secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.muted-num { color: var(--muted); font-weight: 500; }
.muted-num:not(:empty)::before { content: '·'; margin-right: 4px; }

input[type="text"], input[type="search"], input:not([type]), textarea, select {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r); min-width: 0;
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.field-icon { position: relative; display: flex; align-items: center; }
.field-icon > [data-icon] { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.field-icon input { width: 100%; height: 34px; padding: 0 10px 0 32px; }

.select { position: relative; display: inline-flex; align-items: center; }
.select select { appearance: none; height: 34px; padding: 0 30px 0 10px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; max-width: 220px; text-overflow: ellipsis; }
.select::after { content: ''; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select-prefix { position: absolute; left: 10px; font-size: var(--fs-sm); color: var(--muted); pointer-events: none; }
.select.sort select { padding-left: 42px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 28px; height: 16px; border-radius: var(--r-pill); background: var(--line-strong); transition: background var(--t) var(--ease); flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform var(--t) var(--ease); }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::after { transform: translateX(12px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch:hover { color: var(--ink); }

.seg { display: inline-flex; padding: 2px; border-radius: var(--r); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { height: 28px; padding: 0 11px; border-radius: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); transition: color var(--t), background var(--t); white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"], .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgb(0 0 0 / .06); }

.popover { position: absolute; z-index: 50; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); border: 1px solid var(--line); padding: 6px; animation: pop var(--t) var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 8px; border-radius: var(--r-sm); text-align: left; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.menu-item:hover, .menu-item.active { background: var(--hover); color: var(--ink); }
.menu-item[aria-selected="true"] { color: var(--ink); }
.menu-item .check { margin-left: auto; color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 26px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); transition: background var(--t), color var(--t); }
.chip:hover { color: var(--ink); background: var(--hover); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; background: var(--sunken); color: var(--ink-2); }
.badge.good { background: var(--green-soft); color: var(--green-ink); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge .icon { width: 12px; height: 12px; }

.thumb { width: 36px; height: 36px; border-radius: var(--r-sm); object-fit: contain; background: #fff; flex-shrink: 0; box-shadow: inset 0 0 0 1px var(--line); padding: 2px; }
.thumb.fallback { display: grid; place-items: center; color: var(--faint); background: var(--sunken); }
[data-mode="dark"] .thumb:not(.fallback) { background: #f3f2ef; }
@media (prefers-color-scheme: dark) { :root:not([data-mode]) .thumb:not(.fallback) { background: #f3f2ef; } }

/* ---------- Top bar ---------- */
.bar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px); border-bottom: 1px solid var(--line); }
.bar-inner { display: flex; align-items: center; gap: 20px; height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; font: 800 19px/1 var(--font-brand); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.brand img { width: 22px; height: 22px; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-weight: 700; font-size: var(--fs); color: var(--muted); transition: color var(--t); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.bar-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.area-picker { position: relative; }
.area-toggle { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 9px; border-radius: var(--r); font-size: var(--fs-sm); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--surface); transition: background var(--t); }
.area-toggle:hover { background: var(--hover); }
.area-toggle strong { color: var(--ink); font-weight: 700; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.area-toggle .icon { width: 14px; height: 14px; color: var(--muted); }
.area-popover { right: 0; top: calc(100% + 6px); width: 280px; }
.area-popover .field-icon { margin: 2px 2px 6px; }
#area-options { max-height: 280px; overflow: auto; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.area-popover .location .icon { color: var(--muted); }
.area-popover .fine { padding: 2px 8px 6px; }

/* ---------- Basket layout ---------- */
main { padding-block: 20px 48px; }
.basket-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }

.list-panel { position: sticky; top: 72px; display: flex; flex-direction: column; max-height: calc(100vh - 92px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.list-panel.dragging { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 8px 16px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--sunken); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.panel-actions { display: flex; align-items: center; gap: 2px; }
.menu { position: relative; }
.saved-popover { right: 0; top: calc(100% + 6px); width: 260px; }
.saved-row { display: flex; align-items: center; gap: 2px; }
.saved-row .menu-item small { margin-left: auto; color: var(--muted); font-weight: 500; }
.saved-row .icon-btn { opacity: .6; }
.saved-row .icon-btn:hover { opacity: 1; }
.saved-empty { padding: 6px 8px 8px; }
.save-form { display: flex; gap: 6px; padding: 6px 2px 4px; border-top: 1px solid var(--line); margin-top: 4px; }
.save-form input { flex: 1; height: 30px; padding: 0 8px; font-size: var(--fs-sm); }
.save-form button { height: 30px; }
.saved-popover > .fine { padding: 2px 4px 2px; }

.add-form { padding: 0 12px 8px; }
.entry { position: relative; }
.entry-icon { position: absolute; left: 10px; top: 10px; color: var(--muted); pointer-events: none; }
.entry textarea { display: block; width: 100%; min-height: 36px; max-height: 160px; padding: 8px 34px 8px 32px; resize: none; line-height: 1.4; overflow: hidden; font-weight: 600; }
.entry textarea::placeholder { font-weight: 500; }
.entry-kbd { position: absolute; right: 8px; top: 8px; display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 4px; font-size: 11px; color: var(--muted); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); opacity: 0; transition: opacity var(--t); pointer-events: none; }
.entry:focus-within .entry-kbd { opacity: 1; }
.suggestions { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); max-height: 360px; overflow: auto; }
.suggestions li { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: var(--r); cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li[role="option"]:hover { background: var(--hover); }
.suggestions .thumb { width: 32px; height: 32px; }
.suggest-info { display: flex; flex-direction: column; min-width: 0; }
.suggest-info strong { font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-info small { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.suggest-head { padding: 4px 6px 2px; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; cursor: default !important; }
.suggest-head:hover { background: none !important; }
.suggest-free strong { font-weight: 700; }
.suggest-free .thumb.fallback { color: var(--muted); }

.items { overflow: auto; padding: 0 6px; flex: 1 1 auto; min-height: 0; }
.item { position: relative; display: flex; align-items: center; gap: 4px; min-height: 38px; padding: 0 4px 0 10px; border-radius: var(--r); transition: background var(--t); }
.item:hover, .item:focus-within { background: var(--sunken); }
.item + .item::before { content: ''; position: absolute; left: 10px; right: 10px; top: 0; border-top: 1px solid var(--line); }
.item:hover::before, .item:focus-within::before, .item:hover + .item::before, .item:focus-within + .item::before { border-color: transparent; }
.item-name { flex: 1; min-width: 0; height: 30px; padding: 0 6px; margin-left: -6px; border: 1px solid transparent !important; background: transparent !important; border-radius: var(--r-sm); font-weight: 500; text-overflow: ellipsis; }
.item-name:hover { border-color: var(--line-strong) !important; }
.item-name:focus-visible { background: var(--surface) !important; border-color: var(--focus) !important; }
.item .pin { color: var(--green); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-sm); }
.item .pin:hover { background: var(--green-soft); }
.item .pin .icon { width: 13px; height: 13px; }
.stepper { display: inline-flex; align-items: center; height: 26px; border-radius: var(--r-sm); }
.stepper button { width: 22px; height: 26px; display: grid; place-items: center; color: var(--muted); border-radius: var(--r-sm); opacity: 0; transition: opacity var(--t), background var(--t); }
.stepper button .icon { width: 13px; height: 13px; }
.stepper button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.item:hover .stepper button, .item:focus-within .stepper button { opacity: 1; }
.stepper button:disabled { opacity: 0 !important; }
.stepper input { width: 28px; height: 24px; padding: 0; text-align: center; border: 0 !important; background: transparent !important; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; color: var(--ink); }
.stepper.one input { color: var(--faint); font-weight: 500; }
.item:hover .stepper.one input, .item:focus-within .stepper.one input { color: var(--ink-2); }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper input:focus-visible { box-shadow: 0 0 0 2px var(--focus) !important; border-radius: 4px; }
.qty-x { font-size: var(--fs-xs); color: var(--muted); margin-right: -2px; }
.item .remove { opacity: 0; color: var(--muted); }
.item:hover .remove, .item:focus-within .remove { opacity: 1; }
.item-flash { animation: flash 900ms var(--ease); }
@keyframes flash { from { background: var(--green-soft); } }
.list-empty { padding: 4px 16px 14px; color: var(--muted); font-size: var(--fs-sm); display: grid; gap: 10px; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 16px 10px; border-top: 1px solid var(--line); }

/* ---------- Results ---------- */
.results { min-width: 0; display: grid; gap: 12px; }
.results-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; min-height: 34px; }
.status { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.status .spinner { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--ink-2); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#result-content { display: grid; gap: 12px; transition: opacity var(--t); }
#result-content[aria-busy="true"].has-result { opacity: .55; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }

.summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 16px 18px; align-items: center; }
.summary-label { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.summary-total { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.summary-total .cur { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); }
.summary-total strong { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-route { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 500; color: var(--ink-2); }
.summary-route .plus { color: var(--faint); font-weight: 500; }
.summary-facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-2); }
.summary-facts span { display: inline-flex; align-items: center; gap: 6px; }
.summary-facts .icon { width: 14px; height: 14px; color: var(--muted); }
.summary-facts .good { color: var(--green-ink); font-weight: 700; }
.summary-facts .good .icon { color: var(--green); }
.summary-facts .warn { color: var(--amber); font-weight: 700; }
.summary-facts .warn .icon { color: var(--amber); }

.plans { display: flex; gap: 6px; }
.plan-opt { display: grid; gap: 1px; min-width: 104px; padding: 7px 11px; border-radius: var(--r); text-align: left; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow var(--t), background var(--t); }
.plan-opt:hover { background: var(--sunken); }
.plan-opt span { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.plan-opt strong { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.plan-opt small { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); color: var(--muted); }
.plan-opt[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--ink); background: var(--surface); }

.missing { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r-lg); background: var(--amber-soft); color: var(--amber); font-size: var(--fs-sm); }
.missing .icon { margin-top: 2px; }
.missing strong { font-weight: 700; }
.missing p { color: var(--ink-2); }
.missing .chips { margin-top: 6px; }
.missing .chip { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 30%, transparent); background: transparent; }

.store { overflow: hidden; }
.store-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; padding: 12px 16px 10px; }
.store-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.store-name h3 { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-name .badge { font-weight: 600; }
.store-total { text-align: right; font-weight: 700; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.store-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.store-meta b { color: var(--ink-2); font-weight: 700; }
.store-meta .unknown { color: var(--faint); }
.store-meta .pro { color: var(--green-ink); font-weight: 700; }
.min-rail { display: inline-flex; align-items: center; gap: 6px; }
.min-rail i { display: block; width: 44px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.min-rail i::after { content: ''; display: block; height: 100%; width: var(--p); background: var(--green-bar); border-radius: inherit; }
.min-rail.below i::after { background: var(--amber); }
.min-rail.below { color: var(--amber); }

.lines { border-top: 1px solid var(--line); }
.line { border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line-main { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto 28px; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; }
.line-text { min-width: 0; }
.line-name { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-sub { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.line-sub .for { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.line-badges { display: flex; gap: 4px; justify-content: flex-end; }
.line-cost { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 72px; }
.line-cost small { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.swap { color: var(--muted); }
.swap[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.swap[aria-expanded="true"] .icon { transform: rotate(180deg); }
.swap .icon { transition: transform var(--t) var(--ease); }
.alts { padding: 2px 10px 10px 64px; display: grid; gap: 2px; }
.alts-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; font-size: var(--fs-xs); color: var(--muted); }
.alt { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 6px; border-radius: var(--r); text-align: left; width: 100%; }
.alt:hover { background: var(--sunken); }
.alt .thumb { width: 28px; height: 28px; }
.alt-name { display: block; font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alt small { display: block; font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alt-cost { font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.alt-cost small { color: var(--muted); font-weight: 500; }
.alt-cost .cheaper { color: var(--green-ink); }

.compare-table { padding: 4px 0 6px; }
.compare-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 16px 8px; }
.compare-head span { font-size: var(--fs-xs); color: var(--muted); }
.crow { display: grid; grid-template-columns: minmax(0, 1.4fr) 92px 96px minmax(80px, 1fr); gap: 14px; align-items: center; padding: 6px 16px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.crow:hover { background: var(--sunken); }
.crow-name { min-width: 0; display: flex; align-items: center; gap: 8px; }
.crow-name strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow-name small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cov { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 600; }
.cov i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; max-width: 40px; }
.cov i::after { content: ''; display: block; height: 100%; width: var(--p); background: var(--ink-2); }
.cov.full { color: var(--green-ink); }
.cov.full i::after { background: var(--green-bar); }
.crow-total { text-align: right; font-weight: 700; }
.crow-total.na { color: var(--faint); font-weight: 500; }
.crow-bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.crow-bar span { display: block; height: 100%; width: var(--w); border-radius: 3px; background: var(--line-strong); }
.crow.best .crow-bar span { background: var(--green-bar); }
.crow.dim { color: var(--muted); }
.crow.dim .crow-name strong { font-weight: 500; }
.crow-more { display: block; margin: 4px 16px 6px; }

.empty { padding: 28px 24px; display: grid; gap: 14px; justify-items: start; }
.empty h2 { font-size: var(--fs-lg); letter-spacing: -.015em; }
.empty p { color: var(--ink-2); max-width: 52ch; }
.empty .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; margin-top: 4px; }
.empty .step { padding: 12px; border-radius: var(--r); background: var(--sunken); font-size: var(--fs-sm); color: var(--ink-2); }
.empty .step b { display: flex; align-items: center; gap: 6px; color: var(--ink); margin-bottom: 2px; }
.empty .step .icon { width: 14px; height: 14px; color: var(--green); }
.empty .row { display: flex; gap: 8px; flex-wrap: wrap; }
.empty.error h2 { color: var(--red); }

.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunken) 0%, var(--hover) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { padding: 16px 18px; display: grid; gap: 10px; }

.footnote { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-xs); color: var(--muted); padding: 4px 2px; }
.footnote .icon { width: 14px; height: 14px; margin-top: 1px; }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 90; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); padding: 8px 8px 8px 14px; border-radius: var(--r-lg); background: var(--ink); color: var(--bg); font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-pop); animation: toast 200ms var(--ease); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast .link-btn.strong { color: color-mix(in srgb, var(--green) 55%, var(--bg)); }
.toast .icon-btn { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.toast .icon-btn:hover { background: color-mix(in srgb, var(--bg) 12%, transparent); color: var(--bg); }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .basket-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .summary { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  :root { --gutter: 14px; }
  .bar-inner { flex-wrap: wrap; height: auto; gap: 0 10px; padding-top: 8px; }
  .tabs { order: 3; width: 100%; height: 40px; margin-left: -10px; }
  .bar-tools { gap: 6px; }
  .area-toggle strong { max-width: 96px; }
  .bar-tools .switch { gap: 6px; }
  .line-name, .line-sub .for { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .area-popover { right: -40px; width: min(300px, calc(100vw - 28px)); }
  .basket-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .list-panel { position: static; max-height: none; }
  .stepper button, .item .remove { opacity: 1; }
  .line-main { grid-template-columns: 36px minmax(0, 1fr) auto 28px; padding-left: 12px; }
  .line-badges { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }
  .alts { padding-left: 12px; }
  .crow { grid-template-columns: minmax(0, 1fr) 64px 84px; }
  .crow-bar { display: none; }
  .empty .steps { grid-template-columns: minmax(0, 1fr); }
  .plans { overflow-x: auto; }
  .results-bar { gap: 10px 14px; }
  .status { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.tab-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.tabs button[aria-selected="true"] .tab-count { background: var(--ink); color: var(--bg); box-shadow: none; }
.in-plan { color: var(--green-ink); font-weight: 600; }
.missing .chip { cursor: pointer; }
.missing .chip:hover { background: color-mix(in srgb, var(--amber) 12%, transparent); }
@media (hover: none) {
  .stepper button, .item .remove { opacity: 1; }
  .stepper button { width: 32px; height: 32px; }
  .item .remove { width: 32px; height: 32px; }
}
