/* CardiffNLP Twitter-RoBERTa-Base Emotion Showcase
   Strictly uses public/styles.css design tokens.
   Zero raw hex literals. Zero --ok/--err tokens (strictly --good / --warn / --bad / --accent). */

[hidden] {
  display: none !important;
}

button,
.button,
.model-loader button,
select,
input[type="text"],
input[type="number"],
input[type="range"],
summary,
.ladder-nav a,
.crumbs a,
footer.byline a {
  min-block-size: 44px;
}

button,
.button,
.model-loader button,
.ladder-nav a,
.crumbs a,
footer.byline a {
  min-inline-size: 44px;
}

.crumbs a,
footer.byline a {
  display: inline-flex;
  align-items: center;
}

.model-loader summary {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

.em-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Callouts & banners */
.em-callout {
  padding: 0.78rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border));
  border-inline-start: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-raised));
  font-size: 0.88rem;
  margin: 0.75rem 0 1rem;
}

.em-callout.good {
  border-color: color-mix(in srgb, var(--good) 40%, var(--border));
  border-inline-start-color: var(--good);
  background: color-mix(in srgb, var(--good) 8%, var(--bg-raised));
}

.em-callout.accent {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  border-inline-start-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}

.em-callout.warn {
  border-color: color-mix(in srgb, var(--warn) 42%, var(--border));
  border-inline-start-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--bg-raised));
}

.em-callout.bad {
  border-color: color-mix(in srgb, var(--bad) 42%, var(--border));
  border-inline-start-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, var(--bg-raised));
}

/* At-a-glance specs */
.em-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.55rem;
  margin: 0.9rem 0 1.2rem;
}

.em-fact {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.58rem 0.75rem;
  min-inline-size: 0;
}

.em-fact span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.em-fact b,
.em-fact > code {
  display: block;
  margin-top: 0.16rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color);
  word-break: break-word;
}

.em-fact small {
  overflow-wrap: anywhere;
}

/* Preset & filter chips */
.em-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.55rem 0 0.75rem;
}

.em-chip {
  min-block-size: 44px;
  min-inline-size: 44px;
  max-inline-size: 100%;
  text-align: start;
  line-height: 1.3;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.em-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.em-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.em-chip[aria-pressed="true"]:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

/* Toolbars, fields & full-hitbox accessible file upload + dropzone */
.em-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: flex-end;
  margin: 0.75rem 0;
}

.em-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-inline-size: 0;
}

.em-field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.em-textarea {
  inline-size: 100%;
  min-block-size: 6.8rem;
  padding: 0.72rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.55;
  resize: vertical;
}

.em-textarea.mono {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.em-input,
.em-select {
  inline-size: 100%;
  min-block-size: 44px;
  min-inline-size: 44px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.88rem;
}

.em-range {
  inline-size: 100%;
  min-block-size: 44px;
  cursor: pointer;
}

.em-textarea:focus-visible,
.em-input:focus-visible,
.em-select:focus-visible,
.em-range:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Drop zone + full-hitbox file input */
.em-drop-zone {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.75rem 0.9rem;
  margin: 0.6rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: safe center;
  justify-content: space-between;
  gap: 0.65rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.em-drop-zone.is-dragover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-raised));
}

.em-drop-hint {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  min-inline-size: 0;
  flex: 1 1 14rem;
}

.em-upload-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-block-size: 46px;
  min-inline-size: 46px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.em-upload-label input[type="file"] {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 44px;
  min-inline-size: 44px;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.em-upload-label:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.em-upload-label:focus-within,
.em-upload-label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 44x44 accessible checkbox controls */
.em-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-block-size: 44px;
  min-inline-size: 44px;
  max-inline-size: 100%;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}

.em-check-label span {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.em-check-label:hover {
  border-color: var(--accent);
}

.em-check-label:focus-within,
.em-check-label:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.em-check-input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 44px;
  inline-size: 44px;
  block-size: 44px;
  min-inline-size: 44px;
  min-block-size: 44px;
  margin: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.em-check-input::before {
  content: "";
  inline-size: 20px;
  block-size: 20px;
  border-radius: 5px;
  border: 2px solid var(--border-strong);
  background: var(--bg-raised);
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.em-check-input:checked::before {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg-raised);
}

/* Grids & cards */
.em-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 0.95rem;
  margin-top: 0.85rem;
  align-items: start;
}

.em-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.9rem 1rem;
  min-inline-size: 0;
}

.em-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.02rem;
}

/* Metrics & diagnostics strip */
.em-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.2rem), 1fr));
  gap: 0.55rem;
  margin: 0.8rem 0;
}

.em-metric {
  padding: 0.58rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  min-inline-size: 0;
}

.em-metric span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  text-transform: uppercase;
  color: var(--muted);
}

.em-metric b {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.96rem;
  color: var(--color);
  word-break: break-word;
}

