/* UTM SURGEON — Lab arcade chrome, scoped for a campaign-URL operating table. */

@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%;
}

:root {
  color-scheme: dark;

  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --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: 8px;
  --radius-sm: 5px;

  --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);
  --gutter: clamp(0.85rem, 4vw, 2.5rem);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

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

::selection {
  background: rgba(69, 240, 255, 0.3);
  color: var(--text);
}

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

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

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

: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;
}

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

/* ---------- skip + back-to-lab chrome ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-normal) var(--ease-out);
}
.skip-link:focus-visible {
  transform: translateY(68px);
}

.lab-link {
  position: fixed;
  top: clamp(0.6rem, 2vw, 1.1rem);
  left: clamp(0.6rem, 2vw, 1.1rem);
  z-index: 120;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.5rem 0.85rem;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-decoration: none;
  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);
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  border-color: var(--cyan);
  text-shadow: var(--glow-cyan);
  box-shadow: 0 0 18px rgba(69, 240, 255, 0.22);
  transform: translateX(-2px);
}

/* ---------- shell ---------- */
.app-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  padding: clamp(3.75rem, 9vw, 5.5rem) var(--gutter) clamp(3rem, 7vw, 5rem);
}

/* ---------- header / wordmark ---------- */
.app-header {
  display: grid;
  gap: 0.55rem;
  margin-bottom: clamp(1.75rem, 4.5vw, 2.75rem);
}

.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 200, 87, 0.3);
}

.wordmark {
  position: relative;
  margin: 0.1rem 0 0.2rem;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(1.4rem, 0.4rem + 6.2vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: 0.02em;
  color: var(--text);
  text-shadow: 0 0 22px rgba(69, 240, 255, 0.45), 3px 3px 0 var(--magenta);
}

/* layered chromatic ghost on the wordmark for arcade depth */
.wordmark::before,
.wordmark::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  z-index: -1;
}
.wordmark::before {
  color: var(--cyan);
  transform: translate(-2px, -1px);
  text-shadow: none;
}
.wordmark::after {
  color: var(--magenta);
  transform: translate(2px, 1px);
  text-shadow: none;
}

.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(0.78rem, 0.7rem + 0.4vw, 0.95rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.cursor {
  color: var(--cyan);
  margin-left: 0.15em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  max-width: 100%;
  margin: 0.7rem 0 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(65, 255, 139, 0.4);
  border-radius: 999px;
  background: rgba(65, 255, 139, 0.08);
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.privacy-badge__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(65, 255, 139, 0.8);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.78); }
}

/* ---------- panels ---------- */
.panel {
  position: relative;
  margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
  padding: clamp(1.05rem, 2.5vw, 1.6rem);
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 64%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

/* thin neon top-rail per panel role */
.panel::before {
  content: "";
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--rail, var(--cyan));
  box-shadow: 0 0 12px var(--rail, var(--cyan));
  opacity: 0.75;
}
.input-panel { --rail: var(--cyan); }
.parts-panel { --rail: var(--green); }
.preset-panel { --rail: var(--gold); }
.params-panel { --rail: var(--magenta); }
.output-panel { --rail: var(--gold); }
.compare-panel { --rail: var(--magenta); }

.section-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1.15rem;
}
.section-heading__title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.panel-tag {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 2.6rem;
  height: 1.6rem;
  padding: 0 0.5rem;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.04em;
  color: var(--bg);
  background: var(--cyan);
  border-radius: 3px;
  box-shadow: 0 0 14px rgba(69, 240, 255, 0.4);
}
.panel-tag--cyan { background: var(--cyan); box-shadow: 0 0 14px rgba(69, 240, 255, 0.4); }
.panel-tag--magenta { background: var(--magenta); box-shadow: 0 0 14px rgba(255, 61, 139, 0.45); }
.panel-tag--gold { background: var(--gold); box-shadow: 0 0 14px rgba(255, 200, 87, 0.45); }
.panel-tag--green { background: var(--green); box-shadow: 0 0 14px rgba(65, 255, 139, 0.4); }

