/* Module 01 — Tokens.
   Only the things styles.css does not already have: the token stream itself,
   the counter strip, and the small language-cost table. Every colour comes
   from a shared variable — nothing is hard-coded here. */

/* styles.css sets .chip to 40px; this module uses chips as primary controls,
   so raise them to the 44px tap target. Scoped to this module only. */
[data-module="tokens"] .chip { min-height: 44px; }

/* ------------------------------------------------------------ token stream */

.tok-stream {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.tok {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: .92rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Four-colour cycle. It only marks boundaries — it means nothing else. */
.tok-c0 { background: var(--accent-soft); color: var(--accent-dark); }
.tok-c1 { background: var(--ok-soft);     color: var(--ok); }
.tok-c2 { background: var(--warn-soft);   color: var(--warn); }
.tok-c3 { background: var(--surface-alt); color: var(--ink-soft); }

.tok-space-mark { color: var(--ink-faint); font-weight: 700; }
.tok-cont { font-style: italic; opacity: .85; }
.tok-empty { color: var(--ink-faint); font-style: italic; font-family: var(--font); }

/* a piece plus a small count under it (letter-counting demo) */
.tok-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tok-piece-count {
  font-size: .76rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.tok-piece-count.hit { color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------- counters */

.tok-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.tok-stat {
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  text-align: center;
}
.tok-stat b {
  display: block;
  font-family: var(--mono);
  font-size: 1.3rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.tok-stat span {
  display: block;
  font-size: .76rem;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* ----------------------------------------------------------------- legend */

.tok-legend {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  font-size: .88rem;
  color: var(--ink-soft);
}
.tok-legend > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.tok-legend .tok { flex: none; }

.tok-say {
  margin-top: 12px;
  font-size: .95rem;
  color: var(--ink-soft);
}
.tok-say strong { color: var(--ink); }

/* ------------------------------------------------------------------ table */

.tok-table-wrap { overflow-x: auto; }
.tok-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.tok-table th,
.tok-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.tok-table th {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tok-table td.num,
.tok-table th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tok-table td.num { color: var(--ink); }
.tok-table .tok-sentence {
  display: block;
  margin-top: 3px;
  font-size: .84rem;
  font-weight: 400;
  color: var(--ink-soft);
}
.tok-table tbody th { font-size: .92rem; color: var(--ink); text-transform: none; letter-spacing: 0; }
.tok-table td.num .tok-sentence { white-space: normal; font-size: .76rem; }

/* ----------------------------------------------------------------- guided */

.tok-demo-label {
  margin: 14px 0 6px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--ink-soft);
}

@media (max-width: 420px) {
  .tok-stat b { font-size: 1.15rem; }
  .tok { font-size: .88rem; }
}
