/* ============================================================
   DSH 口袋 · 深色主题（对齐 DSH Web GUI 的 token 与观感）
   ============================================================ */

@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat-medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Montserrat";
  src: url("/fonts/montserrat-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #151517;
  --bg-soft: #1b1b1c;
  --surface: #232324;
  --surface-2: #2c2c2e;
  --surface-3: #353638;
  --text: #f9fafb;
  --text-2: #cfd3d6;
  --text-3: #adb2b8;
  --text-4: #7f8287;
  --text-5: #61666b;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --line-3: rgba(255, 255, 255, .17);
  --blue: #4d93f8;
  --blue-2: #7aaaff;
  --green: #4ed17e;
  --red: #f25a5a;
  --violet: #a78bfa;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono",
    Menlo, Courier, "PingFang SC", "Microsoft YaHei";
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #3c3c3d; border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 14px 0;
  background: rgba(21, 21, 23, .86);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark { width: 26px; height: 26px; color: var(--text); flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-line { display: flex; align-items: baseline; gap: 6px; }
.brand-word {
  font-family: "Montserrat", var(--font);
  font-size: 13px; font-weight: 500;
  letter-spacing: .18em;
  color: var(--text);
}
.brand-cn { font-size: 11px; color: var(--text-4); letter-spacing: .04em; }
.conn { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-4); }
.conn .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-5); flex: 0 0 auto;
  transition: background .2s;
}
.conn.online .dot { background: var(--green); }
.conn.busy .dot { background: var(--blue-2); animation: blink 1.2s infinite; }
.conn.offline .dot { background: var(--red); }
@keyframes blink { 50% { opacity: .3; } }

