/* ============================================================
   夜郎星空站 · 设计系统
   原则：深空质感 + 无障碍优先
   - 所有交互元素具备 ≥3:1 非文本对比度、≥4.5:1 正文对比度
   - 焦点环永不被移除，仅强化
   - 支持 高对比 / 大字号 / 减少动画 三种无障碍偏好
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --bg-0: #04060e;
  --bg-1: #080f22;
  --bg-2: #0d1730;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.075);
  --panel-solid: #0c1428;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);

  --text: #eef3ff;
  --text-dim: #b3c0dd;
  --text-mute: #8492b4;

  --brand: #4fd1ff;
  --brand-deep: #1d9fd6;
  --violet: #8b7bff;
  --gold: #ffd479;
  --ok: #57e08e;
  --warn: #ffc44d;
  --danger: #ff7089;

  --focus: #ffd479;
  --radius: 18px;
  --radius-sm: 11px;
  --radius-pill: 999px;
  --shadow-1: 0 24px 60px -28px rgba(0, 0, 0, 0.9);
  --shadow-2: 0 10px 30px -14px rgba(0, 0, 0, 0.7);

  --fs: 16px;
  --content: 1180px;
  --header-h: 68px;
}

body[data-fontsize='large'] { --fs: 18px; }
body[data-fontsize='xlarge'] { --fs: 20px; }

/* 高对比：提升文字与描边对比，移除半透明依赖 */
body[data-contrast='high'] {
  --bg-0: #000000;
  --bg-1: #000000;
  --bg-2: #0a0a0a;
  --panel: #101010;
  --panel-2: #1a1a1a;
  --panel-solid: #0d0d0d;
  --line: #6b6b6b;
  --line-strong: #ffffff;
  --text: #ffffff;
  --text-dim: #f0f0f0;
  --text-mute: #d8d8d8;
  --brand: #7fe3ff;
  --gold: #ffe28a;
  --danger: #ff9aa8;
}
body[data-contrast='high'] .card,
body[data-contrast='high'] .panel {
  border-width: 2px;
  backdrop-filter: none;
  background: var(--panel);
}
body[data-contrast='high'] .starfield,
body[data-contrast='high'] .glow { display: none; }

/* [hidden] 必须始终生效：组件类里的 display 不得覆盖它，
   否则 hidden 属性会失效（无障碍上会读出不存在的控件） */
[hidden] { display: none !important; }

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  font-size: var(--fs);
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-0);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body[data-motion='reduce'] *,
body[data-motion='reduce'] *::before,
body[data-motion='reduce'] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 星空背景（纯装饰，对读屏器隐藏） ---------- */
.starfield,
.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.starfield {
  background-image:
    radial-gradient(2px 2px at 12% 18%, rgba(255, 255, 255, 0.95), transparent 60%),
    radial-gradient(1.6px 1.6px at 68% 8%, rgba(190, 225, 255, 0.9), transparent 60%),
    radial-gradient(2.4px 2.4px at 88% 42%, rgba(255, 255, 255, 0.85), transparent 60%),
    radial-gradient(1.5px 1.5px at 32% 74%, rgba(205, 215, 255, 0.9), transparent 60%),
    radial-gradient(2px 2px at 55% 55%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 5% 60%, rgba(255, 255, 255, 0.8), transparent 60%),
    radial-gradient(1.8px 1.8px at 78% 82%, rgba(160, 205, 255, 0.8), transparent 60%),
    radial-gradient(1.4px 1.4px at 42% 33%, rgba(255, 255, 255, 0.65), transparent 60%),
    radial-gradient(1.2px 1.2px at 25% 92%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 94% 66%, rgba(200, 220, 255, 0.65), transparent 60%);
  background-size: 620px 620px;
  opacity: 0.9;
  animation: drift 240s linear infinite;
}

@keyframes drift {
  from { background-position: 0 0; }
  to { background-position: 620px 1240px; }
}

.glow {
  background:
    radial-gradient(58% 42% at 12% -6%, rgba(79, 209, 255, 0.17), transparent 70%),
    radial-gradient(48% 38% at 88% 2%, rgba(139, 123, 255, 0.15), transparent 72%),
    radial-gradient(70% 50% at 50% 108%, rgba(29, 159, 214, 0.1), transparent 75%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 58%);
}

