/* 浮动之锚 · 全站框架（顶栏、页脚、版本说明、主题变量）
 * 新设计页面（templates/fa/base.html）和旧页面（templates/base.html）都会加载本文件，
 * 所以这里只写设计变量和框架自身的样式，不改动 body、标题等全局元素。 */
:root {
  --bg: #faf5ec;
  --bg-2: #f3ecdf;
  --card: #fffdf8;
  --panel: #fffdf8;
  --paper: #ffffff;
  --ink: #1c1915;
  --ink-2: #3d3830;
  --ink-strong: #000000;
  --muted: #6f675b;
  --muted-2: #a39887;
  --line: #e6dccb;
  --line-2: #d7c8ae;
  --accent: #ef7a3c;
  --accent-ink: #c9561c;
  --accent-soft: #fde4d2;
  --accent-wash: #fff6ee;
  --accent-line: #f3d2ba;
  --sun: #f5c33b;
  --deep: #15120e;
  --on-ink: #ffffff;
  --on-accent: #ffffff;
  --top-bg: rgba(250, 245, 236, .9);
  --shadow: 0 30px 60px -40px rgba(60, 40, 10, .45);
  --brand: #15284b;
  --serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --latin: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --hand: "Liu Jian Mao Cao", "Kaiti SC", "STKaiti", cursive;
  --italic: "Fraunces", Georgia, "Times New Roman", serif;
  --wrap: 1200px;
  /* 共享交互层（术语浮层、原图放大、图中标记） */
  --rc-pop-bg: #fffdf8;
  --rc-pop-fg: #1c1915;
  --rc-pop-muted: #6f675b;
  --rc-pop-line: #e6dccb;
  --rc-pop-accent: #c9561c;
  --rc-pop-radius: 16px;
  --rc-hl: #ef7a3c;
}
/* Dark：暖炭灰底，面板略微抬起，橙色提亮一档 */
html[data-theme="dark"] {
  --bg: #141210;
  --bg-2: #1b1815;
  --card: #1e1b17;
  --panel: #221e1a;
  --paper: #24201b;
  --ink: #f1eadf;
  --ink-2: #d4ccbf;
  --ink-strong: #ffffff;
  --muted: #9d9385;
  --muted-2: #7d7468;
  --line: #322d27;
  --line-2: #4a4239;
  --accent: #f28a4f;
  --accent-ink: #f6a77a;
  --accent-soft: rgba(242, 138, 79, .18);
  --accent-wash: rgba(242, 138, 79, .08);
  --accent-line: rgba(242, 138, 79, .35);
  --deep: #0c0b0a;
  --on-ink: #141210;
  --on-accent: #1a1006;
  --top-bg: rgba(20, 18, 16, .88);
  --shadow: 0 30px 60px -40px rgba(0, 0, 0, .8);
  --brand: #213c68;
  --rc-pop-bg: #221e1a;
  --rc-pop-fg: #f1eadf;
  --rc-pop-muted: #9d9385;
  --rc-pop-line: #322d27;
  --rc-pop-accent: #f6a77a;
}

/* ---------- 顶栏 ---------- */
.top { position: sticky; top: 0; z-index: 50; background: var(--top-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); font-family: var(--sans); color: var(--ink); line-height: 1.5; }
.top *, .foot *, .ver-pop * { box-sizing: border-box; }
.top .wrap, .foot .wrap { width: min(100% - 48px, 1360px); margin: 0 auto; }
:is(.top, .foot) .top-in { display: flex; align-items: center; gap: 14px; height: 66px; }
.fa-skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: var(--on-ink); padding: 8px 14px; border-radius: 8px; }
.fa-skip:focus { left: 12px; }

