/* Memory module UI. Composed from the tokens in tokens.css (spec §6–8). */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { border: none; background: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-12) + var(--sp-8));
  overflow-y: auto;
}
.hidden { display: none !important; }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px;
  display: flex; align-items: center; justify-content: space-around;
  gap: var(--sp-4);
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--hairline);
  z-index: 20;
}
/* chrome disappears during review and editing (spec §6.1) */
body[data-route="review"] .tabbar,
body[data-route="edit"] .tabbar,
body[data-route="summary"] .tabbar { display: none; }
body[data-route="review"] .view,
body[data-route="summary"] .view { padding-bottom: var(--sp-4); }

.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-2) 0;
  color: var(--text-secondary);
  transition: color var(--t-micro);
}
.tab:active { color: var(--accent); }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: var(--fs-caption); font-weight: 600; }

.fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent);
  color: #fff; font-size: 28px; font-weight: 300;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform var(--t-micro);
  flex: none;
}
.fab:active { transform: scale(0.94); }

/* ---------- app bar ---------- */

.appbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
  padding-top: var(--sp-2);
}
.appbar h1 { font-size: var(--fs-display); font-weight: 700; letter-spacing: -0.4px; }
.appbar.compact h1 { font-size: var(--fs-title2); }
.appbar-title {
  flex: 1; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn-placeholder { width: 40px; flex: none; }

.hud { display: flex; gap: var(--sp-2); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: var(--fs-callout); font-weight: 600;
}
.pill .flame { color: var(--streak-flame); }
.pill .gold { color: var(--xp-gold); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 20px; color: var(--text-secondary);
  transition: background var(--t-micro);
}
.icon-btn:hover { background: var(--surface-alt); }
.icon-btn.small { width: 34px; height: 34px; font-size: 17px; }

.link-btn {
  color: var(--accent); font-size: var(--fs-callout); font-weight: 600;
  padding: var(--sp-1) var(--sp-2);
}

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

.btn-primary, .btn-secondary {
  height: 52px; border-radius: var(--r-md);
  font-size: var(--fs-headline); font-weight: 600;
  width: 100%;
  transition: transform var(--t-micro), opacity var(--t-micro);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary.destructive { background: var(--danger); }
.btn-secondary {
  background: var(--surface-alt);
  color: var(--text-primary);
  border: 1px solid var(--hairline);
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: var(--fs-callout); font-weight: 600;
  white-space: nowrap;
  transition: background var(--t-micro), border-color var(--t-micro);
}
.btn-chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- surfaces & sections ---------- */

.card-surface {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-4);
}

.today-hero { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-6) var(--sp-4); }
.today-counts { font-size: var(--fs-title2); font-weight: 600; }
.today-counts .muted { color: var(--text-secondary); font-size: var(--fs-callout); font-weight: 400; }

.stat-strip {
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  color: var(--text-secondary); font-size: var(--fs-callout);
}
.stat-strip b { color: var(--text-primary); font-size: var(--fs-headline); }

.section-label {
  font-size: var(--fs-caption); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-secondary);
}
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-2);
}
section > .section-label { display: block; margin-bottom: var(--sp-2); }

.rows { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ---------- deck & card rows ---------- */

.deck-row, .card-row {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  width: 100%;
}
.deck-row-main, .card-row-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) 0;
  text-align: left;
}
.deck-row > .emoji, .deck-row-main .emoji { font-size: 26px; flex: none; }
.type-icon { font-size: 20px; flex: none; width: 24px; text-align: center; }

