/* Wishful: gallery look. Dark is the default; [data-theme="light"] swaps the tokens. */
:root {
  --bg: #111211;
  --surface: #1a1c1b;
  --surface-2: #222423;
  --ink: #ece8df;
  --muted: #7d807a;
  --line: #262826;
  --accent: #e9846b;
  --accent-ink: #1b0c07;
  --success: #8fb79a;
  --danger: #e0806c;
  --shadow: 0 30px 90px rgba(0, 0, 0, .45);
  --serif: "Instrument Serif", ui-serif, "New York", Georgia, serif;
  --sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --pad: 56px;
  /* Critically damped spring (damping 1.0, response 0.35s): no overshoot, settles naturally. */
  --spring: linear(0, .075 4.2%, .227 8.3%, .39 12.5%, .536 16.7%, .656 20.8%, .75 25%, .821 29.2%, .873 33.3%, .911 37.5%, .938 41.7%, .957 45.8%, .971 50%, .98 54.2%, .986 58.3%, .991 62.5%, .994 66.7%, .996 70.8%, .998 79.2%, .999 87.5%, 1);
  --spring-time: .45s; /* curve is ~95% settled by 45%, so it reads as ~200ms */
  --material: color-mix(in srgb, var(--bg) 72%, transparent);
  --material-edge: rgba(255, 255, 255, .08);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f1ea;
  --surface: #ebe7de;
  --surface-2: #fffdf8;
  --ink: #1b1c1a;
  --muted: #8a877f;
  --line: #ddd8cc;
  --accent: #d4583b;
  --accent-ink: #fff6f2;
  --success: #4f7a5a;
  --danger: #b2452f;
  --shadow: 0 30px 90px rgba(40, 34, 24, .18);
  --material-edge: rgba(255, 255, 255, .7);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); transition: background .35s, color .35s; }
body { min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Feedback on press, not release: every control dips the instant it's pressed. */
button, .search-box { transition: transform 100ms ease-out; }
button:active:not(:disabled), .image-wrap:active { transform: scale(.97); transition-duration: 60ms; }
.image-wrap:active { transform: scale(.985); }

/* Top bar (extra top padding clears the Mac window buttons) */
.topbar { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px;
  padding: 34px var(--pad) 18px; background: var(--material); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
/* Scroll edge effect instead of a hard divider: content softly fades under the bar. */
.topbar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 18px; pointer-events: none;
  background: linear-gradient(var(--material), transparent); }
.brand { display: block; width: 30px; height: 30px; flex: none; color: var(--ink); transition: transform 100ms ease-out, opacity .15s ease; }
.brand-eye { display: block; width: 100%; height: 100%; }
.brand:hover { color: var(--accent); }
.brand:active { transform: scale(.94); }
.main-nav { display: flex; align-items: center; gap: 24px; min-width: 0; overflow-x: auto; scrollbar-width: none; font-size: 14px; }
.main-nav::-webkit-scrollbar { display: none; }
.category-nav { display: contents; }
.nav-item, .category-nav .filter-option { color: var(--muted); white-space: nowrap; transition: color .2s; }
.nav-item:hover, .category-nav .filter-option:hover, .nav-item.active, .category-nav .filter-option.active { color: var(--ink); }
.nav-item em, .filter-option em { font-style: normal; font-size: 10px; margin-left: 2px; vertical-align: super; color: var(--muted); }
.filter-option .dot { display: none; }
.tools { display: flex; align-items: center; gap: 4px; }
.tool-button { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); transition: color .2s, background .2s; }
.tool-button:hover { color: var(--ink); background: var(--surface); }
.tool-button svg { width: 18px; height: 18px; }
:root[data-theme="dark"] .icon-moon, :root[data-theme="light"] .icon-sun { display: none; }
.search-box { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 99px; color: var(--muted); transition: background .2s; }
.search-box:hover, .search-box:focus-within { background: var(--surface); }
.search-box svg { width: 17px; height: 17px; flex: none; }
.search-box input { width: 90px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; transition: width .25s; }
.search-box input:focus, .search-box input:not(:placeholder-shown) { width: 170px; }
.search-box input::placeholder { color: var(--muted); }

/* Intro */
.main-content { padding-bottom: 120px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 48px var(--pad) 28px; }
.intro h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 46px; letter-spacing: -.02em; line-height: 1.02; }
.intro p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.hero-summary { display: flex; gap: 28px; color: var(--muted); font-size: 13px; }
.hero-summary strong { color: var(--ink); font-weight: 500; }

