.utility-tray {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  z-index: var(--z-toast); display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.utility-tray > * { pointer-events: auto; }
/* AI 辅导面板贴右上角展开，它的关闭键与这个工具区同位；面板开着时工具区让位 */
body.ai-coach-open .utility-tray { display: none; }
/* 有顶栏的视图：工具区落进顶栏那一行，与 .reader-action 同一套扁平语言；只有激活页（无顶栏）才是浮起的卡片 */
body:has(.shell:not([data-shell-mode="auth"])) .utility-tray { top: calc(4px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); gap: 6px; }
body:has(.shell:not([data-shell-mode="auth"])) .account-control,
body:has(.shell:not([data-shell-mode="auth"])) .global-fullscreen-exit { border-color: transparent; background: transparent; box-shadow: none; backdrop-filter: none; color: var(--ink-2); }
body:has(.shell:not([data-shell-mode="auth"])) .account-control { padding: 0 10px 0 4px; }
body:has(.shell:not([data-shell-mode="auth"])) .account-control-copy small { display: none; }
body:has(.shell:not([data-shell-mode="auth"])) .account-avatar { width: 28px; height: 28px; font-size: var(--t-xs); }
@media (hover: hover) and (pointer: fine) { body:has(.shell:not([data-shell-mode="auth"])) .account-control:hover, body:has(.shell:not([data-shell-mode="auth"])) .global-fullscreen-exit:hover { color: var(--ink-1); background: var(--surface-2); box-shadow: none; } }
/* 专注阅读只留正文与退出：账户入口退场，退出全屏保留 */
body.reading-focus .account-control { display: none; }
.account-control, .global-fullscreen-exit {
  min-height: 44px; border: 1px solid var(--line); border-radius: var(--r-2);
  background: color-mix(in srgb, var(--surface) 94%, transparent); color: var(--ink-1);
  box-shadow: var(--shadow-1); backdrop-filter: blur(12px);
}
.account-control { display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px 5px 6px; text-align: left; transition: border-color var(--d-fast) ease, background var(--d-fast) ease, box-shadow var(--d-fast) ease, transform var(--d-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .account-control:hover { border-color: var(--line-strong); background: var(--surface); box-shadow: var(--shadow-2); } }
.account-control:active { transform: scale(.97); box-shadow: var(--shadow-press); }
.account-control:focus-visible { outline: 2px solid var(--passfish); outline-offset: 3px; }
.account-avatar, .account-profile-avatar {
  display: grid; place-items: center; flex: none; border-radius: 50%; background: var(--passfish); color: white; font-weight: 600;
}
.account-avatar { width: 32px; height: 32px; font-size: var(--t-sm); }
.account-control-copy { display: grid; gap: 1px; max-width: 132px; }
.account-control-copy b, .account-control-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-control-copy b { font-size: var(--t-sm); font-weight: 600; }
.account-control-copy small { color: var(--ink-3); font-size: var(--t-xs); }
.global-fullscreen-exit { position: static; }
.shell[data-shell-mode="notes"] .topbar { padding-right: 190px; }
body.browser-fullscreen .shell[data-shell-mode="notes"] .topbar { padding-right: 310px; }

.account-panel::backdrop { background: color-mix(in srgb, var(--ink-1) 24%, transparent); backdrop-filter: blur(2px); }
.account-close { width: 44px; height: 44px; margin: -8px -8px 0 0; color: var(--ink-3); font-size: 24px; border-radius: var(--r-2); transition: color var(--d-fast) ease, background var(--d-fast) ease, transform var(--d-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .account-close:hover { color: var(--ink-1); background: var(--surface-2); } }
.account-close:active { transform: scale(.9); }
.account-close:focus-visible { outline: 2px solid var(--passfish); outline-offset: 2px; }

.account-primary, .account-secondary { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--r-2); padding: 0 15px; font-size: var(--t-sm); font-weight: 600; line-height: 1; text-align: center; white-space: nowrap; transition: color var(--d-fast) ease, border-color var(--d-fast) ease, background var(--d-fast) ease, box-shadow var(--d-fast) ease, transform var(--d-press) var(--ease-out), opacity var(--d-fast) ease; }
.account-primary { background: var(--ink-1); color: var(--bg); box-shadow: var(--shadow-1); }
@media (hover: hover) and (pointer: fine) { .account-primary:hover:not(:disabled) { background: var(--ink-2); box-shadow: var(--shadow-2); transform: translateY(-1px); } }
.account-primary:active:not(:disabled) { transform: translateY(1px) scale(.985); box-shadow: var(--shadow-press); }
.account-primary:focus-visible, .account-secondary:focus-visible { outline: 2px solid var(--passfish); outline-offset: 3px; }
.account-primary:disabled, .account-secondary:disabled { cursor: not-allowed; color: var(--ink-3); border-color: var(--line); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); opacity: 1; transform: none; }
.account-primary[data-loading="true"]::before, .account-secondary[data-loading="true"]::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.account-primary.compact { flex: none; }
.account-secondary { border: 1px solid var(--line); color: var(--ink-1); background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .account-secondary:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); box-shadow: var(--shadow-1); } }
.account-secondary:active:not(:disabled) { transform: scale(.97); background: var(--surface-2); box-shadow: var(--shadow-press); }
.account-message { min-height: 20px; margin: 0; color: var(--ink-3); font-size: var(--t-sm); line-height: var(--lh-ui); }
.account-message.error { display: flex; align-items: flex-start; gap: 6px; color: var(--bad-ink); }
.account-message.error::before { content: "!"; display: grid; place-items: center; flex: none; width: 17px; height: 17px; margin-top: 2px; border-radius: 50%; background: var(--bad); color: white; font-size: 11px; font-weight: 600; line-height: 1; }
.account-success { display: grid; justify-items: center; gap: 10px; padding: 8px 0 4px; text-align: center; }
.account-success-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 4px; border-radius: 50%; background: var(--passfish-tint); color: var(--passfish); font-size: 24px; font-weight: 600; }
.account-success h2, .account-success p { margin: 0; }
.account-success h2 { font-size: var(--t-lg); }
.account-success p { max-width: 330px; color: var(--ink-2); font-size: var(--t-sm); line-height: var(--lh-ui); }
.account-success .account-primary { width: 100%; margin-top: 8px; }
.account-success h2 { font-size: var(--t-lg); }
.account-loading { display: grid; place-items: center; gap: 12px; min-height: 180px; color: var(--ink-3); font-size: var(--t-sm); }
.account-loading i { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--passfish); border-radius: 50%; animation: spin .8s linear infinite; }
@media (max-width: 560px) {
  .utility-tray { right: 10px; }
  .account-control { width: 44px; padding: 5px; }
  .account-control-copy { display: none; }
  .shell[data-shell-mode="notes"] .topbar { padding-right: 62px; }
  body.browser-fullscreen .shell[data-shell-mode="notes"] .topbar { padding-right: 114px; }
  .account-panel { width: 100%; max-width: none; max-height: calc(100dvh - 12px); margin: auto 0 0; border-radius: var(--r-4) var(--r-4) 0 0; }
  .account-sheet { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .account-control, .account-close, .account-tabs button, .account-primary, .account-secondary, .account-link, .account-exam, .account-exam i, .account-foot button { transition: none; }
}

/* ---- 表单内的辅助行 ---- */
.account-message.success { color: var(--ok-ink); }

/* ---- 我的考试：身份一行 + 一个盒子 ---- */
.account-identity { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; margin-bottom: 24px; }
.account-identity .account-profile-avatar { width: 42px; height: 42px; }
.account-identity div { display: grid; min-width: 0; gap: 2px; }
.account-identity b, .account-identity span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity b { font-size: var(--t-sm); }
.account-identity span { color: var(--ink-3); font-size: var(--t-xs); }
.account-identity button { min-height: 36px; padding: 0 10px; border-radius: var(--r-1); color: var(--ink-3); font-size: var(--t-xs); transition: color var(--d-fast) ease, background var(--d-fast) ease, transform var(--d-press) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .account-identity button:hover { color: var(--ink-1); background: var(--surface-2); } }
.account-identity button:active { transform: scale(.96); }
.account-identity button:focus-visible { outline: 2px solid var(--passfish); outline-offset: 2px; }
.account-library { border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); overflow: hidden; }
.account-library-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.account-library-head h2 { margin: 0; font-size: var(--t-base); font-weight: 600; }
.account-library-head .account-secondary { min-height: 36px; padding: 0 12px; font-size: var(--t-xs); }
.account-exams { display: grid; gap: 1px; background: var(--line); }
.account-exam { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; background: var(--surface); color: var(--ink-1); text-align: left; transition: background var(--d-fast) ease; }
@media (hover: hover) and (pointer: fine) { .account-exam:hover { background: var(--surface-2); } .account-exam:hover > i { transform: translateX(2px); } }
.account-exam:active { background: var(--surface-3); }
.account-exam:focus-visible { outline: 2px solid var(--passfish); outline-offset: -2px; }
.account-exam-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-2); background: var(--passfish-tint); color: var(--passfish); font-size: var(--t-xs); font-weight: 600; }
.account-exam > span:nth-child(2) { display: grid; gap: 3px; }
.account-exam b { font-size: var(--t-sm); }
.account-exam small, .account-exam i { color: var(--ink-3); font-size: var(--t-xs); font-style: normal; }
.account-exam i { transition: transform var(--d-fast) var(--ease-out); }
.account-redeem { display: grid; gap: 8px; padding: 14px 16px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.account-redeem label { color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; }
.account-redeem input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); color: var(--ink-1); font-family: var(--mono); font-size: var(--t-base); letter-spacing: .04em; text-transform: uppercase; transition: border-color var(--d-fast) ease, box-shadow var(--d-fast) ease; }
.account-redeem input::placeholder { color: var(--ink-3); letter-spacing: .02em; }
.account-redeem input:focus-visible { border-color: var(--passfish); outline: none; box-shadow: 0 0 0 3px var(--passfish-tint), inset 0 0 0 1px var(--passfish-edge); }
.account-redeem input[aria-invalid="true"] { border-color: var(--bad-edge); background: var(--bad-tint); box-shadow: 0 0 0 3px var(--bad-tint); }
.account-redeem .account-message:empty { display: none; }
.account-empty .account-redeem { border-top: 0; background: var(--surface); padding: 18px 16px 20px; }
.account-empty label { color: var(--ink-1); font-size: var(--t-base); font-weight: 600; }
#accountLibraryNotice { margin-top: 12px; }
.account-foot { margin-top: 16px; color: var(--ink-3); font-size: var(--t-xs); text-align: center; }
@media (max-width: 560px) { .account-identity { margin-bottom: 20px; } }

