/* ==========================================================================
   公共页（登录、注册、邮箱绑定、找回密码、用户中心）
   依赖 ui.css 令牌，默认浅色，body.theme-dark 覆盖为深色
   ========================================================================== */

body{min-height:100vh;background:
  radial-gradient(900px 520px at 88% -8%,rgba(20,184,166,.16),transparent 60%),
  radial-gradient(760px 460px at -6% 6%,rgba(14,124,116,.12),transparent 58%),
  var(--bg)}

main{width:min(560px,calc(100% - 32px));margin:6vh auto 48px}
body.wide main{width:min(1080px,calc(100% - 32px))}

.site-header{position:sticky;top:0;z-index:50;backdrop-filter:saturate(180%) blur(14px);
  background:rgba(255,255,255,.8);border-bottom:1px solid var(--line)}
.site-header .inner{width:min(1080px,calc(100% - 32px));margin:0 auto;display:flex;align-items:center;
  justify-content:space-between;gap:16px;min-height:64px;flex-wrap:wrap}
.site-header a{color:var(--ink-2);font-size:14px;font-weight:600}
.site-header a:hover{color:var(--brand)}

.card,.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--radius-lg);
  padding:26px;box-shadow:var(--shadow-1)}
.card{animation:fade-up var(--normal) var(--ease) both}
.card h1{font-size:26px}
.field{display:flex;flex-direction:column;gap:7px;margin:16px 0}
.field label{font-weight:600}
.field input,.field select,.field textarea{width:100%}
.full{width:100%}
.btn{width:100%}
.actions{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:18px}
.links{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:20px;
  font-size:13px}
.hint{margin:0;font-size:12px;color:var(--ink-3)}
.messages{display:flex;flex-direction:column;gap:8px;margin:14px 0}
.message{padding:10px 13px;border-radius:var(--radius-sm);font-size:13px;background:var(--panel-2);
  border:1px solid var(--line);color:var(--ink-2)}
.message.success{background:var(--ok-soft);border-color:rgba(15,122,79,.24);color:var(--ok)}
.message.error{background:var(--danger-soft);border-color:rgba(180,35,24,.24);color:var(--danger)}

.password-row{position:relative;display:flex;align-items:center}
.password-row input{padding-right:52px}
.password-toggle{position:absolute;right:6px;width:36px;height:36px;min-height:0;padding:6px;
  background:transparent;border:0;box-shadow:none;color:var(--ink-3);display:grid;place-items:center}
.password-toggle:hover{background:var(--brand-soft);color:var(--brand);box-shadow:none;filter:none}
.password-toggle svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}

.code-row{display:flex;align-items:center;gap:10px}
.code-row input{flex:1 1 auto;min-width:0}
.code-send{flex:0 0 auto;width:auto;min-width:104px;white-space:nowrap;min-height:44px;padding:0 14px;
  font-size:13px}
.countdown{font-size:12px;color:var(--ink-3)}
.actions .btn{width:auto}

/* 悬浮主题切换按钮（无顶部导航的页面使用） */
.theme-toggle.floating{position:fixed;top:16px;right:16px;z-index:60;box-shadow:var(--shadow-1)}

/* 浏览器自动填充在深色主题下容易变成黑底黑字，用令牌强制对齐 */
.field input:-webkit-autofill,.field input:-webkit-autofill:hover,.field input:-webkit-autofill:focus{
  -webkit-text-fill-color:var(--ink);box-shadow:0 0 0 1000px var(--field-bg) inset;caret-color:var(--ink);
  transition:background-color 9999s ease-out 0s}

/* 密码规则即时校验 */
.password-rule-error{margin:0;font-size:12px;color:var(--danger);line-height:1.45}
.password-row input[aria-invalid="true"]{border-color:var(--danger);box-shadow:0 0 0 3px var(--danger-soft)}

/* 用户中心 */
.shell{width:min(1120px,calc(100% - 32px));margin:24px auto 50px;display:grid;
  grid-template-columns:minmax(0,1fr);gap:20px}
