/* =====================================================================
   reveries.cn · 视觉系统 v1
   配套规范：reveries-visual-system.md（色彩/间距/组件）
             reveries-ux-spec.md（信息架构/交互）
   技术约束：FastAPI + Jinja2 服务端渲染，手写 CSS，零构建。
             改本文件即生效，不引入任何框架。

   层次结构（L0→L5）：
     L0 背景层  bg-1920.webp + 白色柔化渐变，装饰，不承载信息
     L1 表面层  surface-1 / surface-2 / surface-3，承载内容
     L2 文字层  fg / muted / faint（+ on-dark 两级），只在表面上出现
     L3 边框层  edge(.80 结构) / edge-hair(.28 装饰) / edge-strong(聚焦)
     L4 状态层  ok / warn / danger / info，文字色与淡底成对使用
     L5 深色带  aurora 渐变，仅 footer / 认证页 / 模态区
   ===================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  /* L0 背景层 */
  --bg-solid: #EDE4F2;
  --bg-veil: linear-gradient(180deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,.22) 100%);

  /* L1 表面层 —— .62→.78 是本次改版最实质的可读性增益（暗区 5.67:1 → 7.27:1） */
  --surface-1: rgba(255, 255, 255, .78);
  --surface-2: rgba(255, 255, 255, .90);
  --surface-3: #FFFFFF;

  /* L2 文字层 —— fg / muted 已实测达标，本次一字不改 */
  --fg: #261E3A;          /* 正文 / 标题 / 表格主字段 */
  --muted: #4A3D61;       /* 次要说明 / 标签 / 表头 */
  --faint: #63527C;       /* 占位符 / 时间戳；仅限 >=12px 非关键文本 */
  --fg-on-dark: #FFFFFF;
  --muted-on-dark: rgba(255, 255, 255, .88);   /* 不得低于 .88，否则最亮深色带白字不合格 */

  /* L3 边框层 —— .16→.80 是本次改版的胜负手（1.22:1 → 3.73:1，满足 1.4.11） */
  --edge: rgba(107, 90, 143, .80);
  --edge-hair: rgba(107, 90, 143, .28);
  --edge-strong: rgba(107, 90, 143, 1);

  /* L4 状态层 —— 全部 >=5.14:1，为徽章误用在 12px 小字上留余量 */
  --ok: #0F6B4C;      --ok-bg: rgba(15, 107, 76, .13);
  --warn: #7A5000;    --warn-bg: rgba(122, 80, 0, .15);
  --danger: #A81F32;  --danger-bg: rgba(168, 31, 50, .11);
  --info: #2F3E8C;    --info-bg: rgba(47, 62, 140, .11);
  --neutral: #4A3D61; --neutral-bg: rgba(90, 72, 130, .12);

  /* L5 深色带 —— 收窄到 footer / 认证页 / 模态区三处 */
  --aurora: linear-gradient(115deg, #007858 0%, #00667C 28%, #3038A0 55%, #5C2680 80%, #842A62 100%);

  /* 间距：4 基数，只允许这 7 个值 */
  --s1: .25rem;  --s2: .5rem;   --s3: .75rem;  --s4: 1rem;
  --s5: 1.5rem;  --s6: 2rem;    --s7: 3rem;
  --gap-tight: var(--s2);   /* 8px  徽章之间、图标与文字 */
  --gap-form:  var(--s3);   /* 12px 标签与输入框 */
  --gap-item:  var(--s4);   /* 16px 表单字段 / 卡片内小网格之间 */
  --gap-block: var(--s5);   /* 24px 卡片内分组 */
  --gap-panel: var(--s6);   /* 32px 卡片 / 栅格之间 */
  --gap-page:  var(--s7);   /* 48px 页面区块之间 */

  /* 字号：6 级，1.2 比率；13px 是正文下限，12px 只给非关键信息 */
  --fs-display: 1.875rem;  /* lh 38px */
  --fs-h1: 1.5rem;        /* lh 32px */
  --fs-h2: 1.125rem;      /* lh 26px */
  --fs-body: .9375rem;    /* lh 24px */
  --fs-sm: .8125rem;      /* lh 20px */
  --fs-xs: .75rem;        /* lh 16px */

  /* 圆角：3 级。徽章/输入框 8px 避免小尺寸元素「糖果感」 */
  --r-sm: .5rem;
  --r: 1rem;
  --r-lg: 1.5rem;

  /* 阴影：全站唯一配方，层级靠用不用区分，不靠加大阴影 */
  --shadow: 0 1px 2px rgba(38, 30, 58, .05), 0 8px 24px -12px rgba(38, 30, 58, .18);

  /* 容器 */
  --container: 67.5rem;        /* 1080px */
  --container-narrow: 47.5rem; /* 760px */
  --gutter: var(--s4);
}

