/* ===============================================================
   Base — reset, typography and the primitives every screen leans on.

   Card shells   .card  .card--lime .card--paper .card--white
                 .card--deep (the one inversion) .card--olive .card--sphere
   Controls      .round .chip .add .send .go .select .input .kbd
   Marks         .cb (chain disc) .cb-stack  .av (initials avatar)
                 .deep-circle .track .dot
   Type          .ui-num .ui-label .ui-eyebrow .h-lime .h-paper .h-white
   Status        .ui-pill[data-tone]  .flash-up/.flash-down
   Overlays      .overlay .modal .toasts
   =============================================================== */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11" 1, "ss01" 1;
  overflow-x: hidden;
  transition: background var(--t-base) var(--e-smooth), color var(--t-base) var(--e-smooth);
}

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
u { text-decoration: none; }

/* A solid ink outline carries the focus state; the lime ring is decoration. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: var(--ring); }
.card--lime :focus-visible, .card--sphere :focus-visible { outline-color: var(--accent-contrast); }
.card--deep :focus-visible { outline-color: var(--invert-ink); }
.select--native:has(select:focus-visible), .asset:has(select:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
::selection { background: var(--accent-300); color: var(--accent-contrast); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
sub { font-size: .6em; vertical-align: -.2em; line-height: 0; }

/* ---------- type ---------- */

/* Figures line up in columns and never jitter while counting up. */
.ui-num {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: -0.03em;
}

.ui-label { font-size: 12px; font-weight: 500; letter-spacing: 0.02em; color: var(--ink-2); }
.ui-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }

/* Display headings, one per card archetype. */
.h-lime { font-family: var(--font-display); font-size: 42px; font-weight: 600; line-height: 1.02; letter-spacing: -.042em; }
.h-paper { font-family: var(--font-display); font-size: 36px; font-weight: 600; line-height: 1.08; letter-spacing: -.04em; }
.h-white { font-family: var(--font-display); font-size: 33px; font-weight: 600; line-height: 1.08; letter-spacing: -.04em; }
.subline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; font-size: 13px; color: var(--ink-2); }
.subline b { font-weight: 600; color: var(--ink); }
.subline svg { width: 16px; height: 16px; }

.mono { font-family: var(--font-mono); font-size: 12px; font-weight: 500; font-feature-settings: "zero" 1; letter-spacing: 0; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.up { color: var(--ok-fg); }
.down { color: var(--bad-fg); }

/* ---------- card shells ---------- */

.card {
  position: relative;
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  transition: transform var(--t-base) var(--e-out), box-shadow var(--t-base) var(--e-smooth), background var(--t-base) var(--e-smooth);
}
.card.lift:hover { transform: translateY(-3px); box-shadow: var(--sh-hover); }

.card--paper { background: var(--paper); }

.card--lime {
  background: var(--lime-card);
  color: var(--accent-contrast);
  overflow: hidden;
}
.card--lime::after {
  content: ""; position: absolute; right: -80px; top: -90px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .5), transparent 68%);
  pointer-events: none;
}
.card--lime > * { position: relative; z-index: 1; }
.card--lime .sub, .card--lime .ui-label, .card--lime .subline, .card--lime .faint { color: var(--accent-contrast-2); }
.card--lime .subline b { color: var(--accent-contrast); }

/* the one inversion per screen */
.card--deep { background: var(--invert-bg); color: var(--invert-ink); }
.card--deep .ui-label, .card--deep .muted, .card--deep .faint { color: var(--invert-ink-2); }

.card--olive { background: var(--olive); color: var(--olive-ink); }
.card--olive .ui-label, .card--olive .muted { color: var(--olive-ink-2); }

