/* Calm, editorial warm-paper + indigo styles for all 5 PP-OCRv6 Small Det routes.
 * Rules enforced:
 *   - Uses public/styles.css CSS custom properties ONLY (zero raw hex colors)
 *   - Zero dashed borders, zero full-pill radii, zero --ok/--err tokens
 *   - [hidden] { display: none !important; }
 *   - >= 44x44px hit targets on every interactive control, link, and range slider
 *   - 0px horizontal overflow across 1280x800, 390x844, and 360x740 viewports
 */

[hidden] {
  display: none !important;
}

/* Enforce >= 44x44px accessible hit targets across all interactive controls */
button,
.model-loader button,
select,
input:not([type="hidden"]),
summary,
.det-upload-btn {
  min-block-size: 44px;
  min-inline-size: 44px;
}

.crumbs a,
.ladder-nav a,
.byline a,
.det-meta-line a,
.img-credit a,
.model-loader a,
details.show-code .sc-meta a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
}

.img-credit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
  line-height: 1.35;
}

.img-credit a {
  min-inline-size: 44px;
  justify-content: center;
  padding: 0 0.25rem;
}

/* Compact architectural header so interactive DBNet workbench sits above the fold */
.det-header {
  margin-block-end: 0.85rem;
}

.det-header h1 {
  margin: 0.25rem 0 0.35rem;
}

.det-header .lede {
  margin: 0;
  max-inline-size: 74ch;
}

.det-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  margin: 0.55rem 0 0;
}

.det-meta-line span + span::before {
  content: "·";
  margin-inline-end: 0.65rem;
  color: var(--border-strong);
}

.det-loader-bar {
  margin-block-end: 0.85rem;
}

.det-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Primary 2-column workbench with container query + responsive fallback */
.det-studio-wrap {
  container-type: inline-size;
  container-name: detstudio;
}

.det-studio {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(0, 0.92fr);
  gap: 1rem;
  align-items: start;
}

@container detstudio (max-width: 820px) {
  .det-studio {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .det-studio {
    grid-template-columns: minmax(0, 1fr);
  }
}

.det-stage-col,
.det-side-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-inline-size: 0;
}

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

.det-card h2,
.det-card h3 {
  margin: 0 0 0.55rem;
  padding: 0;
  border: 0;
  font-size: 0.98rem;
}

/* Canvas frames */
.det-canvas-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-block-size: 200px;
}

.det-canvas-frame.is-dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.det-canvas-frame canvas {
  display: block;
  max-inline-size: 100%;
  max-block-size: 520px;
  inline-size: auto;
  block-size: auto;
}

.det-canvas-frame canvas.is-interactive {
  cursor: pointer;
}

.det-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 720px) {
  .det-compare-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.det-compare-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.55rem;
  min-inline-size: 0;
}

.det-compare-pane h3 {
  margin: 0 0 0.4rem;
  font-size: 0.86rem;
}

.det-compare-pane canvas {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border-radius: calc(var(--radius-sm) - 3px);
}

/* Toolbars & segmented controls */
.det-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.det-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.det-seg button {
  background: var(--bg-raised);
  color: var(--color);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
}

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

/* Clean hairline upload button (ZERO dashed borders) */
.det-upload-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
}

.det-upload-btn:hover {
  border-color: var(--accent);
}

.det-upload-btn:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.det-upload-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

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

/* Slider fields with accessible >= 44px hit height */
.det-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-block-end: 0.55rem;
}

.det-field:last-child {
  margin-block-end: 0;
}

.det-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.det-field-head output {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

.det-field input[type="range"] {
  inline-size: 100%;
  block-size: 44px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Preset sample strip */
.sample-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.45rem;
}

.sample-btn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--color);
  text-align: left;
  cursor: pointer;
  min-inline-size: 0;
}

.sample-btn img {
  display: block;
  inline-size: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: calc(var(--radius-sm) - 4px);
  background: var(--bg-raised);
}