.em-metric b.good {
  color: var(--good);
}

.em-metric b.accent {
  color: var(--accent);
}

.em-metric b.warn {
  color: var(--warn);
}

.em-metric b.bad {
  color: var(--bad);
}

/* 4-class probability bars */
.em-bars {
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
}

.em-bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.em-bar-row.is-top .em-bar-name {
  font-weight: 700;
  color: var(--color);
}

.em-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
}

.em-bar-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color);
}

.em-bar-pct {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.em-bar-track {
  inline-size: 100%;
  block-size: 10px;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  overflow: hidden;
}

.em-bar-fill {
  block-size: 100%;
  border-radius: 999px;
  transition: inline-size 0.22s ease;
}

.em-bar-fill.tone-good {
  background: var(--good);
}

.em-bar-fill.tone-accent {
  background: var(--accent);
}

.em-bar-fill.tone-warn {
  background: var(--warn);
}

.em-bar-fill.tone-bad {
  background: var(--bad);
}

/* Stacked 4-class distribution bar */
.em-stack-bar {
  display: flex;
  inline-size: 100%;
  min-inline-size: 6rem;
  block-size: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.em-stack-seg.tone-good {
  background: var(--good);
}

.em-stack-seg.tone-accent {
  background: var(--accent);
}

.em-stack-seg.tone-bad {
  background: var(--bad);
}

.em-stack-seg.tone-warn {
  background: var(--warn);
}

/* BPE Token Chip Strip */
.em-token-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.em-tok {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.22rem 0.48rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--color);
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

.em-tok-id {
  font-size: 0.68rem;
  color: var(--muted);
}

.em-tok.is-special {
  border-color: color-mix(in srgb, var(--border-strong) 70%, var(--border));
  color: var(--muted);
}

.em-tok.is-anchor {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised));
  color: var(--accent);
  font-weight: 600;
}

.em-tok.is-dropped {
  border-color: color-mix(in srgb, var(--bad) 50%, var(--border));
  background: color-mix(in srgb, var(--bad) 10%, var(--bg-raised));
  color: var(--bad);
}

/* Semantic pills */
.em-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--color);
  white-space: nowrap;
}

.em-pill.tone-good {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
  background: color-mix(in srgb, var(--good) 12%, var(--bg-raised));
}

.em-pill.tone-accent {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised));
}

.em-pill.tone-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-raised));
}

.em-pill.tone-bad {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, var(--border));
  background: color-mix(in srgb, var(--bad) 12%, var(--bg-raised));
}

/* Preprocess code preview */
.em-pre {
  margin: 0.35rem 0 0;
  padding: 0.68rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Responsive Circumplex Canvas */
.em-canvas-wrap {
  inline-size: 100%;
  max-inline-size: 440px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  padding: 0.5rem;
}

.em-canvas-wrap canvas {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  height: auto;
}

/* Tables */
.em-table-wrap {
  overflow-x: auto;
  max-inline-size: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  margin-top: 0.7rem;
}

.em-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.em-table th,
.em-table td {
  text-align: start;
  padding: 0.56rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.em-table th {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg-secondary);
}

.em-table tr:last-child td {
  border-bottom: 0;
}

.em-table tr.is-active {
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}

/* Pipeline strip */
.em-pipeline-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.65rem;
  margin: 0.8rem 0 1rem;
}

.em-stage {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.72rem 0.82rem;
  min-inline-size: 0;
}

.em-stage-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

.em-stage h3 {
  margin: 0.15rem 0 0.25rem;
  font-size: 0.94rem;
}

.em-stage p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Multi-model stage cards & 4x3 Emotion x Sentiment alignment matrix */
.stage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 0.85rem;
  margin: 0.75rem 0 1rem;
}

.stage-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.75rem 0.85rem;
  min-inline-size: 0;
}

.stage-card h3 {
  margin: 0 0 0.25rem;
  font-size: 0.96rem;
}

.stage-card > p.muted {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.em-matrix-cell {
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid transparent;
}

.em-matrix-cell.is-hit {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-raised));
  font-weight: 700;
}

.em-matrix-cell.is-hit.tone-bad {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, var(--bg-raised));
}

.em-matrix-cell.is-hit.tone-warn {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, var(--bg-raised));
}

.em-matrix-cell.is-hit.tone-good {
  border-color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, var(--bg-raised));
}

.em-delta {
  font-family: var(--font-mono);
  font-weight: 600;
}

.em-delta.good {
  color: var(--good);
}

.em-delta.bad {
  color: var(--bad);
}

.em-delta.muted {
  color: var(--muted);
}

/* Wrap mobile ladder nav cleanly without horizontal clipping (aligned with public/styles.css Batch 2) */
@media (max-width: 640px) {
  .ladder-nav {
    position: static;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .ladder-nav a {
    flex: 1 1 auto;
    white-space: normal;
    text-align: center;
  }
}
