:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e7e9f2;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef0ff;
  --radius: 18px;
  --shadow: 0 24px 60px -28px rgba(16, 24, 40, 0.28), 0 2px 8px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 12% -10%, #e4e6ff 0%, rgba(228, 230, 255, 0) 60%),
    radial-gradient(800px 480px at 92% 0%, #dff3f6 0%, rgba(223, 243, 246, 0) 58%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px 40px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  margin-bottom: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(79, 70, 229, 0.14);
  backdrop-filter: blur(8px);
  margin-bottom: 20px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, #7c3aed 100%);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(79, 70, 229, 0.9);
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--brand-strong);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 26px;
  align-items: start;
}

.editor {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

/* ---------- Tabs ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #f2f3f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  background: #fff;
  color: var(--brand-strong);
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.08);
}

/* ---------- Panels & fields ---------- */
.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  min-width: 0;
}

.field-grow {
  flex: 1;
}

.field-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.field-row.align-start {
  align-items: flex-start;
}

.field-row > .field {
  margin-bottom: 14px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #344054;
}

.field-label output {
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fbfbfe;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  min-width: 0;
}

textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.55;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #a5a2f5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5l3.5 3.5 3.5-3.5' stroke='%23667085' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.hint {
  margin: -6px 0 12px;
  font-size: 12.5px;
  color: #98a2b3;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfbfe;
  font-size: 14px;
  color: #344054;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.check input {
  accent-color: var(--brand);
  width: 15px;
  height: 15px;
  margin: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c7c4fb 0%, #e3e4ef 100%);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: #e3e4ef;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35);
}

/* ---------- Colors ---------- */
.color-row {
  display: flex;
  gap: 10px;
}

.color-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfbfe;
  font-size: 13px;
  color: #475467;
  cursor: pointer;
}

.color-pick input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.color-pick input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-pick input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(16, 24, 40, 0.12);
  border-radius: 7px;
}

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

.swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(16, 24, 40, 0.12);
  background: linear-gradient(135deg, var(--fg) 0 50%, var(--bg) 50% 100%);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px -8px rgba(16, 24, 40, 0.5);
}

.swatch.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

/* ---------- Divider ---------- */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: #98a2b3;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- Preview ---------- */
.preview {
  position: sticky;
  top: 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background:
    linear-gradient(45deg, #f6f7fb 25%, transparent 25% 75%, #f6f7fb 75%),
    linear-gradient(45deg, #f6f7fb 25%, #fff 25% 75%, #f6f7fb 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
  border: 1px solid #f0f1f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
}

#qr-canvas {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
  box-shadow: 0 10px 26px -18px rgba(16, 24, 40, 0.45);
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(3px);
  color: var(--muted);
  font-size: 13px;
}

.canvas-empty[hidden] {
  display: none;
}

.empty-icon {
  font-size: 26px;
}

.canvas-empty p {
  margin: 0;
  max-width: 200px;
  line-height: 1.6;
}

.qr-meta {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: #98a2b3;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  appearance: none;
  flex: 1;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none;
}

.btn-primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, #7c3aed 100%);
  box-shadow: 0 10px 20px -12px rgba(79, 70, 229, 0.9);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px -12px rgba(79, 70, 229, 0.85);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #475467;
}

.btn-ghost:not(:disabled):hover {
  border-color: #c7c4fb;
  color: var(--brand-strong);
  background: #fafaff;
}

/* ---------- History ---------- */
.history {
  margin-top: 22px;
  border-top: 1px dashed var(--line);
  padding-top: 16px;
}

.history[hidden] {
  display: none;
}

.history-title {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #98a2b3;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: #475467;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.history-item:hover {
  background: #f8f8fc;
  border-color: var(--line);
}

.history-tag {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-strong);
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: 999px;
}

.history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ---------- Footer ---------- */
.privacy {
  margin: 18px 0 0;
  font-size: 12.5px;
  color: #98a2b3;
  text-align: center;
  line-height: 1.6;
}

.footer {
  margin-top: 34px;
  text-align: center;
  font-size: 12.5px;
  color: #98a2b3;
}

/* ---------- Responsive ---------- */
@media (max-width: 940px) {
  .page {
    padding: 36px 18px 28px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
    order: -1;
  }

  .preview-card {
    max-width: 360px;
    margin: 0 auto;
  }

  .actions {
    max-width: 360px;
    margin: 18px auto 0;
  }

  .privacy {
    max-width: 360px;
    margin: 16px auto 0;
  }
}

@media (max-width: 560px) {
  .editor {
    padding: 16px;
    border-radius: 18px;
  }

  .preview {
    padding: 16px;
    border-radius: 18px;
  }

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

  .field-row {
    flex-wrap: wrap;
    gap: 0 12px;
  }

  .field-row > .field {
    flex: 1 1 140px;
  }

  .check {
    margin-bottom: 14px;
  }

  .tagline {
    font-size: 14px;
  }
}