/* ---------------------------------------------------------------- reset */
* { box-sizing: border-box; }

html {
  background: var(--bg-veil), url("/static/bg-1920.webp") center center / cover no-repeat fixed, var(--bg-solid);
  background-color: var(--bg-solid);
  -webkit-text-size-adjust: 100%;
}
/* 窄屏用原生 1280 版本，避免放大糊掉 */
@media (max-width: 60rem) {
  html {
    background-image: var(--bg-veil), url("/static/bg.webp");
    background-size: auto, cover;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.6;                /* 中文正文比英文 1.5 更松 */
  font-weight: 400;
  color: var(--fg);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -0.011em; }
p { margin: 0; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
[hidden] { display: none !important; }

/* 全站统一焦点环：#6B5A8F 实色在 surface-1 上 5.76:1，远超 3:1。
   禁止 outline:none 且不提供替代。 */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--edge-strong);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: var(--s4); top: -4rem; z-index: 100;
  padding: var(--s2) var(--s4);
  background: var(--surface-3); color: var(--fg);
  border: 1px solid var(--edge); border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  transition: top .16s;
}
.skip-link:focus { top: var(--s2); }

/* ---------------------------------------------------------------- layout */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.container-narrow { width: 100%; max-width: var(--container-narrow); margin: 0 auto; padding: 0 var(--gutter); }

main { flex: 1 0 auto; padding: var(--gap-page) 0; position: relative; z-index: 1; }

.page-head { margin-bottom: var(--gap-panel); }
.page-head h1 { font-size: var(--fs-h1); font-weight: 600; line-height: 2rem; }
.page-head .sub { margin-top: var(--s2); font-size: var(--fs-body); color: var(--muted); }
.page-section + .page-section { margin-top: var(--gap-page); }

.section-title { font-size: var(--fs-h2); font-weight: 600; line-height: 1.45; margin-bottom: var(--gap-block); }

/* 栅格：统一 --gap-panel，大间距是「简约」的主要来源 */
.grid { display: grid; gap: var(--gap-panel); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 53.75rem) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 35rem)    { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface-2);
  border-bottom: 1px solid var(--edge);
}
.header-inner {
  min-height: 3.75rem;                    /* 60px */
  display: flex; align-items: center; gap: var(--s4);
}
.brand { display: flex; align-items: center; gap: var(--gap-tight); font-weight: 600; font-size: var(--fs-h2); flex: 0 0 auto; }
.brand-dot {
  width: 1.25rem; height: 1.25rem; border-radius: 999px;
  background: var(--aurora);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55);
}

.site-nav { display: flex; align-items: center; gap: var(--s2); margin-right: auto; }
.nav-link {
  display: inline-flex; align-items: center;
  padding: var(--s2) var(--s3); border-radius: var(--r-sm);
  font-size: var(--fs-body); color: var(--muted);
  transition: background-color .16s, color .16s;
}
.nav-link:hover { background: rgba(90, 72, 130, .07); color: var(--fg); }
/* 当前项用字重 + 文字色表示，不加下划线也不加背景块 */
.nav-link.is-active { color: var(--fg); font-weight: 500; }

.header-actions { display: flex; align-items: center; gap: var(--s2); flex: 0 0 auto; }

