/* ============================================================
   DeepChat — 浅色 / iMessage 气泡风格
   ============================================================ */

:root {
  color-scheme: light dark;

  --brand: #007aff;
  --brand-press: #0064d2;

  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f6;

  --text: #0b0b0f;
  --text-2: #6b6b76;
  --text-3: #9a9aa4;
  --line: #e5e5ea;

  --bubble-in: #ececef;
  --bubble-in-text: #0b0b0f;
  --bubble-out: #007aff;
  --bubble-out-text: #ffffff;

  --code-bg: #f4f4f7;

  --danger: #ff3b30;
  --ok: #34c759;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Helvetica Neue", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-soft: #111114;
    --surface: #17171a;
    --surface-2: #222227;
    --text: #f5f5f7;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --line: #2c2c31;
    --bubble-in: #2c2c2e;
    --bubble-in-text: #ffffff;
    --bubble-out: #0a84ff;
    --bubble-out-text: #ffffff;
    --code-bg: #1c1c20;
    --brand: #0a84ff;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: 16px; /* 低于 16px 时 iOS 会自动放大页面 */
  color: inherit;
}

button { cursor: pointer; }

/* ---------------- 骨架 ---------------- */

.app {
  display: flex;
  flex-direction: column;
  height: var(--app-h);
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

@media (min-width: 820px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(4px + var(--safe-top)) 6px 4px;
  min-height: 48px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
}

.topbar-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--brand);
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:active { background: var(--surface-2); transform: scale(0.94); }
.icon-btn.small { width: 32px; height: 32px; color: var(--text-2); }

/* ---------------- 消息区 ---------------- */

.chat-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }

/* ---------------- 空状态 ---------------- */

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  animation: fade-in 0.45s ease;
}
.empty[hidden] { display: none; }

.empty-mark {
  filter: drop-shadow(0 10px 24px rgba(10, 98, 216, 0.2));
  animation: float 6s ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.empty-mark:active { transform: scale(0.96); }
.empty-mark svg { display: block; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* ---------------- 气泡 ---------------- */

.msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  animation: bubble-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }

.bubble {
  max-width: 82%;
  padding: 9px 14px;
  border-radius: 19px;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
}

.msg.user .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.msg.assistant .bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 6px;
}

.msg.assistant .bubble.error {
  background: color-mix(in srgb, var(--danger) 10%, var(--bubble-in));
  color: var(--danger);
}

.msg-error {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--danger);
  font-weight: 500;
}

.msg-meta {
  font-size: 11.5px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  font-variant-numeric: tabular-nums;
}

/* 打字指示器 */
.typing { display: flex; gap: 4px; padding: 3px 2px; }
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: blink 1.3s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }

/* ---------------- Markdown 内容 ---------------- */

.bubble.md > *:first-child { margin-top: 0; }
.bubble.md > *:last-child { margin-bottom: 0; }

.bubble.md p { margin: 0 0 8px; }
.bubble.md h1, .bubble.md h2, .bubble.md h3,
.bubble.md h4, .bubble.md h5, .bubble.md h6 {
  margin: 14px 0 6px;
  line-height: 1.35;
  font-weight: 650;
}
.bubble.md h1 { font-size: 19px; }
.bubble.md h2 { font-size: 17.5px; }
.bubble.md h3 { font-size: 16.5px; }
.bubble.md h4, .bubble.md h5, .bubble.md h6 { font-size: 16px; }

.bubble.md ul, .bubble.md ol { margin: 0 0 8px; padding-left: 22px; }
.bubble.md li { margin: 2px 0; }

