/* Reader services use the shared surface, ink and motion tokens. */
.account-open, .service-text { border: 0; background: transparent; color: var(--ink-1); cursor: pointer; }
.account-open { display: flex; flex: none; align-items: center; justify-content: center; gap: 7px; min-width: 44px; height: 40px; padding: 0 12px; border-radius: var(--r-pill); font: 560 var(--fs-13) var(--font-ui); transition: background-color var(--dur-1) var(--ease-out); }
.account-open:hover { background: var(--surface-1); }
.header-end { gap: 8px; }
/* Theme button · 8px · settings · 20px · 登录 */
.header-end .account-open { margin-left: 12px; }
.account-dialog { width: min(440px, 100vw - 32px); max-width: none; max-height: calc(100dvh - 32px); padding: 28px; overflow-y: auto; }
.account-content { padding: 0; }
.account-dialog > .ov-close { position: absolute; right: 16px; top: 16px; }
.account-content h2 { margin: 0; padding-right: 44px; font-family: var(--font-ui); font-size: var(--fs-20); line-height: var(--lh-20); font-weight: 650; letter-spacing: -.01em; }
.account-content h2:focus { outline: none; }
.account-content h2:focus-visible { border-radius: var(--r-inner); box-shadow: var(--ring); }
#auth-form { margin-top: 24px; }
#auth-form label, .followup-form label { display: block; margin: 0 0 6px; color: var(--ink-2); font: 560 var(--fs-13)/1.5 var(--font-ui); }
#auth-form input, .followup-field input { width: 100%; min-width: 0; height: 48px; border: 0; border-radius: var(--r-field); padding: 0 16px; background: var(--surface-1); color: var(--ink-1); font: 400 16px var(--font-ui); transition: background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out); }
#auth-form input:focus, .followup-field input:focus { outline: none; background: var(--surface-0); box-shadow: var(--shadow-float), var(--ring); }
#auth-form input[readonly] { background: var(--surface-1); color: var(--ink-2); }
#auth-form input.is-invalid { background: var(--danger-a10); box-shadow: var(--ring-danger); }
#auth-form input.is-invalid:focus { background: var(--danger-a10); box-shadow: var(--shadow-float), var(--ring); }
/* Field errors under their input, 6px; only server/overall errors go below the submit. */
.auth-field-error { margin: 6px 2px 0; color: var(--danger); font: var(--fs-13)/1.45 var(--font-ui); }
.auth-field-error[hidden] { display: none; }
.auth-field-wrap { margin-top: 16px; }
.auth-field-wrap:first-child { margin-top: 0; }
.auth-password-row { margin-top: 16px; }
#auth-code { letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.service-primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; border: 0; border-radius: var(--r-pill); padding: 0 20px; background: var(--btn-primary-bg); color: var(--btn-primary-ink); font: 560 var(--fs-15)/1 var(--font-ui); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.service-primary:hover { background: var(--btn-primary-hover); }
.service-primary:active { transform: scale(.97); }
.service-primary:disabled, .quiz-choice:disabled { cursor: default; }
.service-primary:disabled { opacity: .5; }
.service-text { padding: 6px 10px; border-radius: var(--r-pill); font: 560 var(--fs-13)/1.6 var(--font-ui); text-align: left; transition: background-color var(--dur-1) var(--ease-out); }
.service-text:hover { background: var(--surface-1); }
.auth-status { min-height: 20px; margin: 10px 0 0; color: var(--ink-2); font: var(--fs-12)/1.7 var(--font-ui); overflow-wrap: anywhere; }
.auth-status.is-error, .assistant-status.is-error { color: var(--danger); }
.auth-status:empty { min-height: 0; margin: 0; }
.account-switch { display: flex; align-items: center; gap: 4px; margin: 22px 0 2px; font: 400 var(--fs-13)/1.6 var(--font-ui); }
.account-switch > span { color: var(--ink-2); }
.account-nav { margin: 16px 0 16px; }
.account-nav-item { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 10px; color: var(--ink-1); background: var(--surface-1); text-decoration: none; font: 560 var(--fs-13)/1 var(--font-ui); transition: background-color var(--dur-1) var(--ease-out); }
.account-nav-item:hover { background: var(--surface-2); }
.account-nav-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.account-email { margin: 8px 0 24px; color: var(--ink-2); font: var(--fs-15)/1.6 var(--font-ui); overflow-wrap: anywhere; }
.account-detail { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; padding: 16px 0; font: var(--fs-12)/1.6 var(--font-ui); }
.sync-status { color: var(--ink-3); font: var(--fs-12)/1.7 var(--font-ui); }
.account-permission { margin: 16px 0 24px; font: var(--fs-12)/1.7 var(--font-ui); color: var(--ink-2); }
.account-logout { display: inline-flex; }
.continue-reading { display: block; margin: 0 0 20px; padding: 14px 16px; border-radius: var(--r-12); background: var(--surface-1); text-decoration: none; font: var(--fs-13)/1.9 var(--font-ui); }
.continue-reading small { display: block; font: var(--fs-12)/1.6 var(--font-ui); color: var(--ink-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Settings shell lives in styles.css: one anchored popover for desktop and phones. */
.settings-sheet { padding: 0; }
/* Desktop assistant entry (mobile uses the dock). */
.assistant-open { position: fixed; z-index: 45; right: max(24px, calc((100vw - 1440px)/2)); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; height: 44px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: var(--ink-1); color: var(--bg); box-shadow: var(--shadow-float); font: 560 var(--fs-13)/1 var(--font-ui); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.assistant-open svg, .assistant-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.assistant-open:hover { background: color-mix(in srgb, var(--ink-1) 92%, var(--bg)); }
.assistant-open:active { transform: scale(.97); }
.chat-open .assistant-open { display: none; }
@media (max-width: 1023px) { .assistant-open:not(.dock-ai) { display: none; } }
.reader-tools .assistant-open { position: static; flex: none; gap: 7px; min-height: 40px; height: 40px; padding: 0 13px; background: transparent; color: var(--ink-1); font: 560 var(--fs-13)/1 var(--font-ui); white-space: nowrap; }
.reader-tools .assistant-open > * { flex: none; white-space: nowrap; }
@media (hover: hover) { .reader-tools .assistant-open:hover { background: var(--surface-1); } }
.reader-tools .assistant-open svg { width: 16px; height: 16px; }
.reader-tools .assistant-open { box-shadow: none; }
.assistant-panel { --chat-width: 340px; position: fixed; z-index: 85; inset: 84px 12px 12px auto; width: var(--chat-width); /* top clears the sticky header so its controls stay clickable */ height: auto; max-width: none; max-height: none; margin: 0; padding: 0; display: flex; flex-direction: column; border: 0; border-radius: var(--r-sheet); background: var(--surface-0); color: var(--ink-1); box-shadow: var(--shadow-overlay); font: var(--fs-15)/1.7 var(--font-ui); overflow: hidden; }
.assistant-panel:not(.closing) { animation: drawer-right-in 260ms var(--ease-sheet) both; }
@media (max-width: 1023px) {
  /* Phones: the panel is a sheet, so it enters and leaves vertically like every other sheet. */
  .assistant-panel:not(.closing) { animation-name: sheet-in; }
  .assistant-panel.closing { animation-name: sheet-out; }
}
.assistant-panel.closing { animation: drawer-right-out 210ms cubic-bezier(.55, 0, .8, 1) reverse both; }
@media (max-width: 1023px) {
  /* Must come after the shorthand above: the panel slides down, not sideways. */
  .assistant-panel.closing { animation-name: sheet-out; }
}
/* D3: the panel is non-modal (show(), no ::backdrop); it keeps the drawer's shared look. */
#assistant-title:focus { outline: none; }
.assistant-head { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 12px; padding: 14px 14px 8px 20px; }
.assistant-head > div { display: flex; align-items: center; gap: 9px; }
.assistant-mark { display: flex; color: var(--ink-2); }
.assistant-head h2 { margin: 0; font: 600 var(--fs-17)/1.5 var(--font-ui); text-align: left; }
.assistant-head-actions { gap: 1px !important; }
.chat-new, .chat-close, .context-clear { display: grid; place-items: center; border: 0; border-radius: var(--r-pill); padding: 0; width: 36px; height: 36px; background: var(--surface-2); color: var(--ink-1); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.chat-new:hover, .chat-close:hover, .context-clear:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1)); }
.chat-new:active, .chat-close:active, .context-clear:active { transform: scale(.94); }
.chat-new svg, .chat-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.chat-scroll { flex: 1; min-height: 0; padding: 16px 20px 24px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; }
.chat-empty { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding-bottom: 36px; }
.chat-suggestions { display: flex; flex-direction: column; gap: 8px; }
/* Suggestions read as compact pill buttons: bubble glyph + line, no border, no fill shift. */
.chat-suggestion { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 16px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); font: 400 var(--fs-14)/1 var(--font-ui); text-align: left; cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.chat-suggestion svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; color: var(--ink-2); }
.chat-suggestion span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-suggestion:hover { background: color-mix(in srgb, var(--surface-2) 94%, transparent 0%, black 6%); }
.chat-suggestion:active { transform: scale(.97); }
.chat-message { margin: 0 0 24px; min-width: 0; overflow-wrap: anywhere; }
.chat-message.user { margin-left: 20px; padding: 12px 16px; border-radius: var(--r-popover) var(--r-popover) var(--r-inner) var(--r-popover); background: var(--surface-2); }
.chat-message > p { margin: 0 0 12px; white-space: pre-wrap; }
.chat-message > p:last-child { margin-bottom: 0; }
.chat-message blockquote { margin: 0 0 9px; padding: 0; color: var(--ink-2); font-size: var(--fs-12); line-height: 1.8; white-space: pre-wrap; }
.chat-message.assistant { padding: 0 1px; }
.chat-message.is-error { color: var(--ink-2); }
.chat-retry { border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); padding: 0 14px; min-height: 36px; cursor: pointer; font: 560 var(--fs-13) var(--font-ui); }
.chat-pending { display: flex; gap: 5px; align-items: center; height: 24px; }
.chat-pending i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-2); animation: chat-pulse var(--dur-pulse) var(--ease-out) infinite; }
.chat-pending i:nth-child(2) { animation-delay: .15s; }
.chat-pending i:nth-child(3) { animation-delay: .3s; }
.chat-footer { flex: none; padding: 10px 14px 16px; }
.chat-reference { display: flex; align-items: center; gap: 4px; width: fit-content; max-width: 100%; min-height: 36px; margin: 0 0 8px; padding: 0 4px 0 10px; background: var(--surface-2); border-radius: var(--r-pill); }
.context-return { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--ink-2); text-align: left; cursor: pointer; font: var(--fs-12)/1.5 var(--font-ui); }
.context-return svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.context-quote { display: block; max-width: 218px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-clear { flex: none; width: 26px; height: 26px; font-size: 16px; background: transparent; }
.chat-form { position: relative; padding: 14px 14px 54px; border: 0; border-radius: var(--r-field); background: var(--surface-1); }
.chat-form:focus-within { box-shadow: var(--ring); }
.chat-form textarea { display: block; resize: none; width: 100%; min-height: 46px; max-height: 120px; border: 0; padding: 0; color: var(--ink-1); background: transparent; font: var(--fs-15)/1.7 var(--font-ui); outline: none; }
.chat-form textarea::placeholder { color: var(--ink-3); }
.chat-send { position: absolute; right: 10px; bottom: 9px; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-pill); background: var(--btn-primary-bg); color: var(--btn-primary-ink); cursor: pointer; transition: transform var(--dur-1) var(--ease-out), opacity var(--dur-1) var(--ease-out); }
.chat-send:active:not(:disabled) { transform: scale(.94); }
.chat-send:disabled { background: var(--surface-2); color: var(--ink-3); cursor: default; }
.chat-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 0; }
.chat-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: var(--r-pill); padding: 0 12px; background: var(--surface-2); color: var(--ink-2); cursor: pointer; min-height: 34px; white-space: nowrap; font: 560 var(--fs-12)/1.5 var(--font-ui); transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.chat-actions svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .chat-actions button:hover:not(:disabled) { color: var(--ink-1); background: color-mix(in srgb, var(--surface-2) 84%, var(--ink-1)); } }
.chat-actions button:active:not(:disabled) { transform: scale(.97); }
.chat-actions button:disabled { opacity: .45; cursor: default; }
.assistant-gate { margin: 0 4px 8px; color: var(--ink-2); font: var(--fs-12)/1.7 var(--font-ui); }
.assistant-login { margin-left: 8px; }
.assistant-status { margin: 0 4px 10px; color: var(--ink-2); font: var(--fs-12)/1.7 var(--font-ui); }
.assistant-status:empty { display: none; }
.chat-quiz { margin: 16px 0; }
.chat-quiz h3 { margin: 0 0 9px; font: 560 var(--fs-15)/1.7 var(--font-ui); }
.quiz-choices { display: grid; gap: 6px; }
.quiz-choice { display: flex; gap: 9px; width: 100%; min-height: 40px; border: 0; border-radius: var(--r-field); padding: 9px 12px; text-align: left; background: var(--surface-2); color: var(--ink-1); font: var(--fs-13)/1.7 var(--font-ui); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out); }
.quiz-choice > span:first-child { color: var(--ink-2); }
.quiz-choice[aria-pressed="true"] { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.quiz-choice[aria-pressed="true"] > span:first-child { color: inherit; }
.quiz-choice.is-correct:not([aria-pressed="true"]) { background: color-mix(in srgb, var(--success) 16%, var(--surface-2)); }
.quiz-feedback { margin: 8px 2px 0; color: var(--ink-2); font: var(--fs-13)/1.8 var(--font-ui); }
.selection-explain { position: fixed; z-index: 80; border: 0; border-radius: var(--r-pill); padding: 0 16px; min-height: 36px; background: var(--btn-primary-bg); color: var(--btn-primary-ink); box-shadow: var(--shadow-float); font: 560 var(--fs-13)/1.5 var(--font-ui); cursor: pointer; }
.article-content p.is-ai-context { background: var(--accent-a12); border-radius: var(--r-field); }
::selection { background: var(--accent-a20); color: inherit; }
::highlight(reader-selection) { background: var(--accent-a20); color: inherit; }
.article-content .vocab { -webkit-user-select: text; user-select: text; }
.article-content p[data-paragraph] { scroll-margin-top: 96px; }

[hidden] { display: none !important; }
@keyframes chat-pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@media (min-width: 1024px) {
  .chat-open .article-layout { grid-template-columns: minmax(140px, 1fr) minmax(0, 700px) 340px; column-gap: 24px; }
  .chat-open .desktop-toc { display: none; }
  .chat-open .assistant-panel { grid-column: 3; }
}

/* Rails on: the open panel takes the outline's column, so the outline stands down. */
@media (min-width: 1024px) and (max-width: 1199px) {
  .chat-open .article-layout { grid-template-columns: minmax(140px, 1fr) minmax(0, 700px) 320px; }
  .assistant-panel { --chat-width: 320px; }
}
@media (max-width: 1023px) {
  .chat-open .reader-tools { display: none; }
  .assistant-panel { top: calc(var(--chat-viewport-top, 0px) + 72px + env(safe-area-inset-top)); inset-inline-end: 12px; bottom: auto; width: min(380px, calc(100% - 24px)); height: calc(var(--chat-viewport-height, 100dvh) - 84px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .chat-scroll { padding: 16px 20px 24px; }
  .chat-footer { padding: 12px 16px 16px; }
  .chat-form, .chat-message.user, .chat-reference, .quiz-choice:not([aria-pressed="true"]):not(.is-correct) { background: var(--surface-1); }
  .chat-new:hover, .chat-close:hover, .context-clear:hover { background: var(--surface-2); }
  .chat-actions button { background: var(--surface-2); }
  .chat-form textarea { font-size: 16px; }
  .chat-send { width: 44px; height: 44px; }
  .chat-actions button, .quiz-choice { min-height: 44px; }
  .context-clear { width: 44px; height: 44px; }
  .context-return { min-height: 44px; }
  .chat-suggestion { padding: 0 16px; }
  .assistant-panel.chat-compact .assistant-head { padding-block: 4px; }
  .assistant-panel.chat-compact .chat-scroll { padding-block: 4px; }
  .assistant-panel.chat-compact .chat-footer { padding-block: 8px; }
  .assistant-panel.chat-compact .chat-empty { display: none; }
  .assistant-panel.chat-compact .chat-actions, .assistant-panel.chat-compact .assistant-gate { display: none; }
  .assistant-panel.chat-compact .chat-form { padding: 10px 12px 48px; }
  .assistant-panel.chat-compact textarea { height: 44px; min-height: 44px; }
}
@media (max-width: 1023px) { .account-label { display: none; } .header-end { gap: 0; } .header-end .account-open { margin-left: 0; } .site-header { grid-template-columns: 44px minmax(0,1fr) 88px; } }
@media (max-width: 700px) {
  /* CE-20: header icons keep the 40px round hit area on phones too. */
  .site-frame .site-header { grid-template-columns: 40px minmax(0,1fr) 80px; }
  .site-header .btn-icon, .site-header .library-open, .site-header .header-settings { width: 40px; height: 40px; }
  .account-open { width: 40px; min-width: 40px; padding: 0; }
  .site-name { font-size: clamp(13px, 3.9vw, 23px); gap: 5px; }
  .site-name .mark { width: 1.12em; height: 1.12em; }
  .account-content { padding: 0; }
  .account-content h2 { font-size: var(--fs-20); }
  .article-content p[data-paragraph] { scroll-margin-top: 82px; }
  /* Dialog becomes a bottom sheet on phones. */
  dialog.ov-dialog.account-dialog { inset: auto 0 0; width: auto; max-width: none; max-height: min(90dvh, 720px); margin: 0; padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom)); border-top-left-radius: var(--r-sheet); border-top-right-radius: var(--r-sheet); overflow-y: auto; animation-name: sheet-in; animation-duration: 280ms; }
  dialog.ov-dialog.account-dialog.closing { animation-name: sheet-out; animation-duration: 220ms; }
  .account-dialog > .ov-close { top: 16px; right: 18px; }
  dialog.ov-dialog.account-dialog::backdrop { animation-duration: 260ms; }
}
.auth-remember { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 14px 0 0; font: var(--fs-13)/1.5 var(--font-ui); color: var(--ink-2); cursor: pointer; }
.auth-remember input { flex: none; appearance: none; width: 18px; height: 18px; margin: 0; padding: 0; border: 0; border-radius: var(--r-check); background: var(--surface-2); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out); }
.auth-remember input:checked { background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4.5 9.4l3 3 6-6.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px 18px no-repeat; }
.auth-remember input:focus-visible { outline: none; box-shadow: var(--ring); }
[data-study-block] { scroll-margin-top: 96px; }
[data-study-block].is-ai-context { background: var(--accent-a12); border-radius: var(--r-field); }