/* 用户菜单：原生 details/summary，键盘 Enter/Space 天然可用 */
.user-menu { position: relative; }
.user-menu > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: var(--gap-tight);
  padding: var(--s1) var(--s2) var(--s1) var(--s1);
  border-radius: 999px; border: 1px solid transparent;
  transition: background-color .16s, border-color .16s;
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover { background: rgba(90, 72, 130, .07); border-color: var(--edge-hair); }
.avatar {
  width: 1.75rem; height: 1.75rem; border-radius: 999px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #5C2680, #3F1E96);
  color: #fff; font-size: var(--fs-sm); font-weight: 600; line-height: 1;
}
.user-name { font-size: var(--fs-body); color: var(--fg); font-weight: 500; }
.chev { width: .625rem; height: .5rem; fill: none; stroke: var(--muted); stroke-width: 1.6; }
.user-menu[open] .chev { transform: rotate(180deg); }

.menu-panel {
  position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 60;
  min-width: 13rem; padding: var(--s2);
  background: var(--surface-3);          /* L5 允许的弹层 */
  border: 1px solid var(--edge); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.menu-head { padding: var(--s2) var(--s3) var(--s3); border-bottom: 1px solid var(--edge-hair); margin-bottom: var(--s2); }
.menu-nick { display: block; font-weight: 600; font-size: var(--fs-body); }
.menu-mail { display: block; font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.menu-item {
  display: block; width: 100%; text-align: left;
  padding: var(--s2) var(--s3); border: 0; background: none; cursor: pointer;
  border-radius: var(--r-sm);
  font-size: var(--fs-body); color: var(--fg);
}
.menu-item:hover { background: rgba(90, 72, 130, .07); }
.menu-danger { color: var(--danger); }   /* 危险操作除红色外还有文案区分 */
.menu-danger:hover { background: var(--danger-bg); }
.menu-sep { height: 1px; margin: var(--s2) 0; background: var(--edge-hair); border: 0; }

/* 移动端抽屉 */
.nav-toggle {
  display: none; flex: 0 0 auto;
  width: 2.75rem; height: 2.75rem;       /* 44px 触控目标 */
  align-items: center; justify-content: center;
  background: var(--surface-1); border: 1px solid var(--edge);
  border-radius: var(--r-sm); cursor: pointer;
}
.nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
  display: block; width: 1.125rem; height: 2px; background: var(--fg); border-radius: 2px;
}
.nav-toggle-bar { position: relative; }
.nav-toggle-bar::before, .nav-toggle-bar::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }

.mobile-nav {
  border-top: 1px solid var(--edge-hair);
  background: var(--surface-2);
  padding: var(--s2) var(--gutter) var(--s4);
}
.m-link {
  display: block; padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--edge-hair);
  font-size: var(--fs-body); color: var(--fg);
}
.m-link.is-active { font-weight: 500; }
.m-danger { color: var(--danger); width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.m-primary { color: var(--fg); font-weight: 600; }
.mobile-nav form { margin: 0; }

/* 后台顶栏：与前台视觉明确分离 */
.page-admin { background: var(--bg-solid); }
.page-admin .site-header { border-bottom: 3px solid var(--edge-strong); }
.page-admin .brand::after {
  content: "管理后台"; margin-left: var(--s2);
  padding: 2px var(--s2); border-radius: var(--r-sm);
  background: var(--neutral-bg); color: var(--muted);
  font-size: var(--fs-xs); font-weight: 500;
}
.admin-back { font-size: var(--fs-sm); color: var(--muted); }
.admin-back:hover { color: var(--fg); text-decoration: underline; }

.crumb { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s2); }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--fg); text-decoration: underline; }