/* ---------- 布局骨架 ---------- */
.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

main { flex: 1 0 auto; }

.section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.section-tight { padding-block: clamp(1.75rem, 3vw, 2.5rem); }

/* ---------- 无障碍工具 ---------- */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 0.75rem 1.5rem;
  background: var(--gold);
  color: #10131c;
  font-weight: 700;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: top 0.18s ease;
}
.skip-link:focus { top: 0; }

/* 焦点可见：全站统一、强对比、双环 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}
a:focus-visible,
button:focus-visible,
[role='button']:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 212, 121, 0.22);
  border-radius: var(--radius-sm);
}
body[data-contrast='high'] :focus-visible {
  outline: 4px solid #ffffff;
  box-shadow: 0 0 0 8px #000000, 0 0 0 11px #ffffff;
}

/* 屏幕朗读器实时播报区：视觉隐藏，但可被读到 */
#live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ---------- 页头 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: rgba(8, 15, 34, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
body[data-contrast='high'] .site-header { background: #000; }

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--violet));
  color: #04121c;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 0 22px -4px rgba(79, 209, 255, 0.7);
}

.brand-name { font-size: 1.06rem; }
.brand-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-mute);
  letter-spacing: 0.14em;
  margin-top: -2px;
}

.main-nav { display: flex; gap: 0.25rem; margin-inline-start: auto; }

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  transition: color 0.18s, background 0.18s;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link[aria-current='page'] {
  color: #04121c;
  background: linear-gradient(135deg, var(--brand), #7cc6ff);
  font-weight: 700;
}
body[data-contrast='high'] .nav-link[aria-current='page'] { background: #fff; color: #000; }

.header-actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }

/* 窄屏：页头折成两行，导航横向滚动，绝不挤压文字 */
@media (max-width: 760px) {
  :root { --header-h: 112px; }
  .site-header { height: auto; padding-block: 0.55rem; }
  .header-inner {
    flex-wrap: wrap;
    row-gap: 0.45rem;
    align-items: center;
  }
  .brand-sub { display: none; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 0.95rem; }
  .brand-name { font-size: 1rem; }
  .header-actions { margin-inline-start: auto; }
  .header-actions .btn { padding-inline: 0.7rem; font-size: 0.85rem; }
  .main-nav {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
    gap: 0.2rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }
  .main-nav::-webkit-scrollbar { display: none; }
  .nav-link { padding: 0.45rem 0.75rem; font-size: 0.88rem; }
  .hero { padding-block: 2.2rem 1.2rem; }
  .hero-orb { opacity: 0.35; right: -30%; }
  .stat { padding: 0.85rem 0.9rem; }
  .stat-value { font-size: 1.25rem; }
  .section { padding-block: 2.2rem; }
  .admin-shell { gap: 1rem; }
  .toolbar { gap: 0.5rem; }
  .toolbar > * { flex: 1 1 auto; }
  .toolbar .spacer { display: none; }
  .search-box { flex-basis: 100%; }
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .btn { width: 100%; }
}

@media (max-width: 420px) {
  .header-inner { padding-inline: 0.9rem; }
  h1 { font-size: 1.75rem; }
  .hero-actions .btn { flex: 1 1 auto; }
}

/* ---------- 按钮 ---------- */
.btn {
  --btn-bg: var(--panel-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.btn:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.11); }
.btn:active { transform: translateY(1px); }
.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--violet));
  border-color: transparent;
  color: #04121c;
  box-shadow: 0 12px 30px -14px rgba(79, 209, 255, 0.9);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #6fdcff, #9c8dff);
  color: #04121c;
}
body[data-contrast='high'] .btn-primary { background: #fff; color: #000; border: 2px solid #fff; }

.btn-ghost { background: transparent; }
.btn-danger {
  background: rgba(255, 112, 137, 0.14);
  border-color: rgba(255, 112, 137, 0.45);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255, 112, 137, 0.24); }

.btn-sm { min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--panel-2); }

/* ---------- 卡片与面板 ---------- */
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-2);
  padding: clamp(1.1rem, 2.2vw, 1.6rem);
}
.card-interactive { transition: transform 0.18s ease, border-color 0.18s, box-shadow 0.18s; }
.card-interactive:hover {
  transform: translateY(-3px);
  border-color: rgba(79, 209, 255, 0.4);
  box-shadow: 0 26px 60px -30px rgba(79, 209, 255, 0.5);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(12px);
}

