:root {
  --paper: #ebe1c8;
  --shell: #d4c7ab;
  --shell-dark: #8f8268;
  --shell-edge: #4d4839;
  --screen-frame: #384039;
  --screen-bg: #9aa66a;
  --screen-deep: #5e6e42;
  --ink: #201d16;
  --muted: #5b5648;
  --accent: #cf6f2f;
  --accent-dark: #8c4314;
  --olive: #687a36;
  --olive-bright: #98ad4f;
  --cream: #f8f1df;
  --grid-line: rgba(77, 72, 57, 0.16);
}

* {
  box-sizing: border-box;
}

html[data-debug-ui="off"] .debug-only {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(
      0deg,
      rgba(77, 72, 57, 0.05) 0,
      rgba(77, 72, 57, 0.05) 2px,
      transparent 2px,
      transparent 18px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(77, 72, 57, 0.04) 0,
      rgba(77, 72, 57, 0.04) 2px,
      transparent 2px,
      transparent 18px
    ),
    linear-gradient(180deg, #f6efdc 0%, var(--paper) 48%, #ded2b8 100%);
}

code,
.eyebrow,
.panel-kicker,
.field span,
.auth-label,
.console-badge,
.console-label,
.hero-tags span,
.history-item .stamp,
.status,
.links,
button,
input,
select {
  font-family: "Courier Prime", "Menlo", "Monaco", monospace;
}

.page-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background:
    linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 21px,
      rgba(77, 72, 57, 0.06) 21px,
      rgba(77, 72, 57, 0.06) 22px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 21px,
      rgba(77, 72, 57, 0.04) 21px,
      rgba(77, 72, 57, 0.04) 22px
    );
}

.shell {
  position: relative;
  width: min(1240px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 250, 239, 0.92), rgba(236, 227, 204, 0.96)),
    var(--shell);
  border: 3px solid var(--shell-edge);
  border-radius: 0;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.5) inset,
    0 -4px 0 rgba(77, 72, 57, 0.12) inset,
    10px 10px 0 rgba(62, 51, 28, 0.18);
}

.hero,
.controls,
.result,
.history {
  animation: rise-in 420ms ease both;
}

.hero {
  display: grid;
  gap: 22px;
  padding: 26px;
  margin-bottom: 20px;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -26px -34px auto;
  width: 180px;
  height: 180px;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.2), transparent 60%),
    linear-gradient(145deg, var(--olive-bright), var(--olive));
  box-shadow: -10px -10px 0 rgba(77, 72, 57, 0.12);
  opacity: 0.9;
}

.hero-copy,
.hero-callout {
  position: relative;
  z-index: 1;
}

.eyebrow,
.panel-kicker,
.auth-label,
.console-label,
.console-badge {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Book Antiqua", Georgia, serif;
  font-weight: 700;
}

h1 {
  font-size: clamp(2.7rem, 7vw, 5.6rem);
  line-height: 0.9;
  max-width: 7ch;
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.lede,
.panel-copy,
.callout-copy,
.auth-status {
  margin: 0;
  color: var(--muted);
}

.hero-link {
  margin: 14px 0 0;
}

.hero-link a {
  display: inline-grid;
  gap: 4px;
  min-width: min(100%, 320px);
  padding: 12px 14px;
  border: 2px solid var(--shell-edge);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(104, 122, 54, 0.12)),
    rgba(248, 241, 223, 0.82);
  color: var(--ink);
  text-decoration: none;
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.4) inset,
    4px 4px 0 rgba(77, 72, 57, 0.14);
}

.hero-link a:hover {
  transform: translate(-1px, -1px);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.4) inset,
    5px 5px 0 rgba(77, 72, 57, 0.14);
}

.hero-link-label,
.hero-link-value {
  display: block;
}

.hero-link-label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-link-value {
  font-family: "Courier Prime", "Menlo", "Monaco", monospace;
  font-size: 0.95rem;
  color: var(--accent-dark);
  word-break: break-word;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hero-tags span {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border: 2px solid rgba(77, 72, 57, 0.2);
  border-radius: 0;
  background: rgba(255, 253, 248, 0.6);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-callout {
  max-width: 25rem;
  padding: 18px;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(104, 122, 54, 0.16), rgba(255, 255, 255, 0.25)),
    rgba(248, 241, 223, 0.76);
  border: 2px solid rgba(77, 72, 57, 0.2);
}

.callout-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--olive);
}

