/* ==========================================================================
   全站弹窗统一（2026-11-05 定稿 · final-modal.html 替换落地）
   --------------------------------------------------------------------------
   定稿形态：
     · 桌面：380 宽居中模态，遮罩 rgba(17,17,17,.5) + 毛玻璃 2px
     · 内容全部左对齐：40×40 wash 图标块（确认=信息圈 / 危险=警告三角）+ 标题 + 说明
     · 按钮行右对齐横排 34px；取消=灰底 / 确定=黑白反相 / 危险=红底
     · 移动端（≤900）：底部贴边弹层（Bottom Sheet），上两角 14、拖拽条 36×4、按钮竖排全宽
     · 黑白灰阶、零边框、零阴影（遮罩承担层级）、R-C 圆角（卡 14 / 控件 10 / 图标块 10）
   本文件是全站弹窗唯一实现来源（末位加载）：
     .modal 骨架（ui.js confirmDialog / app.js openModal / admin modalShell）
     .confirm 退出登录弹窗（app.js 顶栏）
   ========================================================================== */

/* ---------- 遮罩 ---------- */
.modal-mask,
.confirm {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 17, 17, .5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: modalMaskIn .18s ease both;
}
.confirm { z-index: 90; }
[data-theme="dark"] .modal-mask,
[data-theme="dark"] .confirm { background: rgba(0, 0, 0, .65); }

@keyframes modalMaskIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 弹窗卡（桌面居中模态） ---------- */
.modal {
  position: relative;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 22px 20px;
  border: 0;
  border-radius: var(--r-card);
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
  animation: modalIn .22s cubic-bezier(.2, .8, .2, 1) both;
}
[data-theme="dark"] .modal { background: var(--paper-3); }

.modal.narrow { width: 380px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ---------- 语义图标块：40×40 wash 左对齐 ---------- */
.modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin: 0 0 12px;
  background: var(--gray-wash);
  color: var(--ink);
}
.modal-icon svg { width: 20px; height: 20px; }
.modal-icon.is-danger { background: var(--red-wash); color: var(--red); }
[data-theme="dark"] .modal-icon { background: #262626; color: #f5f5f5; }
[data-theme="dark"] .modal-icon.is-danger { background: rgba(240, 128, 128, .18); color: #f08080; }

/* ---------- 标题 / 说明（左对齐） ---------- */
.modal h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}
.modal-desc {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
}

/* ---------- 关闭按钮：26×26 圆角 8，右上角；× 由 mask 绘制（裸字符 font-size:0 防双影） ---------- */
.modal-close,
.confirm__close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: block;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
  --modal-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 6 12 12M18 6 6 18'/%3E%3C/svg%3E");
}
.modal-close::before,
.confirm__close::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
}
.modal-close::after,
.confirm__close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  background: currentColor;
  -webkit-mask: var(--modal-x) center / contain no-repeat;
  mask: var(--modal-x) center / contain no-repeat;
}
.modal-close:hover,
.confirm__close:hover { background: var(--gray-wash); color: var(--ink); }
/* 退出登录弹窗关闭钮内的内联 SVG 不参与绘制，× 与 .modal-close 同一 mask 路径 */
.confirm__close svg,
.confirm__close .icon { display: none; }

/* 触屏：禁用双击缩放手势，快速连点不再被浏览器吞掉 click（2026-11-05 移动端抽屉按钮概率性无响应修复） */
.modal button,
.confirm button { touch-action: manipulation; }
/* 滚动到抽屉边界时不带动页面滚动（触屏滚动链隔离） */
.modal,
.confirm__panel { overscroll-behavior: contain; }
/* 触屏热区扩展：34px 高的按钮上下左右各扩 3px（40px 有效热区），与相邻按钮 gap 8px 不重叠 */
.modal-row .btn,
.confirm__btn { position: relative; }
.modal-row .btn::before,
.confirm__btn::before { content: ""; position: absolute; inset: -3px; }

/* ---------- 按钮行：右对齐横排 34px ---------- */
.modal-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.modal-row.mt { margin-top: 8px; }
.modal-row.mt-lg { margin-top: 12px; }
.modal-row .btn {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-ctl);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: filter .12s ease, transform .12s ease;
}
.modal-row .btn:active { transform: scale(.97); }
.modal-row .btn:not(.primary):not(.danger) { background: var(--gray-wash); color: var(--ink); }
.modal-row .btn:not(.primary):not(.danger):hover { background: var(--select-wash); color: var(--ink); }
.modal-row .btn.primary { background: var(--select-solid); color: var(--select-solid-ink); }
.modal-row .btn.primary:hover { background: var(--select-solid-hover); }
.modal-row .btn.danger { background: #C62828; color: #FFFFFF; }
.modal-row .btn.danger:hover { background: #A81F1F; }

/* 表单内容保持左对齐 */
.modal .form-row,
.modal .modal-body,
.modal .code-row { text-align: left; }

/* ---------- 退出登录确认（.confirm 结构，同一套定稿语言） ---------- */
.confirm__panel {
  position: relative;
  width: min(100%, 380px);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 22px 20px;
  border: 0;
  border-radius: var(--r-card);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  box-shadow: none;
  animation: modalIn .22s cubic-bezier(.2, .8, .2, 1) both;
}
[data-theme="dark"] .confirm__panel { background: var(--paper-3); }

.confirm__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0 0 12px;
  border-radius: 10px;
  background: var(--gray-wash);
  color: var(--ink);
  box-shadow: none;
}
.confirm__icon .icon { width: 20px; height: 20px; }
[data-theme="dark"] .confirm__icon { background: #262626; color: #f5f5f5; }

.confirm__title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}
.confirm__hint {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
}
[data-theme="dark"] .confirm__hint { color: var(--ink-2); }

.confirm__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.confirm__btn {
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-ctl);
  background: var(--gray-wash);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}
.confirm__btn:hover { background: var(--select-wash); color: var(--ink); }
.confirm__btn--primary { background: var(--select-solid); color: var(--select-solid-ink); }
.confirm__btn--primary:hover { background: var(--select-solid-hover); color: var(--select-solid-ink); }

/* ---------- 后台弹窗沿用同一套浮层语言 ---------- */
body.admin-mode .modal {
  border: 0;
  border-radius: var(--r-card);
  box-shadow: none;
}

/* ---------- 移动端：底部贴边弹层（Bottom Sheet） ---------- */
@media (max-width: 900px) {
  .modal-mask,
  .confirm {
    align-items: flex-end;
    padding: 0;
  }
  .modal,
  .confirm__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    max-height: 85%;
    border-radius: var(--r-card) var(--r-card) 0 0;
    padding: 26px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: modalSheet .28s cubic-bezier(.2, .8, .2, 1) both;
  }
  .modal.narrow { width: 100%; }
  /* 拖拽条 36×4（伪元素，.modal-icon 已是真实 DOM 无冲突） */
  .modal::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--rule-2);
  }
  .modal-close,
  .confirm__close { top: 16px; }
  .modal h3 { font-size: 16px; }
  /* 按钮竖排全宽：确定在上、取消在下 */
  .modal-row,
  .confirm__actions { flex-direction: column-reverse; }
  .modal-row .btn,
  .confirm__btn { width: 100%; }

  @keyframes modalSheet {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
}