/* CSV ALCHEMIST — style.css
   The Lab: dark arcade / retro-terminal. Pixel type (Press Start 2P) for the
   title, panel tabs and HUD labels; clean mono/sans for working surfaces.
   Tokens mirror /lab.css so the app feels native to the arcade. */

/* ---------- fonts (self-hosted, shared with the lab root) ---------- */
@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;

  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --surface-3: #20203030;
  --line: #28283c;
  --control-line: #5e5e80; /* >=3:1 against --surface for field boundaries */
  --text: #e9e9f2;
  --dim: #9aa0b5;

  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --glow-magenta: 0 0 14px rgba(255, 61, 139, 0.4);
  --glow-gold: 0 0 14px rgba(255, 200, 87, 0.35);

  --shadow-panel: 0 18px 40px rgba(0, 0, 0, 0.5);
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

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

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 520px at 50% -8%, rgba(69, 240, 255, 0.06), transparent 68%),
    radial-gradient(900px 520px at 100% 110%, rgba(255, 61, 139, 0.05), transparent 70%),
    var(--bg);
}

::selection { background: rgba(69, 240, 255, 0.3); color: #05050d; }

[hidden] { display: none !important; }

a { color: var(--cyan); }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.18);
  border-radius: 3px;
}

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

/* ---------- global scanline / CRT atmosphere ---------- */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.05) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* CRT mode — toggled on <body> by app.js */
body.crt::before {
  content: "";
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
body.crt::after {
  content: "";
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.42) 100%);
  box-shadow:
    inset 0 0 130px rgba(69, 240, 255, 0.07),
    inset 6px 0 30px rgba(255, 61, 139, 0.05),
    inset -6px 0 30px rgba(69, 240, 255, 0.06);
}

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  left: 12px; top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-out);
}
.skip-link:focus { transform: translateY(64px); }

/* ---------- fixed back-to-lab link ---------- */
.lab-fixed {
  position: fixed;
  top: clamp(0.75rem, 2vw, 1.25rem);
  left: clamp(0.75rem, 2vw, 1.25rem);
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--text);
  text-decoration: none;
  padding: 0.7rem 0.85rem;
  background: rgba(10, 10, 18, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) ease;
}
.lab-fixed:hover,
.lab-fixed:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  transform: translateX(-3px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), var(--glow-cyan);
}

/* ---------- header ---------- */
.app-header {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: clamp(0.75rem, 2vw, 1.1rem);
  text-align: center;
  max-width: 56rem;
  margin: 0 auto;
  padding: clamp(4.5rem, 9vw, 6.5rem) var(--gutter) clamp(1.5rem, 4vw, 2.5rem);
}

.level-tag {
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(8px, 1.7vw, 10px);
  letter-spacing: 0.22em;
  color: var(--gold);
  text-shadow: var(--glow-gold);
}

.title {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(1.6rem, 0.6rem + 6.2vw, 3.75rem);
  line-height: 1.18;
  letter-spacing: 0.01em;
  color: var(--text);
  text-shadow: 0 0 18px rgba(69, 240, 255, 0.4), 0 0 52px rgba(69, 240, 255, 0.16);
}

/* glitch hover on the pixel title */
.glitch { position: relative; }
.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  text-shadow: none;
}
.glitch::before { color: var(--cyan); }
.glitch::after { color: var(--magenta); }
.glitch:hover::before { animation: glitch-a 0.42s steps(3, jump-none) 1; }
.glitch:hover::after { animation: glitch-b 0.42s steps(3, jump-none) 1; }

@keyframes glitch-a {
  0%   { opacity: 0.85; clip-path: inset(8% 0 72% 0);  transform: translate3d(-5px, -2px, 0); }
  33%  { opacity: 0.85; clip-path: inset(54% 0 22% 0); transform: translate3d(4px, 1px, 0); }
  66%  { opacity: 0.85; clip-path: inset(28% 0 50% 0); transform: translate3d(-3px, 2px, 0); }
  100% { opacity: 0;    clip-path: inset(45% 0 45% 0); transform: none; }
}
@keyframes glitch-b {
  0%   { opacity: 0.85; clip-path: inset(64% 0 16% 0); transform: translate3d(5px, 2px, 0); }
  33%  { opacity: 0.85; clip-path: inset(12% 0 70% 0); transform: translate3d(-4px, -1px, 0); }
  66%  { opacity: 0.85; clip-path: inset(42% 0 36% 0); transform: translate3d(3px, -2px, 0); }
  100% { opacity: 0;    clip-path: inset(45% 0 45% 0); transform: none; }
}

