/* 用户管理界面。
   配色变量、页头与页脚样式与官网 apps/web/public/styles.css 保持一致（各自维护，改动时两边对照）。
   默认跟随系统；<html data-theme> 由服务端按 theme Cookie 输出，脚本切换时直接改写。
   方向相关的间距一律用逻辑属性，阿拉伯语页面（dir="rtl"）自动镜像。 */
:root {
  color-scheme: light dark;
  --bg:          light-dark(#f6f5f1, #121211);
  --surface:     light-dark(#fdfcf9, #191917);
  --surface-2:   light-dark(#efede7, #201f1d);
  --line:        light-dark(#e4e1d8, #2b2a27);
  --line-strong: light-dark(#c9c5b9, #3d3b37);
  --btn-line:    light-dark(#cfcbbf, #3a3834);
  --text:        light-dark(#1d1c19, #ecebe6);
  --text-2:      light-dark(#57544c, #a8a59c);
  --text-3:      light-dark(#736f65, #85827a);
  --accent:       light-dark(#4a4fc0, #6f72e6);
  --accent-hover: light-dark(#3e42ad, #7f82ec);
  --accent-2:     light-dark(#8c5bd6, #b48cf0);
  --accent-ink:   light-dark(#3f43b0, #b9bbfa);
  --ok:           light-dark(#1d7a46, #6fd69b);
  --ok-bg:        light-dark(#e8f6ee, #11261a);
  --error:        light-dark(#b42318, #ff8a80);
  --error-bg:     light-dark(#fdecea, #2a1414);
  --page: min(1180px, 100% - 3rem);
  --radius: 14px;
  --s1: .5rem; --s2: 1rem; --s3: 1.5rem; --s4: 2rem; --s5: 3rem;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }
/* 不认 light-dark() 的老浏览器：与官网一样固定深色，并隐藏切换按钮 */
@supports not (color: light-dark(#000, #fff)) {
  :root {
    --bg: #121211; --surface: #191917; --surface-2: #201f1d;
    --line: #2b2a27; --line-strong: #3d3b37; --btn-line: #3a3834;
    --text: #ecebe6; --text-2: #a8a59c; --text-3: #85827a;
    --accent: #6f72e6; --accent-hover: #7f82ec; --accent-2: #b48cf0; --accent-ink: #b9bbfa;
    --ok: #6fd69b; --ok-bg: #11261a; --error: #ff8a80; --error-bg: #2a1414;
    color-scheme: dark;
  }
  .theme-form { display: none; }
  :root .only-light { display: none; }
  .google-button, .google-button:hover { background: #131314; border-color: #8e918f; color: #e3e3e3; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent-ink); }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.6rem; line-height: 1.3; margin: 0 0 var(--s3); }
h2 { font-size: 1.05rem; margin: 0 0 var(--s2); }
p { margin: 0 0 var(--s2); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ------------------------------------------------ 页头（与官网 .nav 相同） */

.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.nav-in {
  width: var(--page); margin-inline: auto;
  height: 62px; display: flex; align-items: center; gap: var(--s3);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 620; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.nav-links { --nav-gap: var(--s3); margin-inline-start: auto; display: flex; align-items: center; gap: var(--nav-gap); }
/* 菜单链接之间保持 --nav-gap；语言、配色、登录这几个按钮之间收紧到 .75rem（与官网页头一致） */
.nav-links .lang ~ * { margin-inline-start: calc(.75rem - var(--nav-gap)); }
.nav-links a { color: var(--text-2); font-size: .92rem; text-decoration: none; transition: color .18s ease; }
.nav-links a:hover { color: var(--text); }
.brand, .nav-links a { white-space: nowrap; }
.nav-links form { margin: 0; }
@media (max-width: 720px) { .nav-links .hide-sm { display: none; } }
@media (max-width: 480px) {
  .nav-in { gap: .75rem; }
  .nav-links { --nav-gap: .9rem; }
}

.theme-toggle {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: transparent; color: var(--text-2); cursor: pointer;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.theme-toggle svg { display: block; width: 17px; height: 17px; }

.lang {
  display: inline-flex; align-items: center; gap: 3px;
  height: 34px; padding-inline: 9px 7px;
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--text-2);
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.lang:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.lang svg { display: block; width: 16px; height: 16px; flex: none; }
.lang select {
  appearance: none; -webkit-appearance: none;
  border: 0; color: inherit;
  font: inherit; font-size: .82rem; line-height: 1.2;
  padding: 0 1px; padding-inline-end: 15px; cursor: pointer; max-width: 8.5em;
  /* 去掉系统样式后自己画下拉箭头：两段渐变拼成一个 V，颜色跟着文字（currentColor）走，不用图片 */
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) no-repeat right 5px top 55% / 4px 4px,
    linear-gradient(135deg, currentColor 50%, transparent 50%) no-repeat right 1px top 55% / 4px 4px,
    transparent;
}
[dir="rtl"] .lang select { background-position: left 1px top 55%, left 5px top 55%, 0 0; }
.lang select option { color: var(--text); background: var(--surface); }
.lang-go { font: inherit; font-size: .78rem; border: 0; background: none; color: var(--accent-ink); cursor: pointer; padding: 0 2px; }
@media (max-width: 640px) { .lang select { max-width: 6em; } }

/* 账户入口：官网（apps/web/public/styles.css）与用户端（apps/backend/ui/account/assets/account.css）相同。
   未登录是实心的「登录」按钮；已登录是首字母圆标 + 用户名的胶囊，首字母由用户名生成，不是头像。 */
.nav-links .account-link {
  display: inline-flex; align-items: center; gap: .5rem;
  height: 34px; max-width: 14em;
  border-radius: 9px; font-size: .88rem; text-decoration: none;
  transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.nav-links .account-link.is-login {
  padding-inline: 14px;
  background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 4px 14px -6px var(--accent);
}
.nav-links .account-link.is-login:hover { background: var(--accent-hover); color: #fff; }
.nav-links .account-link.is-user {
  padding-inline: 4px 11px;
  border: 1px solid var(--line); color: var(--text-2);
}
.nav-links .account-link.is-user:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.account-avatar {
  flex: none; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: .74rem; font-weight: 700; line-height: 1;
}
.account-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
@media (max-width: 620px) {
  /* 窄屏只留首字母圆标，用户名交给 title 与读屏 */
  .nav-links .account-link.is-user { padding-inline: 4px; }
  .account-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav-links .account-link.is-login { padding-inline: 11px; }
}

/* 图标表示「点了会变成什么」：深色时是太阳（.only-dark），浅色时是月亮（.only-light） */
:root[data-theme="dark"] .only-light,
:root[data-theme="light"] .only-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .only-light { display: none; }
}
@supports (color: light-dark(#000, #fff)) {
  @media (prefers-color-scheme: light) {
    :root:not([data-theme]) .only-dark { display: none; }
  }
}

@media (max-width: 620px) {
  .brand span { display: none; }
  .nav-links a[data-nav-github] { display: none; }
  .lang { padding-inline: 7px 5px; }
  .lang svg { display: none; }
  .lang select { max-width: 5.6em; }
  .nav-in { height: auto; min-height: 62px; flex-wrap: wrap; row-gap: .4rem; padding-block: .5rem; }
  .nav-links { --nav-gap: .8rem; flex-wrap: wrap; justify-content: flex-end; row-gap: .4rem; }
  .nav-links a { font-size: .88rem; }
}

/* ------------------------------------------------ 页脚（与官网 .foot 相同） */

.wrap { width: var(--page); margin-inline: auto; }
.foot { border-top: 1px solid var(--line); padding: var(--s4) 0 var(--s5); margin-top: auto; }
.foot-in { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); align-items: center; }
.foot-in p { color: var(--text-3); font-size: .85rem; margin: 0; }
.foot-links { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); }
.foot-links a { color: var(--text-2); font-size: .88rem; text-decoration: none; }
.foot-links a:hover { color: var(--text); }
.foot-note { margin: var(--s3) 0 0; max-width: 72ch; color: var(--text-3); font-size: .78rem; line-height: 1.6; }
@media (max-width: 640px) { .foot-links { margin-inline-start: 0; } }

/* ------------------------------------------------ 账户页面 */

.shell {
  display: grid; gap: var(--s4);
  width: var(--page);
  margin: var(--s4) auto var(--s5);
  flex: 1 0 auto; align-content: start;
}
.signed-in .shell { grid-template-columns: 200px minmax(0, 1fr); }
.signed-out .shell { width: min(440px, 100% - 2rem); }

.side ul { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: 2px; }
.side a {
  display: block; padding: .5rem .75rem; border-radius: 9px;
  color: var(--text-2); text-decoration: none;
}
.side a:hover { background: var(--surface-2); color: var(--text); }
.side a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.side form { margin: 0; padding-inline: .75rem; }

.side, .content { min-width: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s3);
  margin-bottom: var(--s3);
}
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid .card { margin-bottom: 0; }
.empty { color: var(--text-2); }
.empty h1, .empty h2 { color: var(--text); }

.muted { color: var(--text-2); }
.fine { color: var(--text-2); font-size: .85rem; }
.big { font-size: 2rem; font-weight: 700; line-height: 1.2; margin-bottom: var(--s2); }
.big.small { font-size: 1.3rem; }
.unit { font-size: 1rem; font-weight: 500; color: var(--text-2); margin-inline-start: .25rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem var(--s2); margin: 0 0 var(--s2); }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.wide { grid-template-columns: minmax(6rem, max-content) 1fr; }

.stack { display: grid; gap: .5rem; margin-bottom: var(--s2); }
.stack.narrow { max-width: 360px; }
.stack .button { margin-top: .5rem; justify-self: start; }
.auth .stack .button { justify-self: stretch; }
label { font-weight: 600; font-size: .9rem; }
input {
  font: inherit; color: var(--text);
  padding: .6rem .75rem;
  border: 1px solid var(--btn-line); border-radius: 10px;
  background: var(--bg);
  width: 100%;
}

.button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: .6rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--btn-line); background: var(--surface); color: var(--text);
}
.button:hover { background: var(--surface-2); color: var(--text); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.auth > .button { width: 100%; margin-bottom: var(--s2); }

/* Google 登录按钮：按 Google 品牌规范的浅色 / 深色两套（白底灰边、#131314 底），
   官方四色 G 标志放左侧；悬停时叠一层 8% 的文字色。随页面明暗切换。 */
.google-button {
  gap: 12px; min-height: 44px;
  background: light-dark(#ffffff, #131314);
  border-color: light-dark(#747775, #8e918f);
  color: light-dark(#1f1f1f, #e3e3e3);
  font-weight: 500; letter-spacing: .01em;
}
.google-button:hover {
  background: color-mix(in srgb, light-dark(#1f1f1f, #e3e3e3) 8%, light-dark(#ffffff, #131314));
  color: light-dark(#1f1f1f, #e3e3e3);
}
.google-button:active { background: color-mix(in srgb, light-dark(#1f1f1f, #e3e3e3) 12%, light-dark(#ffffff, #131314)); }
.google-logo { width: 18px; height: 18px; flex: none; }
.consent { text-align: center; }
.consent .stack { margin-top: var(--s3); }
.consent-mark { display: block; margin: 0 auto var(--s2); border-radius: 12px; }
.google-button.compact { min-height: 38px; padding-block: .4rem; font-size: .92rem; }
.link-button {
  font: inherit; color: var(--accent-ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
}
.link-button:hover { color: var(--accent-hover); }

.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row form { margin: 0; }
.divider { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); margin: var(--s3) 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.notice { padding: .75rem 1rem; border-radius: 10px; margin-bottom: var(--s3); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--error-bg); color: var(--error); }

.methods { list-style: none; padding: 0; margin: 0 0 var(--s2); }
.methods li { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.methods li > span:first-child { font-weight: 600; min-width: 7rem; }
.methods form { margin: 0; margin-inline-start: auto; }
.links { margin: 0; padding-inline-start: 1.2rem; }

.table-wrap { overflow-x: auto; margin-bottom: var(--s2); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: start; padding: .6rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; }
td form { margin: 0; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: .75rem; padding: 0 .45rem; border-radius: 999px; background: var(--surface-2); color: var(--accent-ink); }

/* 订阅方案：两张卡片并排，年付卡片带渐变描边与角标。 */
.lead { font-size: 1.05rem; color: var(--text-2); margin: 0 0 var(--s3); }
.plans { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: var(--s2); }
.plans .card { margin-bottom: 0; }
.plan { position: relative; display: flex; flex-direction: column; }
.plan.featured {
  border-color: transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), var(--accent-2)) border-box;
  border-width: 2px;
}
.plan-flag {
  position: absolute; inset-block-start: -.75rem; inset-inline-end: var(--s3);
  padding: .15rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.price { display: flex; align-items: baseline; gap: .3rem; margin: .25rem 0 .1rem; }
.price .now { font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.price .per { color: var(--text-2); }
.was { color: var(--text-3); margin: 0 0 var(--s2); }
.perks { list-style: none; padding: 0; margin: 0 0 var(--s3); display: grid; gap: .45rem; flex: 1; }
.perks li { padding-inline-start: 1.5rem; position: relative; }
.perks li::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--ok); font-weight: 700; }
.button.wide { width: 100%; }
.button:disabled { opacity: .55; cursor: not-allowed; }

/* 扩展安装后的欢迎页 */
.welcome { max-width: 560px; margin-inline: auto; text-align: center; }
.welcome .lead { margin-bottom: var(--s2); }
.steps { text-align: start; display: grid; gap: .5rem; margin: 0 auto var(--s3); max-width: 420px; padding-inline-start: 1.4rem; }
.welcome > .button { width: 100%; margin-bottom: var(--s2); }

@media (max-width: 760px) {
  .signed-in .shell { grid-template-columns: minmax(0, 1fr); gap: var(--s2); margin-top: var(--s2); }
  .side ul { display: flex; flex-wrap: wrap; gap: .25rem; }
  .side a { white-space: nowrap; padding: .35rem .65rem; font-size: .9rem; border: 1px solid var(--line); }
  h1 { font-size: 1.35rem; }
  .card { padding: var(--s2); }
}
