:root {
  --bg: #0f1115;
  --bg2: #151922;
  --card: #1a1f29;
  --line: #262c38;
  --fg: #e7eaf0;
  --dim: #98a2b3;
  --acc: #4c8dff;
  --acc2: #7c5cff;
  --ok: #2ecc71;
  --warn: #f1c40f;
  --err: #ff5c5c;
  --r: 14px;
}
[data-theme="light"] {
  --bg: #f5f6fa;
  --bg2: #ffffff;
  --card: #ffffff;
  --line: #e2e5ee;
  --fg: #1b1f2a;
  --dim: #6b7280;
  --acc: #2f6fed;
  --acc2: #6d4aff;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .3px;
}

.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--dim);
  font-size: 14px;
  white-space: nowrap;
}

.tab.active {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
  font-weight: 600;
}

main {
  padding: 12px 14px 40px;
  max-width: 760px;
  margin: 0 auto;
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}

.hint {
  color: var(--dim);
  font-size: 12.5px;
  margin: 8px 0 0;
}

label {
  display: block;
  font-size: 13px;
  color: var(--dim);
  margin: 10px 0 6px;
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="number"],
input[type="url"],
input[type="color"],
select,
textarea {
  width: 100%;
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  font: inherit;
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--acc);
}

input[type="range"] { width: 100%; }

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.row > * { flex: 1 1 auto; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--fg);
  padding: 10px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
}

.btn:active { transform: scale(.98); }

.btn.primary {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
  color: var(--dim);
}

.btn.small { padding: 6px 10px; font-size: 13px; }

.btn.wide { width: 100%; }

.out {
  margin-top: 10px;
  padding: 10px 11px;
  background: var(--bg2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  white-space: pre-wrap;
  min-height: 20px;
}

.out:empty::before {
  content: "…";
  color: var(--dim);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.metric {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}

.metric b {
  display: block;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric span {
  font-size: 11.5px;
  color: var(--dim);
}

.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0 0;
}

#qrCanvas {
  background: #fff;
  border-radius: 10px;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.preview {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
  margin-top: 10px;
}

.swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.swatches button {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 0;
}

footer {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  padding: 0 14px 28px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--fg);
  color: var(--bg);
  font-size: 13.5px;
  padding: 8px 15px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 86vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
  font-size: 13px;
  color: var(--dim);
}

.chip.on {
  border-color: var(--acc);
  color: var(--fg);
  background: var(--bg2);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--fg);
  margin: 8px 0;
}

.check input { width: auto; accent-color: var(--acc); }