/* 账号服务共享样式。语义 token 镜像游戏主站 bzplat/frontend/src/index.css：
   品牌绿 #54715f、浅色默认 + .dark 类切换、3px 控件圆角/5px 卡片圆角、56px 顶栏、44px 触控命中。 */

:root {
  color-scheme: light;
  --background: #fcfdfb;
  --foreground: #303732;
  --card: #ffffff;
  --card-foreground: #303732;
  --muted: #f1f4f1;
  --muted-foreground: #626d67;
  --accent: #e9efeb;
  --accent-foreground: #41564b;
  --primary: #54715f;
  --primary-foreground: #ffffff;
  --destructive: #c5493d;
  --destructive-foreground: #ffffff;
  --border: #dde2dd;
  --input: #c9d3cc;
  --shadow-card: 0 1px 1px rgba(45, 38, 36, .05), 0 2px 8px rgba(45, 38, 36, .03);
  --radius: .3125rem;
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --control-height: 2.5rem;
  --control-height-lg: 2.5rem;
  --shell-header-height: 3.5rem;
  --page-gutter: .75rem;
  /* 焦点环取前景色七成，浅/暗两套都 ≥3:1；不用主站的 35% 透明 ring。 */
  --focus-ring: color-mix(in srgb, var(--foreground) 70%, var(--background));
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

.dark {
  color-scheme: dark;
  --background: #10151b;
  --foreground: #eceff1;
  --card: #1a2027;
  --card-foreground: #eceff1;
  --muted: #232b33;
  --muted-foreground: #a7b4b2;
  --accent: #26333a;
  --accent-foreground: #dbe4e2;
  /* 品牌色在暗色下提亮一档，与主站 index.css 的 oklch 双主题一致。 */
  --primary: oklch(0.72 0.17 162);
  --primary-foreground: oklch(0.16 0.03 162);
  --destructive: #e17b72;
  /* 白字在暗色 destructive 上只有 2.89:1；近黑前景两态都 ≥4.5:1。 */
  --destructive-foreground: #1c0b08;
  --border: rgba(255, 255, 255, .12);
  --input: rgba(255, 255, 255, .16);
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  font: 1rem/1.5 var(--font-sans);
  color: var(--foreground);
  background: var(--background);
  /* 主站同款顶部水墨洗色：低对比渐变仅在页面顶部形成纸面层次。
     no-repeat：渐变盒是视口高度，默认平铺会在每屏顶部重描一条硬边（注册页等长页可见）。 */
  background-image: radial-gradient(ellipse 48% 25% at 10% 0%, rgb(113 136 122 / 10%), transparent 72%),
    radial-gradient(ellipse 38% 22% at 88% 4%, rgb(180 194 184 / 13%), transparent 74%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

.dark body {
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, oklch(0.72 0.17 162 / 0.06), transparent 55%);
}

/* ---- 顶栏：品牌 + 动作，与主站 app-shell 同构 ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--shell-header-height);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 85%, transparent);
  backdrop-filter: blur(8px);
}

.site-header-inner {
  max-width: 80rem;
  margin: 0 auto;
  min-height: var(--shell-header-height);
  padding: 0 var(--page-gutter);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 2.75rem;
  padding: 0 .25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--foreground);
  text-decoration: none;
}

.brand img {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.header-actions {
  position: relative; /* 主题菜单的定位锚点 */
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .25rem;
}

/* 页头动作链接做成 primary 描边按钮（登录/注册页的 CTA），触控命中仍是 44px。 */
.header-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 .875rem;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  color: var(--primary);
  background: transparent;
  text-decoration: none;
}

.header-link:hover { color: var(--primary-foreground); background: var(--primary); text-decoration: none; }

/* ---- 主题切换按钮 ---- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0;
  background: none;
  color: var(--muted-foreground);
  cursor: pointer;
}

.theme-toggle:hover { background: var(--accent); color: var(--accent-foreground); }

.theme-toggle svg { width: 1.15rem; height: 1.15rem; }

.theme-toggle .icon-moon, .theme-toggle .icon-laptop { display: none; }

html.dark .theme-toggle .icon-sun { display: none; }

html.dark .theme-toggle .icon-moon { display: block; }

html.system .theme-toggle .icon-sun, html.system .theme-toggle .icon-moon { display: none; }

html.system .theme-toggle .icon-laptop { display: block; }

@media (pointer: coarse) {
  .theme-toggle { width: 2.75rem; height: 2.75rem; }
}

/* 主题选项菜单由 theme.js 生成并挂在按钮之后。 */
.theme-menu {
  position: absolute;
  top: calc(100% + .25rem);
  right: 0;
  z-index: 20;
  min-width: 8.5rem;
  display: flex;
  flex-direction: column;
  padding: .25rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(45, 38, 36, .14);
}

.theme-option {
  justify-content: flex-start;
  min-height: var(--control-height);
  padding: 0 .5rem;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 400;
}