/* ==== 面板外壳 ==== */
.account-panel { width: min(400px, calc(100vw - 28px)); max-height: min(760px, calc(100dvh - 28px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-4); background: var(--surface); color: var(--ink-1); box-shadow: var(--shadow-3); }
.account-sheet { padding: 24px 28px 24px; overflow: auto; max-height: inherit; }
.account-head { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px 12px; align-items: start; margin-bottom: 24px; }
.account-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-2); overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow-1); }
.account-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }
.account-head-copy { grid-column: 1 / -1; display: grid; gap: 6px; }
.account-head h1 { margin: 0; font-size: var(--t-xl); font-weight: 600; line-height: var(--lh-display); letter-spacing: -0.024em; }
.account-sub { margin: 0; color: var(--ink-2); font-size: var(--t-sm); line-height: var(--lh-ui); text-wrap: pretty; }

/* ==== 表单：一列，字段之间 12，标签与字段 6 ==== */
.account-form { display: grid; gap: 12px; }
.account-form > div:not(.account-label-row) { display: grid; gap: 12px; }
.account-label { display: block; margin-bottom: -6px; color: var(--ink-2); font-size: var(--t-sm); font-weight: 500; }
.account-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: -6px; }
.account-label-row .account-label { margin: 0; }
.account-form input, .account-redeem input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); color: var(--ink-1); font-size: var(--t-base); transition: border-color var(--d-fast) ease, box-shadow var(--d-fast) ease; }
.account-form input::placeholder, .account-redeem input::placeholder { color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .account-form input:hover:not(:focus), .account-redeem input:hover:not(:focus) { border-color: var(--line-strong); } }
.account-form input:focus-visible, .account-redeem input:focus-visible { border-color: var(--ink-edge); outline: none; box-shadow: 0 0 0 3px var(--ink-tint); }
.account-form input[aria-invalid="true"], .account-redeem input[aria-invalid="true"] { border-color: var(--bad-edge); background: var(--bad-tint); box-shadow: 0 0 0 3px var(--bad-tint); }
.account-field { position: relative; display: block; }
.account-field input { padding-right: 104px; }
.account-field:has(.account-field-btn[aria-pressed]) input { padding-right: 60px; }
.account-field-btn { position: absolute; top: 6px; right: 6px; bottom: 6px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: var(--r-1); color: var(--ink-2); font-size: var(--t-xs); font-weight: 500; white-space: nowrap; transition: color var(--d-fast) ease, background var(--d-fast) ease; }
@media (hover: hover) and (pointer: fine) { .account-field-btn:hover:not(:disabled) { color: var(--ink-1); background: var(--surface-2); } }
.account-field-btn:disabled { color: var(--ink-3); cursor: default; }
.account-field-btn:focus-visible { outline: 2px solid var(--passfish); outline-offset: 1px; }
.account-field-btn[data-loading="true"]::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.account-hint { display: block; margin-top: -4px; color: var(--ink-3); font-size: var(--t-xs); line-height: var(--lh-ui); }
.account-link { width: fit-content; min-height: 0; padding: 0; color: var(--ink-3); font-size: var(--t-xs); border-bottom: 1px solid transparent; transition: color var(--d-fast) ease, border-color var(--d-fast) ease; }
.account-link.strong { color: var(--ink-1); font-size: inherit; font-weight: 500; border-bottom-color: var(--line-strong); }
@media (hover: hover) and (pointer: fine) { .account-link:hover { color: var(--passfish); border-bottom-color: var(--passfish-edge); } }
.account-link:focus-visible { outline: 2px solid var(--passfish); outline-offset: 3px; }
.account-form .account-primary { width: 100%; min-height: 46px; margin-top: 4px; }
.account-form .account-message:empty { display: none; }
.account-switch { margin: 20px 0 0; color: var(--ink-3); font-size: var(--t-sm); text-align: center; }
.account-switch .account-link { margin-left: 4px; }
.account-reset-password-stage { display: grid; gap: 12px; }
.account-recovery { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface-2); color: var(--ink-2); font-size: var(--t-sm); }