.grid { display: grid; gap: clamp(0.9rem, 2vw, 1.4rem); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }

/* ---------- 标题与文本 ---------- */
h1, h2, h3, h4 {
  margin: 0 0 0.6em;
  line-height: 1.28;
  letter-spacing: -0.01em;
  font-weight: 700;
}
h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.85rem); }
h3 { font-size: clamp(1.1rem, 1.8vw, 1.28rem); }
h4 { font-size: 1.02rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.lead { font-size: 1.06rem; color: var(--text-dim); }
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.tiny { font-size: 0.8rem; }
.mono { font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace; font-size: 0.86rem; }

.gradient-text {
  background: linear-gradient(120deg, #ffffff 8%, var(--brand) 45%, var(--violet) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body[data-contrast='high'] .gradient-text {
  background: none;
  -webkit-text-fill-color: #ffffff;
  color: #ffffff;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 0.9rem;
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 2px;
  background: linear-gradient(90deg, var(--brand), transparent);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: clamp(1.2rem, 2.5vw, 2rem);
}
.section-head h2 { margin-bottom: 0.15em; }
.section-head .sub { color: var(--text-mute); font-size: 0.94rem; margin: 0; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-brand { border-color: rgba(79, 209, 255, 0.45); color: var(--brand); background: rgba(79, 209, 255, 0.1); }
.badge-gold { border-color: rgba(255, 212, 121, 0.45); color: var(--gold); background: rgba(255, 212, 121, 0.1); }
.badge-ok { border-color: rgba(87, 224, 142, 0.45); color: var(--ok); background: rgba(87, 224, 142, 0.1); }
.badge-warn { border-color: rgba(255, 196, 77, 0.45); color: var(--warn); background: rgba(255, 196, 77, 0.1); }
.badge-danger { border-color: rgba(255, 112, 137, 0.45); color: var(--danger); background: rgba(255, 112, 137, 0.1); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(87, 224, 142, 0.18);
  flex-shrink: 0;
}
.dot-pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(87, 224, 142, 0.2); }
  50% { box-shadow: 0 0 0 7px rgba(87, 224, 142, 0.06); }
}

/* ---------- 首页 Hero ---------- */
.hero {
  position: relative;
  padding-block: clamp(3rem, 8vw, 6rem) clamp(2rem, 5vw, 3.5rem);
  overflow: hidden;
}
.hero-inner { max-width: 780px; }
.hero h1 { margin-bottom: 0.5em; }
.hero .lead { max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.8rem; }

.hero-orb {
  position: absolute;
  right: -8%;
  top: 4%;
  width: clamp(280px, 42vw, 520px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.4), transparent 42%),
    radial-gradient(circle at 65% 70%, rgba(139, 123, 255, 0.55), transparent 58%),
    radial-gradient(circle at 40% 40%, rgba(79, 209, 255, 0.45), transparent 62%);
  filter: blur(6px);
  opacity: 0.55;
  animation: float 18s ease-in-out infinite;
  pointer-events: none;
}
body[data-contrast='high'] .hero-orb { display: none; }
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-18px, 22px, 0) scale(1.05); }
}

/* ---------- 数据条 ---------- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}
.stat {
  background: var(--bg-1);
  padding: 1.1rem 1.2rem;
}
.stat-value {
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 0.8rem; color: var(--text-mute); letter-spacing: 0.04em; }

/* ---------- 公告条 ---------- */
.announce {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid rgba(255, 212, 121, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(255, 212, 121, 0.08);
  color: #ffe9b8;
  font-size: 0.92rem;
}
body[data-contrast='high'] .announce { background: #1a1500; color: #ffe28a; border-width: 2px; }

/* ---------- 文件 / 教程卡片 ---------- */
.item-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  height: 100%;
}
.item-card-head { display: flex; align-items: flex-start; gap: 0.75rem; }
.item-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(150deg, rgba(79, 209, 255, 0.25), rgba(139, 123, 255, 0.22));
  border: 1px solid rgba(79, 209, 255, 0.32);
  color: #bfe9ff;
}
body[data-contrast='high'] .item-icon { background: #000; color: #fff; border: 2px solid #fff; }
.item-title {
  font-size: 1.02rem;
  font-weight: 650;
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
}
.item-desc {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-mute);
  margin-top: auto;
}
.item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- 表单 ---------- */
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 1.15rem 0.85rem;
  margin: 0 0 1.1rem;
}
legend {
  padding: 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
}

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 1rem; }