.theme-option::before { content: ''; width: 1rem; flex: none; }

.theme-option[aria-pressed="true"] { color: var(--primary); font-weight: 600; }

.theme-option[aria-pressed="true"]::before { content: '\2713'; }

.theme-option:hover { background: var(--accent); color: var(--accent-foreground); }

/* ---- 主体：单一中轴，卡片化 ---- */

.site-main {
  flex: 1;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.5rem var(--page-gutter) 3rem;
}

.site-main.wide { max-width: 80rem; }

/* 认证页（登录/找回）走主站 AuthShell 的居中轴：标题与描述居中，卡片保持 24rem。 */
.site-main.auth h1, .site-main.auth .page-description { text-align: center; }

.site-main.auth .card { max-width: 24rem; margin-left: auto; margin-right: auto; }

/* 恢复页表单由 recovery.js 生成（recovery.css 给 #forms form 卡片外观），没有外层
   .card 容器；同样纳入 24rem 居中轴，否则标题居中而表单仍 40rem 左对齐。 */
.site-main.auth #forms > * { width: 100%; max-width: 24rem; margin-left: auto; margin-right: auto; }

.site-main.auth #forms h2 { text-align: center; }

.site-main.auth #forms .links { justify-content: center; }

h1 {
  margin: 0 0 .35rem;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.page-description {
  margin: 0 0 1.5rem;
  font-size: .875rem;
  line-height: 1.6;
  color: var(--muted-foreground);
  overflow-wrap: anywhere;
}

h2 { margin: 1.5rem 0 .75rem; font-size: 1.15rem; line-height: 1.25; text-wrap: balance; }

h3 { margin: 1rem 0 .5rem; font-size: 1rem; line-height: 1.3; }

.card {
  margin: 0 0 1rem;
  padding: 1rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

p { margin: 0 0 .75rem; }

a { color: var(--primary); text-decoration: none; text-underline-offset: 4px; }

a:hover { text-decoration: underline; }

label { display: block; margin: 0 0 1rem; font-size: .875rem; font-weight: 500; }

label > input, label > select { margin-top: .375rem; }

fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

legend { padding: 0 .25rem; font-size: .875rem; font-weight: 500; }

fieldset img { vertical-align: middle; margin: 0 .75rem .5rem 0; border-radius: var(--radius-md); border: 1px solid var(--border); }

/* ---- 表单控件：主站尺寸（40px），触屏放大到 44px ---- */

input, select, textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: .375rem .75rem;
  font: inherit;
  color: var(--foreground);
  background: transparent;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
}

input[type="radio"], input[type="checkbox"] {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  min-height: 0;
  margin: 0 .375rem 0 0;
  accent-color: var(--primary);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--focus-ring);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: var(--control-height);
  padding: .375rem 1rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 500;
  color: var(--foreground);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
}

button[type="submit"], .primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}

/* 认证表单的主按钮做成主站 Login 的通栏大按钮（w-full + control-height-lg）。 */
.card button[type="submit"], .site-main.auth #forms button[type="submit"] {
  width: 100%;
  min-height: var(--control-height-lg);
  font-size: .9375rem;
  font-weight: 600;
}

button[type="submit"]:hover, .primary:hover { background: color-mix(in srgb, var(--primary) 90%, transparent); }

button[type="button"]:not(.theme-toggle) {
  border-color: var(--input);
  background: var(--card);
}

button[type="button"]:not(.theme-toggle):hover { background: var(--accent); color: var(--accent-foreground); }

.danger { color: var(--destructive); }

.danger:hover { background: color-mix(in srgb, var(--destructive) 10%, transparent); }

/* 破坏性确认不走主色、不通栏：注销确认是 destructive 实心按钮，宽度随文字。
   hover 与黑色混合而非 transparent，保证前景对比度不跌出 AA。 */
.card button[type="submit"].danger {
  width: auto;
  min-height: var(--control-height);
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: transparent;
  font-size: .875rem;
  font-weight: 500;
}

.card button[type="submit"].danger:hover { background: color-mix(in srgb, var(--destructive) 90%, black); }

/* ---- 账号中心动作行（/account）：整行可点的按钮行，主入口实心、其余描边 ----
   链接片段由 app.py 以 <p><a> 生成，这里按结构选中，不要求片段带 class。 */
.card.actions > p { margin: 0 0 .5rem; }

.card.actions > p[role="status"] { margin: .75rem 0 0; }

.card.actions > p > a,
.card.actions > button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: var(--control-height);
  padding: .375rem .75rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: none;
}

/* 行尾箭头用边框画，与主站 lucide ChevronRight 同形。 */
.card.actions > p > a::after,
.card.actions summary::after {
  content: '';
  flex: none;
  width: .45rem;
  height: .45rem;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  opacity: .55;
}

.card.actions > p > a:hover { background: var(--accent); color: var(--accent-foreground); }

