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

:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --surface: #1b2535;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #14b8a6;
  --border: #243049;
  --card: #111a2d;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --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;
}

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

body {
  margin: 0;
  font-family: var(--font-display);
  background: radial-gradient(circle at 18% 18%, rgba(20, 184, 166, 0.08), transparent 28%),
    radial-gradient(circle at 82% -6%, rgba(59, 130, 246, 0.08), transparent 32%),
    linear-gradient(145deg, #0c1426 0%, #0a1020 50%, #0d1528 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  padding: 28px 28px 18px;
  align-items: stretch;
  max-width: 1400px;
  margin: 0 auto 28px;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: calc(100vh - 100px);
  overflow: auto;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-credit {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.header-credit .eyebrow {
  margin: 0;
  letter-spacing: 1px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--border);
  box-shadow: none;
  transition: none;
}

.social-link::after {
  content: "↗";
  font-size: 12px;
  opacity: 0.7;
}

h1 {
  margin: 4px 0 0;
  font-size: 26px;
  letter-spacing: -0.5px;
}

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

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

.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: 14px;
  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: 12px;
  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: 10px;
  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;
}

.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: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.icon-btn:hover {
  transform: translateY(-50%) scale(1.02);
}

.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 #fff;
  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;
}

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

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

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

.actions .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;
  height: calc(100vh - 100px);
  min-height: 0;
}

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

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

.qr-frame {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  /* 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;
}

#contentGuard {
  text-align: center;
}

.hint.error {
  color: #fca5a5;
}

@media (min-width: 768px) and (max-width: 1366px) and (orientation: landscape) {
  .app {
    grid-template-columns: minmax(300px, 340px) 1fr;
    gap: 16px;
    padding: 18px;
    margin-bottom: 18px;
  }

  .panel,
  .canvas-area {
    height: calc(100dvh - 72px);
  }

  .panel,
  .preview-card {
    padding: 16px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .app {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
    min-height: auto;
  }

  .panel,
  .canvas-area {
    height: auto;
  }

  .panel {
    overflow: visible;
  }

  .preview-card {
    min-height: 420px;
  }

  .preview-card > .hint {
    text-align: center;
  }

  .qr-frame {
    min-height: 320px;
  }
}

@media (max-width: 767px) {
  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: auto;
  }

  .panel,
  .canvas-area {
    height: auto;
  }

  .panel {
    overflow: visible;
    padding: 14px;
    border-radius: 14px;
    gap: 14px;
  }

  .panel__header {
    align-items: center;
    justify-content: space-between;
    flex-direction: row;
    gap: 10px;
    flex-wrap: wrap;
  }

  .header-credit {
    align-items: flex-end;
  }

  .group {
    border-radius: 14px;
    padding: 14px;
  }

  .preview-card {
    border-radius: 14px;
    padding: 12px;
  }

  .preview-card {
    min-height: 360px;
  }

  .qr-frame {
    min-height: 260px;
    padding: 14px;
  }

  .preview-card > .hint {
    text-align: center;
  }

  h1 {
    font-size: 23px;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 10px;
    gap: 10px;
  }

  .panel {
    padding: 12px;
  }

  .group {
    padding: 14px;
  }

  .preview-card {
    padding: 10px;
  }

  .pill {
    padding: 9px 10px;
    font-size: 13px;
  }

  h1 {
    font-size: 21px;
  }

  .footer-brand {
    padding-top: 10px;
    font-size: 12px;
  }
}
