:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: rgba(255, 255, 255, .82);
  --surface-solid: #fff;
  --surface-muted: #e9e9e5;
  --text: #151516;
  --secondary: #6c6c70;
  --line: rgba(18, 18, 20, .1);
  --accent: #1c64f2;
  --accent-soft: rgba(28, 100, 242, .12);
  --green: #16865a;
  --green-soft: rgba(22, 134, 90, .12);
  --red: #d94a4a;
  --red-soft: rgba(217, 74, 74, .12);
  --amber: #d28a10;
  --shadow: 0 18px 55px rgba(23, 23, 28, .13), 0 2px 10px rgba(23, 23, 28, .06);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --radius: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090a;
  --surface: rgba(29, 29, 31, .78);
  --surface-solid: #1c1c1e;
  --surface-muted: #28282b;
  --text: #f5f5f7;
  --secondary: #a3a3a8;
  --line: rgba(255, 255, 255, .1);
  --accent: #5d91ff;
  --accent-soft: rgba(93, 145, 255, .16);
  --green: #45c88b;
  --green-soft: rgba(69, 200, 139, .15);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, .15);
  --amber: #ffb842;
  --shadow: 0 20px 65px rgba(0, 0, 0, .5), 0 2px 12px rgba(0, 0, 0, .28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #09090a;
    --surface: rgba(29, 29, 31, .78);
    --surface-solid: #1c1c1e;
    --surface-muted: #28282b;
    --text: #f5f5f7;
    --secondary: #a3a3a8;
    --line: rgba(255, 255, 255, .1);
    --accent: #5d91ff;
    --accent-soft: rgba(93, 145, 255, .16);
    --green: #45c88b;
    --green-soft: rgba(69, 200, 139, .15);
    --red: #ff6b6b;
    --red-soft: rgba(255, 107, 107, .15);
    --amber: #ffb842;
    --shadow: 0 20px 65px rgba(0, 0, 0, .5), 0 2px 12px rgba(0, 0, 0, .28);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; }
button, input { font: inherit; }
button { color: inherit; }
button, a, label { touch-action: manipulation; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  width: 100%; min-height: 100dvh; margin: 0 auto; position: relative;
  background:
    radial-gradient(circle at 8% 4%, var(--accent-soft), transparent 24rem),
    var(--bg);
}

