:root {
  --bg: #070b14;
  --bg-2: #0a1120;
  --panel: rgba(17, 25, 42, 0.72);
  --panel-2: rgba(24, 34, 55, 0.6);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.2);
  --text: #e8eefb;
  --muted: #93a3bd;
  --primary: #6388ff;
  --primary-2: #8b6dff;
  --primary-soft: rgba(99, 136, 255, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

/* 带 hidden 属性的元素一律隐藏，避免被组件自身的 display 规则盖掉 */
[hidden] {
  display: none !important;
}

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

body {
  background:
    radial-gradient(900px 480px at 8% -12%, rgba(99, 136, 255, 0.2), transparent 62%),
    radial-gradient(760px 420px at 92% -6%, rgba(139, 109, 255, 0.16), transparent 60%),
    radial-gradient(1200px 700px at 50% 120%, rgba(52, 211, 153, 0.07), transparent 65%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
}

svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 28px;
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.topbar-inner {
  max-width: 1340px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 38px;
  height: 38px;
  padding: 8px;
  color: #fff;
  background: linear-gradient(135deg, #5b7cfa, #7b5cf0);
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(99, 136, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 16px;
  letter-spacing: 0.4px;
  background: linear-gradient(90deg, #fff, #b9c8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
}

/* 没设密码时的醒目提醒 */
.security-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1340px;
  margin: 16px auto 0;
  padding: 11px 16px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: var(--radius-sm);
  background: linear-gradient(155deg, rgba(251, 191, 36, 0.16), rgba(251, 113, 36, 0.07));
  color: #fde68a;
  font-size: 13px;
  font-weight: 600;
}

.security-banner svg {
  width: 18px;
  height: 18px;
  color: #fbbf24;
}

.security-banner span {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .security-banner {
    margin: 12px 16px 0;
    flex-wrap: wrap;
  }
}

/* ---------- 布局与面板 ---------- */

/* 顶栏、上方两栏、下方面板共用同一套左右边距和最大宽度，保证左右边缘对齐 */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 20px;
  padding: 24px 28px 0;
  max-width: 1340px;
  margin: 0 auto;
  position: relative;
}

.page {
  max-width: 1340px;
  margin: 0 auto;
  padding: 20px 28px 0;
}

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(28, 40, 66, 0.55), rgba(15, 22, 38, 0.82));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin: 0 0 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.layout .panel {
  margin: 0;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.layout .panel:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.5);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.h-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  color: #b9ccff;
  background: linear-gradient(140deg, rgba(99, 136, 255, 0.22), rgba(139, 109, 255, 0.12));
  border: 1px solid rgba(120, 140, 255, 0.28);
}

.h-icon svg {
  width: 15px;
  height: 15px;
}

.sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: #22304e;
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

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

.btn-primary {
  background: linear-gradient(135deg, #5b7cfa, #7b5cf0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(99, 136, 255, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #6b89ff, #8a6dff);
  box-shadow: 0 12px 28px rgba(99, 136, 255, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-ghost {
  background: transparent;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 14px;
  border-radius: 12px;
}

.btn-danger {
  color: #ffb4b4;
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.45);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 9px;
}

/* ---------- 订阅源卡片 ---------- */

.source-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.source-card {
  position: relative;
  background: rgba(11, 17, 29, 0.66);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.source-card:hover {
  border-color: rgba(120, 140, 255, 0.32);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  transform: translateY(-1px);
}

.source-card.disabled {
  opacity: 0.55;
}

.source-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.source-head .source-index {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(140deg, rgba(99, 136, 255, 0.3), rgba(139, 109, 255, 0.18));
  border: 1px solid rgba(120, 140, 255, 0.3);
  color: #d5e0ff;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.source-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

/* 切换按钮放在卡片头部：紧挨序号，右侧留白把开关和删除推到最右 */
.source-head .tabs {
  margin: 0 auto 0 0;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  flex: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: #ffb4b4;
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.28);
}

/* 开关 */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .track {
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: #2a3850;
  transition: background 0.18s;
  position: relative;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cbd6e8;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.18s;
}

.switch input:checked + .track {
  background: linear-gradient(135deg, #5b7cfa, #7b5cf0);
  box-shadow: 0 0 0 0 rgba(99, 136, 255, 0.35), inset 0 1px 2px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .track::after {
  transform: translateX(17px);
  background: #fff;
}

.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3px rgba(99, 136, 255, 0.25);
}

/* 页签 */

.tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 10px;
  padding: 3px;
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 10px;
  width: fit-content;
}

.tab {
  padding: 5px 13px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab.active {
  background: linear-gradient(140deg, rgba(99, 136, 255, 0.24), rgba(139, 109, 255, 0.14));
  color: #dbe4ff;
  box-shadow: inset 0 0 0 1px rgba(120, 140, 255, 0.28);
}

/* 输入 */

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 10px 12px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(10, 17, 32, 0.9);
  box-shadow: 0 0 0 3px rgba(99, 136, 255, 0.16);
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.name-style {
  margin-top: 12px;
}

.name-style .hint {
  margin-top: 4px;
}

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

.var-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  font: inherit;
  font-size: 12px;
  color: #c7d4e8;
  background: rgba(99, 136, 255, 0.08);
  border: 1px solid rgba(120, 140, 255, 0.22);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.var-chip code {
  padding: 1px 6px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  color: #b9ccff;
  background: rgba(99, 136, 255, 0.16);
  border-radius: 6px;
}

.var-chip:hover {
  background: rgba(99, 136, 255, 0.18);
  border-color: rgba(120, 140, 255, 0.45);
  transform: translateY(-1px);
}

.var-chip:active {
  transform: translateY(0) scale(0.97);
}

.name-preview span {
  color: #c3d2ff;
  font-weight: 600;
}

.note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.note-label {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.note-label svg {
  width: 13px;
  height: 13px;
  opacity: 0.8;
}

.source-note {
  flex: 1;
  padding: 7px 11px;
  font-size: 12.5px;
}

.panel-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.panel-foot.column {
  flex-direction: column;
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 550;
}

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

/* ---------- 选项 ---------- */

.option-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  background: rgba(11, 17, 29, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.option:hover {
  border-color: rgba(120, 140, 255, 0.3);
  background: rgba(20, 29, 48, 0.7);
  transform: translateX(2px);
}

.option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--primary);
  flex: none;
  cursor: pointer;
}

.option span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.option strong {
  font-size: 13px;
  font-weight: 650;
}

.option em {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 结果区 ---------- */

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 11px;
  margin-bottom: 16px;
}

.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(155deg, rgba(99, 136, 255, 0.14), rgba(139, 109, 255, 0.05));
  border: 1px solid rgba(120, 140, 255, 0.2);
  border-radius: 14px;
  padding: 12px 15px;
}

.stat:nth-child(2) {
  background: linear-gradient(155deg, rgba(52, 211, 153, 0.14), rgba(52, 211, 153, 0.04));
  border-color: rgba(52, 211, 153, 0.22);
}

.stat:nth-child(3) {
  background: linear-gradient(155deg, rgba(251, 191, 36, 0.13), rgba(251, 191, 36, 0.04));
  border-color: rgba(251, 191, 36, 0.2);
}

.stat:nth-child(4) {
  background: linear-gradient(155deg, rgba(248, 113, 113, 0.12), rgba(248, 113, 113, 0.04));
  border-color: rgba(248, 113, 113, 0.2);
}

.stat:nth-child(5) {
  background: linear-gradient(155deg, rgba(96, 165, 250, 0.13), rgba(96, 165, 250, 0.04));
  border-color: rgba(96, 165, 250, 0.2);
}

.stat b {
  display: block;
  font-size: 23px;
  line-height: 1.2;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #fff, #c3d2ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.stat-icon {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 20px;
  height: 20px;
  color: #fff;
  opacity: 0.16;
  pointer-events: none;
}

.regions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: linear-gradient(180deg, rgba(99, 136, 255, 0.14), rgba(99, 136, 255, 0.05));
  border: 1px solid rgba(120, 140, 255, 0.24);
  border-radius: 999px;
  font-size: 12px;
  color: #cdd9f5;
  backdrop-filter: blur(6px);
}

.chip b {
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 合并进度弹窗 ---------- */

.progress-dialog {
  width: min(600px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid rgba(120, 140, 255, 0.28);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 34, 56, 0.98), rgba(13, 20, 35, 0.99));
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.progress-dialog::backdrop {
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(5px);
}

.progress-dialog[open] {
  animation: dialog-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.progress-body {
  display: flex;
  flex-direction: column;
  padding: 20px 22px 16px;
}

.progress-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-head .spinner {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
  border-color: rgba(156, 194, 255, 0.3);
  border-top-color: #9cc2ff;
}

.progress-head-text {
  flex: 1;
  min-width: 0;
}

.progress-head-text h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.progress-head-text .sub {
  margin: 1px 0 0;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 进度条：合并中来回滑动，完成后填满 */
.progress-bar {
  margin: 14px 0 12px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #5b7cfa, #7b5cf0);
  transition: width 0.4s ease;
}

.progress-bar-fill.is-running {
  width: 32%;
  animation: bar-slide 1.15s ease-in-out infinite;
}

.progress-bar-fill.is-done {
  width: 100%;
  background: linear-gradient(90deg, #34d399, #5eead4);
}

.progress-bar-fill.is-failed {
  width: 100%;
  background: linear-gradient(90deg, #f87171, #fbbf24);
}

@keyframes bar-slide {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(330%);
  }
}

/* 日志区：分组标题 + 步骤行 + 缩进的明细 */
.progress-log {
  max-height: min(320px, 42vh);
  min-height: 96px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(5, 9, 17, 0.7);
  font-family: ui-monospace, "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  scroll-behavior: smooth;
}

/* 合并中可以点一下日志跳过动画 */
.progress-dialog.is-running .progress-log {
  cursor: pointer;
}

.pd-section {
  margin: 10px 0 6px;
  padding-left: 8px;
  border-left: 2px solid rgba(120, 140, 255, 0.5);
  color: #b9ccff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.4px;
  animation: line-in 0.2s ease-out;
}

.pd-section:first-child {
  margin-top: 2px;
}

.pd-step {
  animation: line-in 0.22s ease-out;
}

.pd-step-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #e6edf7;
}

/* 正在进行的步骤高亮，完成的变淡，失败的标红 */
.pd-step.is-done .pd-step-line {
  color: var(--muted);
}

.pd-step.is-failed .pd-step-line {
  color: #ffb4b4;
}

.pd-icon {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  flex: none;
  display: grid;
  place-items: center;
  color: #9cc2ff;
}

.pd-icon svg {
  width: 14px;
  height: 14px;
  animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.is-done .pd-icon {
  color: var(--ok);
}

.is-failed .pd-icon {
  color: var(--danger);
}

.pd-icon .spinner {
  width: 12px;
  height: 12px;
  border-width: 2px;
}

.pd-text {
  min-width: 0;
  word-break: break-word;
}

.pd-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 3px 0 2px 22px;
}

.pd-detail {
  color: var(--muted);
  font-size: 12px;
  animation: line-in 0.2s ease-out;
}

.pd-detail::before {
  content: "·";
  margin-right: 6px;
  color: rgba(148, 163, 184, 0.6);
}

.progress-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.progress-count {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

@keyframes line-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.result-body {
  animation: fade-in 0.3s ease-out;
}

.result-body[hidden] {
  display: none;
}

/* 链接区 */

.saved-links {
  margin-bottom: 16px;
  padding: 15px 16px;
  border: 1px solid rgba(52, 211, 153, 0.28);
  background: linear-gradient(155deg, rgba(52, 211, 153, 0.1), rgba(52, 211, 153, 0.03));
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.06), 0 10px 26px rgba(52, 211, 153, 0.06);
}

.saved-title {
  font-weight: 700;
  color: #8ee8ae;
  margin-bottom: 11px;
  font-size: 13.5px;
}

.saved-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-row .link-label {
  width: 68px;
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.link-row input {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  background: rgba(7, 11, 20, 0.8);
}

/* 无法转换 Base64 的节点列表 */

.unsupported-box {
  margin-bottom: 14px;
  padding: 13px 15px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  background: linear-gradient(155deg, rgba(251, 191, 36, 0.1), rgba(251, 191, 36, 0.03));
  border-radius: var(--radius-sm);
}

.unsupported-title {
  font-weight: 650;
  color: #fbd38a;
  margin-bottom: 9px;
  font-size: 13px;
}

.unsupported-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}

.unsupported-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  min-width: 0;
}

.unsupported-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unsupported-reason {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

/* 表格 */

.table-wrap {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 400px;
  background: rgba(9, 14, 24, 0.5);
}

.node-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.node-table th,
.node-table td {
  text-align: left;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  white-space: nowrap;
}

.node-table th {
  position: sticky;
  top: 0;
  background: rgba(20, 29, 47, 0.96);
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.2px;
  z-index: 1;
  backdrop-filter: blur(8px);
}

.node-table tbody tr {
  transition: background 0.12s;
}

.node-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.node-table tbody tr:hover {
  background: rgba(99, 136, 255, 0.09);
}

.node-table td:first-child {
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: #b9ccff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.type-tag[data-type="ss"] {
  background: rgba(96, 165, 250, 0.18);
  color: #93c5fd;
}

.type-tag[data-type="vmess"] {
  background: rgba(167, 139, 250, 0.18);
  color: #c4b5fd;
}

.type-tag[data-type="vless"] {
  background: rgba(45, 212, 191, 0.16);
  color: #5eead4;
}

.type-tag[data-type="trojan"] {
  background: rgba(251, 146, 60, 0.18);
  color: #fdba74;
}

.type-tag[data-type="hysteria2"],
.type-tag[data-type="hy2"] {
  background: rgba(244, 114, 182, 0.18);
  color: #f9a8d4;
}

.type-tag[data-type="tuic"] {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
}

/* ---------- 已保存列表 ---------- */

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: rgba(11, 17, 29, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.saved-item:hover {
  border-color: rgba(120, 140, 255, 0.28);
  background: rgba(20, 29, 48, 0.65);
  transform: translateY(-1px);
}

.saved-item .saved-meta {
  flex: 1;
  min-width: 0;
}

.saved-item .saved-meta strong {
  display: block;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-item .saved-meta span {
  color: var(--muted);
  font-size: 12px;
}

.saved-item .saved-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty {
  margin: 0;
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(9, 14, 24, 0.35);
}

/* ---------- 其它 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 11px 20px;
  background: rgba(22, 32, 52, 0.92);
  border: 1px solid rgba(120, 140, 255, 0.32);
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 550;
  z-index: 60;
  animation: toast-in 0.2s ease-out;
  backdrop-filter: blur(12px);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.45);
  color: #ffc2c2;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.dialog {
  padding: 0;
  border: 1px solid rgba(120, 140, 255, 0.24);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 40, 66, 0.95), rgba(15, 22, 38, 0.98));
  color: var(--text);
  width: min(420px, calc(100vw - 32px));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.dialog::backdrop {
  background: rgba(3, 6, 12, 0.7);
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 22px;
  margin: 0;
}

.dialog-body h3 {
  margin: 0 0 4px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-body input {
  margin-top: 14px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 登录层 ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 14, 0.84);
  backdrop-filter: blur(12px);
  animation: fade-in 0.2s ease-out;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 40px));
  padding: 34px 32px 26px;
  background: linear-gradient(180deg, rgba(28, 40, 66, 0.94), rgba(15, 22, 38, 0.97));
  border: 1px solid rgba(120, 140, 255, 0.26);
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  color: #fff;
  background: linear-gradient(135deg, #5b7cfa, #7b5cf0);
  border-radius: 16px;
  box-shadow: 0 10px 26px rgba(99, 136, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.login-logo svg {
  width: 26px;
  height: 26px;
}

.login-card h1 {
  margin: 6px 0 0;
  font-size: 20px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff, #b9c8ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-card .sub {
  margin: 0 0 6px;
}

.login-card input {
  text-align: left;
}

.login-card .btn-lg {
  width: 100%;
  margin-top: 4px;
}

.login-error {
  color: #ffb4b4;
  font-size: 12.5px;
  margin: 0;
}

.login-foot {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.password-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px 16px 0;
  }

  .page {
    padding: 16px 16px 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar-inner {
    padding: 12px 0;
  }

  .brand-text span {
    display: none;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
  }

  .panel-head {
    flex-direction: column;
  }

  .result-actions {
    justify-content: flex-start;
  }

  .saved-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .saved-item .saved-actions {
    justify-content: flex-start;
  }

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