.admin-tabs { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--gap-panel); }
.admin-tab {
  padding: var(--s2) var(--s4); min-height: 2.25rem;
  display: inline-flex; align-items: center;
  border: 1px solid var(--edge); border-radius: var(--r-sm);
  background: var(--surface-1); color: var(--muted); font-size: var(--fs-sm);
}
.admin-tab:hover { color: var(--fg); background: var(--surface-2); }
.admin-tab.active { background: var(--edge-strong); border-color: var(--edge-strong); color: #fff; font-weight: 600; }

/* 待办角标：只出现在后台导航，且只在有待处理项时渲染。
   数字对色弱不可辨，故必须配 sr-only 文字说明（UX 规范 §8.5）。 */
.admin-tab .nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.375rem; height: 1.375rem; padding: 0 var(--s1);
  margin-left: var(--s1);
  border-radius: var(--r-sm);
  background: var(--warn-bg); color: var(--warn);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.admin-tab.active .nav-badge { background: rgba(255, 255, 255, .22); color: #fff; }
.nav-badge-empty { background: var(--ok-bg); color: var(--ok); }
.admin-tab.active .nav-badge-empty { background: rgba(255, 255, 255, .22); color: #fff; }

/* 仅供读屏：数字角标必须有文字说明，不能只靠数字传达含义 */
.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;
}

/* 顶栏待处理入口：不是导航项（不占 site-nav），是状态提示 + 跳转 */
.admin-pending {
  display: inline-flex; align-items: center; flex: 0 0 auto;
  padding: var(--s1) var(--s2); border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--muted);
}
.admin-pending:hover { background: rgba(90, 72, 130, .07); color: var(--fg); }

/* ---------------------------------------------------------------- footer */
.footer {
  flex: 0 0 auto;
  padding: var(--s5) 0;
  text-align: center;
  background: var(--aurora);              /* L5 深色带，仅此处 */
  color: var(--fg-on-dark);
  font-size: var(--fs-sm);
}
.footer a { color: var(--fg-on-dark); text-decoration: underline; text-underline-offset: 2px; }
.footer-nav { display: flex; justify-content: center; gap: var(--gap-block); margin-bottom: var(--s2); flex-wrap: wrap; }

/* ---------------------------------------------------------------- panel */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: var(--s5);
  box-shadow: var(--shadow);
}
.panel-2 { background: var(--surface-2); }   /* 卡中卡，全站仅此一种变体 */
.panel-flush { padding: 0; }                /* 表格容器专用 */
.panel-lg { padding: var(--s6); }           /* 认证页：暗示独立任务 */

/* 兼容别名：旧模板类名映射到新体系 */
.card {
  background: var(--surface-1);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: var(--s5);
  box-shadow: var(--shadow);
}
.card-opal { position: relative; overflow: hidden; }

.upd {
  background: var(--surface-1);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: var(--s4) var(--s5);
  box-shadow: var(--shadow);
}
.upd-log {
  margin-top: var(--s3); padding-top: var(--s3);
  border-top: 1px solid var(--edge-hair);
  color: var(--muted); white-space: pre-line; font-size: var(--fs-body);
}

/* ---------------------------------------------------------------- buttons */
/* 6 种 → 3 种。每屏 primary 恰好 1 个。 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--gap-tight);
  height: 2.5rem;                        /* 40px */
  padding: 0 var(--s5);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font-size: var(--fs-body); font-weight: 500; line-height: 1;
  white-space: nowrap; cursor: pointer;
  transition: background-color .16s, border-color .16s, color .16s, transform .16s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }   /* 唯一允许的动效 */
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(135deg, #5C2680, #3F1E96); color: #fff; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #672C90, #4622A6); }

.btn-secondary { background: var(--surface-2); color: var(--fg); border-color: var(--edge); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: rgba(90, 72, 130, .07); color: var(--fg); }
.btn-ghost.is-danger { color: var(--danger); }
.btn-ghost.is-danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger); }

/* 尺寸 */
.btn-sm { height: 2rem; padding: 0 var(--s4); font-size: var(--fs-sm); }
.btn-lg { height: 3rem; padding: 0 var(--s6); }
/* .btn-block 是工具类，不是变体 */
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */
.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); margin-bottom: var(--gap-form); }
.help { font-size: var(--fs-xs); color: var(--faint); margin-top: var(--gap-form); }
/* 状态色成对使用：文字色 + 淡底，禁止只改颜色不改可读性 */
.is-ok { color: var(--ok); }
.is-err { color: var(--danger); }

.input, .textarea, .select {
  width: 100%; min-height: 2.75rem;                     /* 44px */
  padding: var(--s2) var(--s3);
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--edge);                        /* 必须有可见边界：仅底线不满足 3:1 */
  border-radius: var(--r-sm);
  font-size: var(--fs-body); color: var(--fg);
  transition: border-color .16s, box-shadow .16s;
}
.textarea { min-height: 5.5rem; padding: var(--s3); line-height: 1.6; resize: vertical; }
.select { appearance: none; padding-right: var(--s6); background-image: none; cursor: pointer; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--edge-strong); outline: none;
  box-shadow: 0 0 0 3px rgba(107, 90, 143, .28);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input-code { text-align: center; letter-spacing: .22em; text-transform: uppercase; font-weight: 500; }