@media (max-width: 359px) {
  .mobile-toc-open { padding-inline: 9px; gap: 5px; }
  .mobile-mode-open { padding-inline: 8px; gap: 5px; }
  .reader-tools .assistant-open { padding-inline: 11px; }
}
@media (min-width: 1024px) { .account-open.btn-icon { width: auto; white-space: nowrap; } }

/* qa-v1 QA-05 (Orion): phones — page scroll locked while the AI panel is open; the panel never chains scroll to the page. */
html.chat-lock, html.chat-lock body { overflow: hidden; }
.assistant-panel { overscroll-behavior: contain; }

/* qa-v1 QA-06 (comps ai-sheet): phones — AI is a bottom sheet, never full screen, stable when the address bar moves. */
@media (max-width: 1023px) {
  .assistant-panel { top: auto; bottom: 0; left: 0; right: 0; inset-inline: 0; width: auto; max-width: none; margin: 0;
    height: min(72dvh, calc(100dvh - var(--chat-header-h, 60px) - 12px)); border-radius: 24px 24px 0 0;
    padding-bottom: env(safe-area-inset-bottom); }
}
@media (min-width: 701px) and (max-width: 1023px) { .assistant-panel { --chat-header-h: 72px; } }

/* ===== Lyra QA re-399d31a (22:38), Orion ===== */
/* 2 AI head: 新对话 + close on one row, right-aligned, gap 8px */
.assistant-head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px !important; flex: none; }
.assistant-head .chat-new, .assistant-head .chat-close { position: relative; inset: auto; top: auto; right: auto; transform: none; flex: none; }
.assistant-head .chat-new:active, .assistant-head .chat-close:active { transform: scale(.97); }
/* 3 guest sheet per comps/ai-sheet-guest */
.assistant-panel .grab { display: none; }
@media (max-width: 1023px) {
  .assistant-panel .grab { display: block; flex: none; width: 40px; height: 5px; border-radius: 5px; background: var(--surface-2); margin: 8px auto 2px; }
}
.assistant-panel.is-guest .chat-scroll, .assistant-panel.is-guest .chat-actions { display: none; }
.assistant-panel.is-guest .chat-footer { flex: 1; display: flex; flex-direction: column; }
.assistant-gate:not([hidden]) { display: flex; flex-direction: column; align-items: center; margin: auto 0; padding: 12px 16px 24px; text-align: center; }
.assistant-gate .gate-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 999px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.assistant-gate .gate-ic svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.assistant-gate .assistant-gate-text { margin: 16px 0 8px; font: 650 20px/1.35 var(--font-ui); color: var(--ink-1); }
.assistant-gate .gate-desc { margin: 0 0 24px; font: 400 15px/1.5 var(--font-ui); color: var(--ink-2); white-space: nowrap; }
.assistant-gate .assistant-login { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 24px 0 22px; font-size: 16px; }
.assistant-gate .assistant-login::before { content: ""; width: 18px; height: 18px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8.2' r='3.6'/%3E%3Cpath d='M5 20c1.1-3.5 3.8-5.4 7-5.4s5.9 1.9 7 5.4'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8.2' r='3.6'/%3E%3Cpath d='M5 20c1.1-3.5 3.8-5.4 7-5.4s5.9 1.9 7 5.4'/%3E%3C/svg%3E") center / contain no-repeat; }
.assistant-panel.is-guest .chat-form { height: 52px; padding: 0 56px 0 16px; display: flex; align-items: center; opacity: .55; }
.assistant-panel.is-guest .chat-form textarea { min-height: 0; height: 26px; line-height: 26px; overflow: hidden; }
.assistant-panel.is-guest .chat-send { top: 8px; bottom: auto; right: 8px; }
/* 4 login dialog: 登录 title + close on one row, vertically centred */
.account-dialog .auth-view > h2 { margin: 0 0 20px; padding-right: 52px; font: 650 24px/40px var(--font-ui); }
.account-dialog > .ov-close, .account-dialog > .service-close { position: absolute; top: 26px; right: 22px; bottom: auto; left: auto; transform: none; }
@media (max-width: 700px) { .account-dialog > .ov-close, .account-dialog > .service-close { top: calc(var(--sp-3) + 2px); right: 14px; } }

/* Review v2: persistent scope, stop-in-place, resume hint and keyboard-safe viewport. */
.chat-reference .context-clear { width: auto; min-width: 64px; min-height: 36px; padding: 0 10px; font: 560 12px/1 var(--font-ui); white-space: nowrap; }
.context-return:disabled { cursor: default; }
.chat-send.is-stopping { width: auto; min-width: 80px; display: flex; gap: 6px; padding: 0 12px; font: 560 13px/1 var(--font-ui); }
.chat-send.is-stopping svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.resume-position { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 110; min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--btn-primary-bg); color: var(--btn-primary-ink); box-shadow: var(--shadow-float); font: 560 14px/1 var(--font-ui); cursor: pointer; }
@media (max-width: 1023px) {
  .assistant-panel { bottom: var(--reader-viewport-bottom, 0px); height: min(72dvh, calc(var(--reader-viewport-height, 100dvh) - 72px)); max-height: calc(var(--reader-viewport-height, 100dvh) - 12px); }
  .assistant-panel.chat-compact { height: calc(var(--reader-viewport-height, 100dvh) - 12px); }
  .assistant-panel.chat-compact .chat-footer { padding: 6px 12px 8px; }
  .assistant-panel.chat-compact .chat-form { padding: 8px 12px 48px; }
  .assistant-panel.chat-compact .chat-reference { margin-bottom: 4px; }
  .assistant-panel.chat-compact.is-guest .assistant-gate { display: flex; padding: 4px; }
  .assistant-panel.chat-compact.is-guest .assistant-gate .gate-ic, .assistant-panel.chat-compact.is-guest .gate-desc { display: none; }
  .assistant-panel.chat-compact.is-guest .assistant-gate-text { font-size: 15px; margin: 0 0 4px; }
  .chat-reference .context-clear { min-height: 44px; }
}



