/* ============================================================
   GcmodAi · 主题层 v1  (theme.css)
   ------------------------------------------------------------
   职责只有四件事，其他文件一律不动：
     1) 黑 / 白双主题：<html data-theme="light|dark">，无属性 = 跟随系统
     2) 顶栏主题切换按钮（.tbtn）：日 / 月 图标交叉溶解
     3) 动效升级：只动 transform / opacity，不加 filter:blur
     4) 手机端零缺陷：安全区、触控尺寸、横向溢出、100dvh、输入不缩放
   加载顺序：site.css → premium.css → theme.css
   所有规则都是"叠加"，不覆盖原布局尺寸。
   ============================================================ */

/* ---------------- 1. 令牌层 ---------------- */

:root{
  /* 主题切换过渡（只在 .theme-anim 时开启，避免首屏变色抖动） */
  --th-t:.34s;
  --th-ease:cubic-bezier(.22,.61,.36,1);
  --th-spring:cubic-bezier(.34,1.4,.5,1);

  /* 顶栏 / 弹层 / 卡片的半透明底色，深浅两套 */
  --glass:rgba(255,255,255,.86);
  --glass-strong:rgba(255,255,255,.96);
  --hair:rgba(0,0,0,.06);
  --hair-2:rgba(0,0,0,.10);
  --spot:rgba(17,24,39,.06);
  --lift-sh:0 2px 6px rgba(0,0,0,.05),0 14px 34px rgba(0,0,0,.08);

  color-scheme: light;
}

html[data-theme="dark"]{
  --glass:rgba(13,13,13,.82);
  --glass-strong:rgba(13,13,13,.95);
  --hair:rgba(255,255,255,.07);
  --hair-2:rgba(255,255,255,.12);
  --spot:rgba(255,255,255,.07);
  --lift-sh:0 2px 6px rgba(0,0,0,.5),0 18px 42px rgba(0,0,0,.55);
  --pr-edge-light:rgba(255,255,255,.10);
  /* 暗色下暖调光斑会发灰发脏，压一档不透明度 */
  --pb-opacity:.2;

  color-scheme: dark;
}
@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]){
    --glass:rgba(13,13,13,.82);
    --glass-strong:rgba(13,13,13,.95);
    --hair:rgba(255,255,255,.07);
    --hair-2:rgba(255,255,255,.12);
    --spot:rgba(255,255,255,.07);
    --lift-sh:0 2px 6px rgba(0,0,0,.5),0 18px 42px rgba(0,0,0,.55);
    --pr-edge-light:rgba(255,255,255,.10);
    --pb-opacity:.2;
    color-scheme: dark;
  }
}

/* 切换瞬间才让"大块面"渐变色。
   只挑容器级元素，不做 * 选择器 —— 后者会给几百个节点挂过渡，反而掉帧。 */
html.theme-anim body,
html.theme-anim .topbar .wrap,
html.theme-anim .card,
html.theme-anim .art-card,
html.theme-anim .qitem,
html.theme-anim .pcard,
html.theme-anim .panel,
html.theme-anim .mnav,
html.theme-anim .copy-pill,
html.theme-anim .badge,
html.theme-anim .pr-table th,
html.theme-anim .pr-table td,
html.theme-anim .article-body,
html.theme-anim .prose,
html.theme-anim .footer,
html.theme-anim .cta-band,
html.theme-anim .kpiband,
html.theme-anim .startband,
html.theme-anim .btn,
html.theme-anim .tbtn,
html.theme-anim .sbtn{
  transition:
    background-color var(--th-t) var(--th-ease),
    border-color var(--th-t) var(--th-ease),
    color var(--th-t) var(--th-ease),
    box-shadow var(--th-t) var(--th-ease) !important;
  transition-delay:0s !important;
}

/* ---------------- 2. 顶栏主题切换按钮 ---------------- */

.tbtn{
  position:relative;
  width:32px;height:32px;flex:0 0 auto;
  display:grid;place-items:center;
  border:0;border-radius:var(--r-pill,999px);
  background:none;color:var(--fg-muted);cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  transition:color var(--t-fast,.15s) var(--th-ease),
             background-color var(--t-fast,.15s) var(--th-ease);
}
.tbtn:hover{background:var(--bg-mute);color:var(--fg)}
.tbtn:active{transform:scale(.94)}
.tbtn:focus-visible{outline:2px solid var(--fg-strong);outline-offset:2px}

