@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@700;800&display=swap');

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

:root {
  --bg: #0c0c0c;
  --surface: #141414;
  --border: #222;
  --border-hi: #333;
  --text: #e8e8e8;
  --muted: #555;
  --accent: #e8e8e8;
  --accent-dim: #2a2a2a;
  --radius: 6px;
  --mono: 'DM Mono', monospace;
  --display: 'Syne', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 128px;
}

main {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

header {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.logo {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.tagline {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

/* Input */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--border-hi); }

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 14px 16px 8px;
  line-height: 1.6;
}
textarea::placeholder { color: var(--muted); }

.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 10px;
  color: var(--muted);
  font-size: 11px;
}

#clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .1s, background .1s;
}
#clear-btn:hover { color: var(--text); background: var(--accent-dim); }

/* Options */
.options {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-group label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color .1s, background .1s;
  border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { color: var(--text); background: var(--accent-dim); }
.seg-btn.active { color: var(--bg); background: var(--accent); }

.color-pair {
  display: flex;
  gap: 6px;
}

.color-swatch {
  position: relative;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color .1s;
}
.color-swatch:hover { border-color: var(--border-hi); }
.color-swatch span { color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.color-swatch input[type="color"] {
  width: 16px; height: 16px;
  border: none; padding: 0; margin: 0;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

/* Generate button */
#generate-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .05em;
  padding: 13px 24px;
  cursor: pointer;
  align-self: flex-start;
  transition: opacity .15s, transform .1s;
}
#generate-btn:hover { opacity: .85; }
#generate-btn:active { transform: scale(.98); }

/* Output */
.output-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.output-section.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.qr-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: inline-flex;
}

#qr-canvas canvas,
#qr-canvas img {
  display: block;
  border-radius: 2px;
}

.actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  padding: 7px 16px;
  cursor: pointer;
  transition: color .1s, border-color .1s, background .1s;
}
.action-btn:hover { color: var(--text); border-color: var(--border-hi); }
.action-btn.flash { color: var(--bg); background: var(--text); border-color: var(--text); }

@media (max-width: 480px) {
  main { padding: 32px 16px 60px; }
  .options { gap: 16px; }
}