.sample-btn .sample-lbl {
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* Telemetry metrics grid */
.det-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

@media (max-width: 520px) {
  .det-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

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

.det-metric strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.94rem;
  color: var(--color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.det-metric strong.is-good {
  color: var(--good);
}

.det-metric strong.is-warn {
  color: var(--warn);
}

.det-metric strong.is-bad {
  color: var(--bad);
}

/* Box inspector list & tables */
.det-box-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-block-size: 320px;
  overflow-y: auto;
}

.det-box-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--color);
  text-align: left;
  cursor: pointer;
}

.det-box-row[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised));
}

.det-table-wrap {
  overflow-x: auto;
  max-inline-size: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.det-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.det-table caption {
  text-align: left;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.det-table th,
.det-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.det-table th {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  background: var(--bg-secondary);
  white-space: nowrap;
}

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

/* Architectural status badge (rectangular radius, no full-pill rounding) */
.det-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  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;
}

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

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

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

/* Cropped text-box gallery (practical/) & line crop thumbnails (multi-model/) */
.det-crop-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.6rem;
}

.det-crop-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-inline-size: 0;
}

.det-crop-card img {
  display: block;
  max-inline-size: 100%;
  block-size: 40px;
  object-fit: contain;
  object-position: left center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
}

.det-crop-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
}

/* Inline crop thumbnail inside multi-model table */
.det-inline-crop {
  display: block;
  max-inline-size: 150px;
  block-size: 28px;
  object-fit: contain;
  object-position: left center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px;
}

/* SVG ablation chart (basics/) */
.det-chart-svg {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.det-chart-bg {
  fill: var(--bg-secondary);
}

.det-chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

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

.det-chart-line-raw {
  fill: none;
  stroke: var(--warn);
  stroke-width: 2.2;
}

.det-chart-line-box {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
}

.det-chart-dot-raw {
  fill: var(--warn);
  stroke: var(--bg-raised);
  stroke-width: 1.5;
}

.det-chart-dot-box {
  fill: var(--accent);
  stroke: var(--bg-raised);
  stroke-width: 1.5;
}

.det-chart-active {
  stroke: var(--good);
  stroke-width: 1.8;
}

/* Legend dots */
.det-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-block-start: 0.45rem;
}

.det-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.det-dot {
  display: inline-block;
  inline-size: 10px;
  block-size: 10px;
  border-radius: 2px;
}

.det-dot-accent {
  background: var(--accent);
}

.det-dot-warn {
  background: var(--warn);
}

.det-dot-good {
  background: var(--good);
}

/* See-inside grid, runtime contract dl, ladder cards, stage cards */
.det-inside-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-block-start: 0.75rem;
}

@media (max-width: 760px) {
  .det-inside-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.det-heatmap-canvas {
  display: block;
  inline-size: 100%;
  block-size: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.det-kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.82rem;
}

.det-kv dt {
  font-family: var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
}

.det-kv dd {
  margin: 0;
  color: var(--color);
  overflow-wrap: anywhere;
}

.det-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-block-start: 0.75rem;
}

.det-ladder-card {
  display: block;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  text-decoration: none;
  color: var(--color);
  min-block-size: 44px;
}

.det-ladder-card:hover {
  border-color: var(--accent);
}

.det-ladder-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.96rem;
  color: var(--accent);
}

.det-ladder-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

.det-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-block-start: 0.75rem;
}

@media (max-width: 760px) {
  .det-stage-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

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

/* Progress bar for Practical batch queue */
.det-progress {
  inline-size: 100%;
  block-size: 10px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-block: 0.45rem;
}

.det-progress-fill {
  block-size: 100%;
  inline-size: 0%;
  background: var(--accent);
  transition: inline-size 0.15s ease;
}

/* Transcript block on multi-model */
.det-transcript {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-block-size: 72px;
}