/* 品牌标识：悬浮锚统一母版 + 字标，所有主题使用同一配色。 */
:is(.top, .foot) .brand { display: flex; align-items: center; gap: 11px; text-decoration: none; flex: none; color: var(--ink); }
:is(.top, .foot) a.brand:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 5px; border-radius: 4px; }
:is(.top, .foot) .mark { display: block; flex: none; width: 42px; height: 42px; object-fit: contain; border-radius: 23%; }
/* 沿用原锚标的歪头角度与回弹节奏，作用于当前顶栏图标。 */
@media (prefers-reduced-motion: no-preference) {
  .top a.brand .mark { transform-origin: 50% 24.17%; transition: transform .6s cubic-bezier(.34, 1.56, .64, 1); }
  .top a.brand:focus-visible .mark { transform: rotate(-9deg); }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .top a.brand:hover .mark { transform: rotate(-9deg); }
}
:is(.top, .foot) .brand-txt { display: flex; flex-direction: column; gap: 3px; }
:is(.top, .foot) .brand-txt b { font: 900 19px/1 var(--serif); letter-spacing: .12em; margin-right: -.12em; }
:is(.top, .foot) a.brand:hover .brand-txt b { color: var(--accent-ink); }
:is(.top, .foot) .brand-txt small { display: flex; align-items: center; gap: 6px; line-height: 1; white-space: nowrap; }
:is(.top, .foot) .brand-txt em { font: 400 16px/1 var(--hand); font-style: normal; color: var(--accent-ink); letter-spacing: .04em; }
:is(.top, .foot) .brand-txt i { width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); }
:is(.top, .foot) .brand-txt small span { font: italic 500 12.5px/1 var(--italic); color: var(--muted); letter-spacing: .03em; }

:is(.top, .foot) .nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
:is(.top, .foot) .nav a { padding: 8px 10px; border-radius: 999px; font-size: 14.5px; color: var(--ink-2); text-decoration: none; transition: background-color .2s, color .2s; white-space: nowrap; }
:is(.top, .foot) .nav a:hover { background: var(--bg-2); color: var(--ink); }
:is(.top, .foot) .nav a[aria-current="page"] { color: var(--ink); font-weight: 700; background: var(--bg-2); }
:is(.top, .foot) .nav a small { font-size: 10.5px; color: var(--accent-ink); margin-left: 2px; }
:is(.top, .foot) .nav .nav-club { margin-left: 8px; border: 1.5px solid var(--ink); font-weight: 600; color: var(--ink); padding: 7px 14px; }
:is(.top, .foot) .nav .nav-club:hover, :is(.top, .foot) .nav .nav-club[aria-current="page"] { background: var(--ink); color: var(--on-ink); }
:is(.top, .foot) .nav .nav-m { display: none; }

:is(.top, .foot) .top-act { display: flex; align-items: center; gap: 6px; flex: none; }
:is(.top, .foot) .top-icon { position: relative; flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); color: var(--ink-2); background: var(--card); text-decoration: none; transition: border-color .2s, color .2s; }
:is(.top, .foot) .top-icon svg { width: 18px; height: 18px; }
:is(.top, .foot) .top-icon:hover { border-color: var(--ink); color: var(--ink); }
:is(.top, .foot) .top-icon.is-dc { color: #5865f2; }
:is(.top, .foot) .top-icon.is-dc:hover { border-color: #5865f2; }
:is(.top, .foot) .top-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 700 10.5px/18px var(--latin); text-align: center; box-shadow: 0 0 0 2px var(--bg); }
:is(.top, .foot) .top-badge[hidden] { display: none; }
:is(.top, .foot) .top-login { flex: none; padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--ink-2); white-space: nowrap; }
:is(.top, .foot) .top-login:hover { background: var(--bg-2); color: var(--ink); }
:is(.top, .foot) .top-signup { flex: none; padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; text-decoration: none; background: var(--ink); color: var(--on-ink); white-space: nowrap; }
:is(.top, .foot) .top-signup:hover { background: var(--ink-strong); color: var(--on-ink); }

