/* ===== 二维码生成器 · 样式 ===== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111a2e;
  --surface-2: #0f1729;
  --border: #1f2b45;
  --border-strong: #33415c;
  --text: #e8eefc;
  --text-2: #a8b6d0;
  --text-3: #6b7a99;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: #16243f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; border: 1px solid var(--border); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 38px; height: 38px; color: var(--primary); flex: none; }
.brand-sub { margin: 1px 0 0; font-size: 12.5px; color: var(--text-3); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: start;
  padding: 18px 24px 0;
  max-width: 1360px;
  margin: 0 auto;
}
.col-editor { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-preview { min-width: 0; }
.sticky { position: sticky; top: 84px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.wide { max-width: 1360px; margin: 18px auto 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--surface), var(--surface-2));
}
.card-body { padding: 18px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.badge {
  font: 500 12px/1 var(--mono);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 9px; border-radius: 999px;
}

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 13px; }
.form.is-hidden, .is-hidden { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline span { font-size: 14px; color: var(--text-2); }
.label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tip { color: var(--primary); font-family: var(--mono); font-size: 12.5px; font-weight: 600; }

input[type="text"], input[type="url"], input[type="tel"], input[type="email"], input[type="password"],
textarea, select {
  width: 100%;
  padding: 9px 11px;
  font: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
input[type="color"] {
  width: 100%; height: 38px; padding: 3px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input[type="range"] { width: 100%; accent-color: var(--primary); height: 22px; cursor: pointer; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex: none; }
input[type="file"] { font-size: 13px; color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.sep { border: 0; border-top: 1px dashed var(--border); margin: 4px 0; }

.input-with-btn { display: flex; gap: 6px; align-items: stretch; }
.input-with-btn input { flex: 1; }

/* ---------- 类型切换 ---------- */
.type-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 15px; }
.tab {
  font: inherit; font-size: 13.5px;
  padding: 6px 13px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { border-color: var(--border-strong); color: var(--text); }
.tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 550;
  padding: 9px 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; font-size: 17px; padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-mini { font-size: 12.5px; padding: 5px 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 提示 ---------- */
.hint { margin: 0; font-size: 12.5px; color: var(--text-3); line-height: 1.55; }
.hint.err { color: var(--danger); }
.hint.ok { color: var(--ok); }
.tips { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }

/* ---------- 预览 ---------- */
.canvas-wrap {
  position: relative;
  display: grid; place-items: center;
  padding: 14px;
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 0 0 / 18px 18px,
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 9px 9px / 18px 18px,
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 300px;
}
#qr-canvas {
  max-width: 100%;
  width: 300px; height: auto;
  image-rendering: pixelated;
  border-radius: 4px;
}
.canvas-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-3); font-size: 13.5px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.meta {
  display: grid; grid-template-columns: 1fr; gap: 7px;
  margin: 15px 0;
}
.meta > div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--border); padding-bottom: 5px; }
.meta dt { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }
.meta dd { margin: 0; font: 500 12.5px/1.5 var(--mono); color: var(--text); white-space: nowrap; }

.downloads { display: flex; flex-direction: column; gap: 9px; }
.dl-row { display: flex; gap: 9px; align-items: center; }
.dl-row .btn { flex: 1; }
.dl-row select { width: auto; min-width: 74px; flex: none; }

/* ---------- 配色预设 ---------- */
.presets { display: flex; flex-direction: column; gap: 7px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
  width: 34px; height: 34px; padding: 0; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: linear-gradient(135deg, var(--a) 0 50%, var(--b) 50% 100%);
  transition: transform .12s;
}
.preset:hover { transform: scale(1.08); }

/* ---------- Logo ---------- */
.file-input { position: relative; display: flex; align-items: center; gap: 9px; min-width: 0; }
.file-input input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-btn {
  flex: none;
  padding: 7px 13px; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: background .15s;
}
.file-input:hover .file-btn { background: var(--surface-2); }
.file-name { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-row { display: flex; align-items: center; gap: 10px; }
#logo-thumb {
  width: 42px; height: 42px; object-fit: contain;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px;
}

/* ---------- 历史 ---------- */
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.history-item {
  position: relative;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2);
  padding: 8px; cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.history-item:hover { border-color: var(--primary); transform: translateY(-2px); }
.history-item img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 6px; display: block; }
.history-item .hi-meta { margin-top: 6px; }
.history-item .hi-type {
  font-size: 11px; color: var(--primary); font-weight: 600;
}
.history-item .hi-text {
  font-size: 11.5px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item .hi-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0; line-height: 1;
  font-size: 13px; color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.history-item:hover .hi-del { opacity: 1; }
.history-item .hi-del:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- 页脚 ---------- */
.foot {
  max-width: 1360px; margin: 22px auto 0; padding: 18px 24px 34px;
  text-align: center; font-size: 12.5px; color: var(--text-3);
}
.foot p { margin: 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; padding: 14px 16px 0; }
  .col-preview { order: -1; }
  .sticky { position: static; }
  .card.wide { margin: 14px 16px 0; }
  #qr-canvas { width: 240px; }
}
@media (max-width: 620px) {
  .topbar { padding: 12px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .canvas-wrap { min-height: 240px; }
  .meta { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .col-editor, .card.wide, .foot, .downloads { display: none !important; }
}
