/* ============================================================
   交互层：弹窗 / 抽屉 / Toast / 下拉 / 步骤条 / 登录 / 应用运行
   ============================================================ */

/* ---------- 遮罩 + 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(38,26,14,.42);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px;
  animation: ovIn .18s ease;
}
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-height: 90vh; display: flex; flex-direction: column;
  animation: mdIn .2s cubic-bezier(.2,.7,.3,1);
}
@keyframes mdIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 0; }
.modal-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-sub { font-size: 13.5px; color: var(--text-2); margin: 4px 0 0; line-height: 1.5; }
.modal-x { margin-left: auto; width: 32px; height: 32px; border-radius: 9px; border: none; background: var(--surface-2); color: var(--text-3); cursor: pointer; display: grid; place-items: center; flex: none; }
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.modal-body { padding: 18px 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-foot.spread { justify-content: space-between; align-items: center; }

/* 抽屉（右侧）：#7 左侧页面不虚化，仅压暗降低色彩，保持可读 */
.drawer-wrap { justify-content: flex-end; padding: 0; backdrop-filter: none; background: rgba(38,26,14,.34); }
.drawer { max-width: 480px; height: 100vh; max-height: 100vh; border-radius: 0; border-right: none; animation: dwIn .24s cubic-bezier(.2,.7,.3,1); }
@keyframes dwIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* 选择卡（弹窗内可选项） */
.pick {
  display: flex; align-items: center; gap: 13px; padding: 14px 15px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); cursor: pointer; transition: all .14s; background: var(--surface);
}
.pick:hover { border-color: var(--border-strong); }
.pick.on { border-color: var(--primary); background: var(--primary-weak); }
.pick-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; display: grid; place-items: center; }
.pick.on .pick-radio { border-color: var(--primary); }
.pick.on .pick-radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 12px 18px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500; animation: tIn .22s ease; pointer-events: auto; min-width: 240px;
}
@keyframes tIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.toast-ico { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.toast.ok .toast-ico { background: var(--ok); }
.toast.info .toast-ico { background: var(--info); }
.toast.warn .toast-ico { background: var(--warn); }
.toast.danger .toast-ico { background: var(--danger); }

/* ---------- 下拉面板（顶栏通知 / 账号） ---------- */
.dd-wrap { position: relative; }
.dd-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 120; width: 320px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: ddIn .16s ease;
}
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.dd-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; }
.dd-item { display: flex; gap: 11px; padding: 12px 16px; cursor: pointer; transition: background .12s; align-items: flex-start; }
.dd-item:hover { background: var(--surface-2); }
.dd-item + .dd-item { border-top: 1px solid var(--border); }
.dd-foot { padding: 11px 16px; text-align: center; border-top: 1px solid var(--border); cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; }
.dd-foot:hover { background: var(--surface-2); }
.menu-item { display: flex; align-items: center; gap: 11px; padding: 11px 14px; cursor: pointer; font-size: 14px; transition: background .12s; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }

/* ---------- 通用下拉框 Select ---------- */
.ui-select { position: relative; width: 100%; }
.ui-select-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px; cursor: pointer;
  text-align: left; transition: border-color .14s, box-shadow .14s;
}
.ui-select-trigger:hover { border-color: var(--primary); }
.ui-select-trigger.open { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.ui-select-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-ph { color: var(--text-3); }
.ui-select.is-disabled { opacity: .6; pointer-events: none; }
.ui-select-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); padding: 5px; max-height: 280px; overflow-y: auto; animation: ddIn .14s ease;
}
.ui-select-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text);
  transition: background .12s, color .12s;
}
.ui-select-opt:hover { background: var(--surface-2); }
.ui-select-opt.on { color: var(--primary); font-weight: 600; background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.ui-select-opt .ico { flex: none; color: var(--primary); }

/* ---------- 在线客服悬浮聊天框 ---------- */
.cs-launcher { position: fixed; right: 24px; bottom: 24px; z-index: 300; width: 56px; height: 56px; border-radius: 50%;
  border: none; cursor: pointer; background: linear-gradient(140deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #f0b25e));
  color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); transition: transform .15s; }
.cs-launcher:hover { transform: translateY(-2px) scale(1.04); }
.cs-launcher .cs-dot { position: absolute; top: 10px; right: 12px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.cs-panel { position: fixed; right: 24px; bottom: 24px; z-index: 300; width: 360px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: ddIn .18s ease; }
.cs-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; color: #fff;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 62%, #f0b25e)); }
.cs-avatar { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.22); display: grid; place-items: center; flex: none; }
.cs-x { border: none; background: rgba(255,255,255,.18); color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.cs-x:hover { background: rgba(255,255,255,.3); }
.cs-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.cs-hint { font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; line-height: 1.7; }
.cs-msg { display: flex; flex-direction: column; max-width: 82%; }
.cs-msg.me { align-self: flex-end; align-items: flex-end; }
.cs-msg.them { align-self: flex-start; }
.cs-msg.sys { align-self: center; max-width: 92%; }
.cs-msg-who { font-size: 11px; color: var(--text-3); margin: 0 0 3px 4px; }
.cs-bubble { font-size: 13.5px; line-height: 1.6; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.cs-msg.them .cs-bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; color: var(--text); }
.cs-msg.me .cs-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.cs-msg.sys .cs-bubble { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); color: var(--text-2); font-size: 12.5px; border-radius: 10px; }
.cs-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.cs-input { flex: 1; border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 12px; font-family: inherit; font-size: 14px; outline: none; }
.cs-input:focus { border-color: var(--primary); }
.cs-send { border: none; cursor: pointer; background: var(--primary); color: #fff; width: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.cs-send:disabled { opacity: .5; cursor: default; }

/* ---------- 步骤条 ---------- */
.stepper { display: flex; align-items: center; gap: 0; margin: 0 auto; max-width: 640px; }
.stepper .st { display: flex; align-items: center; gap: 10px; }
.st-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
  background: var(--surface-3); color: var(--text-3); border: 2px solid transparent; transition: all .2s; }
.st.active .st-dot { background: var(--primary); color: var(--primary-ink); }
.st.done .st-dot { background: var(--ok-weak); color: var(--ok); border-color: var(--ok); }
.st-label { font-size: 14px; font-weight: 600; color: var(--text-3); }
.st.active .st-label, .st.done .st-label { color: var(--text); }
.st-line { width: 48px; height: 2px; background: var(--border-strong); margin: 0 12px; }
.st.done + .st-line, .stepper .st.done ~ .st-line { background: var(--ok); }

/* ---------- 登录页 ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand {
  background: linear-gradient(150deg, var(--primary), color-mix(in srgb, var(--primary) 45%, #f0b25e));
  color: #fff; padding: 56px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-brand .deco { position: absolute; border-radius: 50%; background: rgba(255,255,255,.1); }
.auth-form-side { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 27px; font-weight: 800; margin: 0 0 6px; }
.auth-tab { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 24px 0; }
.auth-tab button { flex: 1; padding: 9px; border: none; background: none; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--text-2); font-family: inherit; transition: all .14s; }
.auth-tab button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.auth-feat { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 14.5px; }
.auth-feat .fk { width: 30px; height: 30px; border-radius: 9px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }

/* ---------- 应用运行页 ---------- */
.run-grid { display: grid; grid-template-columns: 1fr 380px; gap: 22px; align-items: start; }
.run-canvas { min-height: 420px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; position: relative; overflow: hidden; }
.run-result-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; padding: 18px; width: 100%; }
.run-out { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface); position: relative; }
.run-out image-slot { display: block; width: 100%; }
.run-out .ov { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.run-spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--primary-weak-2); border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-ico.spinning { animation: spin .7s linear infinite; }
.run-bar { width: 240px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 16px; }
.run-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* 输入计数胶囊 */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: none; background: none; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text-2); font-family: inherit; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .run-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .overlay { align-items: end; padding: 0; }
  .modal { max-width: none; max-height: min(92dvh, 760px); border-radius: 18px 18px 0 0; border-bottom: 0; }
  .modal-head { padding: 18px 18px 0; }
  .modal-body { padding: 16px 18px; }
  .modal-foot { padding: 14px 18px max(16px, env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .btn { min-height: 42px; }
  .drawer-wrap { align-items: stretch; }
  .drawer { width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; border-radius: 0; }

  .auth-form-side { align-items: start; padding: 32px 20px; }
  .auth-card { max-width: none; }
  .auth-card h1 { font-size: 24px; }
  .run-result-grid { grid-template-columns: 1fr; padding: 12px; }
  .run-canvas { min-height: 300px; }

  .toast-wrap { top: 10px; width: calc(100vw - 24px); }
  .toast { width: 100%; min-width: 0; }
  .cs-launcher { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); width: 52px; height: 52px; }
  .cs-panel { inset: 12px 12px max(12px, env(safe-area-inset-bottom)); width: auto; height: auto; max-width: none; max-height: none; }

  .stepper { align-items: flex-start; justify-content: space-between; }
  .stepper .st { min-width: 0; flex-direction: column; gap: 6px; text-align: center; }
  .st-label { font-size: 12px; }
  .st-line { flex: 1; width: auto; min-width: 10px; margin: 15px 5px 0; }
}

/* 打字指示 */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: typb 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typb { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