/* Shared anchored shell overrides the former account bottom sheet at every width. */
dialog.header-popover.header-popover {
  position: fixed; z-index: 90; inset: auto; width: min(342px, calc(100% - 24px)); max-width: none;
  margin: 0; padding: 18px 20px 20px; border: 0; border-radius: 24px;
  color: var(--ink-1); background: var(--surface-0); box-shadow: 0 14px 44px #0003;
  font-family: var(--font-ui); overflow-y: auto; transform-origin: 100% 0;
  animation: header-popover-in 150ms var(--ease-out) both;
}
dialog.header-popover.header-popover.closing { animation: header-popover-in 120ms var(--ease-out) reverse both; }
@keyframes header-popover-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.header-popover > .ov-close, .header-popover > .service-close { top: 18px; right: 16px; width: 32px; height: 32px; }
.header-popover .ov-close { background: transparent; color: var(--ink-2); }
.header-popover .ov-close:hover { background: var(--surface-2); }
.header-popover .settings-sheet { max-height: none; overflow: visible; padding: 0; }
.header-popover .mobile-toc-head { min-height: 32px; margin: 0 0 12px; padding: 0; display: flex; align-items: center; justify-content: space-between; }
.header-popover .mobile-toc-head h2, .header-popover .account-content h2 { margin: 0; padding: 0; font: 600 16px/1.5 var(--font-ui); }
.header-popover .setting-row { min-height: 58px; padding: 0; gap: 12px; font: 500 14px/1.5 var(--font-ui); }
.header-popover .setting-label { font: inherit; }
.header-popover .settings-rows { padding: 0; }
.header-popover .theme-toggle[hidden] { display: none; }
@media (min-width: 1024px) { .settings-dialog .article-theme-row { display: none; } }
@media (hover: hover) and (pointer: fine) { .settings-dialog .auto-speak-row { display: none; } }
.theme-segments, .header-popover .font-size-control { display: flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); background: var(--surface-1); }
.theme-segments button, .header-popover .font-size-control button { display: inline-flex; align-items: center; justify-content: center; height: 34px; min-height: 34px; min-width: 38px; padding: 0 10px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: 500 13px var(--font-ui); white-space: nowrap; cursor: pointer; }
.theme-seg-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.theme-segments button[aria-pressed="true"], .header-popover .font-size-control button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink-1); box-shadow: 0 2px 5px #0001; }
dialog.header-popover.theme-popover { width: min(216px, calc(100% - 24px)); padding: 8px; border-radius: 20px; }
.theme-menu { display: flex; flex-direction: column; gap: 2px; }
.theme-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--r-12); background: transparent; color: var(--ink-2);
  font: 500 14px/1.4 var(--font-ui); text-align: left; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.theme-menu-item:hover { background: var(--surface-1); color: var(--ink-1); }