.top-actions { display: flex; gap: 2px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background .15s, color .15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------------- 提示条 ---------------- */
.banner {
  flex: 0 0 auto;
  margin: 10px 14px 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  display: flex; align-items: center; gap: 8px;
}
.banner.error { border-color: rgba(242, 90, 90, .28); color: #f2a6a6; }
.banner > span { flex: 1; min-width: 0; }
.banner .b-act { color: var(--blue-2); font-weight: 500; white-space: nowrap; }

/* 新版本提示 */
.update-banner {
  flex: 0 0 auto;
  margin: 10px 14px 0;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, rgba(77, 147, 248, .14), rgba(77, 147, 248, .05));
  border: 1px solid rgba(77, 147, 248, .28);
  color: var(--text-2);
}
.update-copy {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 0; border: 0; background: none; text-align: left;
  color: inherit; font: inherit; cursor: pointer;
}
.update-copy:active { opacity: .82; }
.update-copy b { font-size: 12.5px; font-weight: 500; color: var(--text); }
.update-copy span { font-size: 11px; color: var(--text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.update-copy .update-more {
  margin-left: 4px; padding: 0; color: var(--blue-2);
  font-size: 10.5px; font-weight: 500; white-space: nowrap;
}
.update-download {
  flex: 0 0 auto; padding: 6px 11px; border-radius: 8px;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 500;
}
.update-x {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  color: var(--text-4); font-size: 16px; line-height: 1;
}
.update-x:hover { background: rgba(255, 255, 255, .07); color: var(--text-2); }
.update-sheet-panel { padding-bottom: calc(24px + var(--safe-bottom)); }
.update-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.update-detail-head h2 { margin: 0; font-size: 16px; line-height: 1.4; }
.update-detail-head h2 span { color: var(--blue-2); font-weight: 500; }
.update-detail-notes {
  margin: 12px 0 18px;
  padding: 12px 13px;
  max-height: 42vh;
  max-height: 42dvh;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.75;
}
.b-close {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-4);
  font-size: 15px; line-height: 1;
}
.b-close:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- 消息流 ---------------- */
.feed {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 14px 28px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.feed::-webkit-scrollbar { width: 0; }

.empty {
  min-height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 4px;
  padding: 20px 12px 48px;
  animation: fade .25s ease both;
}
.empty-mark { width: 54px; height: 54px; color: var(--text); opacity: .92; margin-bottom: 14px; }
.empty h2 { margin: 0 0 6px; font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.empty p { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.8; }
.empty-chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 22px; }
.chip {
  padding: 7px 12px; border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  color: var(--text-2); font-size: 12px;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--line-3); background: var(--surface); }
.chip:active { transform: scale(.98); }

/* ---------------- 对话轮次 ---------------- */
.task {
  max-width: 760px;
  margin: 0 auto 30px;
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 用户：右侧气泡，像 DSH 的提问 */
.ask-wrap { display: flex; flex-direction: column; align-items: flex-end; margin-bottom: 14px; }
.ask {
  max-width: 86%;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 16px 16px 5px 16px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.ask .q { display: none; }
.ask-meta { margin-top: 6px; font-size: 10.5px; color: var(--text-5); }

/* 助手：无卡片，直接铺在背景上 */
.task-body { padding: 0; }

.live-phase {
  display: flex; align-items: center; gap: 8px;
  margin-top: 2px;
  font-size: 12px; color: var(--text-3);
}
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--line-2);
  border-top-color: var(--blue-2);
  animation: spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 思考 */
.thinking { margin-top: 6px; }
.thinking summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 2px;
  font-size: 12px; color: var(--text-3);
  user-select: none;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { color: var(--text-2); }
.thinking summary svg { width: 12px; height: 12px; color: var(--text-5); transition: transform .15s; }
.thinking[open] summary svg { transform: rotate(90deg); }
.thinking summary .tg { margin-left: auto; font-size: 10.5px; color: var(--text-5); }
.thinking-text {
  margin: 2px 0 4px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 11.5px; line-height: 1.65;
  color: var(--text-3);
  white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow-y: auto;
}
.thinking-text:empty::after { content: "…"; }

/* 工具 */
.tools { margin-top: 4px; }
.tool { border-radius: 8px; }
.tool-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px;
  font-size: 12px;
  border-radius: 8px;
  cursor: pointer;
}
.tool-row:hover { background: rgba(255, 255, 255, .035); }
.tool-ico { width: 15px; height: 15px; color: var(--text-4); flex: 0 0 auto; display: grid; place-items: center; }
.tool-ico svg { width: 13px; height: 13px; }
.tool-name { font-family: var(--mono); color: var(--text-2); font-weight: 500; flex: 0 0 auto; }
.tool-arg {
  color: var(--text-5); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.tool-state { font-size: 10.5px; color: var(--text-5); flex: 0 0 auto; }
.tool.running .tool-state { color: var(--blue-2); }
.tool.failed .tool-state { color: var(--red); }
.tool-preview {
  display: none;
  margin: 2px 6px 8px;
  padding: 9px 11px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 10.5px; line-height: 1.55;
  color: var(--text-3);
  white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow-y: auto;
}
.tool.open .tool-preview { display: block; }

/* 结果 Markdown */
.answer { margin-top: 10px; font-size: 14.5px; line-height: 1.8; color: var(--text); }
.answer:empty { display: none; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 12px; }
.answer h1, .answer h2, .answer h3 { margin: 22px 0 10px; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; }
.answer h1 { font-size: 20px; }
.answer h2 { font-size: 17px; }
.answer h3 { font-size: 15px; }
.answer ul, .answer ol { margin: 0 0 12px; padding-left: 22px; }
.answer li { margin: 4px 0; }
.answer li::marker { color: var(--text-5); }
.answer code {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface);
  color: #9db9ff;
  padding: .12em .36em;
  border-radius: 5px;
}
.answer pre {
  margin: 12px 0; padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12px; line-height: 1.65;
}
.answer pre code { background: none; padding: 0; color: var(--text-2); font-size: 12px; }
.answer blockquote {
  margin: 12px 0; padding: 2px 0 2px 12px;
  border-left: 2px solid var(--line-2);
  color: var(--text-3);
}
.answer a { color: var(--blue-2); text-decoration: none; }
.answer a:hover { text-decoration: underline; }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.answer table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 12.5px; }
.answer th, .answer td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.answer th { background: var(--bg-soft); font-weight: 500; color: var(--text-2); white-space: nowrap; }

@media (max-width: 620px) {
  .answer table { display: block; border: 0; }
  .answer thead { display: none; }
  .answer tbody { display: block; }
  .answer tr {
    display: block; margin: 0 0 9px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg-soft); overflow: hidden;
  }
  .answer td {
    display: flex; gap: 10px;
    border: 0; border-bottom: 1px solid var(--line);
    padding: 8px 11px; text-align: left;
  }
  .answer tr td:last-child { border-bottom: 0; }
  .answer td::before {
    content: attr(data-label);
    flex: 0 0 64px;
    color: var(--text-5); font-size: 11px; line-height: 1.8;
    word-break: break-word;
  }
  .answer td > .cell { flex: 1; min-width: 0; word-break: break-word; }
  .answer td:empty { display: none; }
}

