/* 登录/注册弹窗 · 内嵌模式（2026-10-31）
 *
 * 宿主 = 丹丹的主站首屏（纯静态工件，docs/homepage-deploy.md）。首页浮层盖一层全屏透明 iframe，
 * iframe 里就是这份登录文档，只是把登录面板包进「注册」那一副卡片外壳
 * （标题 + 右上 logo + 底部版权条，见 app/login/document.ts 的 withLoginDialogShell），摆到正中。
 * 🔴 2026-11-26 起文档里**已经没有**场景 / 页眉 / 页脚（老登录页退役），这里不再需要藏它们。
 *
 * 🔴 面板内部的 DOM 不动（login-auth.js / login-ui.js 的选择器），这里只碰外壳与版式。
 * 🔴 页面自身背景一律透明：宿主浮层已经压过一层，这里是叠在首屏上的。
 */
html.ms-embed,
html.ms-embed body {
  background: transparent !important;
  height: 100%;
  overflow: hidden;
}

/* 首帧保护（2026-11-26）：规则不在这里 —— 必须在 <head> 最前面**内联**（流式响应下本文件被解析到之前
   浏览器已经画了登录卡）。真值 = document.ts 的 withDialogFirst 里那段 <style id="meow-dialog-first">；
   本文件的 `:has(dialog[open])` 负责「脚本接管之后」的隐藏。 */

/* 「裸页」（2026-11-26）：整页直接打开这份文档时（/agent、首页工件缺席时的 /login 兜底），
   背后没有宿主首屏可透 ⇒ 给回太空黑。内嵌档（宿主是首页浮层）仍是透明。 */
html.ms-embed.ms-bare,
html.ms-embed.ms-bare body {
  background: var(--space-black, #08090b) !important;
}

/* 压暗首屏：iframe 盖满视口、背景透明 ⇒ 这一层就是弹窗外面的遮罩
   🔴 **不许给它加 backdrop-filter**（2026-11-04 owner 第二次实拍：「拉滑块还是全黑」的真正元凶）。
   iframe 是跨文档的，里面的 backdrop-filter 拿不到宿主的画面，Chromium 会当成「背后什么都没有」，
   把这一层连同它背后的整屏刷成黑的。平时看不出来——登录卡片自己会画，遮住这个症状；可一旦卡片让位
   （注册 / 重置 / 开通弹窗打开），背后就整屏黑成一片，客户以为离开了首页。
   要糊/要压都由**宿主那一层**做（hero-auth-overlay.js 的浮层自带 rgba .62 + blur(2px)，它在同一份文档里，
   糊得到首屏）；这里只负责压暗。2026-11-02 那回关掉 `dialog::backdrop` 的 blur 同一个道理。 */
html.ms-embed body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 11, 0.45);
}
/* 腾讯滑块那层遮罩（`#t_mask`，login.css 里给了 blur(8px)）在**直连** /login 上是真毛玻璃，
   但一进 iframe 就变成刷黑的帮凶：跨文档拿不到宿主画面，真 GPU 合成时整屏按「背后什么都没有」画成黑
   （2026-11-04 owner 第三次实拍，软件渲染复现不出来，换成真显卡才看见）。内嵌档一律关掉 blur，只留那层淡墨。 */
html.ms-embed #t_mask.t-mask {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* 🔴 过滑块那一段**不让路**（2026-11-04 第四次实拍曾把三层一起抬亮到 ≈36%，同日第五次实拍又撤回）。
   owner 的口径是「全部照登录窗拉滑块那一遍」：卡片留在原地，背后照常 宿主 .62 + 这里 .45 + `#t_mask` .22 的
   压暗与虚化。注册窗现在过滑块也不收卡片（signup-modal.js 只把卡片退出原生顶层），
   要是遮罩单独让路，背景反而比登录窗那一段更亮、更不虚 —— 两副样子正是这次要统一掉的东西。 */

/* 四张卡的页面遮罩（reset-modal.css 的 .reset-scrim）在内嵌档不出：外面已经压过一层（宿主 .62 + 这里 .45），
   再叠 .45 就黑成一片。模糊同理不叠——2026-11-02 prod 实拍过，去掉后与登录卡片同一副观感。 */
html.ms-embed:has(dialog[open]) .reset-scrim {
  display: none;
}