.guide-title {
  margin: 0 0 8px;
  font-family: "Iowan Old Style", "Book Antiqua", Georgia, serif;
  font-size: 1.2rem;
}

.workbench {
  display: grid;
  gap: 20px;
}

.controls,
.history {
  padding: 22px;
}

.panel-head {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.controls {
  align-self: start;
}

.auth-strip {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(104, 122, 54, 0.12)),
    rgba(248, 241, 223, 0.75);
  border: 2px solid rgba(77, 72, 57, 0.16);
}

.auth-actions,
.control-grid,
.control-foot {
  display: grid;
  gap: 10px;
}

.control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.field {
  display: grid;
  gap: 5px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
select,
button {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--shell-edge);
  border-radius: 0;
  font-size: 0.95rem;
  background: rgba(255, 252, 245, 0.96);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.45) inset;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(152, 173, 79, 0.32);
  outline-offset: 2px;
}

button {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #fff7ef;
  background:
    linear-gradient(180deg, #dd8744 0%, var(--accent) 55%, var(--accent-dark) 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.2) inset,
    0 4px 0 rgba(100, 46, 12, 0.22);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button:hover {
  filter: saturate(1.05);
}

button:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.2) inset,
    0 2px 0 rgba(100, 46, 12, 0.22);
}

button.secondary {
  color: var(--ink);
  background:
    linear-gradient(180deg, #f1ead7 0%, #dfd2b7 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.45) inset,
    0 4px 0 rgba(77, 72, 57, 0.12);
}

.checkbox {
  align-content: end;
}

.checkbox input {
  width: 24px;
  height: 24px;
}

.strict-only input:disabled {
  opacity: 0.45;
}

.control-foot {
  align-items: center;
  margin-top: 18px;
  position: sticky;
  bottom: -2px;
  z-index: 4;
  padding: 12px 0 0;
  background:
    linear-gradient(180deg, rgba(235, 225, 200, 0), rgba(235, 225, 200, 0.96) 30%, rgba(235, 225, 200, 1) 100%);
}

.status {
  margin: 0;
  min-height: 1.2rem;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.display-stack {
  display: grid;
  gap: 20px;
}

.compare-panel {
  padding: 22px;
}

.compare-grid {
  display: grid;
  gap: 14px;
}

.compare-card {
  margin: 0;
  display: grid;
  gap: 8px;
}

.compare-card figcaption {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.compare-card img {
  width: 100%;
  min-height: 180px;
  border: 3px solid var(--shell-edge);
  background:
    linear-gradient(180deg, var(--screen-bg), var(--screen-deep));
  image-rendering: pixelated;
}

#compare-source:not([src]),
#compare-source[src=""],
#compare-pixel:not([src]),
#compare-pixel[src=""] {
  opacity: 0;
}

.console {
  padding: 24px;
  background:
    linear-gradient(180deg, #d6c8aa 0%, #c5b794 100%);
  border-radius: 0;
}

.console-screen-frame {
  position: relative;
  padding: 18px;
  border-radius: 0;
  background:
    linear-gradient(180deg, #585e58 0%, #262b26 100%);
  box-shadow:
    0 4px 0 rgba(255, 255, 255, 0.12) inset,
    0 -4px 0 rgba(0, 0, 0, 0.18) inset;
}

.console-screen {
  position: relative;
  overflow: hidden;
  aspect-ratio: 10 / 9;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 3px solid #192014;
  border-radius: 0;
  background:
    radial-gradient(circle at top, rgba(223, 240, 133, 0.18), transparent 32%),
    linear-gradient(180deg, var(--screen-bg), var(--screen-deep));
}

.console-screen::before {
  content: "NO SIGNAL YET";
  position: absolute;
  inset: auto 0 22px;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(35, 46, 25, 0.56);
}

.console-screen.has-image {
  aspect-ratio: auto;
  min-height: 280px;
}

.console-screen.has-image::before {
  display: none;
}

#preview[src] + * {
  display: block;
}

#preview {
  position: relative;
  z-index: 2;
  max-width: min(100%, 540px);
  width: 100%;
  image-rendering: pixelated;
  filter: saturate(0.9) contrast(1.04);
}

#preview:not([src]),
#preview[src=""] {
  opacity: 0;
}

.screen-raster {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(20, 30, 12, 0.1) 0,
      rgba(20, 30, 12, 0.1) 2px,
      transparent 2px,
      transparent 6px
    );
  mix-blend-mode: multiply;
  animation: scan 5s linear infinite;
}