.theme-menu-item[aria-pressed="true"] { background: var(--accent-a12); color: var(--ink-1); font-weight: 560; }
.theme-menu-icon { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-menu-check { flex: none; width: 16px; height: 16px; margin-left: auto; fill: none; stroke: var(--accent); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.theme-menu-item[aria-pressed="true"] .theme-menu-check { opacity: 1; }
.account-heading { display: flex; align-items: center; gap: 8px; min-height: 32px; margin-bottom: 12px; padding-right: 36px; }
.account-heading h2 { flex: 1; white-space: nowrap; }
.account-heading .sync-status { color: var(--ink-2); font: 500 11px/1.5 var(--font-ui); }
.account-heading .sync-status.is-synced { color: var(--success); }
.account-identity { margin: 0; padding: 3px 0 23px; font: 500 13px/1.9 var(--font-ui); overflow-wrap: anywhere; }
.account-identity .account-email { display: inline; margin: 0; color: var(--ink-1); font: inherit; }
.account-identity .account-permission { display: inline-block; vertical-align: middle; margin: 0 0 0 6px; padding: 1px 7px; border-radius: var(--r-pill); color: var(--accent); background: var(--accent-a12); font: 500 10px/1.8 var(--font-ui); }
.account-identity .account-permission[hidden] { display: none; }
.account-actions { display: flex; gap: 10px; }
.account-actions .account-fav-link, .account-actions .account-logout { display: flex; align-items: center; justify-content: center; flex: 1; gap: 8px; min-width: 0; min-height: 44px; height: auto; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); white-space: nowrap; font: 500 13px var(--font-ui); }
.account-actions .account-logout { background: var(--danger-a10); color: var(--danger); }
.account-actions svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.account-actions button:hover, .account-actions a:hover { filter: brightness(1.1); }
.header-popover .auth-view > h2 { min-height: 32px; margin: 0 0 18px; padding-right: 36px; }
.header-popover .auth-view .account-nav { display: inline-flex; margin: 0; }
@media (prefers-reduced-motion: reduce) { dialog.header-popover.header-popover, dialog.header-popover.header-popover.closing { animation: none !important; } }

/* Hide scrollbars inside account/header popovers and AI assistant containers. */
.account-dialog,
dialog.header-popover.header-popover,
.chat-scroll,
.chat-form textarea {
  scrollbar-width: none;
}
.account-dialog::-webkit-scrollbar,
dialog.header-popover.header-popover::-webkit-scrollbar,
.chat-scroll::-webkit-scrollbar,
.chat-form textarea::-webkit-scrollbar {
  display: none;
}

/* P1-3: Calm dark-mode floating AI assistant trigger so it never glares over reading prose. */
html:not([data-theme="light"]) .assistant-open:not(.dock-ai) {
  background: var(--surface-2);
  color: var(--ink-1);
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, .07);
}
html:not([data-theme="light"]) .assistant-open:not(.dock-ai) svg {
  color: var(--accent);
}
html:not([data-theme="light"]) .assistant-open:not(.dock-ai):hover {
  background: color-mix(in srgb, var(--surface-2) 86%, var(--ink-1) 14%);
}

.zyulux-login {display:grid;justify-items:start;gap:10px;margin-top:16px}
.zyulux-login-brand {display:flex;align-items:baseline;gap:8px;margin:0 0 4px;color:var(--ink-2);font:400 var(--fs-12)/1.5 var(--font-ui)}
.zyulux-login-brand strong {color:var(--ink-1);font-weight:650}
.zyulux-login .auth-remember {min-height:36px;margin:0}
.zyulux-login .service-primary {justify-content:space-between}
.zyulux-login .auth-status {margin:0}