.top .top-profile {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 38px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--ink);
  font: 600 14px/1.4 var(--sans);
  text-decoration: none;
}
.top .top-profile span { max-width: 9em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top .top-profile svg { flex: none; color: var(--muted); }
.top .top-profile:hover { background: var(--bg-2); }
.top .top-profile:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

.account-identity {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: 400 12px/1.5 var(--latin);
  pointer-events: none;
}
.account-identity.is-advanced { border-color: var(--line-2); color: var(--ink-2); font-weight: 500; }
.account-identity.is-prime {
  border-color: #cfb078;
  background: linear-gradient(115deg, #f6e6c6, #fff6e3 65%, #f1dfb9);
  color: #715023;
  font-weight: 600;
}
html[data-theme="dark"] .account-identity.is-prime {
  border-color: #8e744b;
  background: linear-gradient(115deg, #403323, #2b241b);
  color: #f2d69e;
}
.account-identity.is-admin {
  padding: 5px 12px;
  border-color: transparent;
  background: linear-gradient(115deg, var(--brand), #101b30) padding-box,
              linear-gradient(120deg, #b98c4b, #f8e2a8 48%, #b98c4b) border-box;
  color: #ffe9b9;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px rgb(233 202 140 / 12%), 0 2px 6px rgb(21 40 75 / 18%);
}
.account-identity.is-admin span { font-size: 15px; line-height: 1; }
@media (forced-colors: active) {
  .account-identity.is-admin { border-color: CanvasText; }
}
@media print { .account-identity { display: none; } }

/* 主题按钮（js/theme.js 控制显示与切换） */
:is(.top, .foot) .theme-btn { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; transition: border-color .2s; padding: 0; }
:is(.top, .foot) .theme-btn[hidden] { display: none; }
:is(.top, .foot) .theme-btn:hover { border-color: var(--ink); }
:is(.top, .foot) .theme-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:is(.top, .foot) .theme-btn .moon { display: none; }
html[data-theme="dark"] .theme-btn .sun { display: none; }
html[data-theme="dark"] .theme-btn .moon { display: block; }
:is(.top, .foot) .theme-btn [data-theme-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:is(.top, .foot) .menu-btn { display: none; }

/* ---------- 页脚 ---------- */
.foot { background: var(--deep); color: rgba(244, 237, 225, .7); padding: 56px 0 36px; font-size: 14px; font-family: var(--sans); line-height: 1.75; }
.foot p { margin: 0; }
:is(.top, .foot) .foot-contact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 28px; align-items: center; padding-bottom: 36px; margin-bottom: 36px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
:is(.top, .foot) .foot-contact .k { display: block; font: italic 500 26px/1.2 var(--italic); color: #fff; margin-bottom: 8px; }
:is(.top, .foot) .foot-contact p { line-height: 1.85; }
:is(.top, .foot) .foot-social { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
:is(.top, .foot) .foot-social a { display: grid; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; text-decoration: none; color: inherit; transition: border-color .2s; }
:is(.top, .foot) .foot-social a:hover { border-color: rgba(255, 255, 255, .4); }
:is(.top, .foot) .foot-social .ico { grid-row: 1 / span 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: rgba(255, 255, 255, .06); color: #fff; }
:is(.top, .foot) .foot-social .ico svg { width: 24px; height: 24px; }
:is(.top, .foot) .foot-social .ico-bili { color: #4fc3f7; }
:is(.top, .foot) .foot-social .ico-dc { color: #8b93ff; }
:is(.top, .foot) .foot-social b { color: #fff; font-size: 14.5px; margin: 0; }
:is(.top, .foot) .foot-social small { color: rgba(244, 237, 225, .55); font-size: 12px; }
:is(.top, .foot) .foot-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 28px; }
:is(.top, .foot) .foot-grid b { display: block; color: #fff; font-weight: 600; margin-bottom: 10px; }
:is(.top, .foot) .foot-grid a { display: block; text-decoration: none; padding: 3px 0; color: rgba(244, 237, 225, .72); }
:is(.top, .foot) .foot-grid a:hover { color: #fff; }
:is(.top, .foot) .foot-brand p { line-height: 1.8; max-width: 22em; }
:is(.top, .foot) .brand-foot { margin-bottom: 14px; color: #fff; }
:is(.top, .foot) .brand-foot .mark { width: 48px; height: 48px; }
:is(.top, .foot) .foot-grid .brand-foot .brand-txt b { font-size: 21px; color: #fff; margin: 0 -.12em 0 0; }
:is(.top, .foot) .brand-foot .brand-txt em { color: #f6a77a; }
:is(.top, .foot) .brand-foot .brand-txt small span { color: rgba(244, 237, 225, .6); }
:is(.top, .foot) .brand-foot .brand-txt i { background: rgba(255, 255, 255, .25); }
:is(.top, .foot) .foot-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 36px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); font-size: 13px; }
.foot .disc { margin-top: 10px; font-size: 12.5px; color: rgba(244, 237, 225, .5); }
.ver { font: 700 12px/1 var(--latin); padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: rgba(244, 237, 225, .85); cursor: pointer; }
.ver:hover { border-color: var(--accent); color: #fff; }

/* 版本说明（数据来自后台 ReleaseNote） */
.ver-pop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(10, 8, 6, .55); backdrop-filter: blur(3px); font-family: var(--sans); }
.ver-pop[hidden] { display: none; }
.ver-card { width: min(92vw, 460px); max-height: 86vh; overflow: auto; padding: 24px 26px; border-radius: 20px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); line-height: 1.75; }
.ver-card p { margin: 0; }
.ver-card .k { font-size: 12.5px; color: var(--muted); }
.ver-card h2 { font: 900 22px/1.3 var(--serif); margin: 4px 0 6px; }
.ver-card .cur { font-size: 14px; color: var(--accent-ink); font-weight: 700; }
.ver-card .sum-h { margin-top: 14px; font-size: 13px; font-weight: 700; }
.ver-card .sum { margin-top: 4px; color: var(--ink-2); white-space: pre-line; }
.ver-card details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.ver-card summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
.ver-card .ver-close { margin-top: 18px; height: 42px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--ink); color: var(--on-ink); font: 600 14px/1 var(--sans); cursor: pointer; }

/* ---------- 响应式 ---------- */
@media (max-width: 1360px) {
  :is(.top, .foot) .nav a { padding: 8px 7px; font-size: 14px; }
  :is(.top, .foot) .nav .nav-club { margin-left: 4px; padding: 7px 12px; }
}
@media (max-width: 1240px) {
  :is(.top, .foot) .nav { display: none; }
  :is(.top, .foot) .nav.open { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: 66px; left: 0; right: 0; max-height: calc(100vh - 66px); overflow: auto; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  :is(.top, .foot) .nav.open a { padding: 12px; font-size: 16px; }
  :is(.top, .foot) .nav.open .nav-club { margin: 8px 0 0; text-align: center; }
  :is(.top, .foot) .nav.open .nav-m { display: block; }
  :is(.top, .foot) .top-act { margin-left: auto; }
  :is(.top, .foot) .menu-btn { display: flex; flex-direction: column; justify-content: center; gap: 6px; width: 42px; height: 42px; padding: 0 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
  :is(.top, .foot) .menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s; }
  :is(.top, .foot) .menu-btn[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  :is(.top, .foot) .menu-btn[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
}
@media (max-width: 1100px) {
  :is(.top, .foot) .foot-grid { grid-template-columns: repeat(3, 1fr); }
  :is(.top, .foot) .foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .top .wrap, .foot .wrap { width: calc(100% - 32px); }
  :is(.top, .foot) .top-in { gap: 8px; }
  .top .mark { width: 36px; height: 36px; }
  .top .brand { gap: 9px; }
  .top .brand-txt b { font-size: 17px; letter-spacing: .08em; margin-right: -.08em; }
  .top .brand-txt small i, .top .brand-txt small span { display: none; }
  :is(.top, .foot) .top-act .is-dc, :is(.top, .foot) .top-act .top-login, :is(.top, .foot) .top-act .top-signup, :is(.top, .foot) .top-act .is-inbox { display: none; }
  .top.is-signed-in .top-act { flex: 0 1 auto; min-width: 0; }
  .top.is-signed-in .menu-btn { flex: none; }
  .top .top-profile { min-height: 44px; padding: 0 4px; }
  :is(.top, .foot) .foot-grid { grid-template-columns: 1fr 1fr; }
  :is(.top, .foot) .foot-contact, :is(.top, .foot) .foot-social { grid-template-columns: 1fr; }
  :is(.top, .foot) .foot-bottom { flex-direction: column; align-items: flex-start; }
}

/* 旧页面（templates/base.html）：去掉原左侧栏留出的边距，内容区与新顶栏同宽 */
body.desk-body.fa-legacy > main { width: min(100% - 48px, 1360px) !important; max-width: none !important; margin: 0 auto !important; padding: 32px 0 64px !important; }
@media (max-width: 760px) { body.desk-body.fa-legacy > main { width: calc(100% - 32px) !important; padding: 20px 0 48px !important; } }

/* Authenticated navigation includes Wiki, Agent, inbox and account controls. */
@media (min-width: 1601px) { .top.is-signed-in .wrap { width: min(100% - 64px, 1760px); } }
@media (max-width: 1600px) {
  .top.is-signed-in .nav { display: none; }
  .top.is-signed-in .nav.open { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: 66px; left: 0; right: 0; max-height: calc(100vh - 66px); overflow: auto; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
  .top.is-signed-in .nav.open a { padding: 12px; font-size: 16px; }
  .top.is-signed-in .nav.open .nav-club { margin: 8px 0 0; text-align: center; }
  .top.is-signed-in .nav.open .nav-m { display: block; }
  .top.is-signed-in .top-act { margin-left: auto; }
  .top.is-signed-in .menu-btn { display: flex; flex-direction: column; justify-content: center; gap: 6px; width: 42px; height: 42px; padding: 0 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
  .top.is-signed-in .menu-btn span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s; }
  .top.is-signed-in .menu-btn[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .top.is-signed-in .menu-btn[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
}
