/* paraphrase-albert-small-v2 — calm, editorial-lab design-system styles.
   Strictly uses CSS custom properties from ../../public/styles.css:
   - zero raw hex color literals
   - calm rounded-rectangle controls (no oversized pill radii), zero --ok/--err tokens
   - [hidden] { display: none !important; }
   - >= 44x44px interactive touch targets everywhere
   - @container responsive workspaces with 0px horizontal overflow down to 360px mobile */

[hidden] {
  display: none !important;
}

button,
.button,
.model-loader button,
.model-pack-bar button,
select,
input[type="text"],
input[type="search"],
input[type="range"],
input[type="file"],
summary,
.model-loader summary,
.model-pack-bar summary,
.ladder-nav a,
.crumbs a,
footer.byline a,
.ap-skip-link,
.ap-file-btn,
.ap-preset,
.ap-seg-btn,
.ap-links a,
.ap-glance a,
.ap-table a,
details.show-code .sc-meta a {
  min-block-size: 44px;
  min-inline-size: 44px;
}

.crumbs a,
footer.byline a,
.ap-skip-link,
.model-loader summary,
.model-pack-bar summary,
.ap-links a,
.ap-glance a,
.ap-table a,
details.show-code .sc-meta a {
  display: inline-flex;
  align-items: center;
}

.ap-skip-link {
  position: absolute;
  inset-block-start: -8rem;
  inset-inline-start: 0.75rem;
  z-index: 90;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.ap-skip-link:focus {
  inset-block-start: 0.75rem;
}

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

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  inline-size: 44px;
  block-size: 44px;
  min-inline-size: 44px;
  min-block-size: 44px;
  flex: none;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  margin: 0;
  border: 0;
  background: transparent;
}

input[type="checkbox"]::before {
  content: "";
  grid-area: 1 / 1;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  border-radius: 5px;
  border: 2px solid var(--border-strong);
  background: var(--bg-raised);
}

input[type="checkbox"]:checked::before {
  border-color: var(--accent);
  background: var(--accent);
}

input[type="checkbox"]:checked::after {
  content: "✓";
  grid-area: 1 / 1;
  color: var(--accent-ink);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Header & calm architectural metadata line */
.ap-header {
  margin-block-end: 0.85rem;
}

.ap-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.ap-meta-sep {
  color: var(--border-strong);
}

.ap-header h1 {
  margin: 0.05rem 0 0.35rem;
  font-size: clamp(1.55rem, 2.5vw, 2.1rem);
}

.ap-header .lede {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.96rem;
  line-height: 1.55;
  max-inline-size: 74ch;
}

/* Workspace-first container with @container sizing */
.ap-workspace {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  margin-block-end: 1.25rem;
}

.ap-workspace.is-drag {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}

.ap-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem 0.8rem;
}

.ap-top-bar h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 1.15rem;
}

.ap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.ap-toolbar > * {
  min-inline-size: 0;
}

/* Preset buttons — calm rounded rectangles */
.ap-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.ap-preset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--color);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  max-inline-size: 100%;
  text-align: start;
  white-space: normal;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.ap-preset:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-raised);
}

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

.ap-preset:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Segmented control */
.ap-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.22rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  max-inline-size: 100%;
}

.ap-seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.78rem;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}

.ap-seg-btn:hover:not(:disabled) {
  color: var(--color);
  background: color-mix(in srgb, var(--bg-raised) 70%, transparent);
}

.ap-seg-btn[aria-pressed="true"] {
  background: var(--bg-raised);
  color: var(--color);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* Solid calm file upload button */
.ap-file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ap-file-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.ap-file-btn:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ap-file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

/* Fields & inputs */
.ap-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-inline-size: 0;
}

.ap-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.ap-field output {
  font-family: var(--font-mono);
  color: var(--color);
  font-variant-numeric: tabular-nums;
}

.ap-field input[type="text"],
.ap-field input[type="search"],
.ap-field select,
.ap-field textarea {
  inline-size: 100%;
  max-inline-size: 100%;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  font-size: 0.9rem;
}

.ap-field textarea {
  min-block-size: 7.2rem;
  resize: vertical;
  line-height: 1.5;
}

.ap-field input[type="range"] {
  inline-size: 100%;
  margin: 0;
}

.ap-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

/* Telemetry readout strip */
.ap-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.1rem), 1fr));
  gap: 0.55rem;
}

.ap-metric {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  min-inline-size: 0;
}

.ap-metric span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-metric strong {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Dual-pane & multi-pane visual grids */
.ap-stage-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.95rem;
  align-items: start;
}

@container (min-width: 720px) {
  .ap-stage-grid {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  }
}

.ap-pane {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.8rem;
  min-inline-size: 0;
}

.ap-pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.6rem;
}

.ap-pane-head h2,
.ap-pane-head h3 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.96rem;
  font-family: var(--font-body);
  font-weight: 600;
}