/* ── 卡片本体：与注册弹窗同一副（背景 #151412 / 1px 发丝 / 圆角 14 / 46px·36px 内边距）──
   🔴 2026-11-04 owner「注册和登录的弹窗不一样大、切换时跳动」：**高度也钉死成同一个数**。
   登录卡的内容高度本来就是固定的（520 宽 + 46/36/24 内边距 + 26px 标题行 + 30 底距 + 五块固定内容
   = 568，含边 570），但矮屏（max-height:850px 那批紧凑规则）会把它压到 ~554，注册卡不跟 ——
   两窗一大一小就是这么来的。这里直接给 570，登录 / 注册两边同一个值，视口再矮就一起缩到 100dvh-32。
   🔴 注册窗口的同一份几何住在 signup-modal.css（它也要能在直连 /login 上单独摆），改这里必须同步那边。
   🔴 用 flex 列：内容少于卡片高度时（矮屏）footer 留在底部，不会浮上来。 */
html.ms-embed .login-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 32px));
  height: min(570px, calc(100dvh - 32px));
  overflow-y: auto;
  overscroll-behavior: contain;
  /* 🔴 卡片不画自己的滚动条（owner 2026-11-04 实拍：卡片右缘那条贯穿全高、带上下箭头的灰条）。
     高度钉死在 570、内容也是 568，余量本来就是 0 —— 字体换行 / 取整只要差 1px，Windows 上就多出
     这条原生滚动条；它不是控件，是从 v1 整页登录卡带过来的滚动能力。滚动照旧可用（矮屏滚轮 / 触屏），
     只是不再把条画出来。 */
  scrollbar-width: none;
  padding: 46px 36px 24px;
  background: #151412;
  border: 1px solid rgba(242, 242, 238, 0.16);
  /* 面板档圆角走 token（login.css 文末镜像的 --v14-r-panel = 12，与 .reset-dialog 同一个值）：
     原来这里写死 14，注册窗由 .reset-dialog 取 12 ⇒ 两窗摆在一起四角差 2px（2026-11-04 真机比对
     computedStyle 抓到的唯一一处还不同的皮）。 */
  border-radius: var(--v14-r-panel, 12px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
}
/* Chromium（含 Windows 上带箭头的经典滚动条）同一条：轨道 / 滑块一律不画。 */
html.ms-embed .login-dialog::-webkit-scrollbar {
  width: 0;
  height: 0;
}
/* 表单吃掉卡片里剩下的高度 ⇒ 底下的版权条被压到卡片底部（矮屏时多出来的空白留在表单里）。
   🔴 只许长、不许缩（flex-shrink:0）：矮于内容时卡片要滚（overflow-y:auto 在外框上），
      压扁会把标题与版权条挤到字叠在一起。 */
html.ms-embed .login-dialog > * {
  flex-shrink: 0;
}
html.ms-embed .login-dialog > form {
  flex: 1 0 auto;
}

/* 头部：标题左、logo 右（同 apply-heading），下留 30px —— 原来「上边缘挤成一团」就是缺这一段 */
html.ms-embed .login-dialog-head {
  margin: 0 0 30px;
  align-items: center;
}
html.ms-embed .login-dialog-head h2 {
  margin: 0;
  /* 与注册弹窗的 apply-heading h2 对齐（26px / 500 / .91px），两块卡片的标题要同一个模子 */
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.91px;
  line-height: 1.2;
  color: var(--moon-white, #f2f2ee);
}
html.ms-embed .login-dialog-head .apply-logo {
  width: 88px;
  height: auto;
  filter: invert(1);
}

/* 表单在卡片里按注册弹窗的节奏排：下面这些是面板原有的类，只校版式 */
html.ms-embed .login-dialog .login-methods {
  margin-bottom: 6px;
}
html.ms-embed .login-dialog .fields {
  margin-top: 18px;
}
html.ms-embed .login-dialog .field-label {
  font-size: 12px;
  color: #b9b6ae;
}
html.ms-embed .login-dialog .input-row {
  min-height: 46px;
}
/* 输入字号对齐注册弹窗的 .apply-input（14px） */
html.ms-embed .login-dialog .input-row input {
  font-size: 14px;
}
html.ms-embed .login-dialog .form-options {
  margin: 10px 0 22px;
}
html.ms-embed .login-dialog .enter-button {
  /* 🔴 .enter-arrow 是 absolute 定位的（button.css），按钮在整页里本来靠别的规则提供定位上下文；
     搬进卡片后若不 relative，箭头会相对 .login-dialog 拉成满高、跑到按钮外面（实测 36×549） */
  position: relative;
  min-height: 50px;
  /* 按钮字对齐注册弹窗的 .reset-modal-submit（12px / 600 / .84px） */
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.84px;
}
/* 底部分隔线 + 版权条：与注册弹窗 apply-help / apply-legal 同款 */
html.ms-embed .login-dialog .login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(242, 242, 238, 0.19);
}
html.ms-embed .login-dialog .consent {
  text-align: left;
  font-size: 12px;
  letter-spacing: normal;
  line-height: 1.8;
  color: #b9b6ae;
}
html.ms-embed .login-dialog .apply-row {
  margin-top: 12px;
  padding-top: 0;
  border-top: 0;
}
html.ms-embed .login-dialog .apply-content > span {
  font-size: 12px;
}
html.ms-embed .login-dialog-legal {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(242, 242, 238, 0.12);
}