/* ==== 并排：输入框 + 主按钮 ==== */
.account-inline { display: flex; gap: 8px; align-items: stretch; }
.account-inline input { min-width: 0; flex: 1; }

/* ==== 重置步骤条 ==== */
.account-steps { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; margin: 0 0 20px; list-style: none; }
.account-steps li { position: relative; display: grid; justify-items: center; gap: 6px; color: var(--ink-3); font-size: var(--t-xs); }
.account-steps li::before { content: ""; position: absolute; z-index: 0; top: 12px; right: 50%; width: 100%; height: 1px; background: var(--line); }
.account-steps li:first-child::before { display: none; }
.account-steps i { position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-style: normal; font-size: var(--t-xs); font-weight: 600; }
.account-steps li.on, .account-steps li.done { color: var(--ink-1); }
.account-steps li.on i { border-color: var(--fill); background: var(--fill); color: var(--inv); }
.account-steps li.done i { border-color: var(--passfish); background: var(--passfish-tint); color: var(--passfish); }
@media (max-width: 560px) { .account-sheet { padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); } }

/* 管理员复用账户列表，通过搜索快速进入任意考试。 */
.account-exam-search { margin-bottom: 16px; }
.account-exam[hidden] { display: none; }
.account-search-empty { margin: 0; padding: 16px; color: var(--ink-2); font-size: var(--t-sm); }
.account-exam:disabled { cursor: wait; opacity: .6; }

/* 社群邀请：首次总览弹一次，侧栏内随时重新打开。 */
.community-panel { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; border-radius: var(--r-3); background: var(--passfish); color: var(--inv); box-shadow: var(--shadow-3); overflow: auto; }
.community-panel::backdrop { background: color-mix(in srgb, var(--ink-1) 24%, transparent); backdrop-filter: blur(2px); }
.community-panel .support-card { position: relative; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 28px; border: 0; }
.community-panel .support-copy { padding-top: 36px; }
.community-panel .support-contact { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.community-close { display: grid; place-items: center; line-height: 1; position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: var(--r-2); font-size: var(--t-xl); color: inherit; }
.community-close:hover { background: color-mix(in srgb, var(--inv) 12%, transparent); }
.community-close:focus-visible { outline: 2px solid var(--inv); outline-offset: -4px; }
@media (max-width: 400px) { .community-panel .support-card { padding: 20px; } }