.console-meta {
  margin-top: 16px;
}

.console-label {
  color: var(--shell-dark);
}

.links {
  margin: 0;
  line-height: 1.8;
}

.links a {
  color: var(--accent-dark);
  text-decoration-thickness: 2px;
}

.console-controls {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 28px;
  align-items: center;
  margin-top: 26px;
}

.dpad {
  position: relative;
  width: 92px;
  height: 92px;
}

.dpad::before,
.dpad::after,
.dpad span {
  content: "";
  position: absolute;
  background: linear-gradient(180deg, #504a3e 0%, #2b281f 100%);
  border-radius: 0;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.08) inset;
}

.dpad::before {
  top: 30px;
  left: 0;
  right: 0;
  height: 32px;
}

.dpad::after {
  left: 30px;
  top: 0;
  bottom: 0;
  width: 32px;
}

.dpad span {
  top: 30px;
  left: 30px;
  width: 32px;
  height: 32px;
}

.action-buttons {
  display: flex;
  gap: 18px;
  align-items: center;
}

.action-buttons span {
  width: 28px;
  height: 28px;
  border-radius: 0;
  background: linear-gradient(180deg, #b55855 0%, #873232 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.12) inset,
    0 4px 0 rgba(91, 29, 29, 0.18);
  transform: rotate(45deg);
}

.speaker-grill {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.speaker-grill span {
  width: 10px;
  height: 56px;
  border-radius: 0;
  background: rgba(77, 72, 57, 0.26);
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.history-head button {
  width: auto;
  min-width: 130px;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-item {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 2px solid rgba(77, 72, 57, 0.18);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(235, 225, 200, 0.9)),
    var(--cream);
}

.history-item::before {
  content: "";
  position: absolute;
  inset: 12px 14px auto auto;
  width: 54px;
  height: 10px;
  border-radius: 999px;
  background: rgba(77, 72, 57, 0.14);
}

.history-item img {
  width: 100%;
  max-width: 220px;
  border: 3px solid var(--shell-edge);
  border-radius: 0;
  background:
    linear-gradient(180deg, var(--screen-bg), var(--screen-deep));
  image-rendering: pixelated;
}

.history-item p {
  margin: 0 0 7px;
}

.history-item strong {
  font-family: "Iowan Old Style", "Book Antiqua", Georgia, serif;
  font-size: 1.15rem;
}

.history-item .links {
  text-align: left;
}

.history-item .stamp {
  display: inline-flex;
  padding: 5px 8px;
  margin-bottom: 8px;
  border-radius: 0;
  background: rgba(104, 122, 54, 0.12);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--olive);
}

.panel::before,
.history-item::after,
.hero-callout::before,
.auth-strip::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--shell-edge);
}

.panel::before {
  top: -3px;
  left: -3px;
}

.history-item::after {
  right: -2px;
  bottom: -2px;
}

.hero-callout::before {
  top: -2px;
  right: -2px;
}

.auth-strip::before {
  left: -2px;
  bottom: -2px;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scan {
  from {
    transform: translateY(-12px);
  }
  to {
    transform: translateY(12px);
  }
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
    align-items: end;
  }

  .workbench {
    grid-template-columns: minmax(460px, 540px) minmax(0, 1fr);
    align-items: start;
  }

  .controls {
    position: sticky;
    top: 18px;
  }

  .auth-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
  }

  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .control-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 899px) {
  .shell {
    width: min(100vw - 18px, 960px);
    padding-top: 18px;
  }

  .hero::after {
    width: 160px;
    height: 160px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .console-controls {
    grid-template-columns: auto auto;
  }

  .speaker-grill {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .hero,
  .controls,
  .result,
  .history {
    border-radius: 0;
  }

  .console {
    border-radius: 0;
  }

  .console-screen-frame {
    padding: 12px;
    border-radius: 0;
  }

  .console-screen {
    min-height: 220px;
  }

  .history-head {
    align-items: stretch;
  }

  .history-head button {
    width: 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }
}
