:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #141414;
  --muted: #6d6a64;
  --line: #e3dfd8;
  --accent: #ff5a36;
  --like: #18a058;
  --nope: #e5484d;
  --shadow: 0 10px 30px rgba(20, 20, 20, .10), 0 2px 6px rgba(20, 20, 20, .06);
  --radius: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111;
    --surface: #1c1c1c;
    --ink: #f2f0ec;
    --muted: #9a968f;
    --line: #2d2d2d;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #111111;
    --surface: #1c1c1c;
    --ink: #f2f0ec;
    --muted: #9a968f;
    --line: #2d2d2d;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.logo { margin: 0; font-size: 22px; letter-spacing: -.02em; font-weight: 800; }
.logo span { color: var(--accent); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center;
}
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.badge:empty, .badge[data-zero] { display: none; }

.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0 16px max(12px, env(safe-area-inset-bottom)); min-height: 0;
}
.sample-bar { width: 100%; max-width: 520px; margin-bottom: 12px; }
.sample-bar input, input[type=search] {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit;
}

.deck { position: relative; width: 100%; max-width: 520px; flex: 1; min-height: 320px; }
.deck-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }

.card {
  position: absolute; inset: 0; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
  touch-action: none; user-select: none; will-change: transform, opacity;
  --ease-out: cubic-bezier(.22, .8, .24, 1);
  transition: transform .5s var(--ease-out), opacity .45s var(--ease-out), box-shadow .5s var(--ease-out);
}
.card.dragging { transition: none; cursor: grabbing; }
.card.snap { transition: transform .45s cubic-bezier(.34, 1.4, .64, 1); }
.card.leaving { pointer-events: none; transition: transform .5s cubic-bezier(.4, .1, .6, 1), opacity .5s ease-in; z-index: 2; }
/* Bagved-kortene: let nedskaleret og tonet ned; --lift (0–1) løfter dem mens man trækker */
.card.behind {
  transform: translateY(calc(14px - 14px * var(--lift, 0))) scale(calc(.95 + .05 * var(--lift, 0)));
  opacity: calc(.7 + .3 * var(--lift, 0)); pointer-events: none; box-shadow: none;
}
.card.behind2 {
  transform: translateY(calc(28px - 14px * var(--lift, 0))) scale(calc(.9 + .05 * var(--lift, 0)));
  opacity: calc(.35 + .35 * var(--lift, 0)); pointer-events: none; box-shadow: none;
}
.card.behind3 { transform: translateY(40px) scale(.86); opacity: 0; pointer-events: none; box-shadow: none; }
.card.behind .card-main, .card.behind2 .card-main, .card.behind3 .card-main { transition: opacity .4s ease; }
.deck:has(.card.dragging) .card.behind, .deck:has(.card.dragging) .card.behind2 { transition: none; }

.tags { display: flex; flex-wrap: nowrap; gap: 6px; padding: 16px 18px 0; min-width: 0; overflow: hidden; }
.tag { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.free { color: var(--like); border-color: color-mix(in srgb, var(--like) 40%, transparent); }

.card-main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 10px 20px; min-height: 0; min-width: 0; overflow: hidden; }
.card-main > * { margin: 0; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.card-name { font-size: 48px; line-height: 1.08; }
.card-sample { font-size: 21px; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.card-alpha { font-size: 16px; line-height: 1.35; color: var(--muted); letter-spacing: .02em; overflow: hidden; flex-shrink: 0; }
.card-alpha span { display: block; white-space: nowrap; overflow-wrap: normal; }
.card-name, .card-sample, .card-alpha, .w-chip { transition: opacity .35s ease; }
.loading .card-name, .loading .card-sample, .loading .card-alpha, .loading .w-chip { opacity: .15; }
.v-toggles { display: flex; gap: 6px; flex-shrink: 0; }
.caps-toggle { letter-spacing: .04em; font-weight: 600; }
body.caps .card-name, body.caps .card-sample, body.caps .detail-sample, body.caps .detail-variant .txt, body.caps .detail-size p { text-transform: uppercase; }

.weights { padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.weights-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 30px; }
.v-label { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it-toggle { flex-shrink: 0; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); font-size: 15px; }
.it-toggle[aria-pressed=true], .w-chip[aria-pressed=true] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.w-chip[aria-pressed=true] small { color: inherit; opacity: .7; }
.w-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.w-chip {
  min-width: 0; text-align: center; font-size: 21px; line-height: 1.1; padding: 6px 0 5px; border-radius: 9px;
  background: var(--bg); border: 1px solid transparent; transition: background .15s, color .15s;
}
.w-chip small { display: block; font: 10px/1 system-ui, sans-serif; color: var(--muted); margin-top: 3px; }
.w-chip:focus-visible, .it-toggle:focus-visible, .ctrl:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stamp {
  position: absolute; top: 26px; padding: 6px 14px; border: 4px solid; border-radius: 10px;
  font: 800 26px/1 system-ui, sans-serif; letter-spacing: .08em; opacity: 0; pointer-events: none;
}
.stamp-like { left: 22px; color: var(--like); transform: rotate(-14deg); }
.stamp-nope { right: 22px; color: var(--nope); transform: rotate(14deg); }

.controls { display: flex; gap: 16px; align-items: center; margin: 16px 0 6px; }
.ctrl {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); display: grid; place-items: center; transition: transform .12s;
}
.ctrl:active { transform: scale(.92); }
.ctrl-like, .ctrl-nope { width: 68px; height: 68px; }
.ctrl-like svg, .ctrl-nope svg { width: 30px; height: 30px; stroke-width: 2.4; }
.ctrl-like { color: var(--like); }
.ctrl-nope { color: var(--nope); }
.ctrl-undo, .ctrl-info { color: var(--muted); }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 10; }
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 11;
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .3s ease; display: flex; flex-direction: column;
}
.sheet-wide { width: min(720px, 100%); }
.sheet.open { transform: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { padding: 16px; overflow-y: auto; flex: 1; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); font-size: 14px; }
.chip[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.btn { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg); }
.saved-item h3 { margin: 0 0 4px; font-size: 26px; font-weight: 400; word-break: break-word; cursor: pointer; }
.saved-item .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.saved-item .row { margin: 0; gap: 6px; }
.saved-item .btn { padding: 6px 10px; font-size: 13px; }
@media (max-width: 400px) { .saved-item .btn { padding: 5px 9px; font-size: 12px; } .saved-item .row { gap: 5px; } }

