/* Tokenio — Relative Market Token Engine · design system
   Minimal · premium · financial · mathematical · calm · slightly futuristic.
   Brand: cream field + navy ink (matches tokenio.io canonical brand). No CDN. */

:root {
  /* surfaces */
  --plane:      #FBF7EE;   /* cream page plane (brand) */
  --surface-1:  #FFFDF8;   /* card surface */
  --surface-2:  #F4EFE3;   /* recessed / hover wash */
  /* ink */
  --ink:        #122234;   /* navy primary (brand) */
  --ink-2:      #47576A;   /* secondary */
  --muted:      #8A94A0;   /* labels / axes */
  --hair:       #E7E0D0;   /* hairline / gridline */
  --hair-2:     #D9D1BF;
  /* series (validated) */
  --input:      #122234;   /* Input line — near-neutral navy */
  --token:      #2A78D6;   /* Token line — palette slot-1 blue */
  --token-soft: rgba(42,120,214,.12);
  /* signal */
  --good:       #0B7A43;
  --warn:       #B4791A;
  --crit:       #C0392B;
  --accent:     #2A78D6;
  --accent-ink: #1B4F91;
  /* geometry */
  --r:   14px;
  --r-s: 10px;
  --maxw: 980px;
  --shadow: 0 1px 2px rgba(18,34,52,.04), 0 8px 30px rgba(18,34,52,.06);
  --shadow-lg: 0 2px 6px rgba(18,34,52,.06), 0 20px 60px rgba(18,34,52,.10);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}
button { font-family: inherit; cursor: pointer; }
h1,h2,h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
.tabular { font-variant-numeric: tabular-nums; }

.stage { min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ===================== HOME / SEARCH ===================== */
#home { align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.home-wrap { width: 100%; max-width: 720px; margin: auto; }

.brand { text-align: center; margin-bottom: 34px; }
.wordmark {
  display: inline-flex; align-items: center; gap: 12px;
  font-weight: 700; font-size: 22px; letter-spacing: 0.14em;
}
.wordmark .mark { display: block; }
.mk-ring { fill: none; stroke: var(--ink); stroke-width: 2; opacity: .9; }
.mk-t { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.lede { font-size: clamp(30px, 6vw, 46px); font-weight: 600; letter-spacing: -0.03em; margin: 26px 0 8px; }
.sub { color: var(--ink-2); font-size: 16px; margin: 0; }

.searchbox {
  background: var(--surface-1); border: 1px solid var(--hair);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 14px 12px;
  transition: box-shadow .25s ease, border-color .25s ease;
}
.searchbox:focus-within { box-shadow: var(--shadow-lg); border-color: var(--hair-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:not(:empty) { margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--hair-2);
  border-radius: 999px; padding: 6px 8px 6px 12px; font-weight: 600; font-size: 14px;
  animation: pop .18s ease;
}
.chip .tk { letter-spacing: .02em; }
.chip .nm { color: var(--ink-2); font-weight: 500; font-size: 12.5px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  border: none; background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
}
.chip button:hover { background: rgba(18,34,52,.08); color: var(--ink); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.input-row { display: flex; align-items: center; gap: 10px; position: relative; }
.input-row .ic { color: var(--muted); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex: none; }
#q {
  flex: 1; border: none; outline: none; background: transparent; color: var(--ink);
  font-size: 18px; padding: 10px 4px; letter-spacing: -0.01em;
}
#q::placeholder { color: var(--muted); }

.suggest {
  position: absolute; top: calc(100% + 8px); left: -6px; right: -6px; z-index: 30;
  background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r-s);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 320px; overflow-y: auto;
}
.sug {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--hair);
}
.sug:last-child { border-bottom: none; }
.sug:hover, .sug.active { background: var(--surface-2); }
.sug .stk { font-weight: 700; min-width: 62px; letter-spacing: .02em; }
.sug .snm { color: var(--ink-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug .ssec { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }

.actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--hair); }
.hint { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: 10px;
  font-weight: 600; font-size: 15px; border: 1px solid transparent; padding: 10px 16px;
  transition: transform .12s ease, background .18s ease, box-shadow .18s ease, opacity .18s;
}
.btn svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--ink); color: #fff; box-shadow: 0 1px 2px rgba(18,34,52,.2); }
.btn.primary:not(:disabled):hover { background: #0c1a2a; transform: translateY(-1px); }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--hair-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }

.examples { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.examples > span { color: var(--muted); font-size: 13px; }
.ex { border: 1px solid var(--hair-2); background: var(--surface-1); color: var(--ink-2); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.ex:hover { border-color: var(--accent); color: var(--accent-ink); }

.foot { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 12px; display: flex; gap: 10px; justify-content: center; align-items: center; padding: 0 16px; }
.foot .dot { opacity: .5; }

/* ===================== GENERATING ===================== */
#generating { align-items: center; justify-content: center; padding: 24px; }
.gen-wrap { width: 100%; max-width: 720px; display: flex; flex-direction: column; align-items: center; }
.relviz { width: min(560px, 92vw); height: min(400px, 60vh); position: relative; }
.gen-status { text-align: center; margin-top: 8px; width: 100%; }
.gen-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; min-height: 28px; }
.gen-steps { list-style: none; margin: 16px auto 0; padding: 0; max-width: 380px; text-align: left; }
.gen-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 4px 0; opacity: .5; transition: opacity .3s, color .3s; }
.gen-steps li.done { color: var(--ink-2); opacity: 1; }
.gen-steps li.active { color: var(--ink); opacity: 1; }
.gen-steps li .tick { width: 16px; height: 16px; flex: none; }
.gen-steps li .tick svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; }

