:root {
  --bg: #fff9f9;
  --surface: #ffffff;
  --ink: #201820;
  --ink-soft: #857d80;
  --accent: #eb1c3e;
  --accent-light: #ff5c77;
  --accent-soft: #c4102f;
  --line: #f2dee1;
  --glow: rgba(235, 28, 62, 0.14);
  --shadow: rgba(235, 28, 62, 0.16);
  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1417;
    --surface: #241c20;
    --ink: #f6eeef;
    --ink-soft: #a99ba0;
    --accent: #ff4767;
    --accent-light: #ff7e93;
    --accent-soft: #eb1c3e;
    --line: #3a2a2f;
    --glow: rgba(255, 71, 103, 0.16);
    --shadow: rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme='dark'] {
  --bg: #1a1417;
  --surface: #241c20;
  --ink: #f6eeef;
  --ink-soft: #a99ba0;
  --accent: #ff4767;
  --accent-light: #ff7e93;
  --accent-soft: #eb1c3e;
  --line: #3a2a2f;
  --glow: rgba(255, 71, 103, 0.16);
  --shadow: rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(560px 320px at 50% -60px, var(--glow), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  min-height: 100vh;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 24px 90px;
}

header {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}
header .logo {
  height: 200px;
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 20px var(--shadow));
}

h1 {
  font-size: 32px;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  text-align: center;
}

.sub {
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.6;
  max-width: 42ch;
  margin: 0 auto 40px;
  text-align: center;
}

.card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 32px;
  border-radius: 28px;
  box-shadow: 0 24px 48px -24px var(--shadow);
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: lowercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  resize: vertical;
  min-height: 84px;
  transition: border-color 0.15s ease;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 20px;
}

.control select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  background: var(--bg);
}
.color-field input[type='color'] {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  padding: 0;
  background: none;
  cursor: pointer;
}
.color-field input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-field input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}
.color-field span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.control-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row;
}
.control-toggle label:first-child {
  margin-bottom: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .slider {
  background: var(--accent);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

button.primary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  cursor: pointer;
  box-shadow: 0 10px 20px -8px var(--shadow);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px -8px var(--shadow);
}
button.primary:active {
  transform: translateY(0);
}

button.ghost {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.12s ease;
}
button.ghost:hover {
  border-color: var(--accent);
}

.output {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px dashed var(--line);
  display: none;
  flex-direction: column;
  align-items: center;
}
.output.show {
  display: flex;
}

.qr-stage {
  position: relative;
  background: #fff;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  display: inline-flex;
  line-height: 0;
  box-shadow: 0 20px 40px -20px var(--shadow);
}
.qr-stage canvas,
.qr-stage svg,
.qr-stage img {
  display: block;
}

.output-meta {
  margin-top: 18px;
  text-align: center;
  max-width: 40ch;
}
.output-meta .label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.output-meta .value {
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 18px;
  line-height: 1.5;
  color: var(--ink);
}

.download-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }
  .controls-grid {
    grid-template-columns: 1fr;
  }
}