.deck-row-text, .card-row-text {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.deck-row .name, .card-row .title {
  font-weight: 600; font-size: var(--fs-headline);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.deck-row .meta, .card-row .meta {
  color: var(--text-secondary); font-size: var(--fs-footnote);
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-row.held { opacity: 0.55; }

.due-badge {
  flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: var(--fs-footnote);
  border-radius: 999px; padding: 4px 10px;
}

.chip {
  flex: none;
  border-radius: 999px; padding: 2px 8px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.chip.new { background: var(--accent-soft); color: var(--accent); }
.chip.learning { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.chip.review { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.chip.muted { background: var(--surface-alt); color: var(--text-secondary); }

.deck-chip {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 10px var(--sp-3);
  font-weight: 600; font-size: var(--fs-callout);
}
.deck-chip-caret { color: var(--text-secondary); }

/* ---------- heatmap ---------- */

.heatmap { display: flex; gap: 6px; }
.heatmap .cell {
  flex: 1; height: 38px; border-radius: 8px;
  background: var(--surface-alt);
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 10px; color: var(--text-secondary);
  padding-bottom: 3px;
  position: relative; overflow: hidden;
}
.heatmap .cell .fill {
  position: absolute; inset: auto 0 0 0;
  background: var(--accent); opacity: 0.85;
  border-radius: 8px 8px 0 0;
}
.heatmap .cell span { position: relative; }

/* ---------- empty state ---------- */

.empty-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3); text-align: center;
  padding: var(--sp-8) var(--sp-4);
}
.empty-art { font-size: 56px; }
.empty-state h2 { font-size: var(--fs-title2); font-weight: 700; }
.empty-state p { color: var(--text-secondary); font-size: var(--fs-callout); }
.empty-state .btn-primary { margin-top: var(--sp-2); max-width: 280px; }

/* ---------- review ---------- */

.review-top { display: flex; align-items: center; gap: var(--sp-3); }
.progress-track {
  flex: 1; height: 4px; border-radius: 2px;
  background: var(--surface-alt); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width var(--t-standard);
}
.progress-label {
  font-size: var(--fs-footnote); color: var(--text-secondary);
  min-width: 48px; text-align: right;
}

.card-stage {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  perspective: 1200px;
  min-height: 300px;
}
.flip-card {
  width: 100%; min-height: 300px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--t-flip);
  cursor: pointer;
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: var(--sp-6);
  text-align: center;
  overflow: auto;
}
.flip-face.back { transform: rotateY(180deg); }
.face-label {
  font-size: var(--fs-caption); text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-secondary); font-weight: 500;
}

/* card content auto-scales by length (spec §8) */
.card-text { font-size: 24px; font-weight: 600; overflow-wrap: anywhere; }
.card-text.long { font-size: 20px; font-weight: 500; }
.card-text.longer { font-size: var(--fs-body); font-weight: 400; }
.card-text p + p { margin-top: var(--sp-3); }
.card-text ul { text-align: left; padding-left: 1.2em; }
.card-text mark { background: color-mix(in srgb, var(--xp-gold) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 3px; }
.card-text code, .preview-body code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--surface-alt); border-radius: 4px; padding: 1px 5px;
}
.code-block {
  font-family: var(--font-mono);
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  text-align: left;
  font-size: var(--fs-footnote);
  font-weight: 400;
  line-height: 1.5;
  overflow-x: auto;
  max-width: 100%;
}
.cloze-blank {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; padding: 0 6px; font-weight: 700;
}
.cloze-answer {
  background: color-mix(in srgb, var(--success) 22%, transparent);
  color: var(--success);
  border-radius: 4px; padding: 0 6px; font-weight: 700;
}

.action-area { min-height: 76px; display: flex; align-items: center; }
.reveal-hint {
  width: 100%; text-align: center; cursor: pointer;
  color: var(--text-secondary); font-size: var(--fs-callout);
  padding: var(--sp-3);
}

.grade-bar {
  width: 100%;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2);
  animation: rise var(--t-standard) both;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.grade-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-3) 0 var(--sp-2);
  border-radius: var(--r-md);
  font-weight: 700; font-size: var(--fs-callout);
  color: #fff;
  transition: transform var(--t-micro);
}
.grade-btn:active { transform: scale(0.95); }
.grade-btn .ivl { font-size: var(--fs-footnote); font-weight: 500; opacity: 0.85; }
.grade-btn.suggested { box-shadow: 0 0 0 3px var(--text-primary); }
.grade-again { background: var(--danger); }
.grade-hard { background: var(--warn); }
.grade-good { background: var(--good); }
.grade-easy { background: var(--success); }

.mcq-options { width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); }
.mcq-option {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  text-align: left;
  font-size: var(--fs-callout);
  transition: border-color var(--t-micro), background var(--t-micro);
}
.mcq-option:hover { border-color: var(--accent); }
.mcq-key {
  flex: none;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--surface-alt); color: var(--text-secondary);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: var(--fs-footnote);
}
.mcq-verdict {
  font-size: var(--fs-callout); font-weight: 600;
  border-radius: var(--r-sm); padding: 6px 12px;
}
.mcq-verdict.right { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.mcq-verdict.wrong { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }

.kbd-hint {
  text-align: center; color: var(--text-secondary);
  font-size: var(--fs-caption);
}
.kbd-hint kbd {
  font-family: var(--font-mono);
  background: var(--surface-alt);
  border-radius: 4px; padding: 1px 5px;
}
@media (pointer: coarse) { .kbd-hint { display: none; } }

/* ---------- summary ---------- */

.screen-summary {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--sp-6); text-align: center;
}
.screen-summary h2 { font-size: var(--fs-title1); font-weight: 700; }
.stats-row { display: flex; gap: var(--sp-3); width: 100%; }
.stat-tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.stat-tile .value { font-size: var(--fs-title2); font-weight: 700; }
.stat-tile .value.gold { color: var(--xp-gold); }
.stat-tile .value.flame { color: var(--streak-flame); }
.stat-tile .value.accent { color: var(--accent); }
.stat-tile .label { font-size: var(--fs-footnote); color: var(--text-secondary); }