.bubble.md a { color: var(--brand); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); }
.msg.user .bubble.md a { color: #fff; }

.bubble.md blockquote {
  margin: 8px 0;
  padding: 2px 0 2px 11px;
  border-left: 3px solid color-mix(in srgb, var(--brand) 45%, transparent);
  color: var(--text-2);
}

.bubble.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.bubble.md img { max-width: 100%; border-radius: 10px; display: block; margin: 6px 0; }

.bubble.md code {
  font-family: var(--mono);
  font-size: 13.5px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  padding: 1.5px 5px;
  border-radius: 5px;
}
.msg.user .bubble code { background: rgba(255, 255, 255, 0.22); }

.code-wrap {
  margin: 10px 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
  border: 0.5px solid var(--line);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 0.5px solid var(--line);
}
.code-copy {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}
.code-copy:active { background: color-mix(in srgb, var(--brand) 14%, transparent); }

.code-wrap pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.code-wrap pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

/* ---------------- 消息操作 / 推理过程 ---------------- */

.msg-actions {
  display: flex;
  gap: 4px;
  margin: 2px 6px 0;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.msg-actions:hover { opacity: 1; }

.act-btn {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 8px;
}
.act-btn:active { background: var(--surface-2); }

/* 编辑已发送的消息 */
.msg.user .bubble.editing {
  width: 100%;
  max-width: 94%;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 45%, var(--line));
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  padding: 10px 12px 8px;
  white-space: normal;
}

.edit-input {
  width: 100%;
  min-height: 46px;
  max-height: 220px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 0;
}

.edit-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.edit-hint {
  flex: 1;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-3);
}

.edit-btn {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
}
.edit-btn:active { background: var(--surface-2); }

.edit-btn.primary {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.edit-btn.primary:active { background: var(--brand-press); }

.reasoning {
  max-width: 82%;
  margin-bottom: 5px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  border: 0.5px solid color-mix(in srgb, var(--brand) 18%, transparent);
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
}
.reasoning > summary {
  cursor: pointer;
  padding: 7px 12px;
  list-style: none;
  color: var(--brand);
  font-size: 12.5px;
  user-select: none;
}
.reasoning > summary::-webkit-details-marker { display: none; }
.reasoning > summary::before { content: "▸ "; display: inline-block; transition: transform 0.15s; }
.reasoning[open] > summary::before { transform: rotate(90deg); }
.reasoning-body {
  padding: 0 12px 9px;
  white-space: pre-wrap;
  line-height: 1.55;
  max-height: 240px;
  overflow-y: auto;
  -webkit-user-select: text;
  user-select: text;
}

/* ---------------- 输入区 ---------------- */

.composer {
  flex: 0 0 auto;
  padding: 6px 10px calc(4px + var(--safe-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--line);
  position: relative;
  z-index: 6;
}

.pill {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 5px 6px 5px 15px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 23px;
  transition: border-color 0.15s;
}
.pill:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }

#input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  padding: 7px 0;
  max-height: 132px;
  line-height: 1.42;
  font-size: 16.5px;
  color: var(--text);
}
#input::placeholder { color: var(--text-3); }

.send-btn {
  flex: 0 0 auto;
  width: 33px;
  height: 33px;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  transition: opacity 0.15s, transform 0.12s, background 0.15s;
}
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.3; transform: none; }
.send-btn.stop { background: var(--text-2); }

.composer-foot {
  margin: 4px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.01em;
}

/* ---------------- 附件 ---------------- */

.attach-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.attach-btn:active { background: var(--surface-2); color: var(--brand); }

.attachments {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.attachments::-webkit-scrollbar { display: none; }
.attachments[hidden] { display: none; }

.pending-chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 210px;
  padding: 5px 7px 5px 5px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  animation: bubble-in 0.18s ease;
}
.pending-chip img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex: 0 0 auto;
}
.pending-ico {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 16px;
}
.pending-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}
.pending-chip.uploading { opacity: 0.65; }
.pending-chip.error {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}
.pending-chip.error .pending-name { color: var(--danger); }

.pending-del {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* 消息里的附件 */
.att-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 84%;
  margin: 5px 2px 0;
  justify-content: flex-end;
}
.att-img {
  width: 116px;
  height: 116px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: block;
}
.att-file {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 230px;
  padding: 7px 10px;
  border-radius: 12px;
  background: var(--bubble-in);
  color: var(--text-2);
  font-size: 12.5px;
}
.att-file .att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- 抽屉 ---------------- */

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 330px);
  background: var(--surface);
  border-right: 0.5px solid var(--line);
  transform: translateX(-103%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 31;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  box-shadow: 6px 0 26px rgba(0, 0, 0, 0.1);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 10px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 12px;
  transition: background 0.15s;
}
.drawer-item:active { background: var(--surface-2); }
.drawer-item.active { background: color-mix(in srgb, var(--brand) 12%, transparent); }

