/* Flohmarkt-Duell – one stylesheet, mobile first (docs/SPEC.md §16) */

:root {
  --bg: #faf6ef;
  --card: #fff;
  --ink: #1f1d1a;
  --muted: #6b655c;
  --line: #e8e1d5;
  --accent: #e76f51;
  --accent-2: #2a9d8f;
  --good: #2a9d8f;
  --bad: #d62828;
  --warn: #e9c46a;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(31, 29, 26, .08);
  --user-color: var(--accent);
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --chip-bg: #f1ebe0;
  --input-bg: #fff;
  --focus: #3a86ff;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --card: #22201d;
    --ink: #f3efe7;
    --muted: #a39c90;
    --line: #352f29;
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
    --chip-bg: #2d2925;
    --input-bg: #1c1a17;
  }
}

/* ----- base ------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent-2); }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { font-size: .85em; background: var(--chip-bg); padding: .1em .35em; border-radius: 6px; }
dl { margin: 0; }
dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
dd { margin: 0; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: #9a6a00; background: rgba(233, 196, 106, .25); padding: .4rem .6rem; border-radius: 8px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
main.with-tabbar { padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
.narrow { max-width: 680px; margin: 0 auto; }
.stack > * + * { margin-top: 1rem; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-bottom: 1rem; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.2rem 0 .6rem; flex-wrap: wrap; }
.section-head h1, .section-head h2 { margin: 0; }
.section-title { margin: 1.2rem 0 .6rem; }
.count { font-weight: 400; font-size: .9em; }

/* ----- money ----------------------------------------------------------------------- */

.money-huge, .money-big, .money-row, .estimate, .paid, .ranking-value, .timeline-result, .stat-grid dd, .score-facts dd {
  font-variant-numeric: tabular-nums;
}
.money-huge { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; margin: .2rem 0 0; color: var(--good); }
.money-huge.neg { color: var(--bad); }
.money-big { font-size: 1.35rem; font-weight: 700; }
.money-row { display: flex; flex-wrap: wrap; gap: .25rem .4rem; align-items: baseline; margin: 0 0 .4rem; }
.money-row .paid, .money-row .estimate { white-space: nowrap; }
.money-row .paid { color: var(--muted); }
.money-row .estimate { font-weight: 700; }
.money-row .arrow { color: var(--muted); }

/* ----- buttons --------------------------------------------------------------------- */

.btn, button.btn, summary.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  list-style: none;
}
.btn:hover { text-decoration: none; background: var(--chip-bg); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #d8604a; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-danger:hover { background: rgba(214, 40, 40, .08); }
.btn-big { min-height: 52px; font-size: 1.05rem; padding: .7rem 1.4rem; }
.btn-small { min-height: 34px; padding: .25rem .8rem; font-size: .9rem; }
.btn-light { background: rgba(255, 255, 255, .25); border-color: rgba(255, 255, 255, .5); color: inherit; }
.btn:disabled { opacity: .6; cursor: progress; }
.linkish { background: none; border: 0; color: var(--accent-2); font: inherit; cursor: pointer; padding: 0; text-decoration: none; }
.linkish:hover { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.inline-form { display: inline; margin: 0; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] > summary { background: var(--chip-bg); }
.manual-form { display: flex; gap: .5rem; margin-top: .6rem; align-items: center; }
.manual-form input { width: 9rem; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom)); background: var(--bg); padding: .6rem 0; }
@media (min-width: 720px) { .sticky-actions { bottom: 8px; } }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

