:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5f5f5f;
  --border: #e0ddd6;
  --accent: #a2542a;
  --accent-contrast: #ffffff;
  --badge-bg: #f0e6dc;
  --code-bg: #f4f1ec;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --surface: #221e18;
    --text: #f2ede4;
    --text-muted: #b8b0a3;
    --border: #3a352c;
    --accent: #e08a53;
    --accent-contrast: #17140f;
    --badge-bg: #3a2c1e;
    --code-bg: #1c1913;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

/* Token chip palette -- distinct, readable in both themes */
:root {
  --tok-0: #ffd8a8; --tok-0-fg: #4a2c00;
  --tok-1: #b2f2bb; --tok-1-fg: #0b3d15;
  --tok-2: #a5d8ff; --tok-2-fg: #06304f;
  --tok-3: #fcc2d7; --tok-3-fg: #5c0a2c;
  --tok-4: #d0bfff; --tok-4-fg: #2e0a5c;
  --tok-5: #ffec99; --tok-5-fg: #4a3c00;
  --tok-6: #99e9f2; --tok-6-fg: #003a40;
  --tok-7: #eebefa; --tok-7-fg: #3c0a4a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tok-0-fg: #1a0f00; --tok-1-fg: #001a05; --tok-2-fg: #001522;
    --tok-3-fg: #2a0414; --tok-4-fg: #16042a; --tok-5-fg: #221c00;
    --tok-6-fg: #001a1c; --tok-7-fg: #1c0422;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero h1 {
  font-size: 1.9rem;
  margin-bottom: 0.4rem;
}

.subtitle {
  color: var(--text-muted);
  max-width: 70ch;
  margin-top: 0;
}

.examples {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.2rem 0;
}

.examples-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.example-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.example-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.example-btn:hover { border-color: var(--accent); }

.input-section {
  margin: 1rem 0 1.4rem;
}

.input-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  font-family: inherit;
  resize: vertical;
  box-shadow: var(--shadow);
}
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.section-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 0.7rem;
  font-weight: 600;
}

.comparison-section {
  margin-bottom: 1.6rem;
}

.comparison-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comparison-row {
  display: grid;
  grid-template-columns: 13rem 1fr 3.5rem;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.85rem;
}

.comparison-row.is-ours .comparison-name { color: var(--accent); font-weight: 600; }

.comparison-track {
  background: var(--code-bg);
  border-radius: 999px;
  height: 0.6rem;
  overflow: hidden;
}

.comparison-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.comparison-row.is-ours .comparison-fill { background: #4caf6d; }

.comparison-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.compare-controls {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
  font-size: 0.9rem;
}

.compare-controls label { color: var(--text-muted); }

#compare-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}

.display-mode {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border: none;
  padding: 0;
  margin: 0;
}

.display-mode legend {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0;
}

.display-mode label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text);
  cursor: pointer;
}

.results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}
@media (max-width: 720px) {
  .results { grid-template-columns: 1fr; }
}

.result-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.result-panel h2 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.h2-logo {
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--badge-bg);
  color: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.stats {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.8rem;
}
.stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.stats strong { color: var(--text); font-size: 1.3rem; line-height: 1.3; }

.token-view {
  min-height: 3.5rem;
  line-height: 2.1;
  word-break: break-word;
}

.unk-warning {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffe69c;
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  margin: 0 0 0.7rem;
}
@media (prefers-color-scheme: dark) {
  .unk-warning {
    background: #3d3319;
    color: #ffdf7e;
    border-color: #5c4a1e;
  }
}

.token-chip {
  display: inline-block;
  padding: 0.05rem 0.15rem;
  margin: 0 1px;
  border-radius: 4px;
  font-family: "SF Mono", Consolas, Menlo, monospace;
  font-size: 0.92rem;
  white-space: pre-wrap;
  cursor: default;
}

.loading-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 1rem;
}
.loading-note.hidden { display: none; }

.citation-section {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1.2rem;
}

.citation-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.citation-toggle:hover { border-color: var(--accent); }

.citation-block {
  margin-top: 0.9rem;
}

.citation-block pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.8rem;
  overflow-x: auto;
}

.copy-button {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.copy-button:hover { opacity: 0.9; }

.site-footer {
  margin-top: 2.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}
.site-footer a { color: var(--accent); }
