:root {
  color-scheme: light;
  --ink: #243047;
  --muted: #718096;
  --line: #e8e3f1;
  --panel: rgba(255, 255, 255, 0.88);
  --page: #fbf9ff;
  --blue: #8b8cf6;
  --blue-soft: #f2efff;
  --slate: #556179;
  --shadow: 0 18px 42px rgba(91, 86, 130, 0.11);
  --soft-shadow: 0 8px 24px rgba(91, 86, 130, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 8% 8%, rgba(139, 140, 246, 0.16), transparent 28%),
    radial-gradient(circle at 90% 20%, rgba(251, 207, 232, 0.18), transparent 30%),
    linear-gradient(180deg, #fffefe 0%, var(--page) 58%, #f7fbff 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  font-size: 0.86rem;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  display: block;
}

.app-header,
.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 12px;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid #ddd6fe;
  border-radius: 7px;
  background: #ffffff;
  color: var(--blue);
  box-shadow: none;
}

.brand-icon svg,
.tab-icon svg,
.setting-icon svg,
.title-spark {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-icon svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.08;
}

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(1.85rem, 3.4vw, 2.65rem);
  font-weight: 950;
}

h1 span {
  color: var(--blue);
}

.title-spark {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 8px;
  color: var(--blue);
  vertical-align: super;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  font-weight: 900;
}

.app-shell {
  padding-bottom: 28px;
}

.type-bar {
  display: grid;
  grid-template-columns: repeat(13, minmax(68px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(16px);
  scrollbar-width: thin;
}

.type-tab,
.color-swatch,
.ghost-button,
.icon-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 850;
  letter-spacing: 0;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.type-tab {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 62px;
  padding: 7px 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab-icon {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  color: var(--slate);
  font-size: 1.15rem;
  line-height: 1;
}

.tab-icon svg {
  width: 19px;
  height: 19px;
}

.type-tab span:last-child {
  font-size: 0.76rem;
}

.type-tab:hover,
.type-tab.is-active {
  border-color: #ddd6fe;
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(139, 140, 246, 0.1);
}

.type-tab:hover .tab-icon,
.type-tab.is-active .tab-icon {
  color: var(--blue);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(420px, 1.12fr);
  gap: 14px;
  margin-top: 16px;
  align-items: start;
}

.setup-column {
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.preview-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 24%, rgba(139, 140, 246, 0.16), transparent 36%),
    radial-gradient(circle at 88% 30%, rgba(216, 249, 234, 0.72), transparent 35%),
    linear-gradient(135deg, rgba(255, 253, 250, 0.96), rgba(247, 244, 255, 0.9));
}

.preview-panel::before {
  content: "";
  position: absolute;
  inset: 76px 24px 72px;
  pointer-events: none;
  background-image: radial-gradient(rgba(139, 140, 246, 0.22) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.8;
}

.preview-panel > * {
  position: relative;
  z-index: 1;
}

.panel-heading,
.preview-top,
.download-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-kicker {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  margin: 0 0 6px;
  padding-inline: 8px;
  border-radius: 999px;
  border: 1px solid #ddd6fe;
  background: #ffffff;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: none;
}

.field-grid {
  display: grid;
  gap: 11px;
  margin-top: 14px;
}

.form-row,
.payload-block {
  display: grid;
  gap: 6px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 0.9rem;
  outline: none;
  min-height: 40px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input:not([type="checkbox"]):not([type="color"]):not([type="range"]),
select,
textarea {
  padding: 9px 11px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input[type="color"] {
  height: 40px;
  padding: 4px;
}

input[type="file"] {
  padding: 7px;
}

input[type="range"] {
  min-height: 34px;
  accent-color: var(--blue);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #c4b5fd;
  box-shadow: 0 0 0 4px rgba(139, 140, 246, 0.14);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--blue);
}

#qr-state {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.canvas-stage {
  display: grid;
  place-items: center;
  min-height: 360px;
  margin-top: 12px;
  padding: 16px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.24);
}

#qr-canvas {
  display: block;
  width: min(100%, 360px);
  height: auto;
  max-height: 58vh;
  filter: drop-shadow(0 22px 30px rgba(63, 78, 150, 0.2));
}

.download-row {
  margin-top: 12px;
}

.download-row button {
  font-size: 0.9rem;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  padding: 0 13px;
}

.primary-button {
  flex: 1 1 auto;
  background: var(--blue);
  color: white;
  box-shadow: 0 12px 22px rgba(139, 140, 246, 0.2);
}

.secondary-button {
  border-color: #ddd6fe;
  background: #ffffff;
  color: var(--blue);
}

.ghost-button {
  border-color: var(--line);
  background: #ffffff;
  color: var(--blue);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.color-swatch:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 1.18rem;
  line-height: 1;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal-close,
.mobile-generate,
.mobile-step {
  display: none;
}

.hidden-control {
  display: none;
}

.controls-panel {
  display: grid;
  gap: 10px;
}

.controls-title {
  padding-bottom: 2px;
}

.control-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  overflow: hidden;
}

.control-group summary {
  min-height: 48px;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.control-group summary::-webkit-details-marker {
  display: none;
}

.setting-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #e0dcff;
  border-radius: 8px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.8);
}