.tbtn .tico{
  position:absolute;inset:0;display:grid;place-items:center;
  transition:opacity .3s var(--th-ease),transform .42s var(--th-spring);
  will-change:transform,opacity;
}
.tbtn svg{width:16px;height:16px;display:block}

/* 亮色下藏月亮、显太阳；暗色反过来 */
.tbtn .ico-moon{opacity:0;transform:rotate(-55deg) scale(.55)}
.tbtn .ico-sun{opacity:1;transform:rotate(0) scale(1)}

html[data-theme="dark"] .tbtn .ico-moon{opacity:1;transform:rotate(0) scale(1)}
html[data-theme="dark"] .tbtn .ico-sun{opacity:0;transform:rotate(55deg) scale(.55)}

@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]) .tbtn .ico-moon{opacity:1;transform:rotate(0) scale(1)}
  html:not([data-theme="light"]) .tbtn .ico-sun{opacity:0;transform:rotate(55deg) scale(.55)}
}

/* 点击时图标轻微"弹"一下，给手指一个明确回执 */
.tbtn.tap .tico{animation:th-tap .46s var(--th-spring)}
@keyframes th-tap{
  0%{transform:scale(1) rotate(0)}
  38%{transform:scale(.72) rotate(-22deg)}
  100%{transform:scale(1) rotate(0)}
}

/* 主题切换的圆形揭幕（View Transitions 可用时才生效） */
::view-transition-old(root),
::view-transition-new(root){animation:none;mix-blend-mode:normal}
html.th-vt::view-transition-new(root){
  animation:th-reveal .52s cubic-bezier(.16,1,.3,1) both;
  clip-path:circle(0 at var(--th-x,50%) var(--th-y,50%));
}
@keyframes th-reveal{
  to{clip-path:circle(var(--th-r,150vmax) at var(--th-x,50%) var(--th-y,50%))}
}

/* ---------------- 3. 动效升级 ---------------- */

/* 3.1 首屏标题：去掉 filter:blur（大字号上等于整块重绘多遍），
      改成"位移 + 极轻微缩放"，观感更利落、手机上不掉帧 */
@keyframes th-word-in{
  from{opacity:0;transform:translate3d(0,20px,0) scale(.986)}
  to{opacity:1;transform:translate3d(0,0,0) scale(1)}
}
h1,.hero-h1{animation:th-word-in .72s cubic-bezier(.16,1,.3,1) both}

/* 3.2 首屏元素级联入场（原本所有块一起出现，现在有节奏） */
.banner .badge{animation:fade-in-subtitle .5s cubic-bezier(.16,1,.3,1) both}
.banner .lead{animation:fade-in-subtitle .6s .1s cubic-bezier(.16,1,.3,1) both}
.banner .hero-acts{animation:fade-in-subtitle .6s .18s cubic-bezier(.16,1,.3,1) both}
.banner .copy-pill{animation:fade-in-subtitle .6s .26s cubic-bezier(.16,1,.3,1) both}

/* 3.3 卡片：悬停抬升用弹簧曲线，落点更"有重量" */
.card,.art-card,.qitem,.pcard{
  transition:
    transform .34s var(--th-spring),
    box-shadow .34s var(--th-ease),
    border-color .24s var(--th-ease),
    background-color .24s var(--th-ease);
}
@media (hover:hover) and (pointer:fine){
  .card:hover,.art-card:hover{transform:translateY(-4px);box-shadow:var(--lift-sh)}
  .qitem:hover{transform:translateY(-2px)}
  .pcard:hover{transform:translateX(2px)}
}

/* 3.4 按钮：按下回弹 + 主按钮光晕呼吸 */
.btn{transition:
  transform .22s var(--th-spring),
  box-shadow .3s var(--th-ease),
  background-color .15s var(--th-ease),
  color .15s var(--th-ease)}
.btn:active{transform:scale(.965)}
.btn.primary:hover{transform:translateY(-1.5px)}
.btn.primary:hover::after{opacity:.9}