.app-header {
  height: calc(68px + var(--top)); padding: calc(14px + var(--top)) 18px 10px;
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 68%, color-mix(in srgb, var(--bg) 74%, transparent));
  backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.brand-mark { width: 34px; height: 34px; border-radius: 11px; background: var(--text); position: relative; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.brand-mark span { position: absolute; width: 7px; border-radius: 999px; background: var(--bg); transform: rotate(35deg); }
.brand-mark span:first-child { height: 16px; left: 10px; top: 8px; }
.brand-mark span:last-child { height: 11px; right: 9px; bottom: 7px; }
.header-copy { min-width: 0; line-height: 1.08; }
.header-copy strong { display: block; font-size: 20px; letter-spacing: -.5px; }
.header-copy span { display: block; color: var(--secondary); font-size: 11px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.icon-button svg { width: 19px; height: 19px; }

main { min-height: calc(100dvh - 68px); padding-bottom: calc(90px + var(--bottom)); }
.view { display: none; animation: view-in .22s ease; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(3px); } }

.swipe-toolbar { height: 38px; padding: 1px 18px 5px; display: flex; align-items: center; justify-content: space-between; }
.filter-button { border: 0; background: transparent; padding: 6px 0; display: flex; align-items: center; gap: 3px; font-weight: 650; cursor: pointer; }
.filter-button svg { width: 16px; height: 16px; }
.counter { font-size: 12px; color: var(--secondary); font-variant-numeric: tabular-nums; }

.card-stage { height: min(59dvh, 580px); min-height: 390px; margin: 2px 18px 0; position: relative; perspective: 1000px; }
.swipe-card { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-solid); box-shadow: var(--shadow); border: 1px solid var(--line); transform-origin: 50% 88%; will-change: transform; z-index: 2; }
.swipe-card.behind { transform: translateY(8px) scale(.965); opacity: .55; z-index: 1; pointer-events: none; }
.swipe-card.behind img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.image-button { width: 100%; height: 100%; padding: 0; border: 0; background: var(--surface-muted); display: block; cursor: zoom-in; }
.image-button img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: top center; user-select: none; -webkit-user-drag: none; }
.swipe-card[data-image-theme="Light"] .image-button { background: #ececea; }
.swipe-card[data-image-theme="Dark"] .image-button { background: #101012; }
.swipe-stamp { position: absolute; z-index: 3; top: 25px; padding: 8px 12px; border: 3px solid currentColor; border-radius: 11px; font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; opacity: 0; pointer-events: none; background: rgba(10,10,12,.52); backdrop-filter: blur(8px); }
.stamp-like { right: 22px; color: #58dfa0; transform: rotate(8deg); }
.stamp-dislike { left: 22px; color: #ff7373; transform: rotate(-8deg); }
.stamp-love { left: 50%; transform: translateX(-50%) rotate(-2deg); color: #ffbe4d; }

.screen-meta { margin: 10px 20px 0; min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.screen-meta > div { min-width: 0; }
.screen-meta strong { font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-meta span { display: block; color: var(--secondary); font-size: 11px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-link { color: var(--secondary); width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); text-decoration: none; }
.source-link svg { width: 16px; height: 16px; }

.reason-strip { min-height: 30px; padding: 2px 18px 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.reason-strip::-webkit-scrollbar { display: none; }
.reason-strip button { white-space: nowrap; border: 1px solid var(--line); background: transparent; color: var(--secondary); height: 27px; padding: 0 10px; border-radius: 9px; font-size: 11px; cursor: pointer; }
.reason-strip button.selected { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 38%, transparent); font-weight: 650; }

.swipe-actions { height: 58px; display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 5px; }
.round-action { width: 51px; height: 51px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 5px 16px rgba(20,20,24,.08); cursor: pointer; transition: transform .15s, background .15s; }
.round-action:active { transform: scale(.9); }
.round-action svg { width: 23px; height: 23px; stroke-width: 2.15; }
.round-action.undo { width: 40px; height: 40px; color: var(--secondary); }
.round-action.undo svg { width: 19px; height: 19px; }
.round-action.undo:disabled { opacity: .3; }
.round-action.dislike { color: var(--red); background: var(--red-soft); }
.round-action.like { color: var(--green); background: var(--green-soft); }
.round-action.love { color: var(--amber); }
.round-action.love svg { fill: currentColor; stroke-width: 1.4; }
.gesture-hint { margin: 1px 0 0; text-align: center; color: var(--secondary); font-size: 10px; }

.empty-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.empty-state.inline { position: static; min-height: 320px; }
.empty-state[hidden], [hidden] { display: none !important; }
.empty-state .empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--green-soft); color: var(--green); font-size: 26px; }
.empty-state h2 { font-size: 20px; margin: 16px 0 5px; }
.empty-state p { color: var(--secondary); font-size: 14px; line-height: 1.4; margin: 0 0 18px; max-width: 260px; }

.tab-bar { position: fixed; z-index: 50; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); bottom: max(8px, var(--bottom)); height: 66px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px 6px; border-radius: 23px; background: color-mix(in srgb, var(--surface-solid) 76%, transparent); border: 1px solid var(--line); box-shadow: 0 10px 35px rgba(10,10,14,.18); backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); }
.tab-bar button { border: 0; background: transparent; border-radius: 17px; color: var(--secondary); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; font-size: 9px; font-weight: 600; cursor: pointer; }
.tab-bar button svg { width: 22px; height: 22px; }
.tab-bar button.active { color: var(--accent); background: var(--accent-soft); }

.segmented { margin: 7px 18px 16px; padding: 3px; display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 12px; background: var(--surface-muted); }
.segmented button { height: 31px; border: 0; background: transparent; color: var(--secondary); border-radius: 9px; font-size: 11px; cursor: pointer; }
.segmented button.active { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 5px rgba(0,0,0,.1); font-weight: 650; }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 18px 22px; }
.library-item { position: relative; min-width: 0; border: 0; padding: 0; border-radius: 16px; overflow: hidden; background: var(--surface-solid); box-shadow: 0 5px 16px rgba(20,20,24,.08); aspect-ratio: .53; cursor: zoom-in; }
.library-item img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.library-item .verdict { position: absolute; top: 8px; right: 8px; width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(10,10,12,.66); backdrop-filter: blur(8px); font-size: 13px; }

#view-taste, #view-import { padding: 7px 18px 28px; }
.taste-summary { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 15px 5px; }
.metric { text-align: center; border-right: 1px solid var(--line); }
.metric:last-child { border: 0; }
.metric strong { display: block; font-size: 22px; line-height: 1; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.metric span { display: block; color: var(--secondary); font-size: 10px; margin-top: 6px; }
.insight-card { margin-top: 12px; padding: 19px; border-radius: 20px; border: 1px solid var(--line); background: linear-gradient(145deg, var(--accent-soft), var(--surface)); }
.section-kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .9px; font-size: 10px; font-weight: 750; }
.insight-card h2 { font-size: 20px; letter-spacing: -.4px; margin: 7px 0 5px; }
.insight-card p { color: var(--secondary); font-size: 13px; line-height: 1.45; margin: 0; }
.insight-section { margin-top: 24px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.section-heading h2 { font-size: 16px; letter-spacing: -.2px; margin: 0; }
.section-heading span { color: var(--secondary); font-size: 10px; }
.insight-list { border-radius: 16px; border: 1px solid var(--line); overflow: hidden; background: var(--surface); }
.insight-row { min-height: 48px; padding: 10px 13px; display: grid; grid-template-columns: minmax(80px, 1fr) 2fr 38px; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); font-size: 12px; }
.insight-row:last-child { border: 0; }
.insight-bar { height: 6px; overflow: hidden; border-radius: 9px; background: var(--surface-muted); }
.insight-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.insight-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-cloud span { padding: 8px 11px; border-radius: 10px; background: var(--surface-muted); font-size: 12px; }

.import-card { padding: 15px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 10px; }
.import-card.featured { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 11px; }
.import-card-title { display: flex; align-items: center; gap: 11px; }
.import-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); flex: 0 0 40px; }
.import-icon svg { width: 20px; height: 20px; }
.import-card h2 { margin: 0; font-size: 15px; letter-spacing: -.2px; }
.import-card p { color: var(--secondary); font-size: 11px; line-height: 1.35; margin: 3px 0 0; }
.import-card.stack form { display: flex; gap: 7px; margin-top: 13px; }
.import-card.stack > button { margin-top: 13px; }
input[type="url"] { min-width: 0; flex: 1; height: 38px; border: 1px solid var(--line); border-radius: 11px; padding: 0 11px; background: var(--surface-solid); color: var(--text); outline: none; font-size: 12px; }
input[type="url"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.primary-button, .secondary-button, .compact-button { border: 0; border-radius: 11px; min-height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 12px; cursor: pointer; }
.primary-button, .compact-button { background: var(--accent); color: white; }
.secondary-button { background: var(--surface-muted); color: var(--text); width: 100%; }
.source-summary { margin-top: 23px; }
.source-list { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.source-row { display: flex; justify-content: space-between; padding: 12px 13px; border-bottom: 1px solid var(--line); font-size: 12px; }
.source-row:last-child { border: 0; }
.source-row span:last-child { color: var(--secondary); font-variant-numeric: tabular-nums; }

dialog { color: var(--text); }
.sheet-dialog { width: min(100%, 430px); max-height: 76dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 26px 26px 0 0; background: var(--surface-solid); box-shadow: 0 -20px 60px rgba(0,0,0,.25); }
.sheet-dialog::backdrop { background: rgba(0,0,0,.36); backdrop-filter: blur(3px); }
.sheet-dialog form { padding: 8px 18px calc(20px + var(--bottom)); }
.sheet-handle { width: 36px; height: 5px; background: var(--line); border-radius: 9px; margin: 0 auto 8px; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; }
.sheet-title h2 { font-size: 19px; margin: 8px 0 13px; }
.option-list { display: grid; gap: 6px; max-height: 56dvh; overflow: auto; }
.option-list button { min-height: 45px; display: flex; justify-content: space-between; align-items: center; border: 0; border-radius: 12px; padding: 0 13px; background: var(--surface-muted); cursor: pointer; }
.option-list button.selected { color: var(--accent); background: var(--accent-soft); font-weight: 650; }

.image-dialog { width: 100vw; height: 100dvh; max-width: none; max-height: none; padding: calc(18px + var(--top)) 10px calc(18px + var(--bottom)); border: 0; background: rgba(0,0,0,.94); }
.image-dialog::backdrop { background: #000; }
.image-dialog img { display: block; width: 100%; height: 100%; object-fit: contain; }
.floating-close { position: fixed; top: calc(12px + var(--top)); right: 14px; z-index: 2; width: 38px; height: 38px; border: 0; border-radius: 50%; color: white; background: rgba(65,65,68,.72); backdrop-filter: blur(12px); display: grid; place-items: center; }
.floating-close svg { width: 19px; height: 19px; }

.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(86px + var(--bottom)); max-width: calc(100% - 34px); transform: translate(-50%, 16px); opacity: 0; pointer-events: none; color: white; background: rgba(20,20,22,.9); backdrop-filter: blur(15px); padding: 10px 14px; border-radius: 12px; font-size: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.24); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 650px) {
  .app-shell { max-width: 470px; min-height: 100dvh; border-left: 1px solid var(--line); border-right: 1px solid var(--line); box-shadow: 0 0 70px rgba(0,0,0,.1); }
  .tab-bar { width: 446px; left: 50%; right: auto; transform: translateX(-50%); }
  .card-stage { height: min(64dvh, 640px); }
}

@media (max-height: 720px) {
  .card-stage { height: 49dvh; min-height: 330px; }
  .screen-meta { margin-top: 7px; }
  .swipe-actions { margin-top: 2px; height: 53px; }
  .round-action { width: 47px; height: 47px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
