/* 瓷脉统一互动层：弹窗 / 确认 / 输入 / 轻提示
   前台、后台、3D 页共用同一套，替代浏览器原生 alert / confirm / prompt。
   命名统一 ym- 前缀，避免与页面既有样式冲突。 */

:root {
  --ym-brand: #2c6a5b;
  --ym-brand-d: #1e4d41;
  --ym-danger: #b03a2a;
  --ym-ink: #22302c;
  --ym-ink2: #4c5a55;
  --ym-ink3: #8a9a94;
  --ym-line: #e6e2d8;
  --ym-bg: #fff;
}

/* ---------- 遮罩 ---------- */
.ym-ovl {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(18, 28, 24, .46);
  -webkit-backdrop-filter: blur(3px) saturate(1.05);
  backdrop-filter: blur(3px) saturate(1.05);
  animation: ym-fade .16s ease-out;
}

@keyframes ym-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes ym-rise { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
@keyframes ym-sheet { from { transform: translateY(100%) } to { transform: none } }

/* ---------- 弹窗主体 ---------- */
.ym-dlg {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ym-bg);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(18, 28, 24, .24), 0 2px 6px rgba(18, 28, 24, .08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ym-ink);
  animation: ym-rise .18s cubic-bezier(.22, .8, .3, 1);
}

.ym-hd {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 20px 20px 0;
}

.ym-ic {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eaf2ef;
  color: var(--ym-brand);
}

.ym-ic.warn { background: #fdf2e6; color: #a2621c }
.ym-ic.danger { background: #fbeceb; color: var(--ym-danger) }

.ym-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding-top: 5px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.4;
}

.ym-x {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin: -2px -4px 0 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ym-ink3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .14s, color .14s;
}

.ym-x:hover { background: #f1efe9; color: var(--ym-ink) }

.ym-bd {
  padding: 12px 20px 4px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ym-ink2);
  -webkit-overflow-scrolling: touch;
}

.ym-bd p { margin: 0 0 8px }
.ym-bd p:last-child { margin-bottom: 0 }
.ym-bd strong { color: var(--ym-ink); font-weight: 600 }
.ym-bd code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #f2f0ea;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.ym-lab {
  display: block;
  margin: 4px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ym-ink3);
  letter-spacing: .04em;
}

.ym-in {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--ym-line);
  border-radius: 10px;
  background: #fdfcfa;
  color: var(--ym-ink);
  font: inherit;
  font-size: 14px;
  outline: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.ym-in:focus {
  border-color: var(--ym-brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(44, 106, 91, .12);
}

.ym-ft {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 20px 20px;
}

.ym-btn {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ym-brand);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .06s;
}

.ym-btn:hover { background: var(--ym-brand-d) }
.ym-btn:active { transform: translateY(1px) }
.ym-btn:disabled { opacity: .55; cursor: not-allowed }
.ym-btn.ghost { background: #fff; border-color: #cfdcd6; color: var(--ym-brand) }
.ym-btn.ghost:hover { background: #f5f9f7 }
.ym-btn.danger { background: var(--ym-danger) }
.ym-btn.danger:hover { background: #8f2f22 }

/* ---------- 轻提示 ---------- */
.ym-toasts {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 9600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.ym-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(90vw, 440px);
  padding: 10px 16px 10px 13px;
  border-radius: 11px;
  background: rgba(34, 48, 44, .95);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 32px rgba(18, 28, 24, .26);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s, transform .2s;
  pointer-events: auto;
}

.ym-toast.on { opacity: 1; transform: none }
.ym-toast .dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #6fbfa4 }
.ym-toast.ok .dot { background: #6fbfa4 }
.ym-toast.warn .dot { background: #e3b04b }
.ym-toast.err .dot { background: #e06a56 }

/* ---------- 窄屏：弹窗落到底部当动作面板 ---------- */
@media (max-width: 560px) {
  .ym-ovl { align-items: flex-end; padding: 0 }
  .ym-dlg {
    max-width: none;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    animation: ym-sheet .22s cubic-bezier(.22, .8, .3, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .ym-ft { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0)) }
  .ym-ft .ym-btn { flex: 1 1 0 }
  .ym-toasts { top: auto; bottom: calc(24px + env(safe-area-inset-bottom, 0)); width: 100%; padding: 0 16px }
  .ym-toast { max-width: none; width: 100% }
}

@media (prefers-reduced-motion: reduce) {
  .ym-ovl, .ym-dlg, .ym-toast { animation: none; transition: none }
}
