/* =========================================================
   基础层：设计变量、重置、通用组件
   ========================================================= */

:root {
  --bg:            #0c0a08;
  --bg-soft:       #12100c;
  --surface:       rgba(24, 20, 16, 0.86);
  --surface-solid: #181410;
  --surface-hi:    rgba(38, 31, 24, 0.9);
  --bar:           rgba(22, 18, 14, 0.94);
  --panel:         rgba(18, 15, 12, 0.92);
  --surface-tint:  rgba(255, 255, 255, 0.022);
  --hover:         rgba(255, 255, 255, 0.04);
  --hover-strong:  rgba(255, 255, 255, 0.08);
  --input-bg:      rgba(255, 255, 255, 0.03);
  --overlay:       rgba(6, 5, 4, 0.72);
  --toast-bg:      rgba(20, 16, 12, 0.96);

  --line:          rgba(201, 162, 39, 0.16);
  --line-soft:     rgba(201, 162, 39, 0.08);

  --gold:          #c9a227;
  --gold-soft:     #e3c46a;
  --gold-dim:      #8a7320;
  --jade:          #4fbf9a;
  --crimson:       #c05858;

  --text:          #efe6d8;
  --text-dim:      #a2937f;
  --text-faint:    #6b6053;

  --stage-bg:      #0b0907;
  --grid:          rgba(201, 162, 39, 0.14);
  --vignette:      rgba(0, 0, 0, 0.55);
  --code-bg:       rgba(0, 0, 0, 0.36);
  --code-text:     #d8c99a;

  --graph-node:     #16110d;
  --graph-node-dim: #0d0b09;
  --graph-label:    #ece3d4;
  --graph-label-dim:#8a7f70;
  --graph-halo:     rgba(0, 0, 0, 0.9);

  --radius:        14px;
  --radius-sm:     9px;

  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  --topbar-h: 64px;
  --sidebar-w: 280px;
  --detail-w: 350px;
  --maxw: 1180px;
}

/* ---------------- 浅色主题 ---------------- */

html[data-theme="light"] {
  --bg:            #f7f2e7;
  --bg-soft:       #efe7d7;
  --surface:       rgba(255, 252, 246, 0.9);
  --surface-solid: #fffdf8;
  --surface-hi:    rgba(255, 250, 240, 0.95);
  --bar:           rgba(250, 245, 235, 0.94);
  --panel:         rgba(253, 249, 241, 0.94);
  --surface-tint:  rgba(120, 90, 30, 0.035);
  --hover:         rgba(120, 90, 30, 0.06);
  --hover-strong:  rgba(120, 90, 30, 0.1);
  --input-bg:      rgba(120, 90, 30, 0.05);
  --overlay:       rgba(52, 42, 28, 0.34);
  --toast-bg:      #fffdf8;

  --line:          rgba(150, 118, 46, 0.24);
  --line-soft:     rgba(150, 118, 46, 0.13);

  --gold:          #b08a1c;
  --gold-soft:     #87640f;
  --gold-dim:      #9a7a20;
  --jade:          #268a6c;
  --crimson:       #a83c3c;

  --text:          #2a231a;
  --text-dim:      #5f5546;
  --text-faint:    #8d8271;

  --stage-bg:      #f2ebdc;
  --grid:          rgba(150, 118, 46, 0.22);
  --vignette:      rgba(140, 110, 50, 0.10);
  --code-bg:       rgba(120, 90, 30, 0.07);
  --code-text:     #6b4f12;

  --graph-node:     #fffdf7;
  --graph-node-dim: #efe7d8;
  --graph-label:    #2b241c;
  --graph-label-dim:#9a8d7c;
  --graph-halo:     rgba(255, 253, 247, 0.92);
}

html[data-theme="light"] body {
  background:
    radial-gradient(1100px 700px at 18% -10%, rgba(201, 162, 39, 0.20), transparent 60%),
    radial-gradient(900px 640px at 100% 110%, rgba(180, 60, 40, 0.07), transparent 62%),
    var(--bg);
}

html[data-theme="light"] ::selection {
  background: rgba(176, 138, 28, 0.24);
  color: #1f1910;
}

* { box-sizing: border-box; }

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

html { height: 100%; }

body {
  min-height: 100%;
  background:
    radial-gradient(1100px 700px at 18% -10%, rgba(201, 162, 39, 0.10), transparent 60%),
    radial-gradient(900px 640px at 100% 110%, rgba(180, 60, 40, 0.10), transparent 62%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { color: #f0d489; }

button { font-family: inherit; color: inherit; }

img, svg { display: block; }

::selection {
  background: rgba(201, 162, 39, 0.32);
  color: #fff;
}

/* ---------------- 滚动条 ---------------- */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(201, 162, 39, 0.22);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(201, 162, 39, 0.38); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(201, 162, 39, 0.32);
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.16), rgba(201, 162, 39, 0.06));
  color: var(--gold-soft);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover {
  border-color: rgba(201, 162, 39, 0.6);
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.26), rgba(201, 162, 39, 0.1));
  transform: translateY(-1px);
  color: #f4dfa4;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(145deg, #f0d489, var(--gold) 55%, #a98418);
  color: #1a1408;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(201, 162, 39, 0.26);
}

.btn-primary:hover {
  color: #120e06;
  background: linear-gradient(145deg, #f6e2a6, #d8b440 55%, #b28c1a);
}

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

.btn-ghost:hover {
  color: var(--text);
  background: var(--hover);
}

.btn-danger {
  border-color: rgba(192, 88, 88, 0.4);
  background: rgba(192, 88, 88, 0.1);
  color: #e08a8a;
}

.btn-danger:hover {
  border-color: rgba(192, 88, 88, 0.7);
  background: rgba(192, 88, 88, 0.18);
  color: #f0a0a0;
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-block { width: 100%; }

/* ---------------- 主题切换 ---------------- */

.theme-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.16s ease;
}

.theme-btn:hover {
  color: var(--gold-soft);
  border-color: rgba(201, 162, 39, 0.45);
  background: var(--hover);
}

.theme-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-btn .icon-sun { display: none; }
html[data-theme="dark"] .theme-btn .icon-sun { display: block; }
html[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* ---------------- 徽标 / 标签 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid currentColor;
  color: var(--gold-soft);
  white-space: nowrap;
}

.badge .bdot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.badge-plain {
  border-color: var(--line);
  color: var(--text-dim);
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--hover);
  border: 1px solid var(--line-soft);
  font-size: 10.5px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ---------------- 表单 ---------------- */

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

.field > span {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, background 0.18s;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.7;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(201, 162, 39, 0.5);
  background: rgba(201, 162, 39, 0.05);
}

.input::placeholder, .textarea::placeholder { color: var(--text-faint); }

.select { appearance: none; cursor: pointer; }
.select option { background: var(--surface-solid); color: var(--text); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.check input { accent-color: var(--gold); width: 14px; height: 14px; }

.hint-text {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-faint);
}

/* ---------------- 弹窗 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease;
}

.modal-backdrop[hidden] { display: none !important; }

.modal {
  width: min(620px, 100%);
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-solid), var(--bg-soft));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  overflow: hidden;
}

.modal.lg { width: min(760px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.modal-head .sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-faint);
}

.modal-close {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { background: var(--hover-strong); color: var(--text); }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-soft);
}

.modal-foot .left { margin-right: auto; }

/* ---------------- 轻提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 20px);
  z-index: 200;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--toast-bg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  font-size: 12.5px;
  color: var(--text);
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: all 0.24s ease;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------- 通用 ---------------- */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@keyframes popIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