/* 3.5 导航胶囊：滚动时的收窄更顺滑，并用 transform 而非 height 抖动 */
.topbar .wrap{transition:
  height .3s var(--th-ease),
  box-shadow .3s var(--th-ease),
  background-color .3s var(--th-ease),
  border-color .3s var(--th-ease)}

/* 3.6 滚动淡入（JS 打 .rv-in；JS 失效时 2.5s 后自动全部显示） */
html.rv-on .rv{opacity:0;transform:translate3d(0,16px,0)}
html.rv-on .rv.rv-in{
  opacity:1;transform:none;
  transition:opacity .5s var(--th-ease),transform .58s cubic-bezier(.16,1,.3,1);
  transition-delay:var(--rv-d,0ms);
}

/* 3.7 链接下划线扫过（正文里的小细节） */
.article-body a:not(.btn):not(.chip){
  background-image:linear-gradient(currentColor,currentColor);
  background-size:0% 1px;background-position:0 100%;background-repeat:no-repeat;
  transition:background-size .3s var(--th-ease);
}
.article-body a:not(.btn):not(.chip):hover{background-size:100% 1px}

/* 3.8 图片载入淡入，避免"啪"地跳出来 */
img[loading="lazy"]{opacity:0;transition:opacity .45s var(--th-ease)}
img[loading="lazy"].th-loaded{opacity:1}

/* 3.9 尊重系统"减少动效" */
@media (prefers-reduced-motion:reduce){
  html.rv-on .rv{opacity:1 !important;transform:none !important}
  h1,.hero-h1,
  .banner .badge,.banner .lead,.banner .hero-acts,.banner .copy-pill{animation:none !important}
  .tbtn.tap .tico{animation:none !important}
  html.th-vt::view-transition-new(root){animation:none !important}
  html.theme-anim,html.theme-anim body,html.theme-anim body *{transition:none !important}
  .card:hover,.art-card:hover,.qitem:hover,.pcard:hover{transform:none !important}
}

/* ---------------- 4. 手机端适配（100% 无横向溢出） ---------------- */

/* 4.1 全局防溢出：clip 不建立滚动容器，不影响 position:sticky */
html,body{max-width:100%;overflow-x:clip}
@supports not (overflow:clip){html,body{overflow-x:hidden}}

/* 4.2 长英文 / 长 URL / 代码块不许撑破版面 */
body{overflow-wrap:break-word;word-break:normal}
.prose,.article-body,.article-body *{overflow-wrap:anywhere}
.prose pre,.article-body pre{overflow-x:auto;-webkit-overflow-scrolling:touch;max-width:100%}
.prose table,.article-body table{max-width:100%}

/* 4.3 移动浏览器地址栏：svh/dvh 替代 vh，首屏不再被截 */
@supports (height:100svh){
  .banner{min-height:100svh}
  .bslide{min-height:100svh}
}
@supports (height:100dvh){
  .mnav{max-height:calc(100dvh - 88px - env(safe-area-inset-bottom,0px))}
  .panel{max-height:calc(100dvh - 108px)}
}

/* 4.4 顶栏吃进刘海安全区（只加顶部，左右内边距保持原设计） */
.topbar{padding-top:calc(8px + env(safe-area-inset-top,0px))}

/* 4.5 触控目标：手指点得到的才算能点 */
@media (max-width:1140px),(pointer:coarse){
  .tbtn,.sbtn{width:38px;height:38px}
  .tbtn svg,.sbtn svg{width:17px;height:17px}
  .burger{width:38px;height:38px}
  .mnav .mi{min-height:48px}
  .mnav summary{min-height:48px;padding:14px 12px}
  .mnav .mfoot .btn{height:44px}
  .mnav .mchips a{padding:10px 14px;font-size:13.5px}
  .btn{height:40px}
  .btn:active{transform:scale(.97)}
  .nav-btn,.mnav .mi,.mnav summary,.tbtn,.sbtn,.burger{
    -webkit-tap-highlight-color:transparent;touch-action:manipulation}
}

/* 4.6 iOS 输入框 <16px 会自动放大页面，这里统一顶住 */
@media (max-width:900px){
  input,textarea,select{font-size:16px !important;line-height:1.5}
  .smodal input,.smodal textarea{font-size:16px !important}
}

