/* Configurator page tokens. Primitives stay here; components use the role names. */
:root {
  --color-bg: #1c130c;
  --color-surface: #2a1d14;
  --color-surface-raised: #38281b;
  --color-surface-hover: #4a3626;
  --color-border: #7d6248;
  --color-text: #fdf3df;
  --color-text-muted: #d8c4a5;
  --color-accent: #ffb938;
  --color-accent-hover: #ffc75f;
  --color-on-accent: #2a1d14;
  --color-focus: #7fd4ff;
  --color-error: #ffb4a8;
  --check-light: #bdbdbd;
  --check-dark: #8a8a8a;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius: 4px;
  --t-small: 14px;
  --t-body: 16px;
  --t-title: 20px;
  --t-brand: 24px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "DejaVu Sans", sans-serif;
  --font-data: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-block-start: var(--space-4);
}
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h2 {
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
h3 {
  font-size: var(--t-body);
  font-weight: 600;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: 2;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-on-accent);
  transform: translateY(-200%);
}
.skip:focus {
  transform: none;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
}
.brand {
  font-size: var(--t-title);
  font-weight: 700;
  line-height: 1.2;
}
.top-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: var(--space-1);
  text-underline-offset: 3px;
}

/* Page grid: preview and URL first, settings beside them once both fit */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  padding: 0 var(--space-4) var(--space-6);
}
.stagearea {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}
.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--check-light);
  background-image: repeating-conic-gradient(var(--check-dark) 0 25%, var(--check-light) 0 50%);
  background-size: 24px 24px;
}
.preview iframe {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  border: 0;
  background: transparent;
  transform-origin: top left;
  pointer-events: none;
}
.output {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
textarea,
select,
input[type="text"],
input[type="url"],
input[type="number"] {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--t-body);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
textarea {
  display: block;
  resize: vertical;
  font-family: var(--font-data);
  font-size: var(--t-small);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
input::placeholder {
  color: var(--color-text-muted);
}
input[aria-invalid="true"] {
  border-color: var(--color-error);
}
input[type="range"] {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  accent-color: var(--color-accent);
}
input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--color-accent);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition-property: scale, background-color;
  transition-duration: 120ms;
  transition-timing-function: ease-out;
}
.btn:active {
  scale: 0.96;
}
@media (hover: hover) {
  .btn:hover:not(:disabled) {
    background: var(--color-surface-hover);
  }
  .btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
  }
}
.btn:disabled {
  color: var(--color-text-muted);
  background: transparent;
  cursor: not-allowed;
}
.btn-primary {
  flex: 1 1 200px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-color: var(--color-accent);
}
.btn-small {
  font-size: var(--t-small);
}
.hint,
.status-line,
.field-msg,
.note {
  color: var(--color-text-muted);
  font-size: var(--t-small);
  text-wrap: pretty;
}
.status-line {
  min-height: 21px;
  color: var(--color-text);
}
.tests {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.test-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  outline: none;
}
fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radius);
}
legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-block-end: var(--space-3);
  font-size: var(--t-title);
  font-weight: 600;
  line-height: 1.25;
}
legend + * {
  clear: both;
}
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}
.field-label {
  font-size: var(--t-small);
  font-weight: 600;
}
.field-label output {
  font-family: var(--font-data);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.field-msg.is-error,
#paste-msg.is-error {
  color: var(--color-error);
}
.field-msg ul {
  margin: var(--space-1) 0 0;
  padding-inline-start: 20px;
}
.inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.inline input {
  flex: 1 1 160px;
  width: auto;
  min-width: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  cursor: pointer;
}
.choices-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}
.choice {
  position: relative;
  display: flex;
  cursor: pointer;
}
.choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.choice span {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface-raised);
  font-size: var(--t-small);
  line-height: 1.25;
  text-align: center;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
}
.choice small {
  color: var(--color-text-muted);
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
}
.choice input:checked + span {
  font-weight: 700;
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
}
.choice input:focus-visible + span {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Setup guide */
.setup {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4) var(--space-8);
}
.setup-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}
.setup ol {
  max-width: 62ch;
  margin: var(--space-2) 0 0;
  padding-inline-start: 24px;
}
.setup li + li {
  margin-block-start: var(--space-1);
}
.note {
  max-width: 62ch;
}

/* Two columns once the preview can stay usefully wide beside the form */
@media (min-width: 60rem) {
  .top,
  .layout,
  .setup {
    padding-inline: var(--space-8);
  }
  .brand {
    font-size: var(--t-brand);
  }
  .layout {
    grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr);
    gap: var(--space-8);
    align-items: start;
  }
  .setup-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* The preview follows the form only when the whole column fits, so nothing sits out of reach. */
@media (min-width: 60rem) and (min-height: 60rem) {
  .stagearea {
    position: sticky;
    inset-block-start: var(--space-4);
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
  .btn:active {
    scale: 1;
  }
}