/* Toolbar */
.collection-toolbar { display: grid; gap: 14px; padding: 0 var(--pad) 36px; font-size: 13px; }
.shop-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.shop-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.shop-filters .filter-option { padding: 6px 12px; border-radius: 99px; background: var(--surface); color: var(--muted); transition: color .15s ease, background .15s ease; }
.shop-filters .filter-option:hover { color: var(--ink); }
.shop-filters .filter-option.active { background: var(--ink); color: var(--bg); }
.shop-filters .filter-option.active em { color: inherit; opacity: .6; }
#clearShop, #clearCategory { display: none; }
#clearShop.visible { display: inline; }
.text-button { color: var(--muted); font-size: 13px; transition: color .2s; }
.text-button:hover { color: var(--ink); }
.text-button.strong { color: var(--ink); font-weight: 500; }
.text-button.danger { color: var(--danger); }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; }
.context-controls { display: flex; align-items: center; gap: 20px; min-width: 0; }
.view-switcher, .subcategory-switcher { display: flex; gap: 16px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.subcategory-switcher::-webkit-scrollbar { display: none; }
.view-switcher button, .subcategory-switcher button { color: var(--muted); white-space: nowrap; transition: color .2s; }
.view-switcher button:hover, .subcategory-switcher button:hover { color: var(--ink); }
.view-switcher button.active, .subcategory-switcher button.active { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; }
.group-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; user-select: none; }
.group-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 26px; height: 15px; padding: 2px; border-radius: 99px; background: var(--surface-2); transition: background .2s ease; }
.toggle-track i { display: block; width: 11px; height: 11px; border-radius: 50%; background: var(--muted); transition: transform .2s cubic-bezier(.23, 1, .32, 1), background .2s ease; }
.group-toggle input:checked + .toggle-track { background: var(--ink); }
.group-toggle input:checked + .toggle-track i { transform: translateX(11px); background: var(--bg); }
.group-toggle b { font-weight: 400; white-space: nowrap; }
.scope-selection-button, .group-selection-button { color: var(--muted); white-space: nowrap; font-size: 13px; transition: color .2s; }
.scope-selection-button:hover, .group-selection-button:hover { color: var(--ink); }
.sort-control { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: none; }
.sort-control select { border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; }

/* Gallery wall */
.collection { padding: 0 var(--pad); }
.collection[hidden] { display: none; }
.product-grid { columns: 4 240px; column-gap: 40px; }
.group-section + .group-section { margin-top: 32px; }
.group-heading { display: flex; align-items: baseline; gap: 14px; margin: 0 0 24px; }
.group-heading h3 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 400; }
.group-heading span { color: var(--muted); font-size: 13px; }

.product-card { break-inside: avoid; display: inline-block; width: 100%; vertical-align: top; margin: 0 0 48px; }
.image-wrap { position: relative; overflow: hidden; background: var(--surface); cursor: pointer; }
.image-wrap { transition: transform var(--spring-time) var(--spring); }
.image-wrap img { display: block; width: 100%; height: auto; max-height: 82vh; object-fit: cover; transition: transform var(--spring-time) var(--spring), opacity .3s; }
.image-wrap img[hidden] { display: none; } /* a broken photo hides itself and shows the fallback */
.image-fallback { aspect-ratio: 4 / 5; display: grid; place-items: center; font-family: var(--serif); font-style: italic; font-size: 64px; color: var(--muted); }
.image-fallback[hidden] { display: none; }
.select-button, .edit-button { position: absolute; top: 12px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(8px); color: var(--ink); font-size: 13px;
  opacity: 0; transform: scale(.85); transition: opacity .2s, transform var(--spring-time) var(--spring), background .2s; }
.select-button { right: 12px; }
.edit-button { left: 12px; font-size: 10px; letter-spacing: 1px; }
.image-wrap:focus-within .edit-button { opacity: 1; transform: none; }
/* Hover motion only with a real pointer; on touch the buttons just stay visible. */
@media (hover: hover) and (pointer: fine) {
  .image-wrap:hover img { transform: scale(1.025); }
  .image-wrap:hover .edit-button { opacity: 1; transform: none; }
}
@media (hover: none) {
  .edit-button { opacity: 1; transform: none; }
}
.product-card.selected .select-button { opacity: 1; transform: none; background: var(--accent); color: var(--accent-ink); }
.product-card.selected .image-wrap img { opacity: .82; }