.redeem-input { max-width: 20rem; }
.select option { background: var(--surface-3); color: var(--fg); }

/* 分段控件：免费/付费不用裸 checkbox（语义弱 + 色弱不可辨） */
.segmented { display: inline-flex; border: 1px solid var(--edge); border-radius: var(--r-sm); overflow: hidden; background: var(--surface-1); }
.segmented label { position: relative; display: inline-flex; align-items: center; gap: var(--gap-tight); padding: var(--s2) var(--s4); font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--edge-strong); color: #fff; font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--edge-strong); outline-offset: -2px; }

.check { display: flex; align-items: center; gap: var(--gap-tight); cursor: pointer; font-size: var(--fs-body); color: var(--fg); }
.check input { width: 1.125rem; height: 1.125rem; accent-color: #5C2680; }

input[type="file"] { font-size: var(--fs-sm); color: var(--muted); }
input[type="file"]::file-selector-button {
  margin-right: var(--s3); padding: var(--s2) var(--s4);
  border: 1px solid var(--edge); background: var(--surface-2); color: var(--fg);
  border-radius: var(--r-sm); cursor: pointer;
}

/* ---------------------------------------------------------------- alerts */
.alert {
  display: flex; gap: var(--gap-tight); flex-wrap: wrap; align-items: baseline;
  padding: var(--s3) var(--s4); margin-bottom: var(--gap-block);
  border: 1px solid; border-radius: var(--r-sm);
  font-size: var(--fs-body);
}
.alert-ok   { background: var(--ok-bg);     border-color: rgba(15, 107, 76, .38);  color: var(--ok); }
.alert-warn { background: var(--warn-bg);   border-color: rgba(122, 80, 0, .38);  color: var(--warn); }
.alert-err  { background: var(--danger-bg); border-color: rgba(168, 31, 50, .38); color: var(--danger); }
.alert-info { background: var(--info-bg);   border-color: rgba(47, 62, 140, .38); color: var(--info); }
.alert :is(a) { text-decoration: underline; text-underline-offset: 2px; }
.alert .alert-body { flex: 1 1 16rem; }

.form-error {
  padding: var(--s3) var(--s4); margin-bottom: var(--gap-block);
  background: var(--danger-bg); border: 1px solid rgba(168, 31, 50, .38);
  border-radius: var(--r-sm); color: var(--danger); font-size: var(--fs-body);
}

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 1.375rem; padding: 0 var(--s2);
  border: 0; border-radius: var(--r-sm);   /* 底色已足够，禁止加边框 */
  font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap;
}
.badge-ok    { background: var(--ok-bg);     color: var(--ok); }
.badge-warn  { background: var(--warn-bg);   color: var(--warn); }
.badge-danger{ background: var(--danger-bg); color: var(--danger); }
.badge-info  { background: var(--info-bg);   color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge-off   { background: var(--neutral-bg); color: var(--neutral); }
/* 付费/免费不能只靠颜色，必须有文字 —— 这里已带文字，仅靠底色区分 */
.badge-opal  { background: var(--info-bg);   color: var(--info); }

/* ---------------------------------------------------------------- hero */
.hero { text-align: center; padding: var(--s7) 0; }
.hero h1 { font-size: clamp(1.75rem, 4.5vw, var(--fs-display)); font-weight: 600; line-height: 1.25; }
.hero .lead { color: var(--muted); max-width: 34rem; margin: var(--s4) auto 0; font-size: var(--fs-h2); font-weight: 400; line-height: 1.5; }
.hero-actions { margin-top: var(--s6); display: flex; gap: var(--s3); justify-content: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- stats */
.stat-grid { display: grid; gap: var(--gap-item); grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 60rem) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 40rem) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat-label { font-size: var(--fs-sm); color: var(--muted); }
.stat-value { font-size: var(--fs-h1); font-weight: 600; margin-top: var(--s1); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tables */
.table-wrap {
  background: var(--surface-2);
  border: 1px solid var(--edge); border-radius: var(--r);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; padding: var(--s3) var(--s4);
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted);
  background: rgba(90, 72, 130, .07);
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--edge-hair); color: var(--fg); }
.table tbody tr:hover { background: rgba(90, 72, 130, .045); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td:last-child, .table th:last-child { text-align: right; }   /* 操作列固定最右 */
.table .empty-row td { padding: var(--s7) var(--s4); text-align: center; color: var(--faint); }

/* ---------------------------------------------------------------- mod cards */
.mod-card {
  display: flex; flex-direction: column; gap: var(--s3);
  background: var(--surface-1);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: var(--s5);
  box-shadow: var(--shadow);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
a.mod-card:hover { transform: translateY(-2px); border-color: var(--edge-strong); }
.mod-card h3 { font-size: var(--fs-h2); font-weight: 600; }
.mod-card .desc { color: var(--muted); font-size: var(--fs-sm); white-space: pre-line; }
.mod-card .meta { display: flex; align-items: center; gap: var(--gap-tight); flex-wrap: wrap; margin-top: auto; }

/* 空状态：现状 + 主动作 + 一句解释，不用灰色占位卡 */
.empty { text-align: center; padding: var(--s7) var(--s5); }
.empty h2 { font-size: var(--fs-h2); font-weight: 600; }
.empty p { color: var(--muted); margin-top: var(--s2); }
.empty .btn { margin-top: var(--s5); }
.empty-note { color: var(--faint); font-size: var(--fs-sm); margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--edge-hair); }
@media (max-width: 40rem) { .empty { padding: var(--s6) var(--s4); } }

/* 详情页：桌面右侧获取卡 sticky，CTA 滚动时始终可见 */
.detail { display: grid; gap: var(--gap-panel); grid-template-columns: minmax(0, 1fr) 20rem; align-items: start; }
.detail-side { position: sticky; top: 5.5rem; }
@media (max-width: 64rem) { .detail { grid-template-columns: 1fr; } .detail-side { position: static; } }

/* 打赏 3 步说明 */
.steps { counter-reset: step; display: grid; gap: var(--gap-item); grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; margin: 0; list-style: none; }
.steps li { position: relative; padding-left: 2.25rem; font-size: var(--fs-sm); color: var(--fg); }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 1.5rem; height: 1.5rem; border-radius: 999px;
  background: var(--edge-strong); color: #fff;
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 600;
}
.steps .step-note { color: var(--muted); font-size: var(--fs-xs); display: block; margin-top: var(--s1); }
@media (max-width: 40rem) { .steps { grid-template-columns: 1fr; } }

