/* 全站 UI 标尺。页面特有图谱/封面沿用原样，交互与内容组件在此统一。
   维护约定：新增组件先引用标尺；避免在页面末尾重复覆盖同一密度。 */
:root {
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-edge: 20px;
  --ui-touch: 44px;
  --ui-text-small: 12px;
  --ui-text-control: 14px;
  --ui-text-body: 16px;
  --ui-leading: 1.8;
  --ui-radius-field: 8px;
  --ui-radius-card: 12px;
  --ui-radius-overlay: 16px;
  --ui-shadow: 0 8px 28px rgb(24 24 26 / .12);
  --ui-layer-nav: 80;
  --ui-layer-dialog: 200;
}
:where(body) { touch-action: manipulation; }
:where(button, input, select, textarea) { font-family: var(--sans, system-ui); letter-spacing: 0; }
:where(button, a[role="button"]) { min-height: var(--ui-touch); touch-action: manipulation; }
:where(button, a, summary):focus-visible { outline: 2px solid var(--seal, var(--rust, #9a463f)); outline-offset: 3px; }
:where(button):disabled { cursor: default; }
:where(main, article, section) { min-width: 0; }
:where(input, textarea, select) { min-width: 0; }
:where(textarea) { line-height: 1.6; }
:where(h1, h2, h3, h4) { overflow-wrap: break-word; }
:where(.knowledge-footer, .ac-account-footer) { overflow-wrap: anywhere; }
:where(.knowledge-footer, .ac-account-footer) a { text-underline-offset: 3px; }

/* 统一浮层容器，内容滚动与关闭按钮分别占位。 */
.wms-auth-sheet, .wm-dialog-card, .ac-events-editor {
  border-radius: var(--ui-radius-overlay);
  box-shadow: var(--ui-shadow);
  overscroll-behavior: contain;
}
.wms-auth-close { width: var(--ui-touch); height: var(--ui-touch); }
.wms-auth-tabs button, .wm-dialog-actions button, .ac-events-actions button,
.ac-book-more, .ac-today-attention button { min-height: var(--ui-touch); }
.wms-auth-form input, .wm-dialog-input, .ac-events-editor input,
.ac-events-editor select, .ac-events-editor textarea { border-radius: var(--ui-radius-field); }
.wm-dialog-card { padding: var(--ui-space-6); }
.wm-dialog-actions { gap: var(--ui-space-2); margin-top: var(--ui-space-4); }
.wm-dialog-actions button { padding: 8px 16px; font-size: var(--ui-text-control); border-radius: var(--ui-radius-field); }

/* 问句是内容气泡，不以 padding 扩大点击区域；段落不能再叠加浏览器默认 margin。 */
#ac-ask-panel .ac-ask-bubble.is-question {
  padding: var(--ui-space-2) var(--ui-space-3);
  background: rgba(125,125,125,.085);
  border-radius: 12px 12px 4px 12px;
  font: 400 var(--ui-text-body)/1.6 var(--sans);
  letter-spacing: 0;
  max-width: min(88%, 620px);
}
#ac-ask-panel .ac-ask-bubble.is-question p { margin: 0; line-height: inherit; text-wrap: pretty; }
#ac-ask-panel .ac-ask-bubble.is-answer { font-size: var(--ui-text-body); line-height: var(--ui-leading); letter-spacing: .01em; }
#ac-ask-panel .ac-ask-bubble.is-answer p { margin: 0 0 var(--ui-space-3); }
#ac-ask-panel .ac-ask-bubble.is-answer > :last-child { margin-bottom: 0; }
#ac-ask-panel .ac-ask-round { padding: 16px 0 20px; gap: var(--ui-space-3); }
#ac-ask-panel .ac-ask-bubble.is-answer h3 { margin: 24px 0 8px; font-size: 20px; line-height: 1.5; }
#ac-ask-panel .ac-ask-bubble.is-answer h4 { margin: 20px 0 8px; font-size: 17px; line-height: 1.5; }
#ac-ask-panel .ac-ask-composer-panel { background: var(--ivory); border: 1px solid var(--border); box-shadow: 0 3px 16px rgb(24 24 26 / .035); padding: 10px 12px 6px; border-radius: var(--ui-radius-overlay); }
#ac-ask-panel #ac-ask-input { min-height: 26px; line-height: 1.6; }
#ac-ask-panel .ac-ask-composer-toolbar { padding-top: 4px; }
#ac-ask-panel .ac-ask-history-toggle { min-height: var(--ui-touch); }
#ac-ask-panel .ac-ask-thread-open b { letter-spacing: 0; }
#ac-ask-panel .ask-answer-actions { margin-top: 4px; }
#ac-ask-panel .ask-answer-actions button { font-size: var(--ui-text-control); }
#ac-ask-panel .ask-answer-actions .ask-answer-action-icon { border-radius: var(--ui-radius-field); }
#ac-ask-panel .ask-answer-actions button:focus-visible { outline: 2px solid var(--seal); outline-offset: -2px; }

@media (max-width: 760px) {
  /* 移动端表单：16px 输入字，统一标签与字段距离，不触碰单选/复选框。 */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]),
  select, textarea { font-size: var(--ui-text-body); }
  .field-grid, .ac-events-fields { gap: var(--ui-space-3); }
  .field-grid label, .ac-events-fields label { gap: 6px; font-size: var(--ui-text-control); }
  .field-grid :is(input, select, textarea) { min-height: 44px; border-radius: var(--ui-radius-field); }
  .form-card, .result-card { padding: var(--ui-space-4); }
  .wms-auth-sheet { padding: 24px 20px max(20px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
  .wms-auth-sheet h2 { font-size: 28px; padding-right: 32px; }
  .wms-auth-kicker { margin-bottom: 12px; }
  .wms-auth-copy { margin: 12px 0 20px; font-size: 14px; line-height: 1.7; }
  .wms-auth-tabs { gap: 20px; margin-bottom: 16px; }
  .wms-auth-form { gap: 12px; }
  .wms-auth-form label { gap: 6px; }
  .wms-auth-fineprint { margin-top: 16px; }
  .wm-dialog-card, #ac-profile-overlay .ac-profile-card, .ac-events-editor { padding: 20px; }
  .wm-dialog-input, .ac-events-editor :is(input, select, textarea) { font-size: 16px; }

  /* 工作台：紧凑分区，封面保持识别度，正文仍可舒适阅读。 */
  body.ac-dashboard .ac-pane { padding-top: 24px; }
  body.ac-dashboard .ac-pane-title { padding-bottom: 16px; gap: 12px; }
  body.ac-dashboard .ac-pane-title h2 { font-size: 28px; line-height: 1.3; }
  body.ac-dashboard .ac-pane-intro { margin: 12px 0 24px; font-size: 14px; }
  #ac-reading-panel .ac-profile-bar { margin-bottom: 20px; }
  .ac-profile-book-guide { padding: 16px; margin: 20px 0 24px; }
  body.ac-dashboard #ac-saved-list .ac-book { gap: 16px; }
  body.ac-dashboard #ac-saved-list .ac-book-meta { row-gap: 6px; }
  .ac-book-current-actions { margin-top: 4px; gap: 8px 16px; }
  .ac-book-current-actions a { display: inline-flex; align-items: center; min-height: 44px; }
  .ac-events-group { margin: 24px 0; }
  .ac-events-group li, .ac-events-fact { padding: 12px 0; gap: 12px; }
  .ac-events-group p, .ac-events-fact p { line-height: 1.7; }
  .ac-daily-basis { padding: 12px; }
  #ac-ask-panel .ac-ask-hero { padding-top: 24px; padding-bottom: 16px; }
  #ac-ask-panel .ac-ask-hero .ac-ask-entry { padding-top: 16px; }
  #ac-ask-panel .ac-ask-thread-row.is-featured .ac-ask-thread-open { padding: 12px 16px; }
  #ac-ask-panel .ac-ask-thread-row.is-daily { margin-bottom: 12px; }
  #ac-ask-panel .ac-ask-thread-group { margin-top: 16px; margin-bottom: 0; }
  #ac-ask-panel .is-daily .ac-ask-thread-open { min-height: 56px; padding-block: 8px; }
  #ac-ask-panel .ac-ask-chat-head > h3 { gap: 8px; }
  #ac-ask-panel .ac-ask-chat-context > span { font-size: 12px; }
  body.ac-dashboard > .wm-mobile-tabs { bottom: max(8px, env(safe-area-inset-bottom)); }
  body.ac-dashboard.wm-mobile-tabs-ready { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  body.ac-dashboard .ac-account-footer { padding: 24px var(--ui-edge) 20px; }
  body.ac-ask-chat-view.wm-mobile-tabs-ready { padding-bottom: 0; }

  /* 阅读模板及公开说明：统一手机边距，按章节分隔而非多层空白。 */
  .knowledge-page { width: 100%; border-inline: 0; }
  .knowledge-hero, .knowledge-hub-hero, .legal-hero { padding: 32px var(--ui-edge); }
  .knowledge-hero h1, .knowledge-hub-hero h1, .legal-hero h1 { margin: 12px 0 16px; font-size: 32px; line-height: 1.3; }
  .knowledge-summary { font-size: 16px; line-height: 1.8; }
  .knowledge-hero-conversion { margin-top: 24px; padding: 16px; gap: 12px; }
  .knowledge-keypoints { margin-top: 24px; }
  .legal-layout { padding-inline: var(--ui-edge); }
  .legal-section { padding-block: 24px; }
  .legal-plain-summary { margin-block: 24px; }
  .legal-license-card, .legal-folio { padding: 16px; }
  .pricing-hero { gap: 20px; padding: 24px var(--ui-edge); }
  .pricing-checkout { padding: 16px; box-shadow: none; border-radius: 12px; background: var(--ivory); }
  .pricing-checkout .pricing-table td { padding: 0; }
  .pricing-checkout .pricing-table tr { padding: 12px 0; gap: 4px 12px; }
  .pricing-checkout .pay-btn[data-pack] { min-height: 44px; border-radius: 8px; }
  .pricing-checkout-trust { font-size: 12px; }
  .pricing-checkout .pay-method span { font-size: 12px; line-height: 1.6; }
  .knowledge-footer { padding: 24px var(--ui-edge); }
  .knowledge-footer a { display: inline-block; padding-block: 8px; }
  .pb-shell { width: auto; margin-inline: var(--ui-edge); }
  .pb-cover { padding-block: 32px; }
  .pb-content .pb-card { padding: 16px; border-radius: 12px; }
  .pb-prose { font-size: 16px; line-height: 1.8; }
  .pb-section { padding-bottom: 32px; }
  .pb-section-head { margin-bottom: 12px; }
  .pb-ask-form textarea { font-size: 16px; }
  .pb-question { padding: 12px; min-height: 44px; }
  .home-volume-shelf, .home-method, .home-continuity { padding-top: 32px; padding-bottom: 40px; }
}
@media (max-width: 374px) { :root { --ui-edge: 16px; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* 独立占星模板沿用本身色板，只统一操作与间距。 */
.wm-paywall-open { overflow: hidden; }
.wm-paywall-card { max-height: calc(100dvh - 24px); border-radius: 16px; padding: 20px; overscroll-behavior: contain; }
.wm-paywall-actions button, .wm-paywall-pay { min-height: 44px; border-radius: 8px; }
@media (max-width: 760px) {
  .astro-form, .vedic-form { padding: 20px 16px 24px; }
  .astro-form .field-row, .vedic-form .field-row { gap: 12px; margin-bottom: 16px; }
  .astro-form input:not([type="checkbox"]):not([type="radio"]), .astro-form select, .astro-form textarea,
  .vedic-form input:not([type="checkbox"]):not([type="radio"]), .vedic-form select, .vedic-form textarea { font-size: 16px; min-height: 44px; padding: 10px 12px; border-radius: 8px; }
  .astro-form label > span, .vedic-form label > span { margin-bottom: 6px; font-size: 14px; }
  .astro-topbar, .vedic-topbar { min-height: 64px; }
  .vedic-hero { padding: 40px 20px 32px; }
  .method-open, .topbar-actions > a { min-height: 44px; font-size: 13px; display: inline-flex; align-items: center; }
  .pb-round { padding-block: 16px; gap: 12px; }
  .pb-round-question { font-size: 16px; line-height: 1.6; }
  .wm-paywall-card { border-radius: 16px 16px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* 书架与续问共用同一个向上优先定位器。 */
.ac-book-more { width: 44px; height: 44px; border-radius: 8px; }
.ac-book-menu { position: fixed; inset: auto; margin: 0; max-height: calc(100dvh - 16px); overflow-y: auto; border-radius: 12px; box-shadow: var(--ui-shadow); }
.ac-book-menu a, .ac-book-menu button { display: flex; align-items: center; min-height: 44px; padding: 8px 12px; font-size: 14px; }

.submit-fine .save-opt:not(:has(input)) { display: block; line-height: 1.7; }
.submit-fine .save-opt a { white-space: nowrap; }
.pb-page { min-height: 100dvh; }