.product-info { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin-top: 14px; font-size: 13px; }
.product-info .no { color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 3px; }
.product-card.selected .product-info .no { color: var(--accent); }
.product-info h3 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 400; line-height: 1.15; letter-spacing: -.01em; }
.product-info .meta, .product-info .no, .hero-summary, .collection-toolbar { letter-spacing: .01em; }
.product-link { text-align: left; transition: color .2s; }
.product-link:hover { color: var(--accent); }
.product-info .meta { grid-column: 2; color: var(--muted); }

/* Empty state */
.empty-state { margin: 40px var(--pad); padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 30px; font-weight: 400; color: var(--ink); }
.empty-state p { margin: 0 0 22px; font-size: 14px; }

/* Selection bar */
.selection-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; align-items: center; gap: 26px;
  padding: 14px 20px; font-size: 13px; color: var(--muted); background: var(--material);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 1px 0 var(--material-edge); /* bright top edge: light catching the material */
  transform: translateY(100%); transition: transform var(--spring-time) var(--spring); }
.selection-bar.visible { transform: none; }
.selection-stack { display: flex; }
.selection-stack img, .selection-thumb { width: 28px; height: 34px; object-fit: cover; margin-left: -8px; border: 2px solid var(--bg); background: var(--surface); }
.selection-stack img:first-child, .selection-thumb:first-child { margin-left: 0; }
.selection-copy strong { color: var(--ink); font-weight: 500; }

/* Buttons */
.primary-button, .secondary-button, .danger-button { padding: 11px 18px; border-radius: 99px; font-size: 13px; font-weight: 500; transition: opacity .15s ease, background .15s ease, transform 100ms ease-out; }
.primary-button { background: var(--ink); color: var(--bg); }
.primary-button:hover { opacity: .85; }
.primary-button:disabled { opacity: .5; cursor: default; }
.secondary-button { border: 1px solid var(--line); }
.secondary-button:hover { background: var(--surface); }
.danger-button { background: var(--danger); color: #fff; }
.danger-button:hover { opacity: .88; }

/* Dialogs */
.modal { width: min(620px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 0; overflow: auto; border: 0; border-radius: 16px; background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow); }
.modal-small { width: min(440px, calc(100vw - 40px)); }
.modal::backdrop { background: rgba(8, 9, 9, .55); backdrop-filter: blur(4px); }
/* Dialogs materialise: scale + fade in on a spring, and leave the same way. */
.modal { box-shadow: var(--shadow), inset 0 1px 0 var(--material-edge);
  transition: opacity .25s ease, transform var(--spring-time) var(--spring), overlay .25s allow-discrete, display .25s allow-discrete;
  opacity: 0; transform: scale(.96); }
.modal[open] { opacity: 1; transform: none; }
@starting-style { .modal[open] { opacity: 0; transform: scale(.96); } }
.modal::backdrop { transition: opacity .25s ease, overlay .25s allow-discrete, display .25s allow-discrete; opacity: 0; }
.modal[open]::backdrop { opacity: 1; }
@starting-style { .modal[open]::backdrop { opacity: 0; } }
.modal form { padding: 28px; }
.modal-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.modal-heading h2 { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 400; line-height: 1.1; }
.icon-button { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: 20px; transition: color .15s ease, background .15s ease; }
.icon-button:hover { background: var(--surface); color: var(--ink); }
.modal-intro { margin: 10px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: block; color: var(--muted); font-size: 12px; }
.field input, .field textarea { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--muted); }
.field-wide { margin-bottom: 14px; }
.form-grid + .field-wide { margin-top: 14px; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-actions .spacer { flex: 1; }

.import-status { display: grid; grid-template-columns: minmax(100px, 1fr) auto; align-items: center; gap: 14px; margin-top: 4px; padding: 12px 14px; border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13px; }
.import-status[hidden] { display: none; }
.import-status.success { color: var(--success); }
.import-status.error { color: var(--danger); }
.import-status p { margin: 0; text-align: right; line-height: 1.4; }
.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .28s ease; }
.import-status.loading .progress-track span { width: 38%; animation: import-progress 1.35s ease-in-out infinite; }
.import-status.success .progress-track span { width: 100%; background: var(--success); }
.import-status.error .progress-track span { width: 100%; background: var(--danger); }
@keyframes import-progress { 0% { transform: translateX(-115%); } 100% { transform: translateX(300%); } }