.qr { display: grid; place-items: center; padding: var(--s5) 0; }
.qr img { max-width: 15rem; border-radius: var(--r-sm); border: 1px solid var(--edge-hair); }

details.fold { border: 1px solid var(--edge); border-radius: var(--r); background: var(--surface-1); box-shadow: var(--shadow); }
details.fold > summary { padding: var(--s4) var(--s5); cursor: pointer; font-weight: 600; font-size: var(--fs-h2); }
details.fold > summary::marker { color: var(--muted); }
details.fold > .fold-body { padding: 0 var(--s5) var(--s5); }

/* ---------------------------------------------------------------- auth page */
/* 独立任务页：无导航栏、400px 居中、恰好 1 个面板 */

/* L0 两层背景：灰蓝纯色底 + 光谱动效层（screen 混合叠加） */
html.prism-on { background-image: none; }

.auth-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.auth-bg-base {
  position: absolute; inset: 0;
  background: var(--bg-base, #b2cae6);   /* 灰蓝纯色底，调试面板可改 */
}
#prism-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  mix-blend-mode: screen;   /* 光谱层与灰蓝底 screen 混合：黑=无光，彩=发光 */
  pointer-events: none;
}

.page-auth { position: relative; background: transparent; }

/* 白纱：暗底上降到极弱，只为面板区域保留一点霜感，不洗白光谱 */
.page-auth::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;   /* 不能拦截事件，否则表单与 shader 视差都会失效 */
  background: radial-gradient(120% 90% at 50% 46%,
    rgba(255, 255, 255, .08) 0%,
    rgba(255, 255, 255, .12) 40%,
    rgba(255, 255, 255, 0) 100%);
}