.card.actions > p > a.primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }

/* hover 与黑混：浅色下与透明混只有 4.35:1，与黑混为 6.28:1（暗色仍 ≥7:1）。 */
.card.actions > p > a.primary:hover { background: color-mix(in srgb, var(--primary) 90%, black); color: var(--primary-foreground); }

/* 危险区：分隔线下方的红色文字行，展开后才显示说明与密码确认。 */
.card.actions details { margin: .75rem 0 0; padding: .5rem 0 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }

.card.actions summary { width: 100%; padding: 0 .75rem; border-radius: var(--radius-md); color: var(--destructive); }

.card.actions details[open] summary::after { transform: rotate(45deg); }

/* 10% 着色底上文字要加深才过 AA（浅 4.18→5.43）；暗色 destructive 本就偏亮，保持原色（4.94）。 */
.card.actions summary:hover { background: color-mix(in srgb, var(--destructive) 10%, transparent); color: color-mix(in srgb, var(--destructive) 85%, black); }

.dark .card.actions summary:hover { color: var(--destructive); }

.card.actions details > p, .card.actions details form { padding: 0 .75rem; }

button:disabled, button[aria-disabled="true"] { opacity: .5; cursor: default; }

button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  :focus-visible { outline: 2px solid CanvasText; }
}

@media (pointer: coarse) {
  :root { --control-height: 2.75rem; --control-height-lg: 3rem; --page-gutter: 1rem; }
  /* 通栏主按钮与注销按钮的字号特异度更高，触屏下显式抬回 1rem（同特异度、靠后生效）。 */
  input, select, textarea, button,
  .card button[type="submit"], .card button[type="submit"].danger,
  .site-main.auth #forms button[type="submit"] { font-size: 1rem; }
  .card.actions > p > a, .card.actions > button { font-size: 1rem; }
}

/* ---- 状态行与链接组 ---- */

p[role="status"] { margin: .75rem 0 0; font-size: .875rem; color: var(--muted-foreground); min-height: 1.25rem; }

.links { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin: 1.25rem 0 0; }

.links a { display: inline-flex; align-items: center; min-height: var(--control-height); font-size: .875rem; }

/* 登录页的「注册账号 · 验证邮箱 · 找回密码」一行：分隔点靠紧两侧链接。 */
p.links { justify-content: center; gap: 0 .5rem; }

.links [aria-hidden="true"] { color: var(--muted-foreground); }

/* ---- 详情/摘要（注销、重发验证码） ---- */

details { margin: 1rem 0; border: 1px dashed var(--border); border-radius: var(--radius-lg); padding: .75rem; }

summary { cursor: pointer; min-height: var(--control-height); display: inline-flex; align-items: center; font-size: .875rem; font-weight: 500; }

/* ---- 表格与分页（账号管理） ---- */

.table-wrap {
  margin: 1rem 0;
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th { background: var(--muted); color: var(--muted-foreground); font-size: .75rem; font-weight: 600; }

/* 单元格不折行（与主站表格一致）；窄屏由 .table-wrap 横向滚动，而不是把字挤成竖排。 */
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }

tbody tr:hover { background: color-mix(in srgb, var(--muted) 50%, transparent); }

.pager { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }

.pager span { margin-right: auto; font-size: .875rem; color: var(--muted-foreground); }

.pager button { border-color: var(--input); background: var(--card); }

/* ---- 对话框（账号管理详情） ---- */

dialog {
  width: min(38rem, 94vw);
  max-height: 88vh;
  padding: 1.25rem;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: auto;
}

dialog::backdrop { background: rgba(0, 0, 0, .5); }

.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.dialog-head h2 { margin: 0; overflow-wrap: anywhere; }

dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .8rem; margin: .75rem 0; }

dt { color: var(--muted-foreground); font-size: .875rem; }

dd { margin: 0; overflow-wrap: anywhere; font-size: .875rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ---- 页脚：两行，与主站一致 ---- */

.site-footer { border-top: 1px solid var(--border); }

.site-footer-inner {
  max-width: 80rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: .125rem;
  padding: 1rem var(--page-gutter);
  font-size: .75rem;
  color: var(--muted-foreground);
}

.site-footer p { margin: 0; }

/* 行内 <a> 上的 min-height 不生效，须用 inline-flex 才能撑出触控命中区（与主站页脚链接同法）。 */
.site-footer a { display: inline-flex; align-items: center; color: inherit; text-decoration: underline; text-underline-offset: 2px; min-height: 1.5rem; }

@media (pointer: coarse) { .site-footer a { min-height: 2.75rem; } }

@media (max-width: 40rem) {
  h1 { font-size: 1.5rem; }
  .site-main { padding-top: 1rem; }
  th, td { padding: .5rem; }
  dl { grid-template-columns: 1fr; gap: .1rem .8rem; }
  dt { margin-top: .4rem; }
}