.checkout-groups { display: grid; gap: 10px; }
.checkout-group { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 16px; border-radius: 12px; background: var(--surface); }
.checkout-group h3 { margin: 0 0 3px; font-family: var(--serif); font-size: 20px; font-weight: 400; }
.checkout-group p { margin: 0; color: var(--muted); font-size: 13px; }
.checkout-group button { padding: 9px 14px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 13px; white-space: nowrap; }

/* Toast */
.toast { position: fixed; top: 24px; left: 50%; z-index: 80; padding: 10px 16px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 13px;
  transform: translate(-50%, -80px); opacity: 0; transition: transform var(--spring-time) var(--spring), opacity .2s ease; pointer-events: none; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

/* Accessibility: gentler motion, solid surfaces, stronger contrast when the Mac asks for them. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .15s !important; transition-timing-function: ease !important; animation: none !important; }
  .image-wrap:hover img, button:active, .image-wrap:active { transform: none !important; }
  .modal, .modal[open] { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .selection-bar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .modal::backdrop { backdrop-filter: none; background: rgba(8, 9, 9, .75); }
}
@media (prefers-contrast: more) {
  :root { --muted: #b4b6b0; --line: #5a5d58; }
  :root[data-theme="light"] { --muted: #55534d; --line: #8f8a7e; }
  .topbar, .selection-bar { background: var(--bg); border-bottom: 1px solid var(--line); }
}

@media (max-width: 980px) {
  :root { --pad: 28px; }
  .topbar { grid-template-columns: auto auto; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; }
  .hero-summary { display: none; }
  .product-grid { column-gap: 24px; }
}
@media (max-width: 600px) {
  :root { --pad: 16px; }
  .product-grid { columns: 2; column-gap: 14px; }
  .product-card { margin-bottom: 30px; }
  .product-info { grid-template-columns: 1fr; }
  .product-info .no { display: none; }
  .product-info .meta { grid-column: 1; }
  .toolbar-row { flex-wrap: wrap; }
  .selection-bar { gap: 14px; }
  .selection-stack { display: none; }
}

/* Small fixes from the break-ui / guidelines pass */
#reviewSelection { white-space: nowrap; }
.selection-copy, .product-info .meta, .hero-summary { font-variant-numeric: tabular-nums; }
.product-info h3 { overflow-wrap: anywhere; }

/* New-category question */
.category-pieces { margin: -8px 0 18px; padding: 0; list-style: none; display: grid; gap: 6px; }
.category-pieces li { font-family: var(--serif); font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.category-pieces li.more { font-family: var(--sans); font-size: 13px; color: var(--muted); }
.category-move select { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 14px; }
.category-move[hidden], #moveToCategory[hidden] { display: none; }

/* Card extras: price drop, size suggestion, note */
.product-info .meta .sep { color: var(--muted); }
.price-drop { color: var(--accent); }
.drops-nav, .drops-nav em { color: var(--accent); }
.price-drop s { color: var(--muted); margin-left: 3px; text-decoration-thickness: 1px; }
.size-suggestion { color: var(--muted); border-bottom: 1px dotted var(--muted); cursor: help; }
.product-info .note { grid-column: 2; margin: 4px 0 0; font-family: var(--serif); font-style: italic; font-size: 15px; line-height: 1.3; color: var(--muted); overflow-wrap: anywhere; }

/* Edit dialog: size hint */
.field-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.use-size { color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.field textarea[name="note"] { font-family: var(--sans); }

/* More panel */
.more-section { padding: 22px 0 4px; }
.more-section + .more-section { border-top: 1px solid var(--line); margin-top: 18px; }
.more-section h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 22px; }
.more-section h4 { margin: 18px 0 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.more-section .modal-intro { margin: 4px 0 14px; }
.size-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.learned-sizes { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 13px; }
.learned-sizes li { display: flex; justify-content: space-between; gap: 12px; }
.learned-sizes li span { color: var(--muted); }
.learned-sizes li strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.learned-sizes li.empty { color: var(--muted); }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.file-button { cursor: pointer; display: inline-block; }
.paste-backup { margin-top: 12px; font-size: 13px; color: var(--muted); }
.paste-backup summary { cursor: pointer; }
.paste-backup textarea { width: 100%; margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: 12px/1.4 ui-monospace, monospace; resize: vertical; }
.more-status { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.more-status.success { color: var(--success); }
.more-status.error { color: var(--danger); }
.more-status[hidden], .nav-item[hidden], .text-button[hidden] { display: none; }

/* ── Glass ──────────────────────────────────────────────────────────────────
   Floating, translucent surfaces: a tinted blur of what's behind, a bright top edge
   where light catches it, a faint rim, a soft shadow, and a gentle sheen on top.
   (True refraction needs the Mac app's own code; this is the web version.) */
:root {
  --glass: rgba(30, 32, 31, .52);
  --glass-strong: rgba(30, 32, 31, .72);
  --glass-hi: rgba(255, 255, 255, .20);
  --glass-rim: rgba(255, 255, 255, .07);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, .38), 0 2px 8px rgba(0, 0, 0, .22);
  --glass-sheen: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(255, 255, 255, 0) 45%);
  --glass-blur: blur(28px) saturate(190%);
}
:root[data-theme="light"] {
  --glass: rgba(255, 253, 248, .58);
  --glass-strong: rgba(255, 253, 248, .80);
  --glass-hi: rgba(255, 255, 255, .95);
  --glass-rim: rgba(40, 34, 24, .08);
  --glass-shadow: 0 12px 40px rgba(40, 34, 24, .14), 0 2px 8px rgba(40, 34, 24, .08);
  --glass-sheen: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 50%);
}

/* Selection bar: a floating glass pill instead of a full-width strip */
.selection-bar {
  left: 50%; right: auto; bottom: 18px; max-width: calc(100vw - 24px); gap: 18px;
  padding: 8px 10px 8px 14px; border-radius: 99px; border-top: 0;
  background: var(--glass) var(--glass-sheen); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-rim), var(--glass-shadow);
  transform: translate(-50%, calc(100% + 32px));
}
.selection-bar.visible { transform: translate(-50%, 0); }
.selection-bar .text-button { padding: 7px 10px; border-radius: 99px; transition: color .15s ease, background .15s ease, transform 100ms ease-out; }
.selection-bar .text-button:hover { background: var(--glass-rim); }
.selection-bar .text-button.strong { background: var(--ink); color: var(--bg); padding: 8px 14px; }
.selection-bar .text-button.strong:hover { opacity: .88; background: var(--ink); }
.selection-stack img, .selection-thumb { border-color: transparent; border-radius: 6px; }

