/* ===========================================================================
   token-diet playground — token economics terminal
   Design system matches k1y0miiii.github.io exactly.
   =========================================================================== */

:root {
  --bg: #0A0B0C;
  --bg-2: #0F1113;
  --surface: #14171A;
  --surface-2: #1A1E22;
  --ink: #F4F6F7;
  --muted: #8A9196;
  --line: rgba(244, 246, 247, .10);
  --line-2: rgba(244, 246, 247, .20);
  --cyan: #34E7FF;        /* THE neon */
  --cyan-dim: #1FAFC4;
  --cyan-glow: rgba(52, 231, 255, .45);
  --warn: #FFC34D;
  --danger: #FF6B6B;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Syne", system-ui, sans-serif;

  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: clip; }
body { overflow-x: clip; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(52, 231, 255, .06), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(52, 231, 255, .03), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--cyan); color: #0A0B0C; }

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }

code {
  font-family: var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: .88em;
  color: var(--cyan);
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--cyan); color: #0A0B0C; padding: 8px 14px; border-radius: 0 0 8px 0;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 17, 19, .8), transparent);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 30;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.prompt { color: var(--cyan); font-weight: 700; letter-spacing: .02em; }
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 17px;
  margin: 0;
  letter-spacing: -.01em;
}
.links { display: flex; gap: 18px; font-size: 13px; }
.links a { color: var(--muted); }
.links a:hover { color: var(--cyan); }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 30px; }
.kicker { color: var(--cyan-dim); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 14px; opacity: .85; }
.headline {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.02;
  letter-spacing: -.02em;
  margin: 0 0 20px;
}
.headline .accent { color: var(--cyan); text-shadow: 0 0 32px var(--cyan-glow); }
.sub { color: var(--muted); max-width: 62ch; font-size: 15px; }
.sub strong { color: var(--ink); font-weight: 500; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- Controls ---------- */
.playground { display: flex; flex-direction: column; gap: 16px; }
.controls {
  display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
  padding: 12px 16px;
}
.control-group { display: flex; align-items: center; gap: 10px; }
.control-label { color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.control-status { margin-left: auto; }

.toggle { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle-btn {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  background: transparent; border: 0; padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: color .18s, background .18s;
}
.toggle-btn:hover { color: var(--ink); }
.toggle-btn.is-active { background: var(--cyan); color: #0A0B0C; font-weight: 700; }

.select {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; cursor: pointer;
}
.select:hover { border-color: var(--line-2); }

.tok-status { font-size: 12px; color: var(--cyan); display: inline-flex; align-items: center; gap: 6px; }
/* glyph as a pure-CSS box; inherits currentColor of its status state */
.tok-status::before {
  content: ""; display: inline-block; box-sizing: border-box;
  width: 9px; height: 9px; flex: none;
}
/* ready — small filled cyan dot */
.tok-status.ready { color: var(--cyan); }
.tok-status.ready::before { border-radius: 50%; background: currentColor; }
/* loading — spinner ring (single-color, currentColor) */
.tok-status.loading { color: var(--warn); }
.tok-status.loading::before {
  border-radius: 50%;
  border: 1.6px solid currentColor; border-top-color: transparent;
  background: transparent;
  animation: tok-spin .7s linear infinite;
}
@keyframes tok-spin { to { transform: rotate(360deg); } }
/* error — an x drawn from two crossing gradients */
.tok-status.error { color: var(--danger); }
.tok-status.error::before {
  background:
    linear-gradient(45deg, transparent 43%, currentColor 43%, currentColor 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, currentColor 43%, currentColor 57%, transparent 57%);
}

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { overflow: hidden; }

.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.panel-head.plain { justify-content: space-between; }
.panel-title { font-size: 13px; color: var(--ink); font-weight: 500; }
.panel-note { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.panel-head.plain .panel-note { margin-left: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-r { background: rgba(244, 246, 247, .20); } .dot-a { background: rgba(244, 246, 247, .35); } .dot-g { background: var(--cyan); }
.json-status { margin-left: auto; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }
.json-status.ok { color: var(--cyan); border: 1px solid var(--cyan-glow); }
.json-status.bad { color: var(--danger); border: 1px solid rgba(255, 107, 107, .45); }

/* ---------- Editor ---------- */
.json-input {
  width: 100%; min-height: 360px; resize: vertical;
  border: 0; background: var(--surface); color: var(--ink);
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  padding: 16px; tab-size: 2;
}
.json-input:focus { outline: none; }

/* ---------- Meters ---------- */
.meter-panel { padding: 18px; display: flex; flex-direction: column; }
.meter-row { display: flex; gap: 16px; }
.meter {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.meter-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; display: flex; gap: 6px; align-items: baseline; }
.meter-enc { color: var(--cyan-dim); text-transform: none; letter-spacing: 0; }
.hint { color: var(--muted); text-transform: none; letter-spacing: 0; opacity: .7; cursor: help; }
.meter-value {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(30px, 5vw, 44px); line-height: 1.1; margin-top: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.meter-value.cost { color: var(--cyan); }
.meter-value.flash { animation: flash .5s ease; }
@keyframes flash { 0% { color: var(--cyan); text-shadow: 0 0 24px var(--cyan-glow); } 100% {} }

/* ---------- Diet CTA ---------- */
.diet-cta-wrap { margin: 18px 0 6px; }
.diet-btn {
  width: 100%; font-family: var(--mono); font-weight: 700; font-size: 15px;
  color: #0A0B0C; background: var(--cyan);
  border: 0; border-radius: var(--radius-sm); padding: 13px 18px; cursor: pointer;
  box-shadow: 0 0 0 0 var(--cyan-glow);
  transition: transform .12s, box-shadow .25s, background .2s;
}
.diet-btn:hover { box-shadow: 0 6px 28px var(--cyan-glow); transform: translateY(-1px); }
.diet-btn:active { transform: translateY(0); }
.diet-btn:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; box-shadow: none; transform: none; }
.diet-btn.dieted { background: var(--surface-2); color: var(--cyan-dim); }
.diet-icon { width: 1.05em; height: 1.05em; vertical-align: -.15em; margin-right: .12em; }

.diet-reveal {
  margin-top: 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.reveal-pct {
  font-family: var(--display); font-weight: 800; font-size: clamp(36px, 7vw, 56px);
  color: var(--cyan); line-height: 1; text-shadow: 0 0 40px var(--cyan-glow);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.reveal-detail { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Chips ---------- */
.chips-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 8px; }
.chips-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.chips-sub { font-size: 11px; color: var(--muted); opacity: .75; }
.chips {
  display: flex; flex-wrap: wrap; gap: 3px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; max-height: 240px; overflow: auto;
  font-size: 12px; line-height: 1.4;
}
.chip {
  font-family: var(--mono); padding: 1px 4px; border-radius: 4px;
  white-space: pre; color: var(--ink);
  border: 1px solid transparent;
}
.chip-nl { width: 100%; height: 0; flex-basis: 100%; }
.chip-more { color: var(--muted); padding: 2px 6px; align-self: center; font-size: 11px; }
/* hashed alternating chip colors — visible token boundaries.
   Single hue (electric cyan) alternating with mono/ghost tints — no second hue. */
.chip.c0 { background: rgba(52, 231, 255, .20); }
.chip.c1 { background: rgba(244, 246, 247, .07); }
.chip.c2 { background: rgba(52, 231, 255, .12); }
.chip.c3 { background: rgba(244, 246, 247, .13); }
.chip.c4 { background: rgba(52, 231, 255, .28); }
.chip.c5 { background: rgba(244, 246, 247, .10); }

/* ---------- Bars ---------- */
.chart-panel { padding: 16px 18px 20px; }
.chart-panel .panel-head.plain { background: transparent; border: 0; padding: 0 0 14px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; }
.bar-name { font-size: 12.5px; color: var(--muted); }
.bar-row.is-best .bar-name { color: var(--cyan); font-weight: 700; }
.bar-track { background: var(--bg-2); border-radius: 6px; height: 22px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill {
  height: 100%; border-radius: 5px 0 0 5px;
  background: linear-gradient(90deg, rgba(138, 145, 150, .5), rgba(138, 145, 150, .8));
  width: 0; transition: width .7s cubic-bezier(.2, .8, .25, 1);
}
.bar-row.is-best .bar-fill { background: linear-gradient(90deg, var(--cyan-dim), var(--cyan)); box-shadow: 0 0 18px var(--cyan-glow); }
.bar-val { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 92px; text-align: right; }
.bar-val .pct { color: var(--muted); margin-left: 6px; }
.bar-row.is-best .bar-val .pct { color: var(--cyan); }
.bar-row.na .bar-track { opacity: .4; }
.bar-row.na .bar-val { color: var(--muted); }

/* ---------- Models ---------- */
.models-panel { padding: 16px 18px 20px; }
.models-panel .panel-head.plain { background: transparent; border: 0; padding: 0 0 14px; }
.models { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.model {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.model-name { font-size: 12.5px; color: var(--ink); font-weight: 500; }
.model-price { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.model-cost {
  font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--cyan);
  margin-top: 8px; font-variant-numeric: tabular-nums;
}
.model.claude .model-cost { color: var(--cyan); }
.model.gpt .model-cost { color: var(--cyan); }

/* ---------- Honesty ---------- */
.honesty { margin: 22px 0 40px; padding: 16px 18px; }
.honesty p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.honesty strong { color: var(--ink); }
.honesty-mark { color: var(--cyan); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 20px 0; }
.site-footer .wrap { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
  .models { grid-template-columns: repeat(2, 1fr); }
  .meter-row { flex-direction: column; }
  .bar-row { grid-template-columns: 96px 1fr; }
  .bar-val { grid-column: 2; text-align: left; min-width: 0; }
  .controls { gap: 14px; }
  .control-status { margin-left: 0; width: 100%; }
}

/* ---------- Phone ---------- */
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .header-inner { height: 52px; }
  .links { gap: 13px; font-size: 12px; }
  .hero { padding: 34px 0 20px; }
  .headline { font-size: clamp(26px, 8.5vw, 40px); }
  .sub { font-size: 14px; }

  /* stack toolbar: each control on its own row, label left / control right */
  .controls { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .control-group { justify-content: space-between; gap: 12px; }
  .control-status { width: 100%; }
  .tok-status { font-size: 11.5px; }

  /* editor shorter so the page isn't a mile of textarea on a phone */
  .json-input { min-height: 220px; font-size: 12.5px; }
  .meter-panel { padding: 14px; }
  .meter-row { gap: 12px; }
  .meter { padding: 12px 14px; }
  .meter-value { font-size: clamp(26px, 9vw, 34px); }

  /* cost cards: keep 2×2 but tighten so numbers never clip */
  .models-panel, .chart-panel { padding: 14px; }
  .models { gap: 10px; }
  .model { padding: 11px 12px; }
  .model-cost { font-size: 18px; }
  .bar-name { font-size: 12px; }
  .chips { max-height: 200px; }
  .honesty { padding: 14px; }
}

@media (max-width: 380px) {
  .models { grid-template-columns: 1fr; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
