/* Tokenizer-specific styles.
 * The shared design system in /style.css does header, palette, layout.
 * This file does: mode tabs, encoder selector, editor, token chips,
 * abstraction-level strips, stats, examples.
 */

/* ── mode tabs (Tokens / Levels / System) ──────────────────── */

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.mode-tabs .mode {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: all 0.15s ease;
}
.mode-tabs .mode:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.mode-tabs .mode.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.mode-tabs .mode .n {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: 0.65;
  letter-spacing: 0.05em;
}

/* ── encoder selector ──────────────────────────────────────── */

.encoder-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.encoder-row .label {
  color: var(--text-muted);
  font-size: 13px;
  margin-right: 4px;
}
.encoder-row .enc {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s ease;
}
.encoder-row .enc:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.encoder-row .enc.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.encoder-row .hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

/* ── shared pane primitive ─────────────────────────────────── */

.pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  margin-bottom: 14px;
}

/* HTML `hidden` attribute must beat .pane/.stats/.examples display rules */
[hidden] { display: none !important; }

/* mode 3 owns its own inputs + stats; hide the shared chrome */
body.mode-system #editor-pane,
body.mode-system > main > .stats,
body.mode-system #examples { display: none !important; }
.pane .pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.pane .pane-header h2 {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.pane .pane-header .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pane .pane-header .actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.pane .pane-header .actions button:hover {
  color: var(--text);
  border-color: var(--text-muted);
}
.pane .pane-header .actions button.toggled {
  color: var(--accent);
  border-color: var(--accent);
}
.pane .pane-header .actions .caption {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}

/* editor textarea */
#editor {
  flex: 1;
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  min-height: 140px;
}
#editor:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── mode sections ─────────────────────────────────────────── */

.mode-section[hidden] { display: none; }

/* ── tokens view (mode 1) ──────────────────────────────────── */

#token-view {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.9;
  overflow-y: auto;
  min-height: 220px;
  word-break: break-word;
  white-space: pre-wrap;
}
#token-view.ids-mode {
  line-height: 2.1;
  font-size: 12px;
}

/* token chips: each token is one span, soft tinted background */
.tok {
  display: inline;
  padding: 1px 3px;
  border-radius: 3px;
  margin: 0 1px;
  border-bottom: 2px solid transparent;
}
.tok .id {
  display: none;
  font-size: 10px;
  vertical-align: top;
  margin-left: 2px;
  color: var(--text-dim);
}
#token-view.ids-mode .tok .id { display: inline; }

/* palette — 10 colours, deterministic by id mod 10 */
.tok.c0  { background: rgba(245, 166, 35, 0.15); border-bottom-color: rgba(245, 166, 35, 0.55); }
.tok.c1  { background: rgba(96, 165, 250, 0.16); border-bottom-color: rgba(96, 165, 250, 0.55); }
.tok.c2  { background: rgba(34, 197, 94, 0.16);  border-bottom-color: rgba(34, 197, 94, 0.55); }
.tok.c3  { background: rgba(244, 114, 182, 0.16); border-bottom-color: rgba(244, 114, 182, 0.55); }
.tok.c4  { background: rgba(168, 85, 247, 0.16); border-bottom-color: rgba(168, 85, 247, 0.55); }
.tok.c5  { background: rgba(234, 179, 8, 0.16);  border-bottom-color: rgba(234, 179, 8, 0.55); }
.tok.c6  { background: rgba(239, 68, 68, 0.16);  border-bottom-color: rgba(239, 68, 68, 0.55); }
.tok.c7  { background: rgba(20, 184, 166, 0.16); border-bottom-color: rgba(20, 184, 166, 0.55); }
.tok.c8  { background: rgba(249, 115, 22, 0.16); border-bottom-color: rgba(249, 115, 22, 0.55); }
.tok.c9  { background: rgba(132, 204, 22, 0.16); border-bottom-color: rgba(132, 204, 22, 0.55); }

.tok .ws { color: var(--text-dim); }
.tok.newline::after { content: "↵\A"; white-space: pre; color: var(--text-dim); }

/* ── levels view (mode 2) ──────────────────────────────────── */

.levels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.strip {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 720px) {
  .strip { grid-template-columns: 1fr; }
}
.strip-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-self: stretch;
}
.strip-label .n {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.strip-label .t {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.strip-label .hint {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.35;
}
.strip-body {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.7;
}
.strip-body.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  gap: 6px;
}

/* L1 chars */
.ch {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 13px;
}
.ch.nl::after { content: "↵"; color: var(--text-dim); }
.ch.sp { color: var(--text-dim); }
.ch.sp::after { content: "·"; }

/* L2 bytes */
.byte {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.18);
  color: rgba(96, 165, 250, 0.95);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.byte.high {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.22);
  color: rgba(239, 68, 68, 0.95);
}

