:root {
  --bg: #f8f7f3;
  --bg-center: #fdfcf9;
  --bg-edge: #efede6;
  --ink: #161614;
  --ink-tld: #615e56;
  --ink-muted: #8a867c;
  --accent: #d94826;
  --accent-soft: rgba(217, 72, 38, 0.14);
  --grid-dot: rgba(22, 22, 20, 0.07);
  --hairline: rgba(22, 22, 20, 0.09);
  --kbd-bg: rgba(252, 251, 248, 0.78);
  --kbd-border: rgba(22, 22, 20, 0.13);
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #0c0d0f;
  --bg-center: #14161b;
  --bg-edge: #08090b;
  --ink: #f0eee6;
  --ink-tld: #918e85;
  --ink-muted: #6e6c65;
  --accent: #ff633e;
  --accent-soft: rgba(255, 99, 62, 0.18);
  --grid-dot: rgba(240, 238, 230, 0.055);
  --hairline: rgba(240, 238, 230, 0.1);
  --kbd-bg: rgba(20, 22, 26, 0.78);
  --kbd-border: rgba(240, 238, 230, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
}

body {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 75% 65% at 50% 48%, var(--bg-center) 0%, var(--bg-edge) 100%);
  color: var(--ink);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.45s ease, color 0.35s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Subtle drafting dot-matrix field */
.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 72% at 50% 50%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 72% at 50% 50%, #000 35%, transparent 100%);
}

/* Corner registration marks */
.crop-marks {
  position: fixed;
  inset: clamp(14px, 2.5vw, 28px);
  pointer-events: none;
  z-index: 1;
}

.crop {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--hairline);
  border-style: solid;
  border-width: 0;
}

.crop--tl { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.crop--tr { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.crop--bl { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.crop--br { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

/* Header metadata bar */
.specimen-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(20px, 3.2vw, 36px) clamp(24px, 4vw, 48px) 0;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  user-select: none;
}

.header-group {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 500;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transition: background-color 0.35s ease, box-shadow 0.35s ease;
}

/* Main Stage */
.stage {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 2rem clamp(12px, 3vw, 40px);
}

.specimen-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.5rem, 4vh, 2.75rem);
}

/* Interactive ASCII grid (ligatures disabled to preserve alignment) */
.ascii-stage {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0.6em 0.8em;
  font-family: var(--font-mono);
  font-size: clamp(0.46rem, 2.45vw, 1.35rem);
  line-height: 1.18;
  letter-spacing: 0;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "dlig" 0;
  white-space: pre;
  user-select: none;
  cursor: pointer;
  outline: none;
  border-radius: 12px;
  touch-action: none;
}

.ascii-stage:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.ascii-row {
  display: block;
  height: 1.18em;
}

.ascii-cell {
  display: inline-block;
  width: 1ch;
  text-align: center;
  color: var(--ink);
  will-change: transform, color;
  transition: color 0.16s ease;
}

.ascii-cell--space {
  pointer-events: none;
}

.ascii-cell--tld {
  color: var(--ink-tld);
}

.ascii-cell--dot {
  color: var(--accent);
  font-weight: 600;
}

.ascii-cell.is-hot {
  color: var(--accent);
}

.ascii-cell.is-scrambling {
  color: var(--accent);
  opacity: 0.88;
}

/* Whisper caption below wordmark */
.specimen-caption {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  opacity: 0.55;
  transition: opacity 0.35s ease;
  user-select: none;
}

.specimen-wrapper:hover .specimen-caption {
  opacity: 0.9;
}

/* Bottom-right text controls */
.specimen-footer {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 clamp(24px, 4vw, 48px) clamp(20px, 3.2vw, 36px);
  user-select: none;
}

.footer-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.footer-sep {
  opacity: 0.45;
}

.footer-action {
  appearance: none;
  border: 0;
  padding: 0.25rem 0.3rem;
  margin: -0.25rem -0.3rem;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: color 0.2s ease, transform 0.15s ease;
}

.footer-action:hover {
  color: var(--ink);
}

.footer-action:active {
  transform: scale(0.97);
}

.footer-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.footer-action kbd {
  display: inline-block;
  padding: 0.12rem 0.36rem;
  border: 1px solid var(--kbd-border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.625rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--kbd-bg);
  transition: border-color 0.2s ease;
}

.footer-action:hover kbd {
  border-color: var(--ink-muted);
}

.theme-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}

@media (max-width: 560px) {
  .specimen-header,
  .footer-controls {
    font-size: 0.62rem;
  }

  .footer-action kbd {
    display: none;
  }

  .specimen-caption {
    font-size: 0.58rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