.uc-top{display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;margin-bottom:22px}
.uc-brand{font-weight:800;color:var(--ink);text-decoration:none}
.uc-nav{display:flex;gap:14px;flex-wrap:wrap;align-items:center}
.uc-nav a{color:var(--brand);text-decoration:none;font-size:14px}
.uc-nav a:hover{text-decoration:underline}
.profile-head{display:flex;align-items:center;gap:18px;flex-wrap:wrap}
.avatar-wrap{position:relative;flex:0 0 auto}
.avatar{width:76px;height:76px;border-radius:24px;overflow:hidden;display:grid;place-items:center;
  background:var(--gradient-brand);color:#fff;font-size:24px;font-weight:800;box-shadow:var(--shadow-2)}
.avatar img{width:100%;height:100%;object-fit:cover}
.avatar-edit{position:absolute;right:-6px;bottom:-6px;width:28px;height:28px;min-height:0;padding:0;
  border-radius:50%;font-size:13px;display:grid;place-items:center}
.profile-title{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.profile-meta{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-top:16px}
.profile-meta-row{display:flex;flex-direction:column;gap:2px;padding:12px 14px;border-radius:var(--radius-sm);
  background:var(--panel-2);border:1px solid var(--line)}
.profile-meta-label{font-size:12px;color:var(--ink-3);letter-spacing:.04em}
.profile-meta-value{font-weight:600;overflow-wrap:anywhere}
.settings-body{display:flex;flex-direction:column;gap:14px}
.save-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.device-note,.search-note{color:var(--ink-3);font-size:13px}
.device-pagination{display:flex;align-items:center;justify-content:center;gap:12px}
.profile-settings{border:1px solid var(--line);border-radius:var(--radius-md);padding:16px;background:var(--panel-2)}
.profile-settings summary{cursor:pointer;font-weight:700}
.profile-settings summary::-webkit-details-marker{display:none}
.profile-settings summary::after{content:"+";float:right;width:24px;height:24px;display:grid;place-items:center;
  border:1px solid var(--line);border-radius:50%;color:var(--brand);font-size:19px;font-weight:400}
.profile-settings[open] summary::after{content:"−"}
.profile-settings .settings-body{margin-top:14px}
.table-wrap{overflow-x:auto;border-radius:var(--radius-md)}
.grid{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}

/* 账号信息（邮箱 / QQ 绑定） */
.account-info{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 20px;max-width:900px;margin-top:18px}
.qq-display{display:flex;align-items:flex-start;gap:10px;margin:0;padding:12px 14px;
  border:1px solid var(--line);border-radius:12px;background:var(--panel-2)}
.qq-label{min-width:58px;font-weight:700}
.qq-label-with-help{display:inline-flex;align-items:center;gap:5px}
.qq-help{position:relative;display:inline-grid;place-items:center;width:17px;height:17px;padding:0;
  border:1px solid var(--line);border-radius:50%;background:transparent;color:var(--ink-3);
  font:700 12px/1 Arial,sans-serif;cursor:help}
.qq-help:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
.qq-help-tooltip{position:absolute;z-index:10;top:calc(100% + 8px);left:50%;width:230px;padding:8px 10px;
  border-radius:8px;background:var(--ink);color:var(--bg);font:400 12px/1.5 system-ui,sans-serif;
  text-align:left;box-shadow:var(--shadow-2);opacity:0;visibility:hidden;pointer-events:none;
  transform:translate(-50%,-3px);transition:opacity .16s ease,transform .16s ease,visibility .16s}
.qq-help:hover .qq-help-tooltip,.qq-help:focus .qq-help-tooltip{opacity:1;visibility:visible;transform:translate(-50%,0)}
.qq-unbind-form{margin:0 0 0 auto}
.qq-unbind-button{min-height:30px;padding:5px 10px;border:1px solid var(--danger);border-radius:8px;
  background:transparent;color:var(--danger);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap}
.qq-unbind-button:hover{background:var(--danger);color:#fff;filter:none;box-shadow:none}
.binding-info{font:inherit;overflow-wrap:anywhere}
.binding-info.unbound{color:var(--ink-3)}

/* 用户名行内编辑 */
.username-value{display:flex;align-items:center;gap:5px}
.username-editor{position:relative}
.username-editor summary{display:grid;place-items:center;width:24px;height:24px;border:0;border-radius:6px;
  color:var(--brand);background:transparent;cursor:pointer;list-style:none}
.username-editor summary::-webkit-details-marker{display:none}
.username-editor summary:hover{background:var(--brand-soft)}
.username-editor summary svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;
  stroke-linecap:round;stroke-linejoin:round}
.username-editor .editor-popover{position:absolute;z-index:5;top:calc(100% + 7px);left:-6px;
  width:min(310px,calc(100vw - 58px));padding:13px;border:1px solid var(--line);border-radius:12px;
  background:var(--panel);box-shadow:var(--shadow-2)}
.username-editor input{width:100%;min-height:38px;padding:8px 10px;border:1px solid var(--line);
  border-radius:8px;background:var(--field-bg);color:inherit;font:inherit}
.username-editor .save-row{margin-top:9px}
.username-editor .btn{padding:7px 11px;font-size:13px;min-height:0;width:auto}

/* 设备查询与列表 */
.device-search{display:flex;gap:10px;align-items:center;margin:0 0 18px;max-width:1040px}
.device-search input{flex:1;min-width:0}
.device-search .btn{white-space:nowrap;width:auto}
.search-result{margin:0 0 22px}
.search-result h3{margin:0 0 10px;font-size:16px}
.devices{min-width:520px}
.devices th,.devices td{white-space:nowrap}
.sn-cell{cursor:pointer}
.sn-code{display:inline-block;max-width:20ch;overflow:hidden;text-overflow:ellipsis;
  white-space:nowrap;vertical-align:bottom}
.sn-cell:hover .sn-code,.sn-cell.is-copied .sn-code{color:var(--brand)}
.device-pagination{margin-top:18px}
.device-pagination .btn{width:auto;min-height:36px;padding:0 14px;font-size:13px}

@media (max-width:780px){
  .account-info{grid-template-columns:1fr}
}

/* 深色主题
   body.theme-dark 令牌块为 templates1 兼容保留；
   templates2 走 html[data-theme=dark]，令牌统一在 ui.css。 */
body.theme-dark{
  --bg:#0B1220;--bg-deep:#0E1828;--panel:#122238;--panel-2:#16283F;--line:#2B4260;--line-strong:#3A5474;
  --field-bg:#1B3050;--field-bg-hover:#21395C;color-scheme:dark;
  --ink:#E9F1F5;--ink-2:#9FB3C8;--ink-3:#7A8FA6;--brand:#5EEAD4;--brand-strong:#99F6E4;--brand-soft:#123B44;
  --accent:#2DD4BF;--gradient-brand:linear-gradient(135deg,#14B8A6,#5EEAD4 60%,#A7F3D0);
  --ok:#4ADE80;--ok-soft:#123528;--danger:#FCA5A5;--danger-soft:#3B1A1A;
  background:radial-gradient(1000px 560px at 86% -8%,rgba(45,212,191,.16),transparent 60%),var(--bg)}
html[data-theme="dark"] body{
  background:radial-gradient(1000px 560px at 86% -8%,rgba(45,212,191,.16),transparent 60%),var(--bg)}
body.theme-dark .site-header,
html[data-theme="dark"] .site-header{background:rgba(11,18,32,.74);border-bottom-color:var(--line)}
body.theme-dark .btn,body.theme-dark button,
html[data-theme="dark"] .btn,html[data-theme="dark"] button{color:#06251F}
/* 非渐变的小按钮：恢复自身文字色，避免被上面的深色规则糊成不可见 */
body.theme-dark .theme-toggle,html[data-theme="dark"] .theme-toggle{color:var(--ink-2)}
body.theme-dark .lang-btn,html[data-theme="dark"] .lang-btn{color:var(--ink-3)}
body.theme-dark .group-pill,html[data-theme="dark"] .group-pill,
body.theme-dark .qr-modal-close,html[data-theme="dark"] .qr-modal-close{color:var(--ink-2)}
body.theme-dark .qq-unbind-button,html[data-theme="dark"] .qq-unbind-button{color:var(--danger)}
body.theme-dark .qq-unbind-button:hover,html[data-theme="dark"] .qq-unbind-button:hover{color:#fff}
body.theme-dark .card,body.theme-dark .panel,
html[data-theme="dark"] .card,html[data-theme="dark"] .panel{box-shadow:var(--shadow-2)}

@media (max-width:640px){
  main{margin-top:24px}
  .card,.panel{padding:20px}
  .actions,.links{justify-content:flex-start}
}