.auth-shell { position: relative; z-index: 2; flex: 1 0 auto; display: flex; flex-direction: column; min-height: 100dvh; }

/* ---------------------------------------------------------------- 背景调试面板 */
.debug-panel {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 10;
  width: 17rem;
  max-height: 72vh;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  font-weight: 600;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--edge-hair);
}
.debug-collapse {
  padding: 0 var(--s2);
  height: 1.5rem;
  font-size: var(--fs-xs);
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--fg);
  cursor: pointer;
}
.debug-panel.is-collapsed .debug-body,
.debug-panel.is-collapsed .debug-foot { display: none; }
.debug-body { padding: var(--s3) var(--s4); }
.debug-foot {
  display: flex; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--edge-hair);
}
.debug-foot button {
  flex: 1;
  padding: var(--s2) 0;
  font-size: var(--fs-sm);
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--fg);
  cursor: pointer;
}
.dbg-group { margin: var(--s4) 0 var(--s2); font-size: var(--fs-xs); color: var(--faint); font-weight: 600; }
.dbg-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 2.5rem;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.dbg-label { font-size: var(--fs-xs); color: var(--muted); }
.dbg-val { font-size: var(--fs-xs); color: var(--fg); text-align: right; font-variant-numeric: tabular-nums; }
.dbg-row input[type="range"] { width: 100%; }
.dbg-row input[type="color"] {
  width: 100%; height: 1.75rem;
  padding: 0;
  border: 1px solid var(--edge-hair);
  border-radius: var(--r-sm);
  background: none;
}
.auth-header {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--gutter);
}
.auth-switch { font-size: var(--fs-sm); color: var(--muted); }
.auth-switch:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.auth-main { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; padding: var(--s5) var(--gutter) var(--s7); }
.auth-card {
  width: 100%; max-width: 25rem;                          /* 400px */
  background: var(--surface-1);
  border: 1px solid var(--edge);
  border-radius: var(--r);
  padding: var(--s6);                                     /* 比常规卡片大，暗示独立任务 */
  box-shadow: var(--shadow);
}
.auth-title { font-size: var(--fs-display); font-weight: 600; line-height: 2.375rem; }
.auth-sub { margin-top: var(--s4); margin-bottom: var(--s6); font-size: var(--fs-body); color: var(--muted); }
.auth-card .btn { margin-top: var(--gap-block); height: 2.75rem; }   /* 与输入框同高 */
.auth-foot { margin-top: var(--s5); font-size: var(--fs-sm); color: var(--muted); text-align: center; }
.auth-foot a { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.auth-band { flex: 0 0 auto; height: var(--s6); background: var(--aurora); }

/* ---------------------------------------------------------------- misc */
.row { display: flex; align-items: center; gap: var(--gap-item); }
.row-between { justify-content: space-between; }
.row-top { align-items: flex-start; }
.row-center { justify-content: center; }
.row-wrap { flex-wrap: wrap; }
.row-tight { gap: var(--gap-tight); }
.stack { display: flex; flex-direction: column; gap: var(--gap-block); }
.stack.is-tight { gap: var(--gap-tight); }
.form-inline { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.form-inline > .input, .form-inline > .select { flex: 1 1 12rem; }
.form-inline > .btn { flex: 0 0 auto; }
/* 表单内并排字段：标签在上、控件在下，宽度可控 */
.form-inline > div { flex: 1 1 12rem; min-width: 0; }
.form-inline > div > .label { margin-bottom: var(--gap-form); }
.form-inline > .field-narrow { flex: 0 0 6rem; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.grad-text {
  background: linear-gradient(115deg, #00705A 0%, #005F78 30%, #3A2F9C 60%, #7B2A86 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.divider { height: 1px; background: var(--edge-hair); border: 0; margin: var(--gap-block) 0; }
.anchor { scroll-margin-top: 5.5rem; }

/* ---------------------------------------------------------------- utils */
/* 间距工具类只有这 10 个。超过说明间距逻辑错了，应改用父级 gap。 */
.mt-1 { margin-top: var(--s1); } .mt-2 { margin-top: var(--s2); }
.mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); }
.mt-5 { margin-top: var(--s5); } .mt-6 { margin-top: var(--s6); }
.mb-1 { margin-bottom: var(--s1); } .mb-2 { margin-bottom: var(--s2); }
.mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); }
.mb-5 { margin-bottom: var(--s5); }

.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.is-strong { font-weight: 600; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.w-full { width: 100%; }
.link { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--edge-strong); }
.mx-auto { margin-left: auto; margin-right: auto; }
.lh-body { line-height: 1.6; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 48rem) {
  /* <16px 会触发 iOS 自动放大导致布局崩坏 —— 移动端输入框必须 16px */
  .input, .textarea, .select { font-size: 1rem; }

  .site-nav, .header-actions { display: none; }
  .nav-toggle { display: inline-flex; }
  .header-inner { min-height: 3.5rem; }

  main { padding: var(--s6) 0; }
  .panel { padding: var(--s4); }
  .auth-card { padding: var(--s5); }

  /* 触控目标 >=44px */
  .btn { min-height: 2.75rem; }
  .btn-sm { min-height: 2.75rem; padding: 0 var(--s4); }
  .m-link { min-height: 2.75rem; display: flex; align-items: center; }
  .menu-item { min-height: 2.75rem; display: flex; align-items: center; }
  .nav-link { min-height: 2.75rem; }

  .hero { padding: var(--s6) 0; }
  .hero-actions .btn { width: 100%; }
  .detail-side { order: -1; }
}

@media (max-width: 48rem) {
  /* 主按钮全宽；次级按钮自适应 */
  .btn-primary.btn-block, form .btn-block { width: 100%; }

  /* 后台表格 <768px 改堆叠卡片，不做横向滚动 */
  .table-wrap { border: 0; background: none; border-radius: 0; overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    background: var(--surface-2);
    border: 1px solid var(--edge); border-radius: var(--r);
    padding: var(--s2) var(--s4) var(--s3);
    margin-bottom: var(--gap-item);
  }
  .table td {
    display: flex; justify-content: space-between; gap: var(--s4); align-items: baseline;
    padding: var(--s2) 0; border-bottom: 1px solid var(--edge-hair); text-align: right;
  }
  .table td:last-child { border-bottom: 0; text-align: right; }
  .table td::before {
    content: attr(data-label);
    flex: 0 0 auto; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-align: left;
  }
  .table .empty-row td { display: block; text-align: center; }
  .table .empty-row td::before { content: none; }
}

@media (max-width: 30rem) {
  .brand-dot { display: none; }
}

/* ---------------------------------------------------------------- a11y */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover:not(:disabled), a.mod-card:hover { transform: none; }
}