/* Buttons floating on photos */
.select-button, .edit-button {
  background: var(--glass) var(--glass-sheen); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-rim), 0 4px 14px rgba(0, 0, 0, .18);
}
.product-card.selected .select-button { background: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 14px rgba(0, 0, 0, .2); }

/* Panels and dialogs */
.modal {
  background: var(--glass-strong) var(--glass-sheen); -webkit-backdrop-filter: blur(40px) saturate(190%); backdrop-filter: blur(40px) saturate(190%);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-rim), var(--shadow);
  border-radius: 22px;
}
.modal::backdrop { background: rgba(8, 9, 9, .35); }
.checkout-group, .import-status { background: var(--glass-rim); }

/* Toast */
.toast {
  background: var(--glass-strong) var(--glass-sheen); color: var(--ink);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-rim), var(--glass-shadow);
}

/* Top bar: a light edge along the bottom where the glass meets the page */
.topbar { box-shadow: inset 0 -1px 0 var(--glass-rim); }

@media (max-width: 600px) {
  .selection-bar { left: 12px; right: 12px; transform: translateY(calc(100% + 32px)); border-radius: 22px; flex-wrap: wrap; justify-content: center; }
  .selection-bar.visible { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .selection-bar, .select-button, .edit-button, .modal, .toast { background: var(--surface-2); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --glass-rim: rgba(255, 255, 255, .35); }
  :root[data-theme="light"] { --glass-rim: rgba(0, 0, 0, .4); }
}

/* ── Outfits ── */
.outfits-view .collection-toolbar, .outfits-view .hero-summary { display: none; }
.outfit-actions { display: flex; justify-content: flex-end; max-width: 980px; margin: -12px 0 18px; }
.outfit-pieces { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; max-width: 980px; }
.outfit-piece { margin: 0; min-width: 0; }
.outfit-photo { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--surface); }
.outfit-photo img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.outfit-fallback { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-style: italic; font-size: 44px; color: var(--muted); }
.outfit-photo .owned { position: absolute; z-index: 2; left: 10px; top: 10px; padding: 4px 9px; border-radius: 99px; font-size: 11px;
  background: var(--glass) var(--glass-sheen); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 0 0 1px var(--glass-rim); }
