/* ============================================================
   霍格沃茨架构学院 · 魔法主题层
   设计：深紫夜空底 + 羊皮纸内容卡 + 描金装饰
   原则：只做「换肤 + 装饰」，不改动任何业务逻辑与布局
   覆盖对象：各页面内联 :root 变量（4 套命名）+ 通用元素样式
   ============================================================ */

/* ---------- 1. 统一变量覆盖（覆盖全部四套命名习惯） ---------- */
:root {
  /* 夜空与羊皮纸 */
  --bg: #17101f !important;
  --card: #f7edd6 !important;
  --paper: #f7edd6 !important;
  --paper-2: #f2e5c8 !important;
  --text: #2c2015 !important;
  --ink: #2c2015 !important;

  /* 墨色层次 */
  --muted: #7a6748 !important;
  --ink-2: #5c4c33 !important;
  --ink-3: #8a7554 !important;

  /* 描金主色 */
  --primary: #9c7620 !important;
  --primary-weak: #f0e2bf !important;
  --brand: #8c1c2b !important;
  --brand-2: #a52333 !important;
  --brand-soft: #f2dfc4 !important;

  /* 学院色 */
  --success: #1f6b4f !important;      /* 斯莱特林绿 */
  --success-weak: #dcefe4 !important;
  --green: #1f6b4f !important;
  --green-soft: #dcefe4 !important;
  --danger: #9b1c1c !important;       /* 格兰芬多红 */
  --danger-weak: #f7e0dc !important;
  --red: #9b1c1c !important;
  --red-soft: #f7e0dc !important;
  --warn: #a06a12 !important;         /* 赫奇帕奇金 */
  --warn-weak: #f7ecd3 !important;
  --amber: #a06a12 !important;
  --amber-soft: #f7ecd3 !important;

  /* 拉文克劳蓝（次要强调） */
  --blue: #2a4d7a !important;
  --blue-l: #dbe6f2 !important;
  --blue-d: #1b355c !important;
  --purple: #5b4391 !important;
  --purple-l: #e7dff5 !important;
  --purple-d: #3f2d6b !important;

  /* 灰阶 */
  --g50: #f7edd6 !important;
  --g100: #f0e2c2 !important;
  --g200: #ddc9a0 !important;
  --g300: #c4ab7c !important;
  --g500: #7a6748 !important;
  --g700: #4a3c28 !important;
  --g800: #33281a !important;
  --g900: #241a10 !important;

  /* 描边与阴影 */
  --border: #cdb488 !important;
  --bd: #cdb488 !important;
  --line: #cdb488 !important;
  --line-2: #b99f74 !important;
  --shadow: 0 2px 4px rgba(0, 0, 0, .18), 0 10px 30px rgba(0, 0, 0, .22) !important;
  --radius: 10px !important;
}

/* ---------- 2. 字体 ---------- */
:root {
  --hw-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  --hw-sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", system-ui, sans-serif;
}

/* 标题走衬线，正文保持无衬线以保证长文可读性 */
h1, h2, h3, h4, h5 {
  font-family: var(--hw-serif) !important;
  letter-spacing: .02em;
}