.drawer-item-main {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  text-align: left;
  padding: 0;
  color: var(--text);
}
.drawer-item-title {
  display: block;
  font-size: 14.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-item-meta {
  display: block;
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 1px;
}

.drawer-del {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.drawer-del:active { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.drawer-edit {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.drawer-edit:active { background: var(--surface-2); color: var(--brand); }

@media (hover: hover) {
  .drawer-item .drawer-edit:hover {
    background: color-mix(in srgb, var(--brand) 10%, transparent);
    color: var(--brand);
  }
  .drawer-item:hover .drawer-del { color: var(--text-2); }
  .drawer-item .drawer-del:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
  }
  .act-btn:hover { background: var(--surface-2); color: var(--text-2); }
  .act-btn[data-act="del"]:hover { color: var(--danger); }
}

.drawer-empty {
  padding: 28px 18px;
  font-size: 13.5px;
  color: var(--text-3);
  text-align: center;
}

.drawer-foot { padding: 10px 14px; border-top: 0.5px solid var(--line); }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 30;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}
.scrim.open { opacity: 1; }
.scrim[hidden] { display: none; }

/* ---------------- 设置面板 ---------------- */

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 780px;
  margin: 0 auto;
  /* 跟随可视视口，键盘弹出时面板不会顶到键盘后面 */
  max-height: calc(var(--app-h, 100dvh) - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 0.5px solid var(--line);
  transform: translateY(103%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 41;
  padding-bottom: calc(18px + var(--safe-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}
.sheet.open { transform: none; }

.sheet-grip {
  width: 36px;
  height: 4.5px;
  border-radius: 3px;
  background: var(--line);
  margin: 8px auto 2px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 6px 18px;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; }

.sheet-body { padding: 4px 18px 0; }

.field { display: block; margin-bottom: 18px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field-label b { color: var(--brand); font-variant-numeric: tabular-nums; }

.field input[type="password"],
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' fill='none' stroke='%238a8a94' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 34px;
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 60%, var(--line));
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
  margin: 2px 0 0;
}

.key-row { display: flex; gap: 7px; }
.key-row input { flex: 1; min-width: 0; }

.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-3);
}

.sheet-actions { margin: 4px 0 16px; }

.primary-btn {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 13px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.12s, background 0.15s;
}
.primary-btn:active { transform: scale(0.985); background: var(--brand-press); }

.ghost-btn {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--brand);
  font-size: 13.5px;
  white-space: nowrap;
}
.ghost-btn:active { background: var(--surface-2); }
.ghost-btn.wide { width: 100%; text-align: center; }
.ghost-btn.danger { color: var(--danger); }

.divider { height: 0.5px; background: var(--line); margin: 4px 0 16px; }

.data-actions { display: flex; flex-direction: column; gap: 9px; }

.sheet-foot {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

/* ---------------- Toast / 确认框 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 14px);
  max-width: 88vw;
  padding: 11px 16px;
  border-radius: 13px;
  background: rgba(28, 28, 32, 0.94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 60;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-action { pointer-events: auto; }

.toast-action {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: #7cc4ff;
  font-size: 13.5px;
  font-weight: 650;
  padding: 2px 2px;
  white-space: nowrap;
}
.toast-action:active { opacity: 0.7; }

.confirm {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.confirm.open { opacity: 1; pointer-events: auto; }

.confirm-card {
  width: 100%;
  max-width: 310px;
  padding: 20px 18px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.24);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.confirm.open .confirm-card { transform: none; }

.confirm-card h3 { margin: 0 0 7px; font-size: 16.5px; font-weight: 650; }
.confirm-card p {
  margin: 0 0 17px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.confirm-card p[hidden] { display: none; }

.confirm-actions { display: flex; gap: 9px; }
.confirm-actions .ghost-btn { flex: 1; padding: 11px; font-size: 15px; text-align: center; }

.danger-btn {
  flex: 1;
  padding: 11px;
  border: 0;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.danger-btn:active { filter: brightness(0.93); }

.confirm-input {
  width: 100%;
  margin: 0 0 16px;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.confirm-input:focus { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.confirm-input[hidden] { display: none; }

/* ---------------- 动画 ---------------- */

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