.error-box {
  margin-top: 10px; padding: 9px 12px;
  border-radius: 10px;
  background: rgba(242, 90, 90, .07);
  border: 1px solid rgba(242, 90, 90, .22);
  color: #f2a6a6;
  font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
}

/* 轮次底部：状态 + 操作 */
.task-foot {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; min-height: 24px;
  flex-wrap: wrap;
}
.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-4);
  background: none; border: 0; padding: 0;
  white-space: nowrap;
}
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.queued { color: var(--text-5); }
.status.running { color: var(--blue-2); }
.status.running::before { animation: blink 1s infinite; }
.status.done { color: var(--green); }
.status.error, .status.canceled { color: var(--red); }
.meta { font-size: 10.5px; color: var(--text-5); margin-left: 2px; }
.foot-spacer { flex: 1; }
.tbtn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 8px;
  border-radius: 7px;
  font-size: 11.5px; color: var(--text-4);
  transition: background .15s, color .15s;
}
.tbtn:hover { background: rgba(255, 255, 255, .05); color: var(--text-2); }
.tbtn svg { width: 13px; height: 13px; }
.tbtn.danger { color: #f28b8b; }
.tbtn.danger:hover { background: rgba(242, 90, 90, .1); }

/* ---------------- 输入区 ---------------- */
.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 55%, rgba(21, 21, 23, 0));
  position: relative;
  z-index: 9;
}
.composer-wrap { max-width: 760px; margin: 0 auto; }
.composer-inner {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 10px 10px 8px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .32);
  transition: border-color .15s;
}
.composer-inner:focus-within { border-color: rgba(122, 170, 255, .42); }
.attachment-strip {
  display: flex; gap: 7px; overflow-x: auto;
  padding: 1px 0 8px;
  scrollbar-width: none;
}
.attachment-strip::-webkit-scrollbar { display: none; }
.att-chip {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  max-width: 190px;
  padding: 4px 5px 4px 4px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
}
.att-chip img {
  width: 30px; height: 30px; border-radius: 6px;
  object-fit: cover; background: var(--surface-3);
}
.att-chip .att-icon {
  width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
}
.att-chip .att-icon svg { width: 15px; height: 15px; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-x {
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-4); flex: 0 0 auto;
}
.att-x:hover { background: rgba(255,255,255,.08); color: var(--text); }
.att-x svg { width: 11px; height: 11px; }
.ask-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ask-att {
  max-width: 100%; padding: 3px 8px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(255,255,255,.035);
  color: var(--text-3); font-size: 11.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#input {
  display: block;
  width: 100%; min-width: 0;
  border: 0; outline: 0; background: none; resize: none;
  font-size: 15px; line-height: 1.55;
  color: var(--text);
  padding: 2px 0 6px;
  max-height: 140px;
}
#input::placeholder { color: var(--text-4); }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.bar-spacer { flex: 1; }
.cbtn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  display: grid; place-items: center;
  flex: 0 0 auto;
  transition: background .15s;
}
.cbtn:hover { background: var(--surface-3); }
.cbtn svg { width: 15px; height: 15px; }
.tag-pill {
  font-size: 11px; color: var(--text-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 4px 9px;
  background: none;
  white-space: nowrap;
}
.tag-pill:hover { border-color: var(--line-3); color: var(--text-2); }
.model-pill {
  font-size: 11px; color: var(--text-4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 128px;
}
.send {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  flex: 0 0 auto;
  transition: background .15s, transform .1s;
}
.send svg { width: 17px; height: 17px; stroke-width: 2.2; }
.send:hover { background: #5c9cf9; }
.send:active { transform: scale(.94); }
.send:disabled { background: var(--blue); color: #fff; opacity: .42; cursor: default; }
.composer-hint {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 8px 0;
  font-size: 10.5px; color: var(--text-5);
}
.session-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbd-hint { white-space: nowrap; }
@media (max-width: 380px) { .kbd-hint { display: none; } }

.jump {
  position: fixed; right: 14px; bottom: calc(150px + var(--safe-bottom));
  z-index: 12;
  padding: 7px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--blue-2); font-size: 11.5px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
  animation: fade .2s ease both;
}

/* ---------------- 配对页 ---------------- */
.setup {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: calc(28px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
  background: var(--bg);
}
.setup-card {
  width: min(410px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  animation: fade .25s ease both;
  text-align: center;
}
.setup-brand { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 16px; }
.setup-mark { width: 30px; height: 30px; color: var(--text); }
.setup-brand .brand-word { font-size: 14px; }
.setup-card h1 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.setup-sub { margin: 0 0 22px; color: var(--text-3); font-size: 12.5px; line-height: 1.75; }
.setup-sub code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface); color: var(--text-2);
  padding: 1px 5px; border-radius: 5px;
}
.field { display: block; text-align: left; margin-bottom: 13px; }
.field span { display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 15px; outline: 0;
  color: var(--text);
  transition: border-color .15s;
}
.field input::placeholder { color: var(--text-5); }
.field input:focus { border-color: rgba(122, 170, 255, .55); }
.primary {
  width: 100%; margin-top: 8px;
  padding: 12px; border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600; font-size: 14px; letter-spacing: .04em;
  transition: opacity .15s;
}
.primary:hover { opacity: .9; }
.primary:active { transform: scale(.99); }
.primary:disabled { opacity: .5; }
.setup-error {
  margin: 0 0 10px; padding: 8px 11px;
  background: rgba(242, 90, 90, .07);
  border: 1px solid rgba(242, 90, 90, .22);
  border-radius: 8px;
  color: #f2a6a6; font-size: 12px; text-align: left;
}
.setup-foot { margin: 16px 0 0; font-size: 10.5px; color: var(--text-5); line-height: 1.7; }

/* ---------------- 抽屉 / 面板 ---------------- */
.drawer, .sheet { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop, .sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .55);
  animation: fadeIn .15s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(84vw, 330px);
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slideRight .2s cubic-bezier(.22, .8, .3, 1) both;
  padding-top: var(--safe-top);
}
@keyframes slideRight { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; }
.drawer-head h2 { margin: 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.history-list { flex: 1; overflow-y: auto; padding: 2px 8px 24px; }
.h-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 8px; margin-bottom: 1px;
  border: 1px solid transparent;
}
.h-item:hover { background: var(--surface); }
.h-item.active { background: var(--surface); border-color: var(--line); }
.h-item b {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px; font-weight: 500; line-height: 1.5; color: var(--text-2);
}
.h-item span { display: block; margin-top: 3px; font-size: 10.5px; color: var(--text-5); }

.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 86vh;
  max-height: 86dvh; overflow-y: auto;
  background: var(--bg-soft);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--line-2);
  padding: 8px 18px calc(20px + var(--safe-bottom));
  animation: slideUp .22s cubic-bezier(.22, .8, .3, 1) both;
}
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-grab { width: 34px; height: 3px; border-radius: 99px; background: var(--surface-3); margin: 6px auto 12px; }
.sheet-panel h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setting-row b { font-size: 13px; font-weight: 500; color: var(--text-2); }
.setting-row span { font-size: 11px; color: var(--text-5); overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere; }
.badge {
  font-size: 10px; color: var(--text-3);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 7px;
}
.mini {
  padding: 5px 10px; border-radius: 7px;
  font-size: 11.5px;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  background: none;
}
.mini:hover { background: var(--surface); }
.wide {
  display: block; width: 100%; margin-top: 10px;
  padding: 12px; border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text-2); font-size: 13px;
  text-align: center;
}
.wide:hover { background: var(--surface-2); }
.wide.danger { color: #f28b8b; border-color: rgba(242, 90, 90, .2); background: none; }
.about { margin: 18px 0 0; text-align: center; font-size: 10.5px; color: var(--text-5); line-height: 1.7; }

.switch { position: relative; width: 40px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--surface-3);
  transition: background .18s;
  pointer-events: none;
}
.switch i::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #d5d7da;
  transition: transform .18s, background .18s;
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(16px); background: #fff; }

/* ---------------- Toast ---------------- */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(66px + var(--safe-top));
  z-index: 60; display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  width: min(88vw, 400px);
  pointer-events: none;
}
.toast {
  padding: 8px 12px; border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  font-size: 11.5px; text-align: center; color: var(--text-2);
  animation: fade .18s ease both;
  white-space: nowrap;
}
.toast.ok::before, .toast.bad::before {
  content: ""; display: inline-block;
  width: 5px; height: 5px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px;
}
.toast.ok::before { background: var(--green); }
.toast.bad::before { background: var(--red); }
.toast.ok { color: var(--text-2); }
.toast.bad { color: #f2a6a6; }

@media (min-width: 720px) {
  .feed { padding-left: 24px; padding-right: 24px; }
}