/* 4.7 手机端顶栏空间分配：窄屏优先保住 主题 + 菜单 + 主按钮 */
@media (max-width:640px){
  .topbar{padding-left:10px;padding-right:10px}
  .topbar .wrap{width:calc(100vw - 20px);gap:4px;padding:0 8px 0 12px}
  .brand{font-size:14.5px;margin-right:2px}
  .brand i{width:24px;height:24px}
  .acts{gap:2px;margin-left:auto}
}
@media (max-width:560px){
  /* 站内搜索收进手机菜单（菜单里已有入口），把位置让给主题开关 */
  .acts .sbtn{display:none}
  .acts .btn.primary{padding:0 14px;font-size:13.5px}
}
@media (max-width:400px){
  .acts .btn.primary{display:none}
  .brand{font-size:14px}
}
@media (max-width:360px){
  .topbar .wrap{padding:0 6px 0 10px}
  .brand i{width:22px;height:22px}
}

/* 4.13 1141–1250px 档：导航条最挤的一段。
      原版在这里 nav 会被 flex 挤到溢出（标签互相叠住），
      收紧胶囊内边距 + 字号，让整条在最小 1141px 也摆得下。 */
@media (min-width:1141px) and (max-width:1250px){
  .topbar .wrap{gap:4px;padding:0 8px 0 12px}
  .nav{gap:1px}
  .nav-btn{padding:0 9px;font-size:13.5px}
  .acts{gap:4px;margin-left:4px}
  .brand{margin-right:4px;font-size:14.5px}
  .acts .btn{height:34px;padding:0 13px;font-size:13px}
  .tbtn,.sbtn{width:32px;height:32px}
  .tbtn svg,.sbtn svg{width:15px;height:15px}
}

/* 4.8 手机端首页首屏节奏：留白收紧、按钮铺满更好点 */
@media (max-width:640px){
  .bslide{padding:112px 0 72px}
  .lead{font-size:15.5px;line-height:1.72}
  .hero-acts{width:100%;gap:8px}
  .hero-acts .btn{flex:1 1 auto;min-width:140px}
  .copy-pill{max-width:100%;font-size:12.5px;padding:0 6px 0 14px}
  h1,.hero-h1{font-size:clamp(28px,8.2vw,42px);line-height:1.12}
}

/* 4.9 手机端地滚手势：横向滚动区域给出摩擦反馈 */
.mnav .mbody,.tablewrap,.pr-wrap,.code,.prose pre{
  overscroll-behavior:contain;-webkit-overflow-scrolling:touch}

/* 4.10 手机端固定浮窗避让安全区 */
@supports (bottom:env(safe-area-inset-bottom)){
  .fab{bottom:calc(20px + env(safe-area-inset-bottom))}
  .dock{bottom:calc(16px + env(safe-area-inset-bottom))}
}

/* 4.11 横屏手机：首屏不再强行 100vh，避免内容被压扁 */
@media (max-height:560px) and (orientation:landscape){
  .banner,.bslide{min-height:auto}
  .bslide{padding:88px 0 56px}
  .hero-chips{display:none}
}

/* 4.12 超大显示器：正文行宽不失控 */
@media (min-width:1600px){
  :root{--wrap:1320px}
}

/* ============================================================
   5. 组件级移动端修补（实测 320/360/390 三档）
   ============================================================ */

/* 5.1 横幅 / 开始条：flex 子项默认不吃到 min-content 以下，
      窄屏上会让标题顶出容器 —— 显式放开收缩 */
.cta-band > *,.startband > *,.kpiband > *{min-width:0}
.cta-band h2,.cta-band p,.startband h2,.startband p{overflow-wrap:anywhere}

@media (max-width:820px){
  .cta-band{padding:30px 24px;gap:18px;align-items:flex-start}
  .cta-band > div{width:100%}
  .cta-band .btn{width:100%;justify-content:center;flex:1 1 100%}
  .cta-band h2{font-size:clamp(20px,5.2vw,28px)}
  .cta-band p{font-size:14px;line-height:1.65}
}
@media (max-width:420px){
  .cta-band{padding:24px 18px;gap:14px}
  .startband{padding:24px 18px !important}
  .kpiband{padding:26px 18px !important}
}