/* ---------- editor ---------- */

/* Wraps instead of scrolling sideways: the rail used to hide its scrollbar,
   so the fifth type ("Kod") sat past the right edge with nothing to suggest
   it was there. Every card type has to stay reachable at any width. */
.type-rail {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}

.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: var(--fs-footnote); font-weight: 600;
  display: flex; align-items: baseline; gap: 6px;
}
.field-hint { color: var(--text-secondary); font-weight: 400; font-size: var(--fs-caption); }

.input {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 12px var(--sp-3);
  width: 100%;
  transition: border-color var(--t-micro);
}
.input:focus { border-color: var(--accent); outline: none; }
.input.area { resize: vertical; min-height: 60px; line-height: 1.4; }
.input.mono { font-family: var(--font-mono); font-size: var(--fs-callout); }
.emoji-input { max-width: 96px; text-align: center; font-size: var(--fs-title2); }

.inline-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.options { display: flex; flex-direction: column; gap: var(--sp-2); }
.option-row { display: flex; align-items: center; gap: var(--sp-2); }
.option-row .option-radio { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }

.preview { padding: var(--sp-3); }
.preview-empty { color: var(--text-secondary); font-size: var(--fs-callout); text-align: center; padding: var(--sp-4); }
.preview-note {
  font-size: var(--fs-footnote); color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}
.preview-pair { display: flex; flex-direction: column; gap: var(--sp-3); }
.preview-face {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
}
.preview-body { font-size: var(--fs-callout); overflow-wrap: anywhere; }
.preview-body p + p { margin-top: var(--sp-2); }
.preview-body ul { padding-left: 1.2em; }

.editor-actions { display: flex; gap: var(--sp-3); }

/* ---------- toast ---------- */

.xp-toast {
  position: fixed; left: 50%; bottom: 104px;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none;
  z-index: 40;
  transition: opacity var(--t-standard), transform var(--t-standard);
}
.xp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.xp-toast[data-tone="xp"] { color: var(--xp-gold); }
.xp-toast[data-tone="warn"] { color: var(--warn); }

/* ---------- sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0;
  transition: opacity var(--t-standard);
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--sp-3);
  transform: translateY(100%);
  transition: transform var(--t-standard);
  max-height: 85dvh; overflow-y: auto;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-grabber {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--surface-alt);
  margin: 0 auto var(--sp-2);
  flex: none;
}
.sheet-title { font-size: var(--fs-title2); font-weight: 700; }
.sheet-message { color: var(--text-secondary); font-size: var(--fs-callout); }
.sheet-list { display: flex; flex-direction: column; }
.sheet-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-sm);
  text-align: left;
  font-size: var(--fs-headline);
  transition: background var(--t-micro);
}
.sheet-item:hover { background: var(--surface-alt); }
.sheet-item.danger { color: var(--danger); }
.sheet-item-icon { font-size: 20px; width: 26px; text-align: center; flex: none; }
.sheet-item-label { display: block; font-weight: 600; }
.sheet-item-hint {
  display: block;
  color: var(--text-secondary); font-size: var(--fs-footnote); font-weight: 400;
}
.sheet-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-2); }

/* ---------- confetti ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i {
  position: absolute; top: -12px;
  width: 8px; height: 12px; border-radius: 2px;
  animation: confetti-fall var(--dur, 1800ms) ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.6; }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .grade-bar { animation: none; }
}

/* ---------- account & sync ---------- */

.account-pill { cursor: pointer; position: relative; }

.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-secondary); opacity: 0.5;
}
.sync-dot[data-state="idle"] { background: var(--success); opacity: 1; }
.sync-dot[data-state="syncing"] {
  background: var(--good); opacity: 1;
  animation: sync-pulse 1s ease-in-out infinite;
}
.sync-dot[data-state="error"] { background: var(--danger); opacity: 1; }
@keyframes sync-pulse {
  50% { transform: scale(1.6); opacity: 0.5; }
}
@media (prefers-reduced-motion: reduce) {
  .sync-dot[data-state="syncing"] { animation: none; }
}