.detail-sample { font-size: 34px; line-height: 1.2; margin: 0 0 18px; word-break: break-word; }
.detail-variant { display: flex; align-items: baseline; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.detail-variant .lbl { width: 110px; flex-shrink: 0; font-size: 12px; color: var(--muted); }
.detail-variant .txt { font-size: 26px; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.detail-size { margin: 18px 0; }
.detail-size p { margin: 4px 0; overflow-wrap: anywhere; }

.toast {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -12px); opacity: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: all .25s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Små skærme (fx iPhone 13 mini: 375 × 812, ~630 px synligt i Safari) */
@media (max-width: 400px) {
  .topbar { padding-left: 14px; padding-right: 14px; padding-bottom: 8px; }
  .logo { font-size: 20px; }
  .icon-btn { width: 38px; height: 38px; }
  .stage { padding-left: 12px; padding-right: 12px; }
  .sample-bar { margin-bottom: 10px; }
  .sample-bar input { padding: 9px 12px; font-size: 16px; }
  .tags { padding: 12px 14px 0; }
  .tag { font-size: 11px; padding: 3px 8px; }
  .card-main { padding: 8px 16px; gap: 8px; }
  .card-sample { font-size: 19px; -webkit-line-clamp: 3; }
  .weights { padding: 8px 12px 12px; }
  .w-row { gap: 4px; }
  .w-chip small { font-size: 9px; }
  .w-chip { font-size: 18px; }
  .controls { gap: 14px; margin: 12px 0 4px; }
  .ctrl { width: 46px; height: 46px; }
  .ctrl-like, .ctrl-nope { width: 58px; height: 58px; }
  .stamp { font-size: 20px; top: 18px; }
}
@media (max-height: 700px) {
  .card-sample { -webkit-line-clamp: 2; }
  .controls { margin: 8px 0 2px; }
}
@media (max-height: 600px) {
  .card-sample { -webkit-line-clamp: 1; }
}

.sync { font-size: 13px; margin: 0 0 14px; padding: 8px 12px; border-radius: 10px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.sync[data-kind=ok] { color: var(--like); }
.sync[data-kind=error] { color: var(--nope); }
.copy-fallback { width: 100%; font: 12px/1.4 ui-monospace, monospace; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .card, .card.leaving, .card.snap, .sheet, .toast, .scrim { transition: opacity .15s linear; } }
.detail-sample, .saved-item h3, .detail-variant .txt, .sheet-head h2 { overflow-wrap: anywhere; min-width: 0; }
.saved-cats { margin-bottom: 14px; }
.chip-n { font-size: 12px; opacity: .6; font-variant-numeric: tabular-nums; }
.saved-group { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 2px 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.saved-group:first-child { margin-top: 0; }
.saved-group span { font-variant-numeric: tabular-nums; }
.remaining {
  flex: 1; min-width: 0; margin: 0 10px; text-align: right; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.tagline { margin: 1px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .01em; white-space: nowrap; }
@media (max-width: 400px) { .tagline { font-size: 11px; } }
.btn[disabled] { opacity: .7; cursor: progress; }
[hidden] { display: none !important; }
/* Tastaturtip: kun på computere (mus/trackpad) med plads til det */
.kbd-hint { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) and (min-height: 640px) {
  .kbd-hint { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
  .kbd-hint span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
  .kbd-hint kbd {
    font: 600 11px/1 system-ui, sans-serif; min-width: 22px; padding: 4px 6px; text-align: center; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  }
}
/* Diplom */
.diploma {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(0,0,0,.45); opacity: 0; transition: opacity .3s ease;
}
.diploma.show { opacity: 1; }
.diploma-card {
  width: min(420px, 100%); max-height: calc(100% - 16px); overflow-y: auto; background: var(--surface); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 22px 18px;
  transform: translateY(16px) scale(.96); transition: transform .45s cubic-bezier(.34, 1.4, .64, 1);
}
.diploma.show .diploma-card { transform: none; }
.dip-eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--like); }
.dip-persona { margin: 6px 0 4px; font-size: 30px; line-height: 1.1; letter-spacing: -.01em; text-wrap: balance; }
.dip-sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.dip-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 18px; }
.dip-stats div { background: var(--bg); border-radius: 12px; padding: 10px; min-width: 0; }
.dip-stats dt { font-size: 11px; color: var(--muted); }
.dip-stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dip-cats { display: grid; gap: 6px; margin-bottom: 16px; }
.dip-bar { display: grid; grid-template-columns: 96px 1fr 28px; align-items: center; gap: 8px; font-size: 12px; }
.dip-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dip-bar-track { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.dip-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.dip-bar-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.dip-love { margin: 0 0 6px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.dip-love span { display: block; font-size: 26px; color: var(--ink); margin-top: 2px; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 40; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .diploma, .diploma-card { transition: opacity .15s linear; transform: none; } }
