/* Firefox TinyBERT Address Autofill — Calm Editorial Lab Stylesheet
   Strictly inherits public/styles.css semantic tokens.
   Zero raw hex literals. Zero --ok/--err tokens (strictly --good / --warn / --bad / --accent).
   Zero capsule pill clutter. Zero dashed borders or buttons. >=44x44px hit targets everywhere. */

[hidden] {
  display: none !important;
}

button,
.button,
.model-loader button,
select,
input[type="text"],
input[type="search"],
input[type="email"],
input[type="tel"],
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,
.model-loader summary {
  display: inline-flex;
  align-items: center;
}

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

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

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

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

.ta-fact b,
.ta-fact > code {
  display: block;
  margin-top: 0.18rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.38;
  color: var(--color);
  overflow-wrap: anywhere;
  background: transparent;
  border: 0;
  padding: 0;
}

/* Calm editorial callouts (solid hairline + left accent rule) */
.ta-note {
  padding: 0.72rem 0.95rem;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  font-size: 0.87rem;
  line-height: 1.55;
  margin: 0.8rem 0;
  color: var(--color);
}

.ta-note.good {
  border-inline-start-color: var(--good);
}

.ta-note.warn {
  border-inline-start-color: var(--warn);
}

.ta-note.bad {
  border-inline-start-color: var(--bad);
}

.ta-note.accent {
  border-inline-start-color: var(--accent);
}

/* Preset buttons (clean rectangular architectural buttons, zero pill bloat) */
.ta-preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.5rem 0 0.9rem;
}

.ta-preset-btn {
  background: var(--bg-raised);
  color: var(--color);
  border: 1px solid var(--border);
  box-shadow: none;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.48rem 0.82rem;
  border-radius: var(--radius-sm);
}

.ta-preset-btn:hover:not(:disabled) {
  background: var(--bg-secondary);
  border-color: var(--border-strong);
  color: var(--color);
  transform: none;
  box-shadow: none;
}

.ta-preset-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-raised));
  border-color: var(--accent);
  color: var(--color);
  font-weight: 600;
}

/* Structured field grids */
.ta-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.72rem;
  margin: 0.75rem 0;
}

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

.ta-field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--color);
}

.ta-input,
.ta-select {
  width: 100%;
  min-inline-size: 0;
  font-family: var(--font-body);
}

/* Accessible :autofill styling with multi-indicator border + inset shadow + preserved focus ring */
.ta-input:autofill,
.ta-input:-webkit-autofill {
  border-color: var(--good);
  box-shadow: inset 0 0 0 1000px color-mix(in srgb, var(--good) 8%, var(--bg-raised));
}

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

.ta-textarea {
  width: 100%;
  min-block-size: 7rem;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 0.83rem;
}

/* Solid hairline file upload / drop bar (never dashed) */
.ta-file-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  margin: 0.75rem 0;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ta-file-bar.is-dragover,
.ta-file-bar:focus-within {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg-raised));
}

.ta-file-hint {
  margin: 0;
  font-size: 0.83rem;
  color: var(--muted);
  flex: 1 1 14rem;
}

.ta-upload-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 44px;
  min-inline-size: 44px;
  padding: 0.48rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.ta-upload-label:hover {
  border-color: var(--border-strong);
}

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

.ta-upload-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Controls & Sliders */
.ta-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 0.75rem;
  margin: 0.85rem 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

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

.ta-slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.ta-slider-head label {
  font-weight: 600;
}

.ta-slider-head output {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

.ta-slider-field input[type="range"] {
  width: 100%;
  min-block-size: 44px;
}

/* Toggle checkboxes (>= 44px touch target) */
.ta-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.ta-toggle-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-block-size: 44px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}

.ta-toggle-item:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}

.ta-toggle-item:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.ta-toggle-item input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  min-block-size: auto;
  min-inline-size: auto;
  margin: 0;
  flex-shrink: 0;
}

.ta-toggle-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ta-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.85rem 0;
}

/* Normalized signature preview strip */
.ta-sig-preview {
  margin: 0.7rem 0;
  padding: 0.62rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.ta-sig-preview span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

/* Metrics grid */
.ta-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.8rem), 1fr));
  gap: 0.55rem;
  margin: 0.85rem 0;
}

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

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

.ta-metric b {
  display: block;
  margin-top: 0.16rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color);
  overflow-wrap: anywhere;
}

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

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

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

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

/* Cards & responsive 2-col grids */
.ta-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 0.85rem;
  margin: 0.85rem 0;
}

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

.ta-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.ta-card-head h3 {
  margin: 0;
  font-size: 1rem;
}

.ta-card-sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.ta-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Probability bars */
.ta-score-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ta-score-row {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.ta-score-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.84rem;
}

.ta-score-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  min-inline-size: 0;
}

.ta-rank-num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.ta-whatwg-hint {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.ta-score-vals {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.ta-logit-val {
  color: var(--muted);
}

.ta-bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
  overflow: hidden;
}

.ta-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.ta-bar-fill.tone-muted {
  background: var(--border-strong);
}

.ta-bar-fill.tone-sub {
  background: color-mix(in srgb, var(--accent) 48%, var(--bg-secondary));
}

/* Canvas container */
.ta-canvas-wrap {
  width: 100%;
  overflow: hidden;
}

.ta-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 190px;
}

/* WordPiece token ribbon */
.ta-token-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  align-items: center;
}

.ta-tok {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.42rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-secondary);
  font-family: var(--font-mono);
  font-size: 0.77rem;
  color: var(--color);
}

.ta-tok.is-special {
  border-color: var(--border-strong);
  color: var(--muted);
  background: var(--bg-raised);
}

.ta-tok.is-subword {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
}

.ta-tok.is-ctx {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
  color: var(--good);
}

/* Tables */
.ta-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.ta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.ta-table th,
.ta-table td {
  padding: 0.58rem 0.72rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

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

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

/* Status tags (subtle architectural rectangles, never full-capsule pills) */
.ta-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--color);
}

.ta-badge.good {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
  background: color-mix(in srgb, var(--good) 10%, var(--bg-raised));
  color: var(--good);
}

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

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

.ta-badge.accent {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-raised));
  color: var(--accent);
}

/* PII inline <mark> highlighting (Multi-model Stage 2) */
.ta-pii-mark {
  background: color-mix(in srgb, var(--warn) 18%, var(--bg-raised));
  color: var(--color);
  border-bottom: 2px solid var(--warn);
  padding: 0.04rem 0.2rem;
  border-radius: 3px;
}

.ta-pii-tag {
  display: inline-block;
  margin-inline-start: 0.25rem;
  padding: 0.02rem 0.28rem;
  border-radius: 3px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color);
}

/* Multi-model stage cards */
.stage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}

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

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

.stage-card p.muted {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

/* Fixed HTML code preview */
.ta-code-out {
  margin: 0.5rem 0 0;
  max-block-size: 22rem;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.48;
  white-space: pre;
}

/* Use-case ladder cards on Overview */
.ta-ladder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.ta-ladder-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  text-decoration: none;
  color: var(--color);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ta-ladder-card:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--bg-raised));
  color: var(--color);
}

.ta-rung-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}

/* Progress bar */
.ta-progress {
  width: 100%;
  height: 10px;
  margin: 0.5rem 0;
}

/* Below-the-fold rendering deferral (never applied above the fold) */
.ta-deferred-section {
  content-visibility: auto;
  contain-intrinsic-size: 1px 420px;
}

@media (max-width: 520px) {
  .ta-toolbar {
    gap: 0.45rem;
  }
  .ta-toolbar button {
    flex: 1 1 auto;
  }
}