/* ===================== RESULT ===================== */
#result { padding: 28px 20px 80px; }
.result-wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; }
.back { margin-bottom: 18px; }

.tok-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.tok-id { display: flex; flex-direction: column; gap: 4px; }
.tok-symbol { font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .08em; color: var(--accent-ink); }
.tok-name { font-size: clamp(24px, 4vw, 34px); font-weight: 600; letter-spacing: -0.025em; }
.match { text-align: right; }
.match-num { font-size: clamp(30px, 6vw, 46px); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.match-num .pct { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .06em; margin-left: 4px; }
.match-sub { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-top: 6px; }
.match-sub.ok { color: var(--good); }
.match-sub.warn { color: var(--warn); }

.tok-summary { color: var(--ink-2); font-size: 15.5px; max-width: 70ch; margin: 16px 0 24px; }

.card { background: var(--surface-1); border: 1px solid var(--hair); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.card-head h2 .vs { color: var(--muted); font-weight: 400; margin: 0 2px; }

.periods { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.periods button { border: none; background: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 6px; }
.periods button.on { background: var(--surface-1); color: var(--ink); box-shadow: 0 1px 2px rgba(18,34,52,.08); }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 20px; margin-top: 10px; flex-wrap: wrap; }
.leg { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.leg .swatch { width: 14px; height: 3px; border-radius: 2px; }
.leg .val { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.chart-foot { margin-top: 10px; color: var(--muted); font-size: 12px; }

.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* composition */
.comp-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--hair); }
.comp-row:last-child { border-bottom: none; }
.comp-tk { display: flex; flex-direction: column; }
.comp-tk .t { font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.comp-tk .in { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--accent-ink); text-transform: uppercase; }
.comp-bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; }
.comp-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--token); border-radius: 999px; display: block; }
.comp-bar.input > i { background: var(--ink); }
.comp-w { font-family: var(--mono); font-weight: 600; font-size: 14px; min-width: 42px; text-align: right; }
.comp-sub { grid-column: 2 / 4; color: var(--muted); font-size: 11.5px; margin-top: -4px; }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--hair); border-radius: var(--r-s); overflow: hidden; }
.stat { background: var(--surface-1); padding: 14px; }
.stat .k { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.stat .v { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.stat .sub2 { color: var(--ink-2); font-size: 11.5px; margin-top: 2px; }

/* why */
.why { display: grid; gap: 14px; }
.why-row { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: start; }
.why-tk { font-weight: 700; font-size: 14px; }
.why-tk .wsim { display: block; font-family: var(--mono); font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.why-tx { color: var(--ink-2); font-size: 14px; }
.why-tx b { color: var(--ink); font-weight: 600; }

.disclaimer { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 22px; max-width: 80ch; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.badge.static { background: var(--surface-2); color: var(--ink-2); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 100; animation: pop .2s ease; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
