/* Shared stylesheet for Gemma 4 E2B Instruct QAT Mobile (models/gemma-4-e2b-it-qat-mobile-onnx/).
   Design tokens from public/styles.css ONLY:
   - zero raw hex literals, solid borders only, bounded corner radii (no pill soup)
   - semantic --good / --bad / --warn / --accent tokens
   - explicit [hidden] { display: none !important; }
   - >= 44x44px hit targets on every interactive control at 1280x800, 390x844, 360x740
   - container queries for card grids (modern-web-guidance: css-layout, size-aware-styling) */

[hidden] {
  display: none !important;
}

button,
.button,
select,
input[type="range"],
input[type="file"],
input[type="text"],
textarea,
summary,
.ladder-nav a,
.crumbs a,
footer a,
.g4-upload,
.g4-chip,
.g4-sample {
  min-block-size: 44px;
  min-inline-size: 44px;
}

.crumbs a,
footer a,
.glance a,
section[aria-labelledby="ref-h"] a,
details.show-code .sc-meta a {
  display: inline-flex;
  align-items: center;
  min-block-size: 44px;
  min-inline-size: 44px;
}

input[type="range"] {
  inline-size: 100%;
  accent-color: var(--accent);
}

main {
  container-type: inline-size;
}

.g4-notice {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-inline-start: 4px solid var(--warn);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.g4-notice.is-good {
  border-inline-start-color: var(--good);
}

.g4-notice.is-bad {
  border-inline-start-color: var(--bad);
}

.g4-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0.65rem 0;
}

.g4-field {
  display: grid;
  gap: 0.3rem;
  flex: 1 1 13rem;
  min-inline-size: 0;
  font-size: 0.85rem;
}

.g4-field label {
  font-weight: 600;
}

.g4-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 44px;
  padding: 0 0.4rem;
  font-size: 0.88rem;
  cursor: pointer;
}

.g4-textarea {
  inline-size: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  resize: vertical;
}

.g4-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

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

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

.g4-drop {
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  transition: border-color 0.15s ease;
}

.g4-drop.is-dragover {
  border-color: var(--accent);
}

.g4-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.65rem 0;
}

.g4-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.85rem;
  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: 600;
  cursor: pointer;
}

.g4-chip[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.g4-chip small {
  color: var(--muted);
  font-weight: 500;
}

.g4-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin: 0.85rem 0;
}

@container (min-width: 760px) {
  .g4-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .g4-grid.is-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

.g4-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.g4-card h4 {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.9rem;
}

.g4-canvas-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.g4-canvas-wrap canvas {
  display: block;
  inline-size: 100%;
  block-size: auto;
}

canvas.g4-wave {
  display: block;
  inline-size: 100%;
  block-size: 96px;
}

.g4-caption {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.g4-output {
  min-block-size: 6rem;
  max-block-size: 22rem;
  overflow: auto;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.g4-output p {
  margin: 0 0 0.5rem;
}

.g4-output ul,
.g4-output ol {
  margin: 0 0 0.5rem;
  padding-inline-start: 1.3rem;
}

.g4-output.is-mono,
.g4-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.g4-think {
  margin: 0 0 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.g4-think summary {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
}

.g4-think pre {
  margin: 0;
  padding: 0.5rem 0.75rem 0.75rem;
  max-block-size: 14rem;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.78rem;
  color: var(--muted);
}

.g4-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.5rem;
  margin: 0.85rem 0;
}

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

.g4-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.g4-metric strong {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.g4-tokbar {
  display: flex;
  block-size: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.g4-tokseg {
  display: block;
  block-size: 100%;
  min-inline-size: 3px;
}

.g4-tokseg.is-text,
.g4-key.is-text {
  background: var(--muted);
}

.g4-tokseg.is-image,
.g4-key.is-image {
  background: var(--accent);
}

.g4-tokseg.is-audio,
.g4-key.is-audio {
  background: var(--good);
}

.g4-toklegend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin: 0.4rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.g4-key {
  display: inline-block;
  inline-size: 12px;
  block-size: 12px;
  border-radius: 3px;
}

.g4-bar-row {
  margin: 0 0 0.55rem;
}

.g4-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.g4-bar-head strong {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: end;
}

.g4-bar-track {
  block-size: 10px;
  margin-top: 0.25rem;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.g4-bar-fill {
  block-size: 100%;
  background: var(--accent);
}

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

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

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

.g4-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.g4-table {
  inline-size: 100%;
  min-inline-size: 62rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.g4-table td {
  min-inline-size: 5.5rem;
  overflow-wrap: break-word;
  word-break: normal;
}

.g4-table td .g4-pill,
.g4-table td.num {
  white-space: nowrap;
}

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

.g4-table th {
  background: var(--bg-secondary);
  font-weight: 700;
  white-space: nowrap;
}

.g4-table td.num {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.g4-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid var(--border-strong);
}

.g4-pill.is-good {
  color: var(--good);
  border-color: var(--good);
}

.g4-pill.is-warn {
  color: var(--warn);
  border-color: var(--warn);
}

.g4-pill.is-bad {
  color: var(--bad);
  border-color: var(--bad);
}

.g4-sample {
  display: grid;
  gap: 0.2rem;
  justify-items: start;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--color);
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.g4-sample[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.g4-sample strong {
  font-size: 0.86rem;
}

.g4-sample span {
  color: var(--muted);
  font-size: 0.74rem;
}

.g4-ladder {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.7rem;
}

.g4-ladder a {
  display: block;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: inherit;
  text-decoration: none;
}

.g4-ladder a:hover,
.g4-ladder a:focus-visible {
  border-color: var(--accent);
}

.g4-ladder h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
}

.g4-ladder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.g4-deferred {
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}

.stage-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

@container (min-width: 760px) {
  .stage-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.g4-stage-meta {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.g4-progress {
  inline-size: 100%;
  block-size: 12px;
  accent-color: var(--accent);
}

.glance {
  inline-size: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.glance th,
.glance td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.glance th {
  inline-size: 30%;
}

.glance caption {
  caption-side: bottom;
  padding-top: 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: start;
}

@media (max-width: 520px) {
  .glance th,
  .glance td {
    display: block;
    inline-size: auto;
    border-bottom: 0;
    padding: 0.2rem 0;
  }
  .glance tr {
    display: block;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
  }
  .g4-toolbar > button,
  .g4-toolbar > .g4-upload {
    flex: 1 1 auto;
  }
}
