:root {
  --paper:      #F0EBE0;
  --surface:    #FFFFFF;
  --surface-2:  #F5F0E8;
  --ink:        #0F1318;
  --muted:      #5B6475;
  --faint:      #8D97A8;
  --amber:      #C47E00;
  --gain:       #0A8A45;
  --loss:       #CC2840;
  --hairline:   rgba(0,0,0,0.07);
  --hairline-2: rgba(0,0,0,0.11);
  --display: 'Bricolage Grotesque', sans-serif;
  --body:    'Inter', sans-serif;
  --mono:    'IBM Plex Mono', monospace;
  --col: 560px;
}

*, *::before, *::after {
  box-sizing: border-box; margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
html, body { height: 100%; }
body {
  background:
    radial-gradient(120% 80% at 50% -10%, #E8E0D2 0%, #F0EBE0 55%),
    #F0EBE0;
  color: var(--ink);
  font-family: var(--body);
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* ── App shell ─────────────────────────────────────── */
.app {
  width: 100%; max-width: var(--col);
  height: 100dvh; min-height: 560px;
  display: flex; flex-direction: column;
  padding: 14px 18px 18px;
  position: relative;
}

/* ── Top bar ────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 16px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; }

.logo { height: 30px; width: auto; display: block; }

.bar-right { display: flex; align-items: center; gap: 12px; }

.watch {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--gain);
  padding: 5px 9px;
  border: 1px solid rgba(10,138,69,.2); border-radius: 999px;
  background: rgba(10,138,69,.06);
}

#date-picker {
  font-family: var(--mono); font-size: 11px;
  color: var(--muted); background: transparent;
  border: none; cursor: pointer; outline: none;
  text-align: right;
}
#date-picker option { background: var(--surface); color: var(--ink); }
#date-picker:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 3px; }

/* ── Deck wrap ──────────────────────────────────────── */
.deck-wrap {
  flex: 1; min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.deck {
  position: relative;
  width: 100%; height: 100%; max-height: 580px;
}

/* ── Card ───────────────────────────────────────────── */
.card {
  position: absolute; inset: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 22px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.05),
    0 20px 50px -16px rgba(0,0,0,0.16);
  will-change: transform;
  transform-origin: center 120%;
  user-select: none; touch-action: none;
}
.card.top { cursor: grab; }
.card.top:active { cursor: grabbing; }

/* ── Card image banner ───────────────────────────────── */
.card-img {
  height: 180px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--hairline);
}

/* ── Card body ──────────────────────────────────────── */
.content {
  padding: 18px 20px 16px;
  display: flex; flex-direction: column; gap: 13px;
  flex: 1; min-height: 0; overflow: hidden;
}
.eyebrow {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); flex-shrink: 0;
}
.cat {
  color: var(--amber);
  display: flex; align-items: center; gap: 6px;
}
.cat::before {
  content: "";
  width: 5px; height: 5px;
  background: var(--amber); border-radius: 1px; flex-shrink: 0;
}
.impact {
  display: flex; gap: 3px; margin-left: auto; align-items: center;
}
.impact .blk {
  width: 4px; height: 11px;
  border-radius: 1px; background: var(--hairline-2);
}
.impact .blk.on { background: var(--amber); }
.read { color: var(--faint); }

.title {
  font-family: var(--display);
  font-weight: 700; font-size: 25px;
  line-height: 1.12; letter-spacing: -.02em;
  flex-shrink: 0;
}
.dek {
  color: var(--muted); font-size: 14.5px; line-height: 1.5;
  overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
}
.tape {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--hairline);
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center;
  flex-shrink: 0;
}
.ent {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 5px;
  padding: 3px 7px;
}
.src {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--faint); margin-left: auto; letter-spacing: .04em;
}

/* ── Swipe stamps ───────────────────────────────────── */
.stamp {
  position: absolute; top: 24px;
  font-family: var(--mono); font-weight: 600;
  font-size: 20px; letter-spacing: .12em;
  padding: 7px 14px; border-radius: 8px; border: 2.5px solid;
  opacity: 0; pointer-events: none; z-index: 5;
}
.stamp.track { right: 20px; color: var(--gain); border-color: var(--gain); transform: rotate(12deg); }
.stamp.pass  { left:  20px; color: var(--loss); border-color: var(--loss); transform: rotate(-12deg); }