@media print {
  .site-header, .footer, .mobile-nav, .auth-band { display: none; }
  body { background: #fff; }
}

/* =====================================================================
   明信片登录 / 注册页 · 页面级适配（2026-10-15）
   —— 卡片本体（光晕底 / 正反面 / 表单）在 app/static/card.css，
      选择器全部限定在 #postcard 之下。
      这里只做「页面骨架」层面的少量覆盖，上面原有规则一个不删不改
      （.card / .panel / .auth-* 等仍被其他页面使用）。
   ===================================================================== */

/* 光晕底自带页面背景，撤掉全站底图，避免和 blur 光晕打架 */
html:has(body.page-auth) {
  background-image: none;
  background-color: #9E7BFF;
}

/* 认证页不滚动：光晕与明信片都收在视口内 */
body.page-auth { overflow: hidden; }

/* 旧的「白纱」径向层是配深色光谱底用的；换成光晕底后关掉它。
   （原规则 .page-auth::before 保留在 style.css:586，仅在此覆盖） */
body.page-auth::before { content: none; }

/* 保险：即便模板漏删，旧的背景 / 调试元素也不显示 */
body.page-auth .auth-bg,
body.page-auth #prism-bg,
body.page-auth .auth-band,
body.page-auth .debug-panel { display: none; }

/* 窄屏：卡片落回常规流后可能高于视口，放开纵向滚动。
   桌面端仍不滚动 —— 上面 style.css:830 的 body.page-auth{overflow:hidden} 不受影响。 */
@media (max-width: 48rem) {
  body.page-auth { overflow: auto; }
}