.ap-pane-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Ranked nearest-match list */
.ap-rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
}

.ap-rank-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  text-align: start;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ap-rank-item:hover {
  border-color: var(--accent);
}

.ap-rank-item[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-raised));
}

.ap-rank-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.6rem;
}

.ap-rank-id {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.ap-rank-score {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ap-rank-text {
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.ap-bar-fill {
  block-size: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.ap-bar-fill.is-good {
  background: var(--good);
}

.ap-bar-fill.is-warn {
  background: var(--warn);
}

.ap-bar-fill.is-bad {
  background: var(--bad);
}

/* SVG chart frame */
.ap-svg-frame {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-sm) - 2px);
  background: var(--bg-raised);
  padding: 0.5rem;
  overflow: hidden;
}

.ap-svg-frame svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
  max-inline-size: 100%;
}

.ap-svg-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.ap-svg-axis {
  stroke: var(--border-strong);
  stroke-width: 1.25;
}

.ap-svg-label {
  fill: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.ap-svg-point-label {
  fill: var(--color);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.ap-svg-point {
  cursor: pointer;
}

.ap-svg-point:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* SentencePiece token ribbon */
.ap-token-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.ap-tok {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  padding: 0.22rem 0.48rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.77rem;
  background: var(--bg-secondary);
  color: var(--color);
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

.ap-tok small {
  font-size: 0.67rem;
  color: var(--muted);
}

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

.ap-tok.is-subword {
  border-color: color-mix(in srgb, var(--warn) 50%, var(--border));
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-raised));
}

.ap-tok.is-truncated {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, var(--bg-raised));
  text-decoration: line-through;
}

/* Semantic badges (calm rounded rectangles) */
.ap-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.48rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.ap-badge.is-good {
  border-color: color-mix(in srgb, var(--good) 42%, var(--border));
  background: color-mix(in srgb, var(--good) 11%, var(--bg-raised));
  color: var(--good);
}

.ap-badge.is-warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-raised));
  color: var(--warn);
}

.ap-badge.is-bad {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--border));
  background: color-mix(in srgb, var(--bad) 11%, var(--bg-raised));
  color: var(--bad);
}

.ap-badge.is-accent {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent) 11%, var(--bg-raised));
  color: var(--accent);
}

/* Callout note */
.ap-callout {
  padding: 0.75rem 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.5rem 0 0;
}

/* Accessible scrollable tables & matrix heatmaps */
.ap-table-wrap {
  overflow-x: auto;
  max-inline-size: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.ap-table {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.ap-table caption {
  text-align: start;
  padding: 0.6rem 0.8rem 0.35rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
}

.ap-table th,
.ap-table td {
  padding: 0.52rem 0.72rem;
  border-top: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

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

.ap-table .is-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ap-matrix-cell {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-inline-size: 3.4rem;
}

.ap-matrix-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  min-inline-size: 44px;
  min-block-size: 44px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--color);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.ap-matrix-btn:hover,
.ap-matrix-btn[aria-pressed="true"] {
  border-color: var(--accent);
}

/* Duplicate cluster cards (Practical) */
.ap-cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 0.75rem;
}

.ap-cluster-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  min-inline-size: 0;
}

.ap-cluster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.ap-cluster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ap-cluster-list li {
  padding: 0.45rem 0.58rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 0.84rem;
  line-height: 1.4;
}

.ap-cluster-list li.is-rep {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}

/* Batch queue progress */
.ap-queue-progress {
  inline-size: 100%;
  block-size: 10px;
  accent-color: var(--accent);
}

/* Multi-model stage cards */
.ap-engine-section {
  margin-block: 1rem 1.25rem;
}

.loaders-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0.85rem;
  margin-block-start: 0.75rem;
}

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

.ap-stage-card h3 {
  margin: 0 0 0.3rem;
  font-size: 0.98rem;
}

.ap-stage-card p {
  margin: 0 0 0.55rem;
  font-size: 0.84rem;
}

/* Ladder cards on Overview */
.ap-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.8rem;
}

.ap-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--color);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.ap-card:hover {
  border-color: var(--accent);
  color: var(--color);
  transform: translateY(-1px);
}

.ap-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
}

.ap-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}

.ap-positive {
  color: var(--good);
  font-weight: 700;
}

.ap-negative {
  color: var(--bad);
  font-weight: 700;
}

@media (max-width: 600px) {
  .ladder-nav {
    justify-content: flex-start;
  }
  .ladder-nav a {
    justify-content: flex-start;
  }
  .ap-workspace {
    padding: 0.75rem;
  }
  .ap-pane {
    padding: 0.65rem;
  }
  .ap-table th,
  .ap-table td {
    padding: 0.42rem 0.52rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ap-card,
  .ap-preset,
  .ap-rank-item,
  .ap-workspace {
    transition: none;
    transform: none;
  }
}