h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(0.72rem, 0.62rem + 0.5vw, 0.95rem);
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--text);
}

/* ---------- two-column workspace ---------- */
.layout-grid {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.5rem);
}
.layout-grid > .panel {
  margin-bottom: 0;
}

/* ---------- fields ---------- */
.field-group {
  display: grid;
  gap: 0.5rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}
.field > span,
label > span {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}
label {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

/* shared control surface (inputs, selects, textareas) */
.control,
.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 8, 14, 0.6);
  color: var(--text);
  transition: border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    background-color var(--duration-fast) ease;
}

.control {
  min-height: 2.8rem;
  padding: 0.7rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

select.control {
  padding-right: 2rem;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) center,
    calc(100% - 0.7rem) center;
  background-size: 0.36rem 0.36rem, 0.36rem 0.36rem;
  background-repeat: no-repeat;
}

.text-input {
  padding: 0.85rem 0.9rem;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.55;
}
.mono-input {
  font-family: var(--mono);
}
.output-url {
  color: var(--cyan);
}

.control::placeholder,
.text-input::placeholder {
  color: rgba(154, 160, 181, 0.6);
}

.control:hover,
.text-input:hover {
  border-color: rgba(69, 240, 255, 0.45);
}
.control:focus,
.text-input:focus {
  outline: none;
  border-color: var(--cyan);
  background: rgba(8, 8, 14, 0.85);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(69, 240, 255, 0.2);
}

/* ---------- presets grid ---------- */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

/* ---------- toggle ---------- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.4rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--dim);
  cursor: pointer;
}
.toggle input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  accent-color: var(--cyan);
}
.toggle span {
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: none;
}

/* ---------- buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.7rem;
  padding: 0.55rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    background-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-out);
}
.button:active {
  transform: translateY(1px);
}

.button-primary {
  border-color: var(--cyan);
  background: rgba(69, 240, 255, 0.12);
  color: var(--cyan);
}
.button-primary:hover {
  background: var(--cyan);
  color: #05050d;
  box-shadow: 0 0 22px rgba(69, 240, 255, 0.4);
}

.button-secondary {
  border-color: var(--gold);
  background: rgba(255, 200, 87, 0.1);
  color: var(--gold);
}
.button-secondary:hover {
  background: var(--gold);
  color: #05050d;
  box-shadow: 0 0 20px rgba(255, 200, 87, 0.35);
}

.button-ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--dim);
}
.button-ghost:hover {
  color: var(--text);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(69, 240, 255, 0.18);
}

.button-danger {
  border-color: rgba(255, 85, 96, 0.45);
  background: rgba(255, 85, 96, 0.08);
  color: var(--red);
}
.button-danger:hover {
  color: #05050d;
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 14px rgba(255, 85, 96, 0.35);
}

.button-icon {
  min-width: 2.7rem;
  padding-inline: 0.6rem;
  font-size: 0.78rem;
}

.button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.button.is-copied {
  background: var(--green);
  border-color: var(--green);
  color: #05050d;
  box-shadow: 0 0 18px rgba(65, 255, 139, 0.4);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.1rem;
}
.button-row.compact {
  margin-top: 0;
  gap: 0.5rem;
}

/* ---------- messages ---------- */
.message-list {
  display: grid;
  gap: 0.55rem;
}
.message-list:not(:empty) {
  margin-top: 1.1rem;
}

.message {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 8, 14, 0.5);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
  color: var(--dim);
}
.message.warning {
  border-color: rgba(255, 200, 87, 0.45);
  border-left-color: var(--gold);
  background: rgba(255, 200, 87, 0.08);
  color: var(--gold);
}
.message.error {
  border-color: rgba(255, 85, 96, 0.5);
  border-left-color: var(--red);
  background: rgba(255, 85, 96, 0.09);
  color: var(--red);
}
.message.success {
  border-color: rgba(65, 255, 139, 0.5);
  border-left-color: var(--green);
  background: rgba(65, 255, 139, 0.09);
  color: var(--green);
}