.card--sphere { background: var(--lime-tile); color: var(--accent-contrast); overflow: hidden; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ---------- controls ---------- */

.round {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); color: var(--ink);
  transition: transform var(--t-fast) var(--e-out), background var(--t-base) var(--e-smooth);
}
.round svg { width: 18px; height: 18px; }
.round:hover { transform: scale(1.08); }
.round--deep { background: var(--invert-bg); color: var(--invert-ink); }
.round--soft { background: var(--surface-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 36px; padding: 0 15px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: border-color var(--t-base) var(--e-smooth), background var(--t-base) var(--e-smooth), color var(--t-base) var(--e-smooth);
}
.chip svg { width: 13px; height: 13px; flex: none; }
.chip:hover { border-color: var(--mark); color: var(--ink); }
.chip.on, .chip[aria-pressed="true"] { background: var(--invert-bg); color: var(--invert-ink); border-color: transparent; }
.chip .cb { --size: 18px; }
.chip--eff { height: 30px; padding: 0 12px; border-color: var(--invert-line); background: transparent; color: var(--invert-ink-2); font-size: 11.5px; }
.chip--eff:hover { border-color: var(--invert-ink-2); color: var(--invert-ink); }
.chip--ghost { background: transparent; border-color: var(--accent-line); color: var(--accent-contrast); }
.chip--ghost:hover { background: rgba(255, 255, 255, .5); border-color: var(--accent-line); color: var(--accent-contrast); }

.add {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none;
  height: 44px; padding: 0 20px; border-radius: var(--r-full);
  background: var(--invert-bg); color: var(--invert-ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: transform var(--t-fast) var(--e-out), background var(--t-base) var(--e-smooth), color var(--t-base) var(--e-smooth);
}
.add svg { width: 15px; height: 15px; }
.add:hover { transform: translateY(-2px); }
.add--lime { background: var(--accent-300); color: var(--accent-contrast); }
.add--white { background: var(--surface); color: var(--ink); }
.add--soft { background: var(--olive-soft); color: inherit; }
.add[disabled], .add[aria-disabled="true"] { opacity: .55; pointer-events: none; }

.select {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 18px;
  border: 1px solid var(--accent-line); border-radius: var(--r-full);
  background: rgba(255, 255, 255, .5); color: var(--accent-contrast);
  font-size: 13px; font-weight: 500; text-align: left;
  transition: background var(--t-base) var(--e-smooth), border-color var(--t-base) var(--e-smooth);
}
.select > span:not(.cb):not(.av) { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select .cb, .select .av { flex: none; }
.select svg { flex: 0 0 auto; width: 16px; height: 16px; }
.select:hover { background: rgba(255, 255, 255, .82); }
.select--surface { background: var(--surface); border-color: var(--line); color: var(--ink); }
.select--surface:hover { background: var(--surface); border-color: var(--mark); }
.select select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.select--native { position: relative; }

.send {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--invert-bg); color: var(--accent-300);
  transition: transform var(--t-base) var(--e-spring), opacity var(--t-base) var(--e-smooth);
}
.send svg { width: 19px; height: 19px; }
.send:hover { transform: translateX(3px) rotate(-8deg); }
:root[data-theme="dark"] .send { color: var(--accent-600); }

.go {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); color: var(--ink);
  transition: transform var(--t-base) var(--e-spring);
}
.go svg { width: 17px; height: 17px; }
a:hover > .go, .card:hover > .go { transform: rotate(45deg); }

.input {
  width: 100%; height: 52px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 500; outline: none;
  transition: border-color var(--t-base) var(--e-smooth), box-shadow var(--t-base) var(--e-smooth);
}
.input::placeholder { color: var(--ink-3); }
.input:focus { box-shadow: var(--ring); }
.input--area { height: auto; min-height: 84px; padding: 14px 18px; border-radius: var(--r-lg); resize: vertical; line-height: 1.45; }

.kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: var(--r-sm); border: 1px solid var(--line); border-bottom-width: 2px;
  font: 500 11px/1 var(--font-mono); color: var(--ink-3); background: var(--surface);
}

/* ---------- marks ---------- */

/* Chain disc: the chain's logo over a coloured letter disc (the fallback while it loads). */
.cb {
  --size: 32px;
  position: relative; overflow: hidden;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--c); color: var(--cf, #fff);
  font-family: var(--font-display); font-size: calc(var(--size) * .42); font-weight: 700; line-height: 1;
}
.cb img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.cb--pad { box-shadow: inset 0 0 0 1px var(--line); }
.cb--pad img { inset: 22%; width: 56%; height: 56%; border-radius: 14%; object-fit: contain; }

/* Palette swatch: accent over ground, split on the diagonal. */
.swatch { --size: 18px; display: inline-block; flex: none; width: var(--size); height: var(--size); border-radius: 50%; background: linear-gradient(135deg, var(--a, var(--accent-300)) 50%, var(--g, var(--bg)) 50%); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.cb-stack { display: inline-flex; align-items: center; }
.cb-stack .cb { box-shadow: 0 0 0 2px var(--ring-c, var(--surface)); }
.cb-stack .cb + .cb { margin-left: -8px; }
.cb-stack .cb-more {
  --size: 32px;
  display: inline-grid; place-items: center; width: var(--size); height: var(--size); margin-left: -8px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2); font: 600 calc(var(--size) * .36)/1 var(--font-display);
  box-shadow: 0 0 0 2px var(--ring-c, var(--surface));
}
.cb-any { --size: 18px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; background: conic-gradient(var(--c-eth), var(--c-base), var(--c-rh), var(--c-bnb), var(--c-eth)); }