.outfit-piece figcaption { margin-top: 8px; font-size: 12px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.outfit-info { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: baseline; margin-top: 14px; max-width: 980px; }
.outfit-info .no { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.outfit-info .why { margin: 0; font-family: var(--serif); font-size: 21px; line-height: 1.2; letter-spacing: -.01em; }
.outfit-info .meta { grid-column: 2; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.outfits-empty { padding: 60px 0; max-width: 480px; color: var(--muted); }
.outfits-empty h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 30px; color: var(--ink); }
@media (max-width: 600px) {
  .outfit-pieces { gap: 6px; }
  .outfit-info { grid-template-columns: 1fr; }
  .outfit-info .no { display: none; }
  .outfit-info .meta { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* Browser version (Windows etc.): no Mac window buttons to clear at the top. */
.browser-app .topbar { padding-top: 18px; }

/* Units switch in the measurements panel */
.unit-switch { display: inline-flex; padding: 3px; margin-bottom: 12px; border-radius: 99px; background: var(--glass-rim); }
.unit-switch button { padding: 5px 12px; border-radius: 99px; font-size: 12px; color: var(--muted); transition: color .15s ease, background .15s ease; }
.unit-switch button.active { background: var(--ink); color: var(--bg); }

/* Highlight colour: the main actions and "you are here" marks use the accent. */
.nav-item.active em, .category-nav .filter-option.active em { color: var(--accent); }
.view-switcher button.active, .subcategory-switcher button.active { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.group-toggle input:checked + .toggle-track { background: var(--accent); }
.group-toggle input:checked + .toggle-track i { background: var(--accent-ink); }
.primary-button { background: var(--accent); color: var(--accent-ink); }
.selection-bar .text-button.strong, .selection-bar .text-button.strong:hover { background: var(--accent); color: var(--accent-ink); }
.selection-copy strong { color: var(--accent); }
.outfit-info .no { color: var(--accent); }
#valueStat { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.text-button[data-outfit-shuffle]:hover { color: var(--accent); }

/* Line icons (Tabler style: 24px grid, round ends) for close, select and edit. */
.icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button .icon { width: 18px; height: 18px; }
.edit-button .icon circle { fill: currentColor; }
.select-button .icon { width: 15px; height: 15px; stroke-width: 2.2; }

/* Progressive blur under the top bar: pieces scrolling up blur gradually as they reach it,
   instead of meeting one hard-edged frosted strip. */
.topbar::after { height: 28px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); }
@media (prefers-reduced-transparency: reduce) {
  .topbar::after { -webkit-backdrop-filter: none; backdrop-filter: none; background: none; }
}

/* Selection stack: a small fanned hand of photos. New ones drop in; hover spreads them. */
.selection-stack { align-items: center; }
.selection-stack .stack-card { transform: rotate(calc((var(--i) - 1.5) * 5deg)); transition: transform .3s var(--spring), margin .3s var(--spring); }
.selection-bar:hover .selection-stack .stack-card { margin-left: 3px; transform: none; }
.selection-bar:hover .selection-stack .stack-card:first-child { margin-left: 0; }
.stack-card.enter { animation: stack-in .35s cubic-bezier(.23, 1, .32, 1) both; }
@keyframes stack-in { from { opacity: 0; transform: translateY(10px) scale(.7); } }
.stack-more { margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
#itemStat, #shopStat, #valueStat, #selectionCount, #selectionTotal { font-variant-numeric: tabular-nums; }

/* Outfits deck (js/deck.js): one card on top, two peeking behind. */
.outfit-deck { display: grid; max-width: 980px; padding-bottom: 8px; }
.outfit-card, .outfit-deck-end { grid-area: 1 / 1; }
.outfit-card { position: relative; padding: 18px; border-radius: 22px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
  transform-origin: 50% 100%; transition: transform var(--spring-time) var(--spring), opacity .25s ease, filter .25s ease; }
.outfit-card img { -webkit-user-drag: none; pointer-events: none; }
.outfit-card.behind { transform: translateY(calc(var(--offset) * 14px)) scale(calc(1 - var(--offset) * .04)); opacity: calc(1 - var(--offset) * .35);
  z-index: calc(5 - var(--offset)); filter: brightness(.85); }
.outfit-card.top { z-index: 10; }
.outfit-card.dragging { transition: none; cursor: grabbing; }
.outfit-card.flying { transition: transform .4s cubic-bezier(.32, .72, 0, 1), opacity .4s ease; opacity: 0; z-index: 11; }
.outfit-card.waiting, .outfit-card.gone:not(.flying) { visibility: hidden; opacity: 0; }
.outfit-card .outfit-info { margin-top: 16px; }
.deck-stamp { position: absolute; z-index: 3; top: 30px; padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; opacity: 0; transition: opacity .15s ease; pointer-events: none; }
.deck-stamp.select { right: 30px; background: var(--accent); color: var(--accent-ink); }
.deck-stamp.skip { left: 30px; background: var(--ink); color: var(--bg); }
.outfit-card[data-lean="select"] .deck-stamp.select, .outfit-card[data-lean="skip"] .deck-stamp.skip { opacity: 1; }
.outfit-deck-controls { display: flex; align-items: center; gap: 14px; max-width: 980px; margin: 34px 0 40px; }
.outfit-deck-controls[hidden], .outfit-deck-end[hidden] { display: none; }
.deck-button { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 100ms ease-out, background .15s ease; }
.deck-button .icon { width: 20px; height: 20px; }
.deck-button:hover { background: var(--surface); }
.deck-button:active { transform: scale(.94); }
.deck-button.select { margin-left: auto; background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.deck-button.select:hover { background: var(--accent); opacity: .9; }
.deck-count { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.deck-hint { font-size: 12px; color: var(--muted); }
.outfit-deck-end { align-self: center; padding: 60px 0; text-align: center; }
.outfit-deck-end h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 30px; }
.outfit-deck-end p { margin: 0 0 20px; color: var(--muted); }
.outfit-deck-end div { display: flex; gap: 10px; justify-content: center; }
@media (hover: none) { .deck-hint { display: none; } }
@media (max-width: 720px) { .outfit-card { padding: 12px; border-radius: 18px; } .deck-stamp { top: 22px; } }

/* ⌘K command menu (js/command.js) */
.command-dialog { width: min(560px, calc(100vw - 32px)); padding: 0; margin-top: 14vh; overflow: hidden; }
.command-box { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.command-box .icon { width: 18px; height: 18px; color: var(--muted); flex: none; }
.command-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; font-size: 16px; }
.command-box kbd { font: inherit; font-size: 11px; color: var(--muted); padding: 2px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }
.command-list { list-style: none; margin: 0; padding: 6px; max-height: min(380px, 55vh); overflow-y: auto; }
.command-group { padding: 10px 12px 4px; font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.command-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.command-item.active { background: var(--surface); }
.command-item.active .command-label { color: var(--accent); }
.command-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-item em { font-style: normal; font-size: 12px; color: var(--muted); }
.command-thumb { width: 24px; height: 30px; flex: none; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.command-thumb img { width: 100%; height: 100%; object-fit: cover; }
.command-empty { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* Cards fade in from a slight blur when the view changes (js/render.js). */
.product-card.fade-in { animation: blur-fade .45s cubic-bezier(.23, 1, .32, 1) both; animation-delay: calc(var(--i) * 30ms); }
@keyframes blur-fade { from { opacity: 0; filter: blur(6px); transform: translateY(8px); } }
.outfit-deck, .outfit-deck-controls { max-width: 760px; }
.outfit-card .outfit-photo { aspect-ratio: 4 / 5; }

/* Lookbook (js/lookbook.js): outfits as small flat-lays, several per row. */
.lookbook { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 40px 24px; padding-bottom: 40px; }
.look { display: block; width: 100%; padding: 0; text-align: left; color: inherit; }
.look-collage { display: grid; grid-template-columns: 1.35fr 1fr; grid-template-rows: repeat(var(--side), 1fr); gap: 5px; aspect-ratio: 1; }
.look-photo { position: relative; overflow: hidden; background: var(--surface); border-radius: 6px; }
.look-photo:first-child { grid-row: 1 / -1; }
.look-photo:only-child { grid-column: 1 / -1; }
.look-photo img { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; transition: transform .4s cubic-bezier(.23, 1, .32, 1); }
.look-photo .outfit-fallback { font-size: 28px; }
.look-photo .owned { position: absolute; z-index: 2; left: 6px; top: 6px; padding: 2px 7px; border-radius: 99px; font-size: 10px;
  background: var(--material); color: var(--ink); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.look:hover .look-photo img { transform: scale(1.03); }
.look-why { display: block; margin-top: 12px; font-family: var(--serif); font-size: 19px; line-height: 1.2; }
.look:hover .look-why { color: var(--accent); }
.look-meta { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.left-out { max-width: 640px; padding: 8px 0 60px; }
.left-out h3 { margin: 0 0 10px; font-family: var(--serif); font-weight: 400; font-size: 24px; }
.left-out ul { list-style: none; margin: 0; padding: 0; }
.left-out li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.left-out em { font-style: normal; color: var(--muted); }

/* The bigger view and Style it */
.look-dialog { width: min(860px, calc(100vw - 32px)); }
.look-body { display: grid; gap: 36px; padding: 0 24px 28px; }
.look-detail .outfit-info { grid-template-columns: auto 1fr auto; }
.look-detail .text-button.strong { grid-column: 3; grid-row: 1 / span 2; align-self: center; padding: 8px 16px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); }
.look-empty { margin: 0; color: var(--muted); }
.style-it { grid-column: 2; justify-self: start; margin-top: 6px; padding: 0; font-size: 12px; color: var(--muted);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; transition: color .15s ease; }
.style-it:hover { color: var(--accent); text-decoration-color: currentColor; }
@media (max-width: 720px) {
  .look-body { padding: 0 16px 20px; }
  .look-detail .outfit-info { grid-template-columns: 1fr; }
  .look-detail .text-button.strong { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* Outfit pop-up: same padding as the other dialogs; opens focused on itself, so the close
   button doesn't start with a focus ring. */
.look-dialog { padding: 28px 0 0; }
.look-dialog > .modal-heading { padding: 0 24px 18px; align-items: center; }


/* Close buttons: just a coral ×, no circle. */
.modal .icon-button { color: var(--accent); background: none; }
.modal .icon-button:hover { background: none; color: var(--accent); opacity: .75; }

/* Selection bar: brighter text on the glass. */
.selection-bar, .selection-bar .text-button { color: color-mix(in srgb, var(--ink) 85%, transparent); }
.selection-bar .text-button:hover { color: var(--ink); }
.selection-bar .stack-more { color: color-mix(in srgb, var(--ink) 75%, transparent); }

/* Outfits: Ideas / Saved switch, Save button, wardrobe summary (js/saved.js). */
.outfit-actions { justify-content: space-between; align-items: center; }
.outfit-actions .view-switcher em { font-style: normal; font-size: 10px; vertical-align: super; margin-left: 2px; color: var(--accent); }
.look-buttons { grid-column: 3; grid-row: 1 / span 2; align-self: center; display: flex; align-items: center; gap: 8px; }
.look-detail .look-buttons .text-button.strong { grid-column: auto; grid-row: auto; }
.save-look { padding: 8px 14px; border-radius: 99px; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.save-look:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.save-look.saved { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.save-look.saved::before { content: "✓ "; }
.saved-summary { margin: -6px 0 22px; font-size: 13px; color: var(--muted); }
.look-meta .complete { font-weight: 500; color: var(--accent); }
@media (max-width: 720px) { .look-buttons { grid-column: 1; grid-row: auto; } }
/* Pop-ups open focused on their heading (js/saved.js), not on the close button. */
.modal h2:focus { outline: none; }


/* Light mode: a soft darker shadow under the top bar (the dark-mode fade read as a white band here). */
:root[data-theme="light"] .topbar::after { background: linear-gradient(rgba(40, 34, 24, .09), transparent); }

/* Sync section in the ⋯ panel */
.sync-fields { margin-bottom: 14px; }
.sync-signed-in strong { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
#syncPanel [hidden] { display: none; }

/* Phones: notch and home-bar room (the home-screen app draws under the status bar),
   no grey flash on tap, and inputs at 16px so iPhone doesn't zoom in when you type. */
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
.modal { max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.topbar { padding-top: calc(34px + env(safe-area-inset-top)); padding-left: calc(var(--pad) + env(safe-area-inset-left)); padding-right: calc(var(--pad) + env(safe-area-inset-right)); }
.toast { top: calc(24px + env(safe-area-inset-top)); }
.main-content { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.selection-bar { bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (display-mode: standalone) { .topbar { padding-top: calc(12px + env(safe-area-inset-top)); } }
@media (max-width: 600px) {
  input, textarea, select, .field input, .field textarea { font-size: 16px; }
  .form-grid.sync-fields { grid-template-columns: 1fr; }
}