/* ----- chips ----------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--chip-bg); color: var(--ink); text-decoration: none; white-space: nowrap;
}
.chip-good { background: rgba(42, 157, 143, .18); color: var(--good); }
.chip-bad { background: rgba(214, 40, 40, .14); color: var(--bad); }
.chip-ai { background: rgba(58, 134, 255, .14); color: #2a66c9; }
.chip-wait { background: rgba(233, 196, 106, .3); color: #7a5a00; }
.chip-muted { color: var(--muted); }
.chip-active { background: var(--accent); color: #fff; }
.chip-conf-hoch { background: rgba(42, 157, 143, .18); color: var(--good); }
.chip-conf-mittel { background: rgba(233, 196, 106, .3); color: #7a5a00; }
.chip-conf-niedrig { background: rgba(214, 40, 40, .14); color: var(--bad); }
@media (prefers-color-scheme: dark) {
  .chip-ai { color: #8fb8ff; }
  .chip-wait, .chip-conf-mittel { color: #f0d27a; }
  .warn { color: #f0d27a; }
}
.qmark { font-weight: 800; }
.chip-radio { position: relative; }
.chip-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-radio span, .chip-radio label {
  display: inline-flex; align-items: center; min-height: 40px; padding: .4rem .9rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 500; user-select: none;
}
.chip-radio input:checked + span, .chip-radio input:checked + label { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-radio input:focus-visible + span, .chip-radio input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip-radio input:disabled + span { opacity: .4; cursor: not-allowed; }
.avatar-radio span { font-size: 1.4rem; padding: .3rem .5rem; min-width: 48px; justify-content: center; }
.color-radio span.swatch { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--user-color); border: 3px solid transparent; }
.color-radio input:checked + span.swatch { background: var(--user-color); border-color: var(--ink); box-shadow: 0 0 0 3px var(--card) inset; }
.color-radio.taken span.swatch::after { content: "✕"; color: #fff; display: block; text-align: center; line-height: 38px; font-weight: 700; }
.year-filter { margin-bottom: 1rem; }
.filter-bar .chip-radio label { min-height: 40px; }
.filter-bar .chip-radio input:checked + label { background: var(--user-color); border-color: var(--user-color); }
.filter-bar .chip-radio:first-child input:checked + label { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ----- avatars --------------------------------------------------------------------- */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; border-radius: 50%; font-size: 1.3rem;
  background: var(--user-color); box-shadow: 0 0 0 2px var(--card);
}
.avatar-big { width: 4rem; height: 4rem; font-size: 2.3rem; }
.avatar-small { width: 1.6rem; height: 1.6rem; font-size: .95rem; vertical-align: middle; }
.avatar-dot {
  position: absolute; left: 8px; bottom: 8px; width: 2rem; height: 2rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
  background: var(--user-color); box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* ----- navigation ------------------------------------------------------------------ */

.topbar { display: none; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 8px; padding-bottom: 8px; }
.brand { font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: .3rem; align-items: center; }
.topnav-link {
  display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .8rem; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 600; min-height: 40px;
}
.topnav-link:hover { background: var(--chip-bg); text-decoration: none; }
.topnav-link.active { background: var(--chip-bg); color: var(--accent); }
.topnav-add { background: var(--accent); color: #fff; }
.topnav-add:hover, .topnav-add.active { background: #d8604a; color: #fff; }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.3rem; height: 1.3rem;
  padding: 0 .35rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600; min-height: 44px;
}
.tab:hover { text-decoration: none; }
.tab.active { color: var(--accent); }
.tab-icon { font-size: 1.35rem; line-height: 1; position: relative; }
.tab-icon .badge-count { position: absolute; top: -6px; right: -12px; }
.tab-add .tab-icon {
  width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: 0 4px 12px rgba(231, 111, 81, .45);
}
.tab-add .tab-label { color: var(--accent); }
@media (min-width: 720px) {
  .topbar { display: block; }
  .tabbar { display: none; }
  main.with-tabbar { padding-bottom: 32px; }
}

/* ----- flash ----------------------------------------------------------------------- */

.flash {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-weight: 600;
}
.flash-ok { background: var(--accent-2); color: #fff; }
.flash-error { background: var(--bad); color: #fff; }
.flash a.btn-light { color: #fff; }

/* ----- hero & scoreboard ----------------------------------------------------------- */

.hero { text-align: center; padding: .4rem 0 .8rem; }
.hero-title { font-size: 2rem; font-weight: 900; letter-spacing: -.02em; margin-bottom: .3rem; }
.taunt { font-size: 1.05rem; color: var(--muted); max-width: 560px; margin: 0 auto; }
.auth-page { max-width: 520px; margin: 2rem auto; text-align: center; }
.auth-page .card { text-align: left; }
.auth-page .lead { color: var(--muted); font-size: 1.05rem; }
.partner-card { text-align: center; border: 2px dashed var(--accent); }

.scoreboard { position: relative; overflow: hidden; }
.score-columns { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: start; }
.score-col { text-align: center; padding: .6rem .2rem; border-radius: var(--radius); }
.score-col.is-leader { background: color-mix(in srgb, var(--user-color) 12%, transparent); }
.score-avatar { position: relative; display: inline-block; }
.crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-12deg); font-size: 1.6rem; }
.score-name { margin: .4rem 0 0; font-size: 1.15rem; color: var(--user-color); }
.score-col .money-huge { font-size: 1.7rem; }
.score-facts { display: grid; gap: .3rem; margin-top: .6rem; }
.score-facts dt { font-size: .68rem; }
.score-facts dd { font-weight: 600; }
.vs-badge {
  align-self: center; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--bg); font-weight: 900; font-size: .85rem; box-shadow: var(--shadow);
}
.lead-sentence { text-align: center; font-weight: 700; font-size: 1.1rem; margin: 1rem 0 .6rem; }
.share-bar { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: var(--chip-bg); }
.share-seg { background: var(--user-color); display: flex; align-items: center; justify-content: center; min-width: 0; transition: width .4s ease; }
.share-label { color: #fff; font-size: .72rem; font-weight: 700; padding: 0 .4rem; white-space: nowrap; overflow: hidden; }
.month-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--line); font-size: .92rem; }
.month-label { color: var(--muted); }
.month-values { display: flex; gap: 1rem; }
.month-value { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; }
@media (min-width: 720px) {
  .score-col .money-huge { font-size: 2.4rem; }
  .score-facts { grid-template-columns: repeat(3, 1fr); }
  .vs-badge { width: 56px; height: 56px; font-size: 1.05rem; }
}
.ai-status { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; margin: 1rem 0; }

/* ----- cards grid ------------------------------------------------------------------ */

.cards-grid { display: grid; gap: .8rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .cards-grid { grid-template-columns: repeat(4, 1fr); } }
.cards-grid-single { grid-template-columns: 1fr; max-width: 420px; }
.cards-row { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .4rem; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.cards-row .item-card { flex: 0 0 200px; scroll-snap-align: start; }
.item-card { padding: 0; overflow: hidden; color: inherit; text-decoration: none; margin: 0; display: flex; flex-direction: column; border-top: 4px solid var(--user-color); }
.item-card:hover { text-decoration: none; transform: translateY(-2px); transition: transform .12s ease; }
.item-card.is-new { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.thumb-wrap { position: relative; aspect-ratio: 4 / 3; background: var(--chip-bg); }
.thumb { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.new-dot { position: absolute; top: 8px; right: 8px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 800; padding: .15rem .5rem; border-radius: 999px; }
.card-body { padding: .6rem .7rem .8rem; }
.card-title { font-size: .95rem; margin: 0 0 .3rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-card .chips { gap: .3rem; }
.item-card .chip { font-size: .72rem; padding: .15rem .5rem; }
.empty-state { text-align: center; padding: 2rem 1rem; }
.empty-state .btn { margin-top: .5rem; }

/* ----- filter bar & pagination ----------------------------------------------------- */

.filter-bar { padding: .8rem; }
.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filter-row + .filter-row { margin-top: .6rem; }
.filter-row input[type="search"] { flex: 1; min-width: 160px; }
.select-wrap select { min-height: 40px; border-radius: 999px; padding: .3rem .9rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1.2rem 0; }

/* ----- forms ----------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: .3rem; }
.field + .field { margin-top: .8rem; }
.field-row { display: grid; gap: .8rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }
label, .label { font-weight: 600; font-size: .92rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
  font: inherit; color: var(--ink); background: var(--input-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .8rem; min-height: 44px; width: 100%;
}
textarea { resize: vertical; }
.input-money { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.has-error input, .has-error textarea { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: .85rem; margin: .2rem 0 0; font-weight: 600; }
.req { color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0 .4rem; }
.check { display: flex; align-items: center; gap: .5rem; min-height: 44px; }
.check input { width: 22px; height: 22px; }
.sys-grid { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; }
.sys-grid dt { align-self: center; }
.user-picker { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.user-pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .8rem 1.2rem; border-radius: var(--radius); border: 2px solid var(--line); cursor: pointer; min-width: 130px; }
.user-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.user-pick:has(input:checked) { border-color: var(--user-color); background: color-mix(in srgb, var(--user-color) 12%, transparent); }
.user-pick:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.user-pick-name { font-weight: 700; }
.profile-block { background: var(--card); }

/* photo field */
.photo-field { text-align: center; }
[hidden] { display: none !important; }
.photo-preview-wrap { margin-bottom: .8rem; }
.photo-preview { max-height: 320px; width: auto; margin: 0 auto; border-radius: 10px; object-fit: contain; }
.photo-preview-small { max-height: 120px; margin-top: .6rem; }
.photo-buttons { display: none; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.photo-buttons .btn { flex: 1 1 160px; }
html.js .photo-buttons { display: flex; }
/* Visually hidden, not display:none: the input stays `required`, so the browser can still show its validation bubble. */
html.js .file-fallback { position: absolute; left: 50%; bottom: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
html.js .file-fallback.visible { position: static; width: auto; height: auto; opacity: 1; overflow: visible; display: block; margin-top: .6rem; }
.photo-field { position: relative; }
input[type="file"] { font: inherit; min-height: 44px; }
.btn-file { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-weight: 600; }
html.js .btn-file + input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* ----- detail ---------------------------------------------------------------------- */

.detail-photos { display: grid; grid-template-columns: 1fr; gap: .6rem; margin-bottom: 1rem; }
.detail-photos img { border-radius: var(--radius); width: 100%; object-fit: contain; max-height: 70vh; background: var(--chip-bg); }
.photo-second img { max-height: 160px; width: auto; }
@media (min-width: 720px) { .detail-photos { grid-template-columns: 3fr 1fr; align-items: start; } .photo-second img { max-height: none; width: 100%; } }
.detail-head h1 { font-size: 1.5rem; overflow-wrap: anywhere; }
.detail-head .meta { color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: .3rem; }
.money-block { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center; }
.money-cell { display: flex; flex-direction: column; gap: .1rem; }
.money-cell .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.money-cell .money-big { font-size: 1.25rem; }
@media (min-width: 560px) { .money-cell .money-big { font-size: 1.6rem; } }
.estimate-box { border-left: 4px solid var(--accent-2); }
.estimate-box[data-status="queued"], .estimate-box[data-status="running"] { border-left-color: var(--warn); }
.estimate-box[data-status="failed"] { border-left-color: var(--bad); }
.est-state { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-weight: 600; }
.est-failed { color: var(--bad); }
.est-old { margin-top: .4rem; }
.est-value { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.est-done .chips { margin-bottom: .6rem; }
.est-reasoning { overflow-wrap: anywhere; }
.sources { padding-left: 1.2rem; margin: .4rem 0; }
.sources li { overflow-wrap: anywhere; }
.est-suggestion { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
.reactions { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.react-btn {
  display: inline-flex; align-items: center; gap: .3rem; min-height: 44px; padding: .4rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); font: inherit; cursor: pointer; font-weight: 600;
}
.react-btn .react-emoji { font-size: 1.2rem; }
.react-btn.active { background: rgba(231, 111, 81, .15); border-color: var(--accent); }
.comments .comment { display: flex; gap: .6rem; align-items: flex-start; padding: .6rem 0; border-top: 1px solid var(--line); }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { margin: 0 0 .2rem; font-size: .9rem; }
.comment-form { margin-top: .8rem; }
.detail-actions { margin-top: .5rem; }

/* ----- chart ----------------------------------------------------------------------- */

.chart-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; font-size: .9rem; }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--user-color); display: inline-block; }
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; }
.bar-group { display: flex; flex-direction: column; align-items: center; gap: .3rem; min-width: 0; }
.bar-area { position: relative; width: 100%; height: 150px; }
.zero-line { position: absolute; left: 0; right: 0; bottom: var(--zero); border-top: 1px solid var(--line); }
.bar { position: absolute; width: 42%; border-radius: 3px 3px 0 0; background: var(--user-color); min-height: 1px; }
.bar.neg { border-radius: 0 0 3px 3px; opacity: .8; }
.bar:nth-child(2) { left: 4%; }
.bar:nth-child(3) { right: 4%; }
.bar-label { font-size: .62rem; color: var(--muted); white-space: nowrap; }
@media (min-width: 560px) { .bar-label { font-size: .72rem; } }
@media (max-width: 559px) { .bar-group:not(:nth-child(3n)) .bar-label { visibility: hidden; } }
.cumulative { width: 100%; height: 120px; margin-top: 1rem; display: block; }
.svg-zero { stroke: var(--line); stroke-width: 1; }

/* ----- stats ----------------------------------------------------------------------- */

.user-stats { border-top: 4px solid var(--user-color); }
.user-stats h2 { display: flex; align-items: center; gap: .5rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .8rem; margin: .8rem 0 1rem; }
.stat-grid dd { font-weight: 600; overflow-wrap: anywhere; }
.badges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem; padding: .6rem .4rem; border-radius: 10px; border: 1px solid var(--line); opacity: .55; filter: grayscale(1); }
.badge.earned { opacity: 1; filter: none; border-color: var(--warn); background: rgba(233, 196, 106, .14); }
.badge-emoji { font-size: 1.6rem; }
.badge-name { font-weight: 700; font-size: .85rem; }
.badge-desc { font-size: .72rem; line-height: 1.25; }
.badge-progress { font-size: .75rem; font-weight: 700; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.timeline-item.running { border-top: 0; font-weight: 600; color: var(--accent); }
.timeline-month { font-weight: 600; }
.plain-list { padding-left: 1.2rem; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); text-align: left; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rules ul { padding-left: 1.2rem; }
.rules li { margin-bottom: .4rem; }

/* ----- hall of fame ---------------------------------------------------------------- */

.ranking { list-style: none; padding: 0; margin: 0; }
.ranking-item { display: grid; grid-template-columns: 2rem 56px 1fr auto; gap: .6rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--line); }
.ranking-item:first-child { border-top: 0; }
.rank { font-weight: 900; color: var(--muted); text-align: center; }
.ranking-item:nth-child(1) .rank { color: #d4a017; }
.ranking-item:nth-child(2) .rank { color: #8a8f99; }
.ranking-item:nth-child(3) .rank { color: #b87333; }
.ranking-thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--chip-bg); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.ranking-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ranking-body { min-width: 0; display: flex; flex-direction: column; }
.ranking-title { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-value { text-align: right; font-weight: 800; display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }

/* ----- error page ------------------------------------------------------------------ */

.error-card { text-align: center; max-width: 560px; margin: 2rem auto; }
.error-code { font-size: 3rem; font-weight: 900; color: var(--accent); margin: 0; line-height: 1; }
.error-card .actions { justify-content: center; margin-top: 1rem; }
