:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1e293b;
  --text2: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary2: #6366f1;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 240px);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  font-size: 17px;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 9px 16px;
  font-size: 14px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text2);
  transition: all 0.15s;
}
.tab-btn:hover { background: #eef2ff; color: var(--primary); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* ---------- 主区 ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 6px; font-size: 19px; }
.desc { color: var(--text2); font-size: 13.5px; line-height: 1.7; margin: 0 0 18px; }

/* ---------- 表单 ---------- */
.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.form-row input {
  flex: 1;
  min-width: 220px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fbfcfe;
}
.form-row input:focus {
  border-color: var(--primary2);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  background: #fff;
}
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  background: #fbfcfe;
}
textarea:focus { border-color: var(--primary2); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); background: #fff; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary2); color: var(--primary); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

/* ---------- 短链结果 ---------- */
.result {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff, #ecfeff);
  border: 1px solid #e0e7ff;
  animation: fade 0.3s ease;
}
.result-main { flex: 1; min-width: 0; }
.result-label { font-size: 12px; color: var(--primary); font-weight: 700; margin-bottom: 6px; letter-spacing: 1px; }
.short-url {
  font-size: 17px;
  font-weight: 700;
  word-break: break-all;
  margin-bottom: 12px;
  color: #312e81;
}
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-actions.center { justify-content: center; margin-top: 16px; }
.qr-mini {
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

/* ---------- 二维码选项 ---------- */
.opts {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px 0 4px;
  font-size: 13.5px;
  color: var(--text2);
}
.opts label { display: flex; align-items: center; gap: 7px; }
.opts select, .opts input[type="number"] {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: #fbfcfe;
}
.opts input[type="color"] {
  width: 34px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  background: #fff;
  cursor: pointer;
}
.qr-stage {
  display: flex;
  justify-content: center;
  padding: 22px;
  margin-top: 10px;
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 0 0 / 22px 22px;
  border-radius: 12px;
  border: 1px dashed var(--line);
}
#qr-canvas { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 2px 14px rgba(15, 23, 42, 0.12); }
.qr-placeholder {
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
  line-height: 2;
  padding: 80px 20px;
}

/* ---------- 管理 ---------- */
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.admin-head h2 { margin: 0; }
.create-live { margin-bottom: 14px; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text2);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--primary2); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.empty {
  text-align: center;
  color: #94a3b8;
  padding: 44px 0;
  font-size: 14px;
}

.link-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.link-card:hover { border-color: #c7d2fe; }
.link-card.highlight { border-color: var(--primary2); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }
.link-card.is-live { background: linear-gradient(135deg, #ffffff, #f5f3ff); }

.lc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.badge.live { background: #ede9fe; color: #6d28d9; }
.badge.short { background: #e0f2fe; color: #0369a1; }
.lc-name { font-weight: 600; font-size: 15px; word-break: break-all; }
.lc-warn {
  font-size: 12px;
  color: #b45309;
  background: #fef3c7;
  padding: 2px 10px;
  border-radius: 999px;
}

.lc-url { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lc-url-text {
  font-size: 13.5px;
  color: var(--primary);
  font-weight: 600;
  word-break: break-all;
  font-family: ui-monospace, Consolas, monospace;
}

.lc-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lc-label { width: 100%; font-size: 12px; color: var(--text2); }
.lc-target {
  flex: 1;
  min-width: 240px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  outline: none;
  background: #fbfcfe;
}
.lc-target:focus { border-color: var(--primary2); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); background: #fff; }
.lc-msg { font-size: 12.5px; color: #059669; min-width: 60px; }

.lc-stats { font-size: 12.5px; color: var(--text2); border-top: 1px dashed var(--line); padding-top: 10px; }

.lc-right {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.lc-qr {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 78px;
  height: 78px;
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  color: #94a3b8;
  font-size: 12.5px;
  padding: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; justify-content: center; }
  .container { padding: 20px 12px 36px; }
  .card { padding: 18px; }
  .result { flex-direction: column; text-align: center; }
  .result-actions { justify-content: center; }
  .link-card { padding-right: 16px; }
  .lc-right { position: static; flex-direction: row; align-self: flex-start; }
  .lc-qr { width: 64px; height: 64px; }
}