/* ---------- 3. 夜空背景与星空 ---------- */
body {
  background-color: #17101f !important;
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, #2e1b45 0%, rgba(46, 27, 69, 0) 60%),
    radial-gradient(ellipse 90% 60% at 10% 100%, #1d2a3d 0%, rgba(29, 42, 61, 0) 55%),
    radial-gradient(ellipse 90% 60% at 90% 100%, #2a1630 0%, rgba(42, 22, 48, 0) 55%),
    linear-gradient(180deg, #17101f 0%, #1c1329 50%, #150e1c 100%) !important;
  background-attachment: fixed !important;
  color: #e8dcc4 !important;
}

/* 星空层：由 JS 注入星点，这里只定义容器与闪烁动画 */
#hw-starry {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#hw-starry i {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: #fff8e1;
  animation: hw-twinkle linear infinite;
}

@keyframes hw-twinkle {
  0%, 100% { opacity: .18; transform: scale(.85); }
  50%      { opacity: .95; transform: scale(1.15); }
}

/* 让页面内容浮在星空之上 */
body > *:not(#hw-starry):not(script):not(style) {
  position: relative;
  z-index: 1;
}

/* ---------- 4. 羊皮纸卡片 ---------- */
/* 覆盖常见容器类名，赋予羊皮纸质感 + 描金细边 */
.card, .panel, .box, .section, .container, main > div, .wrap, .sheet {
  background-color: var(--card) !important;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 88% 82%, rgba(160, 120, 60, .10) 0%, rgba(160, 120, 60, 0) 46%),
    linear-gradient(160deg, #f9f1dc 0%, #f5e9cf 100%) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow) !important;
}

/* 卡片内文字统一为墨色，避免继承夜空的浅色字 */
.card, .card *, .panel, .panel *, .box, .box *, .section, .section * {
  color: var(--text);
}

/* ---------- 5. 顶栏 / 导航：深色魔法条 ---------- */
.topbar, header.topbar, .navbar, nav.tabs, .tabs {
  background: linear-gradient(180deg, rgba(28, 18, 42, .97) 0%, rgba(20, 13, 30, .97) 100%) !important;
  border-bottom: 1px solid rgba(201, 162, 39, .45) !important;
  backdrop-filter: blur(6px);
}

.topbar h1, .topbar h2, .topbar p, .brand-txt h1, .brand-txt p {
  color: #f0e0b8 !important;
}

.tabs a, nav.tabs a {
  color: #d9c9a4 !important;
  border-bottom-color: transparent !important;
}

.tabs a:hover, nav.tabs a:hover {
  color: #ffdf8a !important;
}

.tabs a.active, nav.tabs a.active {
  color: #ffd76a !important;
  border-bottom-color: #c9a227 !important;
}

/* ---------- 6. 按钮：描金 + 深红 ---------- */
.btn, button, input[type="button"], input[type="submit"] {
  border-radius: 8px !important;
  transition: all .18s ease !important;
}

.btn-primary, .btn.primary, button.primary {
  background: linear-gradient(180deg, #8c1c2b 0%, #6d1522 100%) !important;
  border: 1px solid #c9a227 !important;
  color: #f7e6c4 !important;
  box-shadow: 0 2px 8px rgba(140, 28, 43, .35) !important;
}

.btn-primary:hover, .btn.primary:hover, button.primary:hover {
  background: linear-gradient(180deg, #a52333 0%, #7d1a29 100%) !important;
  box-shadow: 0 4px 14px rgba(201, 162, 39, .4) !important;
}

/* 幽灵按钮：羊皮纸底 + 金边 */
.btn.ghost, button.ghost {
  background: rgba(247, 237, 214, .08) !important;
  color: #f0e0b8 !important;
  border-color: rgba(201, 162, 39, .5) !important;
}

.btn.ghost:hover, button.ghost:hover {
  background: rgba(201, 162, 39, .16) !important;
  border-color: #c9a227 !important;
}

/* ---------- 7. 通用元素微调 ---------- */
/* 链接 */
a {
  color: #b8912f !important;
}

a:hover {
  color: #ffd76a !important;
}

/* 表格 */
table {
  border-collapse: collapse;
}

th {
  background: linear-gradient(180deg, #efe0bd 0%, #e6d4ad 100%) !important;
  color: #4a3c28 !important;
  font-family: var(--hw-serif) !important;
  border-bottom: 2px solid #c9a227 !important;
}

td, th {
  border: 1px solid var(--border) !important;
}

tr:nth-child(even) td {
  background: rgba(240, 226, 194, .45) !important;
}

/* 代码块 / 引用 */
pre, code, kbd {
  background: #2a1f14 !important;
  color: #e8d9b8 !important;
  border: 1px solid #5c4c33 !important;
  border-radius: 6px;
}

blockquote {
  border-left: 3px solid #c9a227 !important;
  background: rgba(201, 162, 39, .08) !important;
  color: #5c4c33 !important;
}

/* 输入框 */
input, textarea, select {
  background: #fdf7e8 !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
}

input:focus, textarea:focus, select:focus {
  outline: none !important;
  border-color: #c9a227 !important;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .22) !important;
}

/* ---------- 8. 滚动条 ---------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #1c1329;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6b4f2a 0%, #4a3c28 100%);
  border-radius: 5px;
  border: 1px solid rgba(201, 162, 39, .3);
}

::-webkit-scrollbar-thumb:hover {
  background: #8c6a35;
}

/* ---------- 9. 统一导航条（由 JS 注入 .hw-nav） ---------- */
.hw-nav {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 22px;
  background: linear-gradient(180deg, rgba(26, 16, 36, .98) 0%, rgba(17, 10, 24, .98) 100%);
  border-bottom: 2px solid rgba(201, 162, 39, .5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .45);
  flex-wrap: wrap;
}

.hw-nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c9a227 20%, #ffd76a 50%, #c9a227 80%, transparent);
  opacity: .7;
}

.hw-nav .hw-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--hw-serif);
  font-size: 16px;
  font-weight: 700;
  color: #ffd76a !important;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .04em;
}

.hw-nav .hw-crest {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #c9a227;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a2a4d, #1a1024);
  color: #ffd76a;
  font-size: 14px;
}

.hw-nav .hw-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.hw-nav .hw-links a {
  padding: 6px 13px;
  border-radius: 16px;
  font-size: 14px;
  color: #d9c9a4 !important;
  text-decoration: none;
  transition: all .18s ease;
  white-space: nowrap;
  border: 1px solid transparent;
}

.hw-nav .hw-links a:hover {
  color: #ffdf8a !important;
  background: rgba(201, 162, 39, .14);
  border-color: rgba(201, 162, 39, .4);
}

.hw-nav .hw-links a.hw-active {
  color: #1a1024 !important;
  background: linear-gradient(180deg, #ffd76a 0%, #c9a227 100%);
  border-color: #ffd76a;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(201, 162, 39, .5);
}

/* 学院杯积分徽章 */
.hw-points {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(140, 28, 43, .9), rgba(90, 16, 28, .9));
  border: 1px solid #c9a227;
  color: #ffe9b8 !important;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.hw-points b {
  color: #ffd76a !important;
  font-size: 15px;
}

/* ---------- 9.5 导航右侧：用户区 ---------- */
.hw-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.hw-user { position: relative; }

.hw-user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 18px;
  background: rgba(247, 237, 214, .08);
  border: 1px solid rgba(201, 162, 39, .45);
  color: #f0e0b8 !important;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s ease;
}

.hw-user-btn:hover {
  background: rgba(201, 162, 39, .16);
  border-color: #c9a227;
}

.hw-user .hw-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #fff;
  font-family: var(--hw-serif);
  flex: none;
}

