@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f4f5f9;
  --panel: #ffffff;
  --surface: #eceef6;
  --text: #181a2e;
  --muted: #5a5d7a;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --border: rgba(24, 26, 46, 0.13);
  --card: #fafbff;
  --warm: #7c3aed;
  --shadow: 0 16px 40px rgba(24, 26, 46, 0.11);
  --font-display: "Space Grotesk", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e1a;
  --panel: #13152a;
  --surface: #1a1d38;
  --text: #eef0f8;
  --muted: #9a9dc0;
  --accent: #818cf8;
  --accent-ink: #0a0b1e;
  --border: rgba(238, 240, 248, 0.12);
  --card: #101228;
  --warm: #c084fc;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.38);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(129, 140, 248, 0.08), transparent 34%),
    linear-gradient(145deg, #0e0f22 0%, #0d0e1a 54%, #130d22 100%);
}

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

body {
  margin: 0;
  font-family: var(--font-display);
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.1), transparent 34%),
    linear-gradient(145deg, #f8f9ff 0%, #eceefc 52%, #f5f0ff 100%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: stretch;
  width: min(1400px, 90vw);
  margin: 0 auto;
  height: calc(100dvh - 120px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: -0.2px;
}

h3 {
  margin: 0;
  font-size: 18px;
}

.qr-eyebrow {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  gap: 8px;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-style: normal;
}

.group__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.group__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.style-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pill-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.pill input,
.checkbox input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
  opacity: 0;
}

.pill.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.pill:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}

.content-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hidden {
  display: none !important;
}

.appearance-grid {
  align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.color-grid {
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* keep the Style selector from stretching full width */
.qr-style-field {
  width: fit-content;
  max-width: 260px;
}

.style-row .qr-style-field {
  width: 100%;
  max-width: none;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
}

.field textarea {
  resize: vertical;
  min-height: 74px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.color-field {
  position: relative;
}

.color-field.compact .color-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-radius: 12px;
}

.color-field .swatch {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
}

.color-field .swatch::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.color-field .swatch::-moz-color-swatch {
  border: none;
  border-radius: 8px;
}

.color-field .swatch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.color-field .swatch:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: saturate(0.65);
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 48px;
}

.icon-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn.active {
  color: var(--accent);
}

.color-grid .checkbox {
  padding: 6px 0 0;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 14px;
  color: var(--text);
  padding: 8px 6px;
  position: relative;
}

.checkbox.inline {
  padding: 6px 0 0;
}

.checkbox__box {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  position: relative;
}

.checkbox:focus-within .checkbox__box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.checkbox input:checked + .checkbox__box {
  border-color: var(--accent);
  background: var(--accent);
}

.checkbox input:checked + .checkbox__box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Highlight animation for the transparent background hint */
@keyframes bgHintFlash {
  0% {
    background-color: transparent;
    color: var(--muted);
  }
  50% {
    /* subtle glow using accent colour */
    background-color: color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--text);
  }
  100% {
    background-color: transparent;
    color: var(--muted);
  }
}

/* Apply the flash to #bgHint when the highlight class is present */
#bgHint.highlight {
  animation: bgHintFlash 1.2s ease-out 0s 2;
  border-radius: 6px;
  padding: 4px 8px;
}

.file input {
  padding: 9px 10px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.content-generate {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.actions button,
.content-generate button {
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.12s ease, filter 0.15s;
}

.actions button:disabled,
.content-generate button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 60%, transparent);
}

.ghost {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
}

.download {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.download button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.canvas-area {
  display: flex;
  align-items: stretch;
  
}

.preview-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.qr-frame {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  /* Safari overflow fix: flex + hidden keeps the QR canvas clipped inside frame */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.qr-frame canvas,
.qr-frame svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}