.tagline {
  margin: 0;
  max-width: 40rem;
  color: var(--dim);
  font-size: clamp(0.95rem, 0.9rem + 0.5vw, 1.15rem);
}

.ink { font-weight: 700; }
.ink--cyan { color: var(--cyan); }
.ink--magenta { color: var(--magenta); }
.ink--gold { color: var(--gold); }
.ink--green { color: var(--green); }

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
}
.badge--green { color: var(--green); border-color: rgba(65, 255, 139, 0.4); }
.badge__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(65, 255, 139, 0.8);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- app shell / responsive layout ---------- */
.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  width: min(100%, 84rem);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(2rem, 5vw, 3.5rem);
}

/* ---------- panel ---------- */
.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 65%);
  box-shadow: var(--shadow-panel);
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
}

/* thin top accent rail per panel — colour set by modifier */
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--cyan), transparent 70%);
  opacity: 0.85;
}
.transform-panel::before { background: linear-gradient(90deg, var(--magenta), transparent 70%); }
.output-panel::before { background: linear-gradient(90deg, var(--gold), transparent 70%); }
.preview-panel::before { background: linear-gradient(90deg, var(--green), transparent 70%); }

.panel-heading {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.panel-title-block {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.panel-tab {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.1rem; height: 2.1rem;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--bg);
  background: var(--cyan);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 14px rgba(69, 240, 255, 0.35);
}
.panel-tab--magenta { background: var(--magenta); box-shadow: var(--glow-magenta); }
.panel-tab--gold { background: var(--gold); box-shadow: var(--glow-gold); }
.panel-tab--green { background: var(--green); box-shadow: 0 0 14px rgba(65, 255, 139, 0.35); }

h1, h2, h3, p { margin-top: 0; }

h2 {
  margin: 0 0 0.15rem;
  font-family: var(--mono);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

h3 {
  margin: 0 0 0.2rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.hint {
  margin: 0;
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* status pill */
.status-text {
  justify-self: start;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--cyan);
  background: rgba(69, 240, 255, 0.08);
  border: 1px solid rgba(69, 240, 255, 0.3);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
}

/* ---------- form fields ---------- */
.field,
.check-field {
  display: grid;
  gap: 0.4rem;
}

.field-label,
.field > span,
.check-field > span {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

textarea, input, select {
  width: 100%;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-sm);
  background: #0c0c16;
  color: var(--text);
  transition: border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}

textarea { resize: vertical; }

select, input[type="text"] {
  min-height: 2.85rem;
  padding: 0.55rem 0.75rem;
}

textarea:hover:not(:disabled),
input:hover:not(:disabled),
select:hover:not(:disabled) { border-color: var(--cyan); }

textarea:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(69, 240, 255, 0.2);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-style: dashed;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(1.15rem),
    calc(100% - 13px) calc(1.15rem);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

/* ---------- drop zone ---------- */
.drop-zone {
  display: grid;
  gap: 0.75rem;
  border: 1px dashed var(--control-line);
  border-radius: var(--radius-sm);
  background: rgba(10, 10, 18, 0.4);
  padding: 0.85rem;
  transition: border-color var(--duration-fast) ease,
    background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}
.drop-zone.is-dragging {
  border-color: var(--cyan);
  border-style: solid;
  background: rgba(69, 240, 255, 0.07);
  box-shadow: inset 0 0 30px rgba(69, 240, 255, 0.12), var(--glow-cyan);
}

.source-input,
.output-text {
  min-height: 15rem;
  padding: 0.9rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
}
.output-text {
  min-height: 19rem;
  color: var(--green);
}

/* ---------- buttons ---------- */
.input-actions,
.output-actions,
.column-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.85rem;
  min-width: 2.85rem;
  border: 1px solid var(--control-line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}
.button__glyph { font-size: 1em; line-height: 1; }

.button:hover:not(:disabled) {
  border-color: var(--cyan);
  color: var(--cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), var(--glow-cyan);
}
.button:active:not(:disabled) { transform: translateY(0); }

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button-secondary { background: transparent; color: var(--dim); }
.button-secondary:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 14px rgba(255, 85, 96, 0.3);
}

.button-primary {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 18px rgba(255, 200, 87, 0.25);
}
.button-primary:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), 0 0 26px rgba(255, 200, 87, 0.5);
}