.openhint {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 34px; height: 4px; border-radius: 3px;
  background: var(--hairline-2); opacity: 0; transition: opacity .2s;
  z-index: 5;
}
.card.top .openhint { opacity: 1; }

/* ── Controls ───────────────────────────────────────── */
.controls {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; padding-top: 16px; flex-shrink: 0;
}
.btn {
  border: 1px solid var(--hairline); background: var(--surface);
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s, background .15s, color .15s;
  color: var(--ink); flex: none;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.94); }
.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.btn svg { width: 22px; height: 22px; }

.btn-pass  { width: 56px; height: 56px; }
.btn-track { width: 56px; height: 56px; }
.btn-open  { width: 46px; height: 46px; }
.btn-open svg { width: 18px; height: 18px; }

.btn-pass:hover  { border-color: var(--loss); background: rgba(204,40,64,.07);  color: var(--loss); }
.btn-track:hover { border-color: var(--gain); background: rgba(10,138,69,.07);  color: var(--gain); }
.btn-open:hover  { border-color: var(--amber);background: rgba(196,126,0,.07);  color: var(--amber); }

.hint {
  text-align: center;
  font-family: var(--mono); font-size: 10.5px;
  color: var(--faint); letter-spacing: .06em;
  margin-top: 10px; flex-shrink: 0;
}

/* ── Progress ───────────────────────────────────────── */
.progress {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 11px;
  color: var(--faint); letter-spacing: .08em;
  white-space: nowrap;
}

/* ── Read sheet ─────────────────────────────────────── */
.sheet {
  position: absolute; inset: 0;
  background: var(--surface); border-radius: 22px;
  z-index: 50;
  transform: translateY(101%);
  transition: transform .34s cubic-bezier(.32,.72,0,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet.open { transform: translateY(0); }

.sheet-head {
  padding: 16px 20px; border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.sheet-cat {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--amber);
}
.sheet-close {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-family: var(--mono); font-size: 12px;
  display: flex; align-items: center; gap: 6px; padding: 0;
}
.sheet-close:hover { color: var(--ink); }
.sheet-close:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 3px; }

.sheet-body {
  padding: 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; flex: 1;
}
.sheet-body h2 {
  font-family: var(--display);
  font-weight: 700; font-size: 24px;
  line-height: 1.15; letter-spacing: -.02em;
}
.sheet-body p { color: var(--muted); font-size: 15px; line-height: 1.62; }
.sheet-body p strong { color: var(--ink); font-weight: 600; }
.ticker-line {
  font-family: var(--mono); font-size: 11px;
  color: var(--faint); letter-spacing: .06em;
}
.sheet-ents { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }

/* ── End state ──────────────────────────────────────── */
.end {
  position: absolute; inset: 0; z-index: 20;
  background: var(--surface);
  border-radius: 22px;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 30px;
}
.end.show { display: flex; }

.end .big {
  font-family: var(--display); font-weight: 800;
  font-size: 54px; color: var(--amber);
  line-height: 1; letter-spacing: -.03em;
}
.end h2 {
  font-family: var(--display); font-weight: 700;
  font-size: 23px; letter-spacing: -.02em;
}
.end p { color: var(--muted); font-size: 14px; max-width: 280px; line-height: 1.55; }

.end .list {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  text-align: left; width: 100%; max-width: 300px;
  display: flex; flex-direction: column; gap: 7px; margin-top: 6px;
}
.end .list .row {
  display: flex; gap: 9px; align-items: baseline;
  padding-bottom: 7px; border-bottom: 1px solid var(--hairline);
}
.end .list .row .n { color: var(--gain); }

.restart {
  margin-top: 8px;
  font-family: var(--mono); font-size: 12px;
  color: #fff; background: var(--amber);
  border: none; border-radius: 999px;
  padding: 11px 22px; cursor: pointer;
  letter-spacing: .04em; font-weight: 600;
}
.restart:hover { filter: brightness(1.08); }
.restart:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ── No-data placeholder ────────────────────────────── */
.no-data {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 30px;
}
.no-data p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.no-data code {
  font-family: var(--mono); font-size: 12px;
  color: var(--faint); background: var(--surface-2);
  padding: 8px 14px; border-radius: 8px;
}

/* ── A11y ───────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Responsive ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .card, .sheet { transition: none !important; }
}
@media (max-height: 680px) {
  .title    { font-size: 22px; }
  .card-img { height: 130px; }
}