/* 5.2 价格筛选 Tab / 轮播圆点 / 复制按钮：视觉不变，热区放大 */
.tab{position:relative}
@media (max-width:1140px),(pointer:coarse){
  .tab{height:auto;min-height:40px;display:inline-flex;align-items:center}

  /* 轮播圆点：把按钮撑到 44×44，真正的"点"用 ::before 画在正中间。
     这样手指点得中，视觉上还是那排小圆点，也不会互相抢点击。 */
  .bdots{gap:0;bottom:8px}
  .bdots button{
    width:44px;height:44px;display:grid;place-items:center;
    background:none;border-radius:0;
    transition:none}
  .bdots button::before{
    content:"";display:block;width:7px;height:7px;border-radius:999px;
    background:var(--line-2);
    transition:width .3s var(--th-ease),background-color .3s var(--th-ease)}
  .bdots button.on{width:44px;background:none}
  .bdots button.on::before{width:24px;background:var(--fg)}

  /* 复制按钮：文字块旁边的小方块，热区顶到 44 */
  .copy-pill button{position:relative;width:38px;height:38px}
  .copy-pill button::after{content:"";position:absolute;inset:-5px;border-radius:999px}
}

/* 5.3 顶栏控件热区（桌面 34px 起点，触屏 42px） */
.tbtn,.sbtn{width:34px;height:34px}
.nav-btn{height:34px}
@media (max-width:1140px),(pointer:coarse){
  .tbtn,.sbtn,.burger{width:42px;height:42px}
  .tbtn svg,.sbtn svg{width:18px;height:18px}
  .fab a,.fab button{width:42px;height:42px}
}

/* 5.4 文章页：正文左右留白在窄屏收紧，代码块与表格自己滚 */
@media (max-width:640px){
  .article-body{padding:32px 18px 72px;font-size:16px;line-height:1.82}
  .article-body h2{margin-top:44px}
}
@media (max-width:400px){
  .article-body{padding:26px 15px 64px}
}

/* 5.5 页脚：窄屏单列后不再挤成一坨 */
@media (max-width:560px){
  footer{padding:40px 0 28px}
  .fcols{gap:22px}
}

/* 5.6 手机端禁止"长按选中菜单 / 双击缩放"干扰，同时保留正文可选中 */
@media (max-width:900px){
  .topbar,.mnav,.fab,.dock,.bdots,.bnav,.tab{
    -webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
}

/* 5.7 输入框聚焦时 iOS 不缩放（字号已在 4.6 顶到 16px），
      这里再补一条：聚焦时不要被键盘顶飞 */
@media (max-width:900px){
  input,textarea,select{scroll-margin-top:96px}
}

/* 5.8 兜底：任何元素都不许在窄屏上撑出横向滚动 */
@media (max-width:480px){
  .pr-table{min-width:520px}
  .prose img,.article-body img{max-width:100%;height:auto}
  iframe,video,embed,object{max-width:100%}
  pre,code{max-width:100%}
}

/* ---------------- 6. 暗色细节微调 ---------------- */

/* 描边水印字在暗色里几乎看不见 —— 提亮到能隐约看到的程度 */
html[data-theme="dark"] .watermark{-webkit-text-stroke-color:rgba(255,255,255,.13);opacity:.4}
@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]) .watermark{-webkit-text-stroke-color:rgba(255,255,255,.13);opacity:.4}
}

/* 滑块指示器在暗色里阴影换成冷调，别在近白滑块下面拖出暖灰 */
html[data-theme="dark"] .pr-tabind{box-shadow:0 2px 10px -2px rgba(0,0,0,.5)}
@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]) .pr-tabind{box-shadow:0 2px 10px -2px rgba(0,0,0,.5)}
}

/* 暗色下滚动条描边跟底色对齐 */
html[data-theme="dark"] ::-webkit-scrollbar-thumb{border-color:var(--bg)}
@media (prefers-color-scheme:dark){
  html:not([data-theme="light"]) ::-webkit-scrollbar-thumb{border-color:var(--bg)}
}