.file-button { cursor: pointer; }

/* ---------- control grid ---------- */
.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
}

/* ---------- checkboxes ---------- */
.check-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.85rem;
}
.check-field > span {
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 0.85rem;
  color: var(--text);
}
.check-field input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  accent-color: var(--cyan);
  cursor: pointer;
}

/* ---------- column controls ---------- */
.column-section { margin-top: 1.25rem; }
.section-heading { margin-bottom: 0.85rem; }

.column-controls {
  display: grid;
  gap: 0.5rem;
}

.column-empty {
  margin: 0;
  padding: 0.85rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--dim);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.column-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(10, 10, 18, 0.4);
  padding: 0.55rem 0.65rem;
  transition: border-color var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}
.column-item:hover { border-color: var(--control-line); background: rgba(69, 240, 255, 0.04); }

.column-item .check-field { min-height: 0; }

.column-name {
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.icon-button {
  width: 2.6rem;
  min-width: 2.6rem;
  padding: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* ---------- error ---------- */
.error-text {
  margin: 1rem 0 0;
  border: 1px solid var(--red);
  border-left: 4px solid var(--red);
  border-radius: var(--radius-sm);
  background: rgba(255, 85, 96, 0.08);
  color: var(--red);
  padding: 0.8rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- output field ---------- */
.output-field { margin-top: 1rem; }

/* ---------- table preview ---------- */
.table-preview {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0c0c16;
  min-height: 8rem;
  max-height: 30rem;
}

.table-preview table {
  width: 100%;
  min-width: 34rem;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.table-preview th,
.table-preview td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.table-preview th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: inset 0 -1px 0 var(--line);
}

.table-preview tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.018); }
.table-preview tbody tr:hover td { background: rgba(69, 240, 255, 0.06); }

.table-preview td {
  max-width: 24rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: var(--text);
}

.empty-state {
  margin: 0;
  padding: 1.25rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--dim);
}

/* ---------- footer ---------- */
.app-footer {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: clamp(2rem, 5vw, 3.5rem) var(--gutter) clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer__copy {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.footer__blink { display: inline-block; color: var(--gold); animation: blink 2.2s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

.footer__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.footer__link {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--dim);
  text-decoration-color: var(--line);
  transition: color var(--duration-fast) ease;
}
.footer__link:hover { color: var(--cyan); }

.footer__crt {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.85rem;
  cursor: pointer;
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}
.footer__crt:hover { color: var(--cyan); border-color: var(--cyan); }
.footer__crt[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(65, 255, 139, 0.35);
}

.footer__flavor {
  margin: 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--gold);
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: min(20rem, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.85;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 200, 87, 0.18);
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}
.toast--cyan { border-color: var(--cyan); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(69, 240, 255, 0.2); }
.toast--red { border-color: var(--red); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 85, 96, 0.2); }
.toast--in { opacity: 1; transform: none; }
.toast--out { opacity: 0; transform: translate3d(0, -10px, 0); }

/* ---------- responsive ---------- */
@media (min-width: 700px) {
  .panel-heading {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
  .source-panel,
  .transform-panel { grid-column: 1; }
  .output-panel,
  .preview-panel { grid-column: 2; }
}

@media (min-width: 1280px) {
  .app-shell {
    grid-template-columns: minmax(0, 1.05fr) minmax(24rem, 0.95fr);
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .glitch:hover::before,
  .glitch:hover::after { animation: none !important; opacity: 0 !important; }
  .button:hover:not(:disabled),
  .lab-fixed:hover,
  .lab-fixed:focus-visible,
  .button-primary:hover:not(:disabled) { transform: none; }
}