.control-group summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid #536482;
  border-bottom: 2px solid #536482;
  transform: rotate(45deg);
  transition: transform 160ms ease;
}

.control-group[open] summary::after {
  transform: rotate(225deg);
}

.control-body {
  display: grid;
  gap: 10px;
  padding: 0 12px 12px;
}

.frame-color-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
}

.color-swatch {
  min-height: 36px;
  padding: 0;
  border-color: var(--line);
  background: var(--swatch);
  box-shadow: inset 0 0 0 4px #ffffff;
}

.color-swatch.is-selected {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 4px #ffffff, 0 0 0 3px rgba(139, 140, 246, 0.18);
}

.error-message {
  border: 1px solid #ffc3cf;
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff4f6;
  color: #af2e49;
  font-weight: 760;
}

@media (max-width: 1060px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }

  .form-panel {
    order: 0;
  }

  .controls-panel {
    order: 1;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14.5px;
    background:
      radial-gradient(circle at 12% 0%, rgba(139, 140, 246, 0.14), transparent 32%),
      radial-gradient(circle at 88% 18%, rgba(251, 207, 232, 0.16), transparent 30%),
      linear-gradient(180deg, #fffefe 0%, #fbf9ff 100%);
  }

  .app-header,
  .app-shell {
    width: min(100% - 18px, 1180px);
  }

  .app-header {
    display: grid;
    gap: 10px;
    padding: 14px 0 10px;
  }

  h1 {
    margin-bottom: 0;
    font-size: 1.68rem;
  }

  .eyebrow {
    margin-bottom: 6px;
  }

  .type-bar {
    display: flex;
    gap: 6px;
    margin-inline: -2px;
    padding: 6px;
  }

  .type-tab {
    min-width: 62px;
    min-height: 58px;
    padding-inline: 8px;
  }

  .type-tab span:last-child {
    font-size: 0.72rem;
  }

  .workspace-grid {
    gap: 11px;
    margin-top: 11px;
  }

  .form-panel,
  .controls-panel {
    padding: 12px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .ghost-button {
    min-width: 86px;
  }

  .two-cols {
    grid-template-columns: 1fr;
  }

  .frame-color-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .desktop-step {
    display: none;
  }

  .mobile-step {
    display: inline-grid;
  }

  .mobile-generate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
  }

  .preview-panel {
    display: none;
  }

  .preview-panel.is-open {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    min-height: 100dvh;
    padding: 12px;
    border: 0;
    border-radius: 0;
    background:
      radial-gradient(circle at 16% 12%, rgba(139, 140, 246, 0.16), transparent 34%),
      radial-gradient(circle at 90% 24%, rgba(216, 249, 234, 0.6), transparent 34%),
      #fbf9ff;
    box-shadow: none;
    overflow: auto;
  }

  .preview-panel.is-open .modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .preview-panel.is-open #qr-state {
    display: none;
  }

  .canvas-stage {
    min-height: auto;
    padding: 8px;
  }

  #qr-canvas {
    width: min(100%, 292px);
    max-height: none;
  }

  .download-row {
    align-items: stretch;
  }

  .download-row > button {
    flex: 1 1 0;
  }

  input,
  select,
  textarea,
  .type-tab,
  .color-swatch,
  .ghost-button,
  .icon-button,
  .primary-button,
  .secondary-button {
    min-height: 42px;
  }

  input,
  select,
  textarea {
    font-size: 0.88rem;
  }

  textarea {
    min-height: 92px;
  }
}

@media (max-width: 420px) {
  .app-header,
  .app-shell {
    width: min(100% - 16px, 1180px);
  }

  h1 {
    font-size: 1.56rem;
  }

  .preview-top,
  .download-row {
    gap: 8px;
  }

  .download-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

}