/* L3 token chips (reuse .tok via shared palette) */
.strip-body .tok {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  border-bottom-width: 2px;
}

/* L4 IDs */
.id-num {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* L5 embedding shape */
.vec {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.10);
  border: 1px solid rgba(168, 85, 247, 0.30);
  color: rgba(196, 162, 230, 0.95);
  font-family: var(--font-mono);
  font-size: 11px;
}
.vec .dim {
  font-weight: 600;
  color: rgba(196, 162, 230, 1);
}
.vec .sample {
  color: var(--text-dim);
  font-size: 10px;
}

/* ── stats bar ─────────────────────────────────────────────── */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 18px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .v {
  font-family: var(--font-mono);
  font-size: 20px;
  color: var(--accent);
  font-weight: 600;
}
.stat .k {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── example chips ─────────────────────────────────────────── */

.examples {
  margin-bottom: 24px;
}
.examples .label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.examples .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.examples .ex {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.examples .ex:hover {
  color: var(--text);
  border-color: var(--accent);
  border-style: solid;
}

/* ── mode 03 — system prompt trust-boundary reveal ─────────── */

.sys-intro {
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 14px;
}
.sys-intro p { margin: 0; }
.sys-intro em {
  font-style: normal;
  color: var(--text);
  font-weight: 600;
}
.sys-intro code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

.sys-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.sys-pane {
  padding: 12px 14px;
}
.sys-pane .pane-header h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sys-pane .pane-header .caption {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.sys-pane textarea {
  width: 100%;
  min-height: 72px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}
.sys-pane textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.tpl-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  padding: 8px 10px;
  background: var(--accent-soft);
  border: 1px dashed rgba(245, 166, 35, 0.35);
  border-radius: 5px;
  white-space: pre;
  overflow-x: auto;
}

.sys-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
}
.sys-dot.tpl { background: var(--accent); }
.sys-dot.sys { background: #6ec1d4; }
.sys-dot.usr { background: #b88adf; }

.sys-stream {
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 120px;
  line-height: 2.2;
  font-family: var(--font-mono);
  font-size: 13px;
}
.sys-stream .stok {
  display: inline-block;
  padding: 2px 6px;
  margin: 2px 2px;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: pre;
}
.sys-stream .stok.tpl {
  background: var(--accent-soft);
  border-color: rgba(245, 166, 35, 0.30);
  color: var(--accent);
}
.sys-stream .stok.sys {
  background: rgba(110, 193, 212, 0.10);
  border-color: rgba(110, 193, 212, 0.30);
  color: #6ec1d4;
}
.sys-stream .stok.usr {
  background: rgba(184, 138, 223, 0.10);
  border-color: rgba(184, 138, 223, 0.30);
  color: #b88adf;
}
.sys-stream .stok .ws {
  color: var(--text-dim);
  opacity: 0.6;
}

.sys-legend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.sys-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sys-stats {
  display: flex;
  gap: 24px;
  padding: 14px 16px;
  margin-top: 14px;
  background: var(--bg-elevated);
  border-radius: 6px;
}
.sys-stats .stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sys-stats .stat .v {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}
.sys-stats .stat .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.sys-punchline {
  margin-top: 18px;
  padding: 16px 18px;
  background: rgba(220, 80, 80, 0.06);
  border-left: 3px solid #d05050;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.sys-punchline strong { color: var(--text); }

/* legacy alias retained for any stragglers */
.placeholder-inline {
  padding: 22px 18px;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ── explainer (collapsible) ───────────────────────────────── */

.explainer {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 8px;
}
.explainer summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.explainer summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
  font-size: 12px;
}
.explainer[open] summary::before { transform: rotate(90deg); }
.explainer .body {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}
.explainer .body h3 {
  color: var(--text);
  margin: 18px 0 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.explainer .body p { margin: 0 0 10px; }

.loading {
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── history timeline (collapsible) ─────────────────────────── */

.history {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 14px;
}
.history summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.history summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
  font-size: 12px;
}
.history[open] summary::before { transform: rotate(90deg); }
.history .body { margin-top: 14px; }
.history .lead {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.timeline li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  align-items: start;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border-radius: 8px;
  border-left: 2px solid var(--accent);
}
.timeline .yr {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  padding-top: 1px;
}
.timeline li > div {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}
.timeline li > div strong { color: var(--text); }
.timeline li > div code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}
