/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --paper: #f7f6f2;
  --grid-line: #dde1e8;
  --ink: #1b1d22;
  --ink-soft: #565c66;
  --accent: #2757c8;
  --accent-soft: #e9eefb;
  --ready: #1f8a5f;
  --ready-soft: #e6f4ee;
  --error: #c23b3b;
  --error-soft: #fbebeb;
  --border: #c9cdd6;

  --font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius: 4px;
  --gap: 1.25rem;
}

/* ==========================================================================
   Reset / base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
}

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

/* ==========================================================================
   Sheet / card
   ========================================================================== */
.sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(27, 29, 34, 0.04), 0 12px 32px rgba(27, 29, 34, 0.08);
  padding: 2rem;
}

.sheet__header { margin-bottom: 1.75rem; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin: 0;
}

.sheet__footer {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.sheet__footer p {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
}

/* ==========================================================================
   Form
   ========================================================================== */
.panel {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: none;
  padding: 0;
  margin: 0;
}

.field > label,
.field > legend {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0;
}

input[type="url"],
select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  width: 100%;
}

input[type="url"]:focus-visible,
select:focus-visible,
.btn:focus-visible,
.radio-chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="url"].is-invalid {
  border-color: var(--error);
  background: var(--error-soft);
}

.field__hint {
  min-height: 1.1em;
  font-size: 0.78rem;
  color: var(--error);
  margin: 0;
}

.field--inline select { max-width: 220px; }

/* Size radio chips */
.radio-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.radio-chip {
  position: relative;
  flex: 1 1 auto;
}

.radio-chip input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.radio-chip span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.radio-chip span em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.radio-chip input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--ink);
  color: #fff;
}
.btn--primary:hover { background: #000; }
.btn--primary:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.btn--secondary {
  background: var(--ready-soft);
  color: var(--ready);
  border-color: var(--ready);
  width: 100%;
}
.btn--secondary:hover { background: #d8efe4; }

/* ==========================================================================
   Output
   ========================================================================== */
.output {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.output__frame {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.output__code {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.output__code img,
.output__code svg {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.output__placeholder {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 0 1rem;
  margin: 0;
}

/* Corner registration marks — echoes the QR code's own finder-pattern squares */
.corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  opacity: 0.35;
}
.corner--tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.corner--tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.corner--bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.corner--br { bottom: 0; right: 0; border-left: none; border-top: none; }

.output__spec {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  min-height: 1em;
  margin: 0;
}

.output__spec.is-error { color: var(--error); }

#downloadBtn { max-width: 260px; }

/* ==========================================================================
   Small screens
   ========================================================================== */
@media (max-width: 400px) {
  .sheet { padding: 1.5rem; }
  .radio-row { flex-direction: column; }
  .radio-chip span { flex-direction: row; justify-content: space-between; }
}
