:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-2: #fafbfd;
  --line: #e6e9f0;
  --line-2: #eef1f6;
  --text: #0f172a;
  --muted: #6b7280;
  --muted-2: #94a3b8;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --accent-soft: #eef2ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.10);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg: #0b1020;
  --panel: #161f3d;
  --panel-2: #1c274a;
  --line: #2a3563;
  --line-2: #1f2950;
  --text: #e6edf7;
  --muted: #98a3c4;
  --muted-2: #6b7898;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .preview-wrapper {
  background: repeating-conic-gradient(#0e1530 0% 25%, #0b1020 0% 50%) 50% / 18px 18px;
}
[data-theme="dark"] .foot {
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Theme Toggle Button ===== */
.theme-btn {
  position: absolute;
  top: 36px;
  right: 28px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.theme-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .icon-sun  { display: inline-flex; }
.theme-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-btn .icon-sun  { display: none; }
[data-theme="dark"] .theme-btn .icon-moon { display: inline-flex; }

/* ===== Hero ===== */
.hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 16px;
  position: relative;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-dot {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}
.hero h1 { margin: 0; font-size: 22px; letter-spacing: 0.3px; font-weight: 700; }
.subtitle { margin: 4px 0 0 40px; color: var(--muted); font-size: 13px; }

/* ===== Layout ===== */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 28px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

/* ===== Panels ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.form-panel { padding: 8px; }
.preview-panel { padding: 20px; position: sticky; top: 16px; }

/* ===== Sections ===== */
.section {
  padding: 18px 18px;
  border-bottom: 1px solid var(--line-2);
}
.section:last-child { border-bottom: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; }
.section-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.section-title-inline {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.hint-inline { font-size: 12px; color: var(--muted-2); font-weight: 400; letter-spacing: 0; text-transform: none; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.tab {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--panel);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Form ===== */
.field { display: block; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
input[type="text"], input[type="url"], input[type="email"], input[type="tel"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
textarea { resize: vertical; }
input[type="file"] {
  padding: 7px;
  font-size: 12px;
}
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] {
  width: 38px; height: 36px;
  padding: 2px;
  border-radius: 8px;
  cursor: pointer;
}
.color-row input[type="text"] {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
}

/* ===== Style Grid (scrollable) ===== */
.style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 230px;
  overflow-y: auto;
  padding: 2px 6px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.style-grid::-webkit-scrollbar { width: 6px; }
.style-grid::-webkit-scrollbar-track { background: transparent; }
.style-grid::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}
.style-grid::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }
.style-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 4px 4px;
  cursor: pointer;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
  position: relative;
}
.style-card:hover {
  border-color: var(--accent-2);
  transform: translateY(-1px);
}
.style-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.style-card canvas, .style-card svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 6px;
}
.style-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.style-card.active .style-name { color: var(--accent); }
.style-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center;
}
.style-card.active .style-check { display: flex; }

/* ===== Custom colors (collapsible inline) ===== */
.custom-colors {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* ===== Size Presets ===== */
.size-presets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
@media (max-width: 540px) { .size-presets { grid-template-columns: repeat(3, 1fr); } }
.size-btn {
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}
.size-btn:hover { border-color: var(--accent-2); }
.size-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.size-btn-num { font-size: 13px; font-weight: 700; line-height: 1; }
.size-btn-tag { font-size: 10px; color: var(--muted); line-height: 1; }
.size-btn.active .size-btn-tag { color: var(--accent); opacity: 0.7; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-2.compact { margin-top: 4px; }

/* ===== Collapsible section ===== */
.section-details { padding: 0; }
.section-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  user-select: none;
}
.section-details > summary::-webkit-details-marker { display: none; }
.section-details > summary::before {
  content: "▸";
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s ease;
}
.section-details[open] > summary::before { transform: rotate(90deg); }
.section-details .section-body { padding: 0 18px 18px; }

/* ===== Hint ===== */
.hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.6;
}
.hint code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* ===== Toggle ===== */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.toggle-track {
  width: 40px; height: 22px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  transition: background 0.2s ease;
}
.toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}
.toggle input:checked + .toggle-track {
  background: var(--accent);
}
.toggle input:checked + .toggle-track .toggle-knob { transform: translateX(18px); }
[data-theme="dark"] .toggle-track { background: #2a3563; }
.toggle-label { font-size: 13.5px; font-weight: 500; }

.live-controls {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.short-status { font-size: 12px; color: var(--muted); word-break: break-all; }
.short-status:empty { display: none; }

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.15s ease;
}
.btn:hover {
  border-color: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-ghost {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-2); }
.btn-ghost.full { width: 100%; }

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ===== Preview ===== */
.preview-wrapper {
  position: relative;
  background: repeating-conic-gradient(#f3f4f8 0% 25%, #ffffff 0% 50%) 50% / 18px 18px;
  border-radius: var(--radius-sm);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
}
.qr-output {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.qr-output canvas, .qr-output svg {
  display: block;
  max-width: 100%;
  height: auto;
}
.live-badge {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--accent-2);
  color: #04322f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* ===== Meta strip ===== */
.meta-strip {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (max-width: 540px) { .meta-strip { grid-template-columns: repeat(2, 1fr); } }
.meta-strip > div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-strip span { font-size: 11px; color: var(--muted); }
.meta-strip b { font-size: 13px; font-weight: 600; color: var(--text); }

/* ===== Downloads ===== */
.downloads {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
#copy-clip { margin-top: 8px; }

/* ===== Footer ===== */
.foot {
  text-align: center;
  color: var(--muted);
  padding: 28px 24px;
  font-size: 12.5px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  max-width: 1280px;
  margin: 0 auto;
}
.foot p { margin: 4px 0; }
.foot-disclaimer { color: var(--muted); }
.foot-contact a { color: var(--accent); text-decoration: none; }
.foot-contact a:hover { text-decoration: underline; }

/* ===== Info Tooltip ===== */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  margin-left: 4px;
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.info-icon:hover,
.info-icon:focus {
  background: var(--accent);
  color: #fff;
  outline: none;
}
.info-icon[data-tip]:hover::after,
.info-icon[data-tip]:focus::after,
.info-icon.tip-open::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.55;
  width: max-content;
  max-width: 320px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  white-space: normal;
  text-align: left;
  pointer-events: none;
}
.info-icon[data-tip]:hover::before,
.info-icon[data-tip]:focus::before,
.info-icon.tip-open::before {
  content: "";
  position: absolute;
  top: calc(100% + 4px);
  left: 8px;
  border: 5px solid transparent;
  border-bottom-color: #0f172a;
  z-index: 100;
}

.placeholder { color: var(--muted); padding: 60px 20px; text-align: center; font-size: 14px; }