.hw-user .hw-caret { font-size: 9px; opacity: .7; }

.hw-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 212px;
  background: linear-gradient(160deg, #f9f1dc 0%, #f2e5c8 100%);
  border: 1px solid #c9a227;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  padding: 8px;
  z-index: 1000;
  display: none;
}

.hw-menu.open { display: block; }

.hw-menu .hw-menu-title {
  font-size: 11px;
  color: #8a7554;
  padding: 6px 10px 4px;
  font-family: var(--hw-serif);
  letter-spacing: .05em;
}

.hw-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  color: #2c2015 !important;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.hw-menu button:hover { background: rgba(140, 28, 43, .1); }
.hw-menu button.on { background: rgba(201, 162, 39, .28); font-weight: 700; }
.hw-menu button.danger { color: #9b1c1c !important; }

.hw-menu .hw-sep {
  height: 1px;
  background: #ddc9a0;
  margin: 6px 4px;
}

.hw-menu .hw-row { display: flex; gap: 6px; }
.hw-menu .hw-row button { flex: 1; text-align: center; }

.hw-login-btn {
  padding: 5px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffd76a, #c9a227);
  border: 1px solid #ffd76a;
  color: #1a1024 !important;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.hw-login-btn:hover { box-shadow: 0 0 12px rgba(201, 162, 39, .6); }

.hw-sync {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a9c7a;
  flex: none;
  box-shadow: 0 0 6px rgba(74, 156, 122, .8);
}

.hw-sync.busy { background: #d4a017; box-shadow: 0 0 6px rgba(212, 160, 23, .8); }
.hw-sync.err  { background: #b03a2e; box-shadow: 0 0 6px rgba(176, 58, 46, .8); }

/* ---------- 10. 页脚 ---------- */
.hw-footer {
  margin-top: 40px;
  padding: 22px 20px 30px;
  text-align: center;
  color: #8a7554 !important;
  font-size: 12.5px;
  border-top: 1px solid rgba(201, 162, 39, .25);
  font-family: var(--hw-serif);
}

.hw-footer .hw-sig {
  color: #c9a227 !important;
  letter-spacing: .1em;
}

/* ---------- 11. 移动端适配 ---------- */
@media (max-width: 720px) {
  .hw-nav {
    padding: 8px 12px;
    gap: 10px;
  }

  .hw-nav .hw-brand span {
    display: none;
  }

  .hw-nav .hw-links a {
    padding: 5px 10px;
    font-size: 13px;
  }

  .hw-points {
    font-size: 12px;
    padding: 4px 10px;
  }
}

/* ---------- 12. 打印：回归纸感 ---------- */
@media print {
  #hw-starry, .hw-nav, .hw-footer, .no-print {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .card, .panel, .box, .section {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
  }
}