label, .label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.required-mark { color: var(--danger); }

input[type='text'],
input[type='password'],
input[type='email'],
input[type='search'],
input[type='number'],
input[type='url'],
input[type='datetime-local'],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: var(--radius-sm);
  background: rgba(4, 8, 18, 0.6);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
body[data-contrast='high'] input,
body[data-contrast='high'] select,
body[data-contrast='high'] textarea { background: #000; border: 2px solid #fff; }

textarea { min-height: 130px; resize: vertical; line-height: 1.65; }

input::placeholder, textarea::placeholder { color: var(--text-mute); opacity: 1; }

input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.35); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79, 209, 255, 0.16);
  outline: none;
}
input[aria-invalid='true'],
textarea[aria-invalid='true'],
select[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 112, 137, 0.16);
}

.hint { font-size: 0.8rem; color: var(--text-mute); }
.error-text {
  font-size: 0.82rem;
  color: var(--danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.search-box { position: relative; flex: 1 1 220px; min-width: 180px; }
.search-box input { padding-inline-start: 2.4rem; }
.search-box::before {
  content: '⌕';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mute);
  font-size: 1.1rem;
  pointer-events: none;
}

/* 原生 checkbox / radio 放大，保证触控与识别 */
input[type='file'] {
  padding: 0.3rem;
  cursor: pointer;
}
input[type='file']::file-selector-button {
  margin-right: 0.8rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
input[type='file']::file-selector-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

input[type='checkbox'],
input[type='radio'] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.55rem 0;
}
.check-row label { font-weight: 500; color: var(--text-dim); cursor: pointer; }

/* 开关：用 checkbox 承载语义，读屏器播报「已选中/未选中」 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  padding: 0.4rem 0;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #cfd8ee;
  transition: transform 0.2s ease, background 0.2s;
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--brand), var(--violet));
  border-color: transparent;
}
.switch input:checked + .switch-track::after { transform: translateX(22px); background: #04121c; }
.switch input:focus-visible + .switch-track {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.switch-state { font-size: 0.85rem; font-weight: 600; color: var(--text-mute); min-width: 2.6em; }
.switch input:checked ~ .switch-state { color: var(--ok); }

/* ---------- 表格 ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
caption {
  text-align: left;
  padding: 0.9rem 1rem 0.2rem;
  font-size: 0.82rem;
  color: var(--text-mute);
}
th, td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: rgba(255, 255, 255, 0.035);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
td .row-actions { display: flex; gap: 0.35rem; flex-wrap: nowrap; }
td .row-actions .btn { white-space: nowrap; }
td .row-actions .icon-btn { width: 36px; height: 36px; }
body[data-contrast='high'] td, body[data-contrast='high'] th { border-bottom: 2px solid #555; }

/* ---------- 标签页（管理后台） ---------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  scrollbar-width: thin;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 42px;
  padding: 0.5rem 0.95rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab[aria-selected='true'] {
  background: linear-gradient(135deg, rgba(79, 209, 255, 0.22), rgba(139, 123, 255, 0.2));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(79, 209, 255, 0.45);
}
body[data-contrast='high'] .tab[aria-selected='true'] { background: #fff; color: #000; }

.tabpanel { padding-top: 1.4rem; }
.tabpanel[hidden] { display: none; }

/* ---------- 对话框（原生 dialog，天然支持焦点与 Esc） ---------- */
dialog {
  width: min(620px, calc(100vw - 2rem));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow-1);
  overflow: auto;
}
dialog::backdrop {
  background: rgba(2, 5, 12, 0.78);
  backdrop-filter: blur(4px);
}
.dialog-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.4rem 0.9rem;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: 1.3rem 1.4rem; }
.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.4rem;
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ---------- 提示 / 状态 ---------- */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-mute);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--text-dim); margin-bottom: 0.35rem; font-size: 1rem; }