/* ---------- parts list (URL anatomy) ---------- */
.parts-list {
  display: grid;
  grid-template-columns: minmax(6.5rem, 30%) 1fr;
  gap: 0.1rem 0.85rem;
  margin: 0;
}
.parts-list dt {
  padding: 0.5rem 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--gold);
  align-self: center;
}
.parts-list dd {
  min-width: 0;
  margin: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
}
.parts-list dt {
  border-bottom: 1px solid var(--line);
}
.parts-list dt:last-of-type,
.parts-list dd:last-of-type {
  border-bottom: 0;
}

/* ---------- data tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 8, 14, 0.4);
  margin-top: 1.1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  position: sticky;
  top: 0;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  color: var(--dim);
  white-space: nowrap;
}
.data-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table tbody tr:last-child td {
  border-bottom: 0;
}
.data-table tbody tr {
  transition: background-color var(--duration-fast) ease;
}
.data-table tbody tr:hover {
  background: rgba(69, 240, 255, 0.04);
}

#params-table {
  min-width: 38rem;
}
.compare-table {
  min-width: 40rem;
}

.control-cell {
  min-width: 9rem;
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
}

/* ---------- kind + status badges ---------- */
.kind-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.kind-badge.utm {
  border-color: rgba(69, 240, 255, 0.5);
  background: rgba(69, 240, 255, 0.1);
  color: var(--cyan);
}
.kind-badge.query {
  border-color: var(--line);
  background: rgba(154, 160, 181, 0.08);
  color: var(--dim);
}

.status-badge.same {
  border-color: rgba(65, 255, 139, 0.5);
  background: rgba(65, 255, 139, 0.1);
  color: var(--green);
}
.status-badge.different {
  border-color: rgba(255, 200, 87, 0.5);
  background: rgba(255, 200, 87, 0.1);
  color: var(--gold);
}
.status-badge.missing {
  border-color: rgba(255, 61, 139, 0.5);
  background: rgba(255, 61, 139, 0.1);
  color: var(--magenta);
}
.status-badge.invalid {
  border-color: rgba(255, 85, 96, 0.5);
  background: rgba(255, 85, 96, 0.1);
  color: var(--red);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ---------- value lists in compare cells ---------- */
.value-list {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.value-list li {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.value-list code {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: rgba(8, 8, 14, 0.7);
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* ---------- empty + copy states ---------- */
.empty-state {
  padding: 1.5rem 0.85rem !important;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.85rem;
  text-align: center;
}

.copy-status {
  min-height: 1.4rem;
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--dim);
}
.copy-status[data-state="ok"] { color: var(--green); }
.copy-status[data-state="error"] { color: var(--red); }

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

/* ---------- add-param form ---------- */
.add-param-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: end;
}
.add-param-form .button {
  min-height: 2.8rem;
}

/* ---------- footer ---------- */
.app-footer {
  display: grid;
  gap: 0.85rem;
  justify-items: center;
  margin-top: clamp(2rem, 5vw, 3.5rem);
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
  border-top: 1px solid var(--line);
  text-align: center;
}
.app-footer__copy {
  margin: 0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 0.12em;
  line-height: 2;
  color: var(--dim);
}
.app-footer__tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
}
.app-footer__tags span {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--dim);
}
.app-footer__note {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--dim);
}

/* ---------- a11y helper ---------- */
.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;
}

/* ---------- responsive: tablet ---------- */
@media (min-width: 40rem) {
  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field--wide {
    grid-column: 1 / -1;
  }
  .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .add-param-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  }
  .privacy-badge {
    font-size: 0.82rem;
  }
}

/* ---------- responsive: desktop two-column workspace ---------- */
@media (min-width: 64rem) {
  .layout-grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(22rem, 0.9fr);
    align-items: start;
  }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .cursor,
  .privacy-badge__dot {
    animation: none !important;
  }
  .button:active {
    transform: none;
  }
}