/* 注册 / 留资 / 重置的 <dialog> 打开时，底下的登录卡片让位——否则两块卡片叠在一起（owner 2026-10-31 实拍）。
   过腾讯滑块那一段也算「开着」：那时卡片只是退出原生顶层改非模态常驻，open 属性一直在
   （signup-modal.js / reset-modal.js 的 overlay），不会把登录卡片露回来（owner 2026-11-03 实拍的那一幕）。 */
html.ms-embed:has(dialog[open]) .login-dialog {
  /* 🔴 不能用 display:none：text-proximity.js 会把每个字包成 span 并按 getBoundingClientRect 锁字宽，
     隐藏态量出来全是 0 ⇒ 卡片再次露面时所有字叠在一起（看着像乱码/方块，owner 2026-10-31 实拍）。
     visibility:hidden 保留布局与尺寸，量宽正常。 */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

/* 聚焦下划线统一成**粗线**（owner 2026-10-31：登录卡是粗的、注册卡是细的，一律照登录卡）。
   两块卡片的输入框都含 .apply-input / .field，这里一次管住，包含 :focus-within 与外露的 input 聚焦。 */
html.ms-embed .field:focus-within,
html.ms-embed .apply-input:focus {
  border-bottom-width: 2px !important;
  border-bottom-color: var(--signal-orange, #d98859) !important;
}
/* 手机 tab 的验证码行 2026-11-02 起把线画在控件自己身上（拆成两段，照注册弹窗），.field:focus-within 那一条
   就够不着了 ⇒ 单独给输入框补同一档粗线。 */
html.ms-embed #phone-code:focus {
  border-bottom-width: 2px !important;
  border-bottom-color: var(--signal-orange, #d98859) !important;
}

/* ── 「MCP 接入」弹窗的内嵌版（2026-11-02）──
   宿主 = 主站首页顶栏 / 手机菜单的「MCP&Agent」。这份文档里要的只是 MCP 那一窗，
   登录卡片不出（它是整页语义，在这一档里没有位置）；其余规则与登录浮层完全共用。 */
html.ms-embed-mcp .login-panel {
  display: none !important;
}

/* 关闭按钮：与注册弹窗的 apply-close 同位置 */
html.ms-embed .ms-embed-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #b9b6ae;
  cursor: pointer;
}
html.ms-embed .ms-embed-close:hover {
  background: #201e1b;
  color: #f2f2ee;
}

/* 弹窗里不再有「整页」语义的元素 */
html.ms-embed .login-dialog .panel-topline,
html.ms-embed .login-dialog .welcome-eyebrow,
html.ms-embed .login-dialog .login-description {
  display: none;
}

/* 手机档：贴底铺满。
   高度同样钉死（注册窗同一组数，见 signup-modal.css 的手机档）：手机版的内边距 34/22/20 +
   页脚两行，内容比桌面版高 —— 390/360 宽实测 586，「登录即表示同意…」与「还没有账号？注册」各占一行。
   写 588（含两条边）刚好容下；再窄（≤320）或再矮就框内滚。 */
@media (max-width: 600px) {
  html.ms-embed .login-dialog {
    width: 100%;
    height: min(588px, 92dvh);
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    left: 0;
    top: auto;
    bottom: 0;
    transform: none;
    padding: 34px 22px 20px;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  html.ms-embed .login-dialog-head h2 {
    font-size: 22px;
  }
  html.ms-embed .login-dialog-head .apply-logo {
    width: 76px;
  }
}
