/* Shared portal controls: one bottom-right anchor for every module and task shell. */
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) {
  --portal-control-line: rgba(255, 255, 255, .18);
  --portal-control-text: #fff;
  position: fixed;
  right: max(40px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  box-sizing: border-box;
  border: 1px solid var(--portal-control-line);
  border-radius: 999px;
  background: rgba(20, 14, 36, .48);
  box-shadow: 0 12px 34px rgba(3, 7, 18, .24);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
}
html[data-theme="light"] body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) {
  --portal-control-line: rgba(20, 20, 40, .14);
  --portal-control-text: #1f2440;
  background: rgba(255, 255, 255, .46);
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) :is(.home-link, .task-home-link, .portal-home, #theme-toggle) {
  position: relative;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  flex: 0 0 48px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--portal-control-line);
  border-radius: 50%;
  background: rgba(20, 14, 36, .66);
  color: var(--portal-control-text);
  text-decoration: none;
  font: 400 22px/1 "Segoe UI Symbol", "Microsoft YaHei", sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
}
html[data-theme="light"] body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) :is(.home-link, .task-home-link, .portal-home, #theme-toggle) {
  background: rgba(255, 255, 255, .8);
  border-color: var(--portal-control-line);
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) :is(.home-link, .task-home-link, .portal-home) {
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), box-shadow .25s, background .3s, border-color .25s;
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) :is(.home-link, .task-home-link, .portal-home):hover {
  transform: translateY(-3px) scale(1.06);
  border-color: rgba(109, 139, 255, .68);
  box-shadow: 0 0 0 2px rgba(109, 139, 255, .34), 0 8px 22px rgba(3, 7, 18, .2);
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) #theme-toggle {
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), box-shadow .25s, background .3s, border-color .25s;
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) #theme-toggle:hover {
  transform: translateY(-3px) scale(1.06);
  border-color: rgba(109, 139, 255, .68);
  box-shadow: 0 0 0 2px rgba(109, 139, 255, .34), 0 8px 22px rgba(3, 7, 18, .2);
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) #theme-toggle::after {
  position: absolute;
  inset: 50%;
  z-index: -1;
  content: "";
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 220, 120, .52), rgba(192, 132, 252, .18) 52%, transparent 72%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.2);
}
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) #theme-toggle.theme-switching { animation: sharedThemeControlPulse .9s cubic-bezier(.22, 1, .36, 1); }
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) #theme-toggle.theme-switching::after { animation: sharedThemeRipple .58s ease-out; }
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) :is(.home-link, .task-home-link, .portal-home, #theme-toggle):focus-visible { outline: 2px solid rgba(109, 139, 255, .82); outline-offset: 3px; }
@keyframes sharedThemeControlPulse { 0% { transform: scale(1); } 42% { transform: scale(1.28) translateY(-3px); } 100% { transform: scale(1); } }
@keyframes sharedThemeRipple { 0% { opacity: .72; transform: translate(-50%, -50%) scale(.18); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(2.3); } }
@media (max-width: 720px) { :is(#portal-controls, #task-portal-controls) { right: max(40px, env(safe-area-inset-right, 0px)); bottom: max(24px, env(safe-area-inset-bottom, 0px)); } }
@media (prefers-reduced-motion: reduce) { :is(#portal-controls, #task-portal-controls) * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
/* Override page-local legacy offsets so every shared dock uses one viewport anchor. */
html body :is(#portal-controls, #task-portal-controls, #topbar:has(> .home-link)) {
  top: auto !important;
  left: auto !important;
  right: calc(max(40px, env(safe-area-inset-right, 0px)) - (100vw - 100%)) !important;
  bottom: max(24px, env(safe-area-inset-bottom, 0px)) !important;
}
/* 认证文档的「找回密码」弹窗（auth_portal.html #authRecoveryDialog）：原生 <dialog>
   模态，浅/深主题各自一套底色、文字与输入框配色；只作用于该弹窗，不影响其它页面。 */
.auth-recovery-dialog {
  width: min(400px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-sizing: border-box;
  padding: 16px 18px 18px; margin: auto; overflow: auto;
  color: #ece8f6; background: #1c1729; border: 1px solid rgba(120, 120, 160, .3);
  border-radius: 14px; box-shadow: 0 28px 70px rgba(0, 0, 0, .42);
}
html[data-theme="light"] .auth-recovery-dialog {
  color: #3a2c52; background: #ffffff; border-color: rgba(66, 52, 112, .2);
  box-shadow: 0 28px 70px rgba(30, 25, 60, .25);
}
.auth-recovery-dialog::backdrop { background: rgba(8, 8, 24, .55); }
html[data-theme="light"] .auth-recovery-dialog::backdrop { background: rgba(28, 32, 48, .3); }
.auth-recovery-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-recovery-title { margin: 0; font-size: 16px; font-weight: 600; }
.auth-recovery-dialog .auth-recovery-close {
  flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; padding: 0;
  font: inherit; font-size: 18px; line-height: 1; cursor: pointer;
  color: inherit; background: transparent; border: 1px solid rgba(120, 120, 160, .35); border-radius: 8px;
}
html[data-theme="light"] .auth-recovery-dialog .auth-recovery-close { border-color: rgba(66, 52, 112, .22); }
.auth-recovery-dialog .auth-recovery-close:hover { background: rgba(128, 128, 160, .18); }
.auth-recovery-dialog .auth-recovery-close:focus-visible { outline: 2px solid #a679dc; outline-offset: 2px; }
html[data-theme="light"] .auth-recovery-dialog .auth-recovery-close:focus-visible { outline-color: #7434d6; }
.auth-recovery-body #forgotForm { margin-top: 12px; }
.auth-recovery-foot { display: flex; justify-content: flex-end; margin-top: 12px; }
.auth-recovery-dialog .auth-recovery-back { padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.auth-recovery-dialog .auth-recovery-back:focus-visible { outline: 2px solid #a679dc; outline-offset: 2px; }
html[data-theme="light"] .auth-recovery-dialog .auth-recovery-back:focus-visible { outline-color: #7434d6; }
/* 弹窗打开期间 #forgotForm 由弹窗负责显示：auth-root 的 showAuthTab 会在登录 tab 下
   把它设为 hidden（弹窗仍应显示邮箱申请）。弹窗内单个字段/按钮的 [hidden] 照常生效；
   关闭后 #forgotForm 回到 auth-root 管理的真实可见性，不长期改写它。 */
.auth-recovery-dialog[open] #forgotForm[hidden] { display: flex !important; }
.auth-recovery-dialog [hidden] { display: none !important; }
.auth-recovery-dialog .auth-form input {
  color: inherit; background: rgba(128, 128, 160, .12);
  border-color: rgba(120, 120, 160, .38);
}
html[data-theme="light"] .auth-recovery-dialog .auth-form input {
  color: #2b2140; background: #f5f2fb; border-color: rgba(66, 52, 112, .22);
}
.auth-recovery-dialog .auth-form label { opacity: .9; }
html[data-theme="light"] .auth-recovery-dialog .auth-form label { opacity: 1; color: #4a3d63; }
.auth-recovery-dialog .auth-secondary { color: inherit; border-color: rgba(120, 120, 160, .36); }
html[data-theme="light"] .auth-recovery-dialog .auth-secondary { border-color: rgba(66, 52, 112, .22); }
html[data-theme="light"] .auth-recovery-dialog .auth-link { opacity: 1; color: #7434d6; }
html[data-theme="light"] .auth-recovery-dialog .auth-form-hint { opacity: 1; color: #4d4166; }
html[data-theme="light"] .auth-recovery-dialog .auth-error { color: #b3261e; }
html[data-theme="light"] .auth-recovery-dialog .auth-error.success { color: #1b6e46; }