.account-box { display: flex; flex-direction: column; gap: var(--sp-4); }
.account-blurb {
  color: var(--text-secondary); font-size: var(--fs-callout); line-height: 1.5;
}
.account-row { display: flex; align-items: center; gap: var(--sp-3); }
.account-avatar {
  font-size: var(--fs-title2);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
}
.account-id { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.account-id .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.account-id .meta { color: var(--text-secondary); font-size: var(--fs-footnote); }
.sync-err { color: var(--danger); }

/* ---------- charts ---------- */

.appbar-actions { display: flex; align-items: center; gap: var(--sp-1); }

.kpi-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3);
}
.stat-tile {
  background: var(--surface); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-card);
}
/* Proportional figures: tabular-nums makes a large value look loose. */
.stat-value { font-size: var(--fs-title2); font-weight: 600; line-height: 1.1; }
.stat-label { font-size: var(--fs-footnote); color: var(--text-secondary); }
.stat-hint { font-size: var(--fs-caption); color: var(--text-secondary); opacity: 0.8; }

.chart-card { display: flex; flex-direction: column; gap: var(--sp-2); }
.chart-controls { display: flex; align-items: center; gap: var(--sp-3); }
.chart-body { padding: var(--sp-4); }
.chart-empty {
  color: var(--text-secondary); font-size: var(--fs-callout);
  text-align: center; padding: var(--sp-6) 0;
}

/* Columns: thin marks, rounded data-end, square baseline, 2px surface gap. */
.col-chart {
  display: flex; align-items: flex-end; gap: 2px;
  height: 132px; padding-top: var(--sp-4);
}
.col {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  position: relative;
}
.col-fill {
  width: 100%; max-width: 24px;
  background: var(--ramp-3);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height var(--t-standard);
}
.col-fill[data-zero="true"] { background: var(--grid); }
.col-value {
  position: absolute; top: -2px;
  font-size: var(--fs-caption); color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.col-label {
  margin-top: 4px; min-height: 12px;
  font-size: var(--fs-caption); color: var(--text-secondary);
  white-space: nowrap;
}
/* The baseline is a solid hairline one step off the surface, never dashed. */
.col-chart { border-bottom: 1px solid var(--grid); }

/* Heatmap: sequential, empty days keep the surface tone so "no study" never
   reads as a low count. */
.heat-wrap { display: flex; flex-direction: column; gap: var(--sp-3); }
.heat-grid {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr);
  gap: 2px; overflow-x: auto; padding-bottom: 2px;
}
.heat-cell {
  width: 100%; aspect-ratio: 1; min-width: 8px;
  border-radius: 2px; background: var(--surface-alt);
}
.heat-cell[data-step="1"] { background: var(--ramp-1); }
.heat-cell[data-step="2"] { background: var(--ramp-2); }
.heat-cell[data-step="3"] { background: var(--ramp-3); }
.heat-cell[data-step="4"] { background: var(--ramp-4); }
.heat-legend {
  display: flex; align-items: center; gap: 3px;
  font-size: var(--fs-caption);
}
.heat-legend .heat-cell { width: 11px; height: 11px; min-width: 11px; flex: none; }

/* Stacked bar: the 2px gap is the separator — no borders on marks. */
.stack-wrap { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack-bar {
  display: flex; gap: 2px; height: 28px;
  border-radius: var(--r-sm); overflow: hidden;
}
.stack-seg {
  display: grid; place-items: center;
  min-width: 2px;
  transition: width var(--t-standard);
}
/* Ink comes from the segment's own --ramp-N-ink token (set inline), because
   the right choice flips between the ramp's light and dark ends. */
.stack-seg-value {
  font-size: var(--fs-caption); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-footnote); color: var(--text-secondary);
}
.legend-item b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.table-wrap { overflow-x: auto; max-height: 320px; overflow-y: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-footnote); }
.data-table th, .data-table td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--hairline);
}
.data-table th { color: var(--text-secondary); font-weight: 600; }
.data-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- segmented control ---------- */

.segmented {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--surface-alt); border-radius: var(--r-sm);
}
.segmented.wide { display: flex; }
.segmented.wide .seg { flex: 1; }
.seg {
  padding: 6px var(--sp-3); border-radius: 8px;
  font-size: var(--fs-footnote); font-weight: 600;
  color: var(--text-secondary); background: transparent;
}
.seg.selected { background: var(--surface); color: var(--text-primary); }

/* ---------- search ---------- */

.search-input { font-size: var(--fs-body); }
.chip-row {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
}
.search-count { font-size: var(--fs-footnote); }
.empty-state.small { padding: var(--sp-8) var(--sp-4); }

/* ---------- settings ---------- */

.setting-group { display: flex; flex-direction: column; gap: var(--sp-4); }
.slider-row { display: flex; align-items: center; gap: var(--sp-4); }
.slider { flex: 1; accent-color: var(--accent); }
.slider-value {
  font-size: var(--fs-title2); font-weight: 600; min-width: 62px; text-align: right;
}