.notice {
  display: flex;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.9rem;
}
.notice-ok { border-color: rgba(87, 224, 142, 0.4); background: rgba(87, 224, 142, 0.09); color: #c8ffdd; }
.notice-warn { border-color: rgba(255, 196, 77, 0.4); background: rgba(255, 196, 77, 0.09); color: #ffe9b5; }
.notice-danger { border-color: rgba(255, 112, 137, 0.4); background: rgba(255, 112, 137, 0.09); color: #ffd0d8; }

/* Toast：视觉提示，同时写入 aria-live 区域 */
#toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  box-shadow: var(--shadow-1);
  font-size: 0.9rem;
  animation: toast-in 0.22s ease;
}
.toast.ok { border-color: rgba(87, 224, 142, 0.55); }
.toast.err { border-color: rgba(255, 112, 137, 0.55); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* 骨架屏 */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  min-height: 90px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 1.8rem;
}
.pagination .btn { min-width: 44px; }
.pagination [aria-current='page'] {
  background: linear-gradient(135deg, var(--brand), var(--violet));
  color: #04121c;
  border-color: transparent;
  font-weight: 800;
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-block: 2rem;
  color: var(--text-mute);
  font-size: 0.86rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.footer-links { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }

/* ---------- 管理后台布局 ---------- */
.admin-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 1.4rem;
  align-items: start;
  padding-block: 1.8rem 3rem;
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
}

/* 面板下拉仅在窄屏出现，桌面端由侧边 tablist 承担导航 */
#panel-select-wrap { display: none; }
@media (max-width: 900px) {
  #panel-select-wrap { display: block; }
}

.admin-side {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
@media (max-width: 900px) {
  .admin-side { position: static; flex-direction: row; overflow-x: auto; }
}

.tab {
  justify-content: flex-start;
  width: 100%;
  text-align: left;
}
@media (max-width: 900px) { .tab { width: auto; } }

.admin-main { min-width: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.2rem;
}
.toolbar .spacer { flex: 1 1 auto; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 560px) {
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat-card {
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.stat-card .k { font-size: 0.78rem; color: var(--text-mute); letter-spacing: 0.05em; }
.stat-card .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }

.subpanel {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.1rem;
  background: rgba(255, 255, 255, 0.022);
}
.subpanel > h3 { margin-bottom: 0.9rem; font-size: 1rem; }

/* 上传拖拽区 */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 0.5rem;
  padding: 2.4rem 1.5rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-over {
  border-color: var(--brand);
  background: rgba(79, 209, 255, 0.07);
}
.dropzone input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* 进度条 */
.progress {
  height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--violet));
  transition: width 0.2s ease;
}

/* 登录页 */
.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - var(--header-h) - 120px);
  padding-block: 2rem;
}
.auth-card { width: min(430px, 100%); }

/* ---------- 文章正文排版 ---------- */
.prose {
  font-size: 1.02rem;
  line-height: 1.85;
  color: var(--text-dim);
  max-width: 76ch;
}
.prose h2 { color: var(--text); margin-top: 2em; font-size: 1.4rem; }
.prose h3 { color: var(--text); margin-top: 1.7em; font-size: 1.15rem; }
.prose h4 { color: var(--text); margin-top: 1.5em; }
.prose a { color: var(--brand); text-underline-offset: 3px; }
.prose a:hover { color: #8be6ff; }
.prose ul, .prose ol { padding-left: 1.4em; margin-bottom: 1.1em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote {
  margin: 1.4em 0;
  padding: 0.8em 1.1em;
  border-left: 3px solid var(--brand);
  background: rgba(79, 209, 255, 0.07);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}
.prose code {
  padding: 0.14em 0.42em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  font-size: 0.88em;
  color: #a9e8ff;
}
.prose pre {
  margin: 1.3em 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #060b18;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; color: #cfe6ff; font-size: 0.86rem; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { margin: 1.2em 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }

/* ---------- 工具类 ---------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.4rem; }
.gap-2 { gap: 0.75rem; }
.gap-3 { gap: 1.2rem; }
.wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.8rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.8rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- 打印 ---------- */
@media print {
  .site-header, .site-footer, .hero-orb, .starfield, .glow, #toast-stack { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .panel { border: 1px solid #ccc; background: #fff; }
}