/* Initials avatar, four template colours. */
.av {
  --size: 32px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  font-family: var(--font-display); font-size: max(9px, calc(var(--size) * .3)); font-weight: 700; color: #fff; text-decoration: none;
}
.av[data-i="0"] { background: var(--av-0); }
.av[data-i="1"] { background: var(--av-1); }
.av[data-i="2"] { background: var(--av-2); }
.av[data-i="3"] { background: var(--av-3); }
.av-stack { display: inline-flex; }
.av-stack .av { border: 2px solid var(--ring-c, var(--surface)); }
.av-stack .av + .av { margin-left: -8px; }

.art { display: block; flex: none; overflow: hidden; border-radius: 50%; background: var(--surface-3); }
.art svg, .art img { width: 100%; height: 100%; object-fit: cover; }

.deep-circle {
  display: grid; place-items: center; flex: none;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--deep); color: var(--deep-ink);
  font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.03em;
}

.track { display: block; height: 7px; border-radius: var(--r-full); background: rgba(255, 255, 255, .62); overflow: hidden; }
.track i { display: block; width: 0; height: 100%; border-radius: var(--r-full); background: var(--accent-contrast); transition: width var(--t-draw) var(--e-out); }
.track[data-in="true"] i { width: var(--w); }
.track--soft { background: var(--surface-2); }
.track--soft i { background: var(--accent-300); }
.track--deep { background: var(--invert-soft); }
.track--deep i { background: var(--wave); }

/* Live dot: deep on white/paper (like the template's paging dot), lime only on the inversion and toasts. */
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; color: var(--deep); flex: none; }
.card--deep .dot, .toast .dot { color: var(--wave); }
.dot.live { animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklab, currentColor 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- status ---------- */

.ui-pill {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 3px 8px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap;
}
.ui-pill[data-tone="up"] { background: var(--ok-bg); color: var(--ok-fg); }
.ui-pill[data-tone="down"] { background: var(--bad-bg); color: var(--bad-fg); }
.ui-pill[data-tone="flat"] { background: var(--surface-2); color: var(--ink-2); }
.ui-pill[data-tone="accent"] { background: var(--accent-300); color: var(--accent-contrast); }
.ui-pill[data-tone="ink"] { background: var(--deep); color: var(--accent-300); }
.ui-pill[data-tone="dim"] { background: rgba(27, 36, 8, .14); color: var(--accent-contrast); }
.ui-pill[data-tone="warn"] { background: var(--warn-bg); color: var(--warn-fg); }
.ui-pill[data-tone="info"] { background: var(--info-bg); color: var(--info-fg); }
.ui-pill[data-tone="white"] { background: var(--surface); color: var(--deep); }
.ui-pill .dot { width: 6px; height: 6px; color: inherit; }
:root[data-theme="dark"] .ui-pill[data-tone="ink"] { color: var(--accent-700); }

.flash-up { animation: flashUp .9s var(--e-out); }
.flash-down { animation: flashDown .9s var(--e-out); }
@keyframes flashUp { 0% { color: var(--ok-fg); } 60% { color: var(--ok-fg); } }
@keyframes flashDown { 0% { color: var(--bad-fg); } 60% { color: var(--bad-fg); } }
.flash-lime { animation: flashLime .5s var(--e-out); }
@keyframes flashLime { 0% { filter: brightness(1.08); } }

/* Entrance. Opt in with data-in, flipped by the in-view observer. */
.ui-rise {
  opacity: 0; transform: translateY(14px);
  transition: opacity var(--t-slow) var(--e-out), transform var(--t-slow) var(--e-out);
  transition-delay: var(--delay, 0ms);
}
.ui-rise[data-in="true"] { opacity: 1; transform: none; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(20, 23, 15, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 26px; border-radius: var(--r-card); background: var(--surface); color: var(--ink); box-shadow: var(--sh-4);
  animation: popIn .3s var(--e-out);
}
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 10px; }
.modal-head .round { background: var(--surface-2); }
.modal p.lead { font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }
.modal-foot { margin-top: 16px; text-align: center; }

.toasts {
  position: fixed; left: 16px; bottom: 18px; z-index: 120;
  display: grid; gap: 8px; justify-items: start; pointer-events: none; max-width: min(520px, calc(100% - 32px));
}
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 18px 0 14px; border-radius: var(--r-full);
  background: var(--invert-bg); color: var(--invert-ink);
  font-size: 13px; font-weight: 500; box-shadow: var(--sh-3);
  animation: toastIn .24s var(--e-out);
}
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
.toast .art { width: 20px; height: 20px; }

.view-enter { animation: viewIn .45s var(--e-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
