/* =========================================================
   QChat — a mobile-first, QQ-flavoured AI chat client
   ========================================================= */

:root {
  color-scheme: light;
  --blue: #0a8ff0;
  --blue-2: #12b7f5;
  --blue-deep: #056fd3;
  --blue-soft: rgba(10, 143, 240, .09);
  --blue-softer: rgba(10, 143, 240, .055);
  --green: #1fc66b;
  --red: #ff5a5f;
  --red-soft: rgba(255, 90, 95, .1);
  --orange: #ff9d3c;
  --violet: #8b6df6;
  --bg: #edf1f6;
  --surface: #ffffff;
  --surface-2: #f3f6fa;
  --surface-3: #e9eef5;
  --text: #1d2430;
  --text-2: #4d5869;
  --muted: #8a94a4;
  --line: rgba(23, 39, 64, .075);
  --line-strong: rgba(23, 39, 64, .12);
  --chat-bg: #eef2f7;
  --bubble-in: #ffffff;
  --bubble-in-text: #202733;
  --bubble-out: linear-gradient(135deg, #1db9ff 0%, #0b8ff0 52%, #0879e2 100%);
  --shadow-sm: 0 1px 2px rgba(23, 39, 64, .04), 0 4px 12px rgba(23, 39, 64, .035);
  --shadow-md: 0 8px 30px rgba(16, 35, 61, .09);
  --shadow-lg: 0 28px 70px rgba(14, 32, 56, .22);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --blue: #37b6ff;
  --blue-2: #45c4ff;
  --blue-deep: #1b9bee;
  --blue-soft: rgba(55, 182, 255, .13);
  --blue-softer: rgba(55, 182, 255, .07);
  --red: #ff7075;
  --red-soft: rgba(255, 112, 117, .13);
  --bg: #0a0f17;
  --surface: #141b25;
  --surface-2: #1c2430;
  --surface-3: #232d3a;
  --text: #e9eff8;
  --text-2: #bdc8d7;
  --muted: #8592a5;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .12);
  --chat-bg: #0c121a;
  --bubble-in: #1a222e;
  --bubble-in-text: #e7edf6;
  --bubble-out: linear-gradient(135deg, #1aa8ec 0%, #0b7cdb 60%, #0868c4 100%);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .2), 0 4px 12px rgba(0, 0, 0, .14);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, .32);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #e6ecf5;
  overflow: hidden;
}
[data-theme="dark"] body { background: #05080d; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(42vw 42vw at 12% 8%, rgba(18, 183, 245, .18), transparent 62%),
    radial-gradient(38vw 38vw at 88% 92%, rgba(118, 98, 255, .13), transparent 62%),
    linear-gradient(140deg, #f5f8fc 0%, #e7edf6 55%, #eef3f9 100%);
}
[data-theme="dark"] body::before {
  background:
    radial-gradient(42vw 42vw at 10% 5%, rgba(12, 126, 210, .22), transparent 64%),
    radial-gradient(38vw 38vw at 92% 95%, rgba(94, 77, 200, .16), transparent 62%),
    linear-gradient(150deg, #080d14 0%, #05080d 60%, #080d14 100%);
}

button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { cursor: default; }
input, textarea { border: 0; outline: 0; }
svg { display: block; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
::selection { background: rgba(18, 183, 245, .25); }

.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.chevron { width: 18px; height: 18px; color: var(--muted); stroke-width: 2; }

/* ---------- App shell ---------- */
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.overlay-screen {
  z-index: 30;
  animation: screenInRight .28s cubic-bezier(.32, .72, 0, 1) both;
}
@keyframes screenInRight {
  from { transform: translateX(22px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- Common bits ---------- */
.eyebrow {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.2px;
  color: rgba(255, 255, 255, .64);
  margin-bottom: 1px;
}
.eyebrow-dark { color: var(--blue); }
.eyebrow-light { color: rgba(255, 255, 255, .68); }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background .18s, transform .18s;
}
.icon-btn:active { transform: scale(.93); }
.icon-btn .icon { width: 21px; height: 21px; }
.on-blue { color: #fff; background: rgba(255, 255, 255, .15); border: 1px solid rgba(255, 255, 255, .16); }
.on-blue:hover { background: rgba(255, 255, 255, .23); }
.on-light { color: var(--text-2); }
.on-light:hover { background: var(--surface-2); }
.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--surface-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.avatar svg { width: 100%; height: 100%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.assistant-avatar { box-shadow: 0 4px 14px rgba(7, 117, 213, .22); }
.small-avatar { width: 38px; height: 38px; }
.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 21px;
  background: linear-gradient(135deg, #ffb45f, #ff6b7a);
  box-shadow: 0 4px 14px rgba(255, 107, 122, .24);
}

/* ---------- Home ---------- */
.home-screen { background: var(--bg); }
.home-header {
  position: relative;
  flex: none;
  padding: calc(15px + var(--safe-top)) 20px 36px;
  color: #fff;
  background: linear-gradient(133deg, #22c7ff 0%, #0b93f4 48%, #0878df 100%);
  overflow: hidden;
}
.home-header::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  right: -130px;
  top: 50px;
  background: radial-gradient(circle, rgba(255, 255, 255, .15), transparent 68%);
  pointer-events: none;
}
.home-header-glow {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  left: -64px;
  top: -82px;
  background: rgba(117, 224, 255, .34);
  filter: blur(2px);
}
.home-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.home-heading h1 {
  margin: 0;
  font-size: 29px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.7px;
}
.search-fake {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 41px;
  margin-top: 17px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .93);
  color: #788597;
  font-size: 13px;
  text-align: left;
  box-shadow: 0 5px 18px rgba(3, 74, 140, .13);
  transition: background .2s, transform .2s;
}
.search-fake:active { transform: scale(.99); background: #fff; }
.search-fake .icon { width: 18px; height: 18px; stroke-width: 2; color: #7b8a9e; }
[data-theme="dark"] .search-fake { background: rgba(255, 255, 255, .13); color: rgba(255, 255, 255, .72); box-shadow: none; }
[data-theme="dark"] .search-fake .icon { color: rgba(255, 255, 255, .7); }

.home-body {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  margin-top: -22px;
  padding-bottom: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -12px 32px rgba(7, 64, 119, .09);
  scrollbar-width: none;
}
.home-body::-webkit-scrollbar { display: none; }
.setup-banner {
  margin: 16px 16px 2px;
  padding: 13px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(10, 143, 240, .13);
  border-radius: 17px;
  background: linear-gradient(120deg, rgba(18, 183, 245, .11), rgba(93, 124, 255, .075));
}
.setup-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #29c7ff, #0a88ee);
  box-shadow: 0 4px 10px rgba(10, 143, 240, .23);
  flex: none;
}
.setup-icon .icon { width: 19px; height: 19px; }
.setup-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.setup-copy strong { font-size: 13px; font-weight: 700; }
.setup-copy span { font-size: 11px; color: var(--muted); }
.banner-btn {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(10, 143, 240, .22);
}
.list-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 19px 18px 7px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}
.list-label span:last-child { font-size: 10.5px; color: var(--muted); opacity: .8; }
.thread {
  width: 100%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--line);
  transition: background .16s;
}
.thread:hover { background: var(--surface-2); }
.thread:active { background: var(--blue-softer); }
.thread-avatar { position: relative; flex: none; display: inline-flex; }
.online-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  right: -1px;
  bottom: 1px;
  border-radius: 50%;
  background: var(--green);
  border: 2.5px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(31, 198, 107, .12);
}
.thread-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.thread-top, .thread-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.thread-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15.5px; font-weight: 650; color: var(--text); }
.thread-time { flex: none; font-size: 10.5px; color: var(--muted); }
.pin-tag {
  font-size: 8.5px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 600;
  letter-spacing: .2px;
}
.thread-preview {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-preview.is-typing { color: var(--blue); }
.unread-badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(255, 90, 95, .3);
}
.home-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 18px 18px 4px;
  color: var(--muted);
  font-size: 10.5px;
}
.home-tip .icon { width: 13px; height: 13px; stroke-width: 2; }
.home-feature {
  position: relative;
  margin: 16px;
  padding: 21px 19px;
  min-height: 148px;
  border-radius: 22px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #0c1e35 0%, #0b2c50 58%, #0b4b82 100%);
  box-shadow: 0 14px 30px rgba(8, 39, 74, .17);
}
[data-theme="dark"] .home-feature { background: linear-gradient(135deg, #0e1d30 0%, #0d2945 58%, #0a3d66 100%); box-shadow: none; border: 1px solid rgba(255, 255, 255, .06); }
.feature-orb {
  position: absolute;
  width: 190px;
  height: 190px;
  right: -72px;
  top: -80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 55%, rgba(40, 201, 255, .58), rgba(16, 104, 211, .12) 60%, transparent 72%);
}
.feature-copy { position: relative; z-index: 2; max-width: 78%; }
.feature-kicker { font-size: 8.5px; letter-spacing: 1.9px; color: rgba(255, 255, 255, .48); font-weight: 700; }
.feature-copy h2 { margin: 9px 0 8px; font-size: 18px; line-height: 1.46; font-weight: 700; letter-spacing: -.3px; }
.feature-copy p { margin: 0; font-size: 10.5px; color: rgba(255, 255, 255, .53); line-height: 1.6; }
.feature-avatar {
  position: absolute;
  z-index: 2;
  right: 16px;
  bottom: 15px;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  overflow: hidden;
  transform: rotate(5deg);
  border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .25);
}
.feature-avatar svg { width: 100%; height: 100%; }
.feature-avatar img { width: 100%; height: 100%; object-fit: cover; }
.home-guide {
  margin: 0 16px 18px;
  padding: 2px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.guide-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.guide-row:last-child { border-bottom: 0; }
.guide-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--blue);
  background: var(--blue-soft);
}
.guide-icon .icon { width: 15px; height: 15px; }
.guide-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.guide-copy strong { font-size: 11.5px; font-weight: 650; color: var(--text-2); }
.guide-copy small { font-size: 9.5px; color: var(--muted); }

/* ---------- Tab bar ---------- */
.tabbar {
  flex: none;
  display: flex;
  align-items: stretch;
  height: calc(58px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 5;
}
@supports not (background: color-mix(in srgb, #fff 90%, transparent)) {
  .tabbar { background: var(--surface); }
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  transition: color .18s;
}
.tab .icon { width: 22px; height: 22px; stroke-width: 1.8; }
.tab.is-active { color: var(--blue); font-weight: 600; }
.tab.is-active .icon { stroke-width: 2.2; }
.tab:active { opacity: .65; }

/* ---------- Plain tab pages ---------- */
.tab-screen { background: var(--bg); }
.plain-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(18px + var(--safe-top)) 20px 14px;
  background: var(--surface);
}
.plain-header h1 { margin: 0; font-size: 27px; line-height: 1.2; font-weight: 800; letter-spacing: -.6px; }
.tab-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(26px + var(--safe-bottom));
}
.section-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 3px 9px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
}
.section-caption span { color: var(--muted); font-size: 10px; font-weight: 500; opacity: .8; }
.contact-card, .connection-card, .menu-group, .about-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.contact-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  border-radius: 19px;
  text-align: left;
  margin-bottom: 21px;
}
.contact-card:active { background: var(--surface-2); }
.contact-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.contact-name { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 650; }
.online-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(31, 198, 107, .1);
  color: #13a957;
  font-size: 9px;
  font-weight: 600;
}
[data-theme="dark"] .online-pill { color: #5bdf9a; }
.contact-desc { font-size: 11.5px; color: var(--muted); }
.connection-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  border-radius: 17px;
  text-align: left;
  margin-bottom: 18px;
}
.connection-card:active { background: var(--surface-2); }
.connection-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  flex: none;
}
.connection-icon .icon { width: 19px; height: 19px; }
.connection-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.connection-title { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; }
.status-pill {
  font-size: 8.5px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 600;
}
.status-pill.is-on { color: #13a957; background: rgba(31, 198, 107, .1); }
[data-theme="dark"] .status-pill.is-on { color: #5bdf9a; }
.connection-meta { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.privacy-card {
  display: flex;
  gap: 11px;
  padding: 14px;
  border-radius: 17px;
  border: 1px solid var(--blue-soft);
  background: linear-gradient(130deg, var(--blue-soft), transparent 140%);
}
.privacy-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--blue);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.privacy-icon .icon { width: 17px; height: 17px; }
.privacy-card strong { font-size: 12.5px; font-weight: 650; }
.privacy-card p { margin: 4px 0 0; color: var(--muted); font-size: 10.8px; line-height: 1.65; }
.tab-footnote { margin: 22px 4px 0; text-align: center; color: var(--muted); font-size: 10px; line-height: 1.6; opacity: .8; }

/* ---------- Me ---------- */
.me-screen { background: var(--bg); }
.me-body { padding: 0; }
.me-hero {
  position: relative;
  padding: calc(16px + var(--safe-top)) 20px 24px;
  color: #fff;
  background: linear-gradient(136deg, #20c6ff 0%, #0a90f1 50%, #0875dd 100%);
  border-radius: 0 0 28px 28px;
  overflow: hidden;
  flex: none;
}
.me-hero-glow {
  position: absolute;
  width: 230px;
  height: 230px;
  right: -100px;
  bottom: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 68%);
}
.me-top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; }
.me-profile {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  text-align: left;
  color: #fff;
}
.me-avatar { width: 64px; height: 64px; border: 2.5px solid rgba(255, 255, 255, .44); font-size: 25px; box-shadow: 0 8px 22px rgba(0, 45, 100, .23); }
.me-profile-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.me-name { font-size: 21px; font-weight: 750; letter-spacing: -.3px; }
.me-signature { font-size: 11.5px; color: rgba(255, 255, 255, .67); }
.me-profile .chevron { color: rgba(255, 255, 255, .55); }
.me-stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, .15);
  background: rgba(255, 255, 255, .11);
  border-radius: 17px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
}
.me-stats > div { padding: 11px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.me-stats > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  height: 56%;
  width: 1px;
  background: rgba(255, 255, 255, .16);
}
.me-stats strong { font-size: 15px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-stats span { font-size: 9px; color: rgba(255, 255, 255, .6); }
.me-content { position: relative; z-index: 3; padding: 16px 16px calc(28px + var(--safe-bottom)); margin-top: -10px; }
.menu-group { border-radius: 19px; overflow: hidden; margin-bottom: 13px; }
.menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.menu-row:last-child { border-bottom: 0; }
.menu-row:active { background: var(--surface-2); }
.menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: none;
}
.menu-icon .icon { width: 18px; height: 18px; }
.menu-icon.blue { color: #0a8ff0; background: rgba(10, 143, 240, .1); }
.menu-icon.violet { color: #7c63ee; background: rgba(124, 99, 238, .1); }
.menu-icon.orange { color: #f08a26; background: rgba(240, 138, 38, .1); }
.menu-icon.green { color: #12b66a; background: rgba(18, 182, 106, .1); }
.menu-icon.red { color: #f05058; background: rgba(240, 80, 88, .09); }
.menu-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.menu-copy strong { font-size: 13.5px; font-weight: 600; }
.menu-copy small { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.about-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 18px;
  text-align: left;
  margin-top: 16px;
}
.about-card:active { background: var(--surface-2); }
.about-logo { width: 36px; height: 36px; border-radius: 10px; overflow: hidden; flex: none; }
.about-logo svg { width: 100%; height: 100%; }
.about-copy { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.about-copy strong { font-size: 13px; font-weight: 650; }
.about-copy small { font-size: 10px; color: var(--muted); }

/* ---------- Chat ---------- */
.chat-screen {
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 15% 8%, rgba(18, 183, 245, .075), transparent 35%),
    radial-gradient(circle at 88% 88%, rgba(116, 95, 245, .055), transparent 38%),
    radial-gradient(rgba(31, 53, 84, .055) 1px, transparent 1px);
  background-size: auto, auto, 18px 18px;
}
[data-theme="dark"] .chat-screen {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(18, 183, 245, .09), transparent 35%),
    radial-gradient(circle at 88% 88%, rgba(116, 95, 245, .07), transparent 38%),
    radial-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px);
}
.chat-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: calc(7px + var(--safe-top)) 8px 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 6;
}
@supports not (background: color-mix(in srgb, #fff 90%, transparent)) {
  .chat-header { background: var(--surface); }
}
.back-btn { margin-right: -1px; }
.chat-peer {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 3px 5px;
  border-radius: 12px;
}
.chat-peer:active { background: var(--surface-2); }
.chat-peer-avatar { position: relative; flex: none; display: inline-flex; }
.chat-peer-avatar .online-dot { width: 10px; height: 10px; border-width: 2px; bottom: 0; right: 0; }
.chat-peer-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-peer-name { font-size: 15.5px; font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-peer-status { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); line-height: 1.3; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2.5px rgba(31, 198, 107, .12); }
.chat-peer-status.is-typing { color: var(--blue); }
.chat-peer-status.is-typing .status-dot { background: var(--blue); animation: statusPulse 1.1s ease-in-out infinite; }
@keyframes statusPulse { 0%, 100% { opacity: .35; transform: scale(.82); } 50% { opacity: 1; transform: scale(1.15); } }
.chat-main { flex: 1; min-height: 0; position: relative; }
.chat-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 13px 22px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 140, 165, .24) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 4px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(120, 140, 165, .24); border-radius: 4px; }
.chat-inner { width: 100%; max-width: 680px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.chat-notice {
  width: fit-content;
  max-width: 100%;
  margin: 1px auto 15px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  background: rgba(120, 140, 165, .1);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}
.chat-notice .icon { width: 11px; height: 11px; stroke-width: 2; color: var(--blue); }
.time-divider {
  display: flex;
  justify-content: center;
  margin: 18px 0 8px;
}
.time-divider span {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(120, 140, 165, .1);
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.5;
}
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 13px 0;
  position: relative;
}
.msg-row .msg-avatar { width: 35px; height: 35px; flex: none; margin-top: 1px; }
.msg-row .msg-avatar.user-avatar { font-size: 14px; }
.msg-row.outgoing { flex-direction: row-reverse; }
.msg-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: calc(100% - 43px);
  min-width: 0;
}
.msg-row.outgoing .msg-content { align-items: flex-end; max-width: calc(100% - 43px); }
.bubble {
  position: relative;
  max-width: 100%;
  padding: 10px 13px;
  border-radius: 5px 16px 16px 16px;
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  box-shadow: 0 2px 9px rgba(21, 44, 74, .055);
  font-size: 14px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 1px solid rgba(23, 39, 64, .045);
}
[data-theme="dark"] .bubble { border-color: rgba(255, 255, 255, .045); box-shadow: 0 3px 12px rgba(0, 0, 0, .18); }
.bubble::before {
  content: "";
  position: absolute;
  top: 10px;
  left: -4px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--bubble-in);
  transform: rotate(45deg);
  border-left: 1px solid rgba(23, 39, 64, .045);
  border-bottom: 1px solid rgba(23, 39, 64, .045);
}
.msg-row.outgoing .bubble {
  color: #fff;
  background: var(--bubble-out);
  border: 0;
  border-radius: 16px 5px 16px 16px;
  box-shadow: 0 4px 14px rgba(8, 130, 225, .22);
}
.msg-row.outgoing .bubble::before {
  left: auto;
  right: -4px;
  background: #0b8ff0;
  border: 0;
  border-right: 0;
}
.bubble-text { min-width: 0; }
.bubble-text.is-streaming { white-space: pre-wrap; }
.bubble-text.is-streaming .stream-content { white-space: pre-wrap; }
.stream-content:empty + .stream-cursor { display: none; }
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -2px;
  border-radius: 2px;
  background: currentColor;
  animation: caretBlink .85s steps(1) infinite;
  opacity: .8;
}
@keyframes caretBlink { 0%, 45% { opacity: 1; } 46%, 100% { opacity: 0; } }
.typing-dots { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 2px; }
.typing-dots i {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.25s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .16s; }
.typing-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes typingBounce { 0%, 55%, 100% { transform: translateY(0); opacity: .4; } 28% { transform: translateY(-4px); opacity: .95; } }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 3px;
  color: var(--muted);
  font-size: 9px;
  opacity: .82;
}
.msg-row.outgoing .msg-meta { justify-content: flex-end; }
.msg-sticker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px;
  max-width: 290px;
}
.msg-row.outgoing .msg-sticker { justify-content: flex-end; }
.msg-sticker .sticker-art {
  width: 128px;
  height: 128px;
  border-radius: 17px;
  background: transparent;
  filter: drop-shadow(0 5px 12px rgba(20, 46, 80, .1));
}
.msg-sticker .sticker-art + .sticker-art { width: 108px; height: 108px; }
.sticker-inline {
  display: inline-flex;
  width: 88px;
  height: 88px;
  margin: 3px 2px;
  vertical-align: middle;
  border-radius: 13px;
  overflow: hidden;
}
.sticker-inline .sticker-art { width: 100%; height: 100%; }
.msg-row .bubble:has(.sticker-inline) { padding-bottom: 8px; }
@media (max-width: 370px) {
  .msg-sticker .sticker-art { width: 116px; height: 116px; }
  .sticker-inline { width: 78px; height: 78px; }
}
.bubble-error {
  background: var(--red-soft) !important;
  border: 1px solid rgba(255, 90, 95, .2) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}
.bubble-error::before { background: var(--red-soft) !important; border: 0 !important; }
.error-head { display: flex; align-items: center; gap: 6px; color: #d64046; font-weight: 650; font-size: 12.5px; margin-bottom: 3px; }
[data-theme="dark"] .error-head { color: #ff8b8f; }
.error-head .icon { width: 15px; height: 15px; }
.error-text { font-size: 11.5px; line-height: 1.65; color: var(--text-2); white-space: pre-line; }
.inline-error {
  margin-top: 8px;
  padding: 8px 10px 9px;
  border-radius: 9px;
  background: rgba(255, 90, 95, .07);
  border: 1px solid rgba(255, 90, 95, .14);
}
.inline-error .error-head { margin-bottom: 1px; }
.bubble-error .inline-error {
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.retry-btn {
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--blue-soft);
}
.retry-btn:active { opacity: .7; }

/* reasoning */
.reasoning {
  margin: 1px 0 8px;
  border: 1px dashed rgba(10, 143, 240, .22);
  border-radius: 10px;
  background: var(--blue-softer);
  overflow: hidden;
}
.reasoning summary {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary .icon { width: 12px; height: 12px; }
.reasoning summary .reasoning-chevron { margin-left: auto; transition: transform .2s; }
.reasoning[open] summary .reasoning-chevron { transform: rotate(90deg); }
.reasoning-text {
  max-height: 190px;
  overflow: auto;
  padding: 0 9px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-top: 1px dashed rgba(10, 143, 240, .13);
  padding-top: 6px;
}
.reasoning.is-live summary { animation: reasoningGlow 2s ease-in-out infinite; }
@keyframes reasoningGlow { 0%, 100% { opacity: .75; } 50% { opacity: 1; } }

/* markdown */
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: .55em 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  margin: .85em 0 .4em;
  line-height: 1.4;
  font-weight: 700;
}
.markdown h1 { font-size: 1.28em; }
.markdown h2 { font-size: 1.17em; }
.markdown h3 { font-size: 1.08em; }
.markdown h4 { font-size: 1em; }
.markdown strong { font-weight: 700; }
.markdown em { font-style: italic; }
.markdown del { opacity: .65; }
.markdown a { color: #087dd6; text-decoration: underline; text-underline-offset: 2px; }
.msg-row.outgoing .markdown a { color: #fff; }
.markdown ul, .markdown ol { margin: .5em 0; padding-left: 1.35em; }
.markdown li { margin: .2em 0; }
.markdown li::marker { color: var(--muted); }
.markdown blockquote {
  margin: .6em 0;
  padding: 5px 10px;
  border-left: 3px solid rgba(10, 143, 240, .3);
  border-radius: 0 8px 8px 0;
  background: rgba(10, 143, 240, .055);
  color: var(--text-2);
}
.msg-row.outgoing .markdown blockquote { background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .88); border-left-color: rgba(255, 255, 255, .4); }
.markdown hr { border: 0; border-top: 1px solid var(--line-strong); margin: .9em 0; }
.markdown code {
  padding: 1.5px 5px;
  border-radius: 5px;
  background: rgba(23, 39, 64, .065);
  font-family: var(--mono);
  font-size: .87em;
}
.msg-row.outgoing .markdown code { background: rgba(255, 255, 255, .17); }
.markdown .code-block {
  margin: .7em 0;
  border-radius: 11px;
  overflow: hidden;
  background: #0f1724;
  border: 1px solid rgba(255, 255, 255, .07);
  color: #e5edf7;
  font-size: 12px;
}
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #172233;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: #91a3bb;
  font-size: 9.5px;
  font-family: var(--mono);
  letter-spacing: .3px;
}
.code-copy {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px;
  border-radius: 4px;
  color: #9fb1c8;
  font-size: 9.5px;
  font-family: var(--font);
}
.code-copy:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.code-copy .icon { width: 11px; height: 11px; }
.code-block pre {
  margin: 0;
  padding: 9px 11px 11px;
  overflow-x: auto;
  line-height: 1.62;
  scrollbar-width: thin;
}
.code-block code {
  padding: 0;
  background: none;
  color: inherit;
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: pre;
}
.markdown table {
  width: 100%;
  margin: .7em 0;
  border-collapse: collapse;
  font-size: .9em;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td { border: 1px solid var(--line-strong); padding: 5px 7px; text-align: left; }
.markdown th { background: rgba(23, 39, 64, .04); font-weight: 650; }
.msg-row.outgoing .markdown th { background: rgba(255, 255, 255, .1); }
.msg-row.outgoing .markdown th, .msg-row.outgoing .markdown td { border-color: rgba(255, 255, 255, .22); }

/* empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 8px 46px;
  text-align: center;
  animation: fadeUp .45s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.empty-avatar-wrap { position: relative; width: 82px; height: 82px; margin: 0 auto 14px; }
.empty-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid rgba(10, 143, 240, .15);
  animation: ringPulse 3.4s ease-in-out infinite;
}
@keyframes ringPulse { 0%, 100% { transform: scale(.97); opacity: .7; } 50% { transform: scale(1.04); opacity: 1; } }
.empty-avatar { width: 82px; height: 82px; box-shadow: 0 12px 32px rgba(7, 117, 213, .25); }
.empty-spark { position: absolute; color: var(--blue-2); font-size: 13px; animation: sparkFloat 3s ease-in-out infinite; opacity: .8; }
.spark-a { top: 0; right: -9px; }
.spark-b { bottom: 8px; left: -12px; font-size: 9px; animation-delay: 1.3s; }
@keyframes sparkFloat { 0%, 100% { transform: translateY(0) rotate(0deg); opacity: .5; } 50% { transform: translateY(-5px) rotate(16deg); opacity: 1; } }
.empty-state h2 { margin: 0 0 7px; font-size: 19px; font-weight: 750; letter-spacing: -.2px; }
.empty-desc { margin: 0 auto; max-width: 255px; color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 330px;
  margin: 22px auto 0;
}
.suggestions button {
  padding: 11px 11px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .16s, border-color .16s, color .16s;
}
.suggestions button:hover { border-color: rgba(10, 143, 240, .28); color: var(--blue); }
.suggestions button:active { transform: scale(.97); }
.empty-note { display: flex; align-items: center; justify-content: center; gap: 4px; margin: 18px 0 0; color: var(--muted); font-size: 9.5px; }
.empty-note .icon { width: 11px; height: 11px; }
.empty-setup-btn {
  margin: 16px auto 0;
  padding: 9px 17px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(10, 143, 240, .24);
}
.jump-bottom {
  position: absolute;
  right: 15px;
  bottom: 13px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  z-index: 4;
  animation: fadeUp .2s ease both;
}
.jump-bottom .icon { width: 17px; height: 17px; }

/* composer */
.composer-wrap {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + var(--safe-bottom));
  z-index: 7;
}
.composer { display: flex; align-items: flex-end; gap: 5px; }
.composer-btn {
  width: 38px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
  transition: color .16s, background .16s;
}
.composer-btn:hover, .composer-btn.is-active { color: var(--blue); background: var(--blue-soft); }
.composer-btn .icon { width: 23px; height: 23px; stroke-width: 1.8; }
.input-shell {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 20px;
  transition: background .18s, border-color .18s, box-shadow .18s;
}
.input-shell:focus-within {
  background: var(--surface);
  border-color: rgba(10, 143, 240, .42);
  box-shadow: 0 0 0 3px rgba(10, 143, 240, .08);
}
#messageInput {
  display: block;
  width: 100%;
  max-height: 118px;
  min-height: 22px;
  padding: 9px 0 8px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  scrollbar-width: none;
}
#messageInput::-webkit-scrollbar { display: none; }
#messageInput::placeholder { color: var(--muted); opacity: .9; }
.send-btn {
  flex: none;
  height: 36px;
  min-width: 57px;
  margin-bottom: 2px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 18px;
  background: linear-gradient(135deg, #25c2ff, #0a8ff0);
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .2px;
  box-shadow: 0 5px 13px rgba(10, 143, 240, .25);
  transition: opacity .18s, transform .18s, background .18s;
}
.send-btn:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; opacity: .75; }
.send-btn:not(:disabled):active { transform: scale(.96); }
.send-btn.is-stop { background: linear-gradient(135deg, #ff7b80, #f04e55); box-shadow: 0 5px 13px rgba(240, 78, 85, .22); }
.send-stop-icon { display: none; width: 12px !important; height: 12px !important; }
.send-btn.is-stop .send-stop-icon { display: block; }
.emoji-panel {
  margin: -1px 0 8px;
  padding: 8px 2px 2px;
  border-top: 1px solid var(--line);
  animation: emojiIn .18s ease both;
}
@keyframes emojiIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.emoji-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 5px 7px;
  color: var(--muted);
  font-size: 10px;
}
.emoji-head > button { color: var(--muted); width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.emoji-head > button .icon { width: 14px; height: 14px; }
.panel-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
}
.panel-tab {
  height: 25px;
  padding: 0 10px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 550;
  transition: background .16s, color .16s, box-shadow .16s;
}
.panel-tab.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(20, 40, 70, .1);
}
.tab-count {
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface-3);
  font-size: 8px;
  line-height: 1;
}
.panel-tab.is-active .tab-count { color: var(--blue); background: var(--blue-soft); }
.emoji-pane { max-height: 214px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sticker-pane { max-height: 312px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 1px 2px 4px;
}
.sticker-tile {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform .14s, background .14s;
  -webkit-touch-callout: none;
  user-select: none;
}
.sticker-tile img { pointer-events: none; }
.sticker-tile:active { transform: scale(.95); }
.sticker-tile .sticker-art { width: 100%; height: 100%; }
.sticker-art {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}
.sticker-art svg,
.sticker-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.sticker-add {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 13px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
}
.sticker-add .icon { width: 17px; height: 17px; }
.sticker-add:active { background: var(--surface-2); }
.sticker-add.is-busy { opacity: .55; pointer-events: none; }
.sticker-hint {
  margin: 5px 2px 1px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  text-align: center;
}
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; }
.emoji-grid button {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 21px;
  line-height: 1;
  transition: background .14s, transform .14s;
}
.emoji-grid button:hover { background: var(--surface-2); }
.emoji-grid button:active { transform: scale(.86); }

/* ---------- Settings ---------- */
.settings-screen { background: var(--bg); }
.sub-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: calc(58px + var(--safe-top));
  padding: var(--safe-top) 12px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 3;
}
.sub-header h1 { flex: 1; margin: 0; text-align: center; font-size: 16.5px; font-weight: 650; }
.sub-header-spacer { width: 40px; flex: none; }
.settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px calc(112px + var(--safe-bottom));
  scrollbar-width: thin;
}
.setup-callout {
  display: flex;
  gap: 11px;
  padding: 14px;
  margin-bottom: 20px;
  border-radius: 17px;
  border: 1px solid rgba(10, 143, 240, .15);
  background: linear-gradient(120deg, rgba(18, 183, 245, .13), rgba(94, 111, 255, .07));
}
.setup-callout.is-done { display: none; }
.setup-callout-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  color: #fff;
  background: linear-gradient(135deg, #2ac8ff, #0a88ec);
  box-shadow: 0 4px 10px rgba(10, 143, 240, .22);
}
.setup-callout-icon .icon { width: 17px; height: 17px; }
.setup-callout strong { font-size: 12.5px; font-weight: 650; }
.setup-callout p { margin: 3px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.6; }
.settings-section { margin-bottom: 21px; scroll-margin-top: 14px; }
.settings-title { display: flex; align-items: center; gap: 7px; margin: 0 3px 8px; }
.settings-title h2 { margin: 0; font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .2px; }
.required-tag, .optional-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 8.5px;
  line-height: 1.4;
  font-weight: 600;
}
.required-tag { color: #ea5961; background: rgba(234, 89, 97, .09); }
.optional-tag { color: var(--muted); background: var(--surface-2); }
.settings-card {
  padding: 2px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.field {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }
.field > label:not(.check-row), .label-row label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}
.avatar-editor {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 5px 0 2px;
}
.avatar-preview {
  width: 64px;
  height: 64px;
  border: 2px solid var(--surface);
  box-shadow: 0 5px 16px rgba(10, 143, 240, .2), 0 0 0 1px var(--line);
}
.avatar-editor-copy { flex: 1; min-width: 0; }
.avatar-editor-copy strong { display: block; font-size: 12.5px; font-weight: 650; }
.avatar-editor-copy p { margin: 3px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.55; }
.avatar-editor-actions { display: flex; align-items: center; gap: 11px; margin-top: 8px; }
.soft-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(10, 143, 240, .14);
  font-size: 10.5px;
  font-weight: 600;
}
.soft-btn .icon { width: 13px; height: 13px; }
.soft-btn:active { transform: scale(.97); }
.soft-btn:disabled { opacity: .6; }
.text-btn { color: var(--muted); font-size: 10.5px; padding: 2px 0; }
.text-btn:hover { color: var(--text-2); }
.avatar-presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  margin-top: 13px;
}
.preset-avatar-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 5px 0 4px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
}
.preset-avatar-btn:hover { background: var(--surface-2); }
.preset-avatar-btn.is-active { color: var(--blue); font-weight: 650; }
.preset-thumb {
  width: 42px;
  height: 42px;
  border: 2px solid transparent;
  box-shadow: none;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.preset-avatar-btn.is-active .preset-thumb {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  transform: translateY(-1px);
}
.preset-check {
  position: absolute;
  top: 0;
  right: calc(50% - 27px);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: none;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border: 2px solid var(--surface);
  box-shadow: 0 2px 5px rgba(10, 143, 240, .25);
}
.preset-avatar-btn.is-active .preset-check { display: grid; }
.preset-check .icon { width: 9px; height: 9px; stroke-width: 3; }
.field input[type="text"], .field input[type="url"], .field input[type="password"], .field input[type="number"], .field textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.field input:focus, .field textarea:focus {
  background: var(--surface);
  border-color: rgba(10, 143, 240, .45);
  box-shadow: 0 0 0 3px rgba(10, 143, 240, .075);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .8; }
.field textarea { resize: vertical; min-height: 92px; line-height: 1.65; }
.field-hint { margin: 6px 1px 0; color: var(--muted); font-size: 10px; line-height: 1.58; }
.field-hint code { padding: 1px 4px; border-radius: 4px; background: var(--surface-2); font-family: var(--mono); font-size: .94em; }
.provider-chips, .model-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.provider-chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 550;
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s;
}
.provider-chip.is-active { background: var(--blue-soft); color: var(--blue); border-color: rgba(10, 143, 240, .22); font-weight: 650; }
.provider-chip:active { transform: scale(.97); }
.key-input { position: relative; }
.key-input input { padding-right: 45px !important; }
.key-toggle {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 9px;
}
.key-toggle .icon { width: 18px; height: 18px; }
.key-toggle .eye-closed { display: none; }
.key-toggle.is-visible .eye-open { display: none; }
.key-toggle.is-visible .eye-closed { display: block; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
  cursor: pointer;
  position: relative;
}
.check-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 0;
  color: #fff;
  background: var(--surface);
  transition: background .16s, border-color .16s;
}
.check-box .icon { width: 11px; height: 11px; stroke-width: 3; opacity: 0; transform: scale(.6); transition: opacity .16s, transform .16s; }
.check-row input:checked + .check-box { background: var(--blue); border-color: var(--blue); }
.check-row input:checked + .check-box .icon { opacity: 1; transform: none; }
.check-row small { display: block; margin-top: 1px; font-size: 9.5px; color: var(--muted); opacity: .75; }
.model-chips { margin-top: 7px; }
.model-chip {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  border: 1px solid transparent;
}
.model-chip:hover { color: var(--blue); border-color: var(--blue-soft); }
.proxy-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.proactive-card .proactive-toggle { border-top: 0; padding-top: 13px; padding-bottom: 13px; }
.proactive-options { border-top: 1px solid var(--line); }
.proactive-options .field { padding-top: 13px; padding-bottom: 4px; border-bottom: 0; }
.proactive-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0 1px;
  border-top: 1px dashed var(--line);
}
#proactiveStatus { color: var(--muted); font-size: 10px; line-height: 1.5; }
#btnProactiveTest { flex: none; color: var(--blue); font-weight: 600; }
#btnProactiveTest:disabled { color: var(--muted); opacity: .55; }
.proxy-copy { display: flex; flex-direction: column; gap: 3px; }
.proxy-copy strong { font-size: 12px; font-weight: 650; }
.proxy-copy small { color: var(--muted); font-size: 9.5px; line-height: 1.5; }
.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  display: block;
  width: 43px;
  height: 25px;
  border-radius: 999px;
  background: var(--surface-3);
  transition: background .2s;
  position: relative;
  cursor: pointer;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 21px;
  height: 21px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(20, 40, 70, .2);
  transition: transform .2s cubic-bezier(.3, .8, .4, 1);
}
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }
.test-btn {
  width: 100%;
  height: 41px;
  margin: 6px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: 1px dashed rgba(10, 143, 240, .3);
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  transition: background .16s;
}
.test-btn:hover { background: rgba(10, 143, 240, .14); }
.test-btn:disabled { opacity: .65; }
.test-btn-label { display: flex; align-items: center; gap: 6px; }
.test-btn-label .icon { width: 16px; height: 16px; }
.test-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(10, 143, 240, .22);
  border-top-color: var(--blue);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.test-result {
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 10.5px;
  line-height: 1.6;
  border: 1px solid transparent;
  word-break: break-word;
  white-space: pre-line;
}
.test-result.success { color: #0d9256; background: rgba(31, 198, 107, .08); border-color: rgba(31, 198, 107, .15); }
.test-result.error { color: #d33f45; background: var(--red-soft); border-color: rgba(255, 90, 95, .15); }
[data-theme="dark"] .test-result.success { color: #62dda0; }
[data-theme="dark"] .test-result.error { color: #ff9296; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.two-col > div { min-width: 0; }
.two-col label { margin-bottom: 7px; }
.label-row { display: flex; justify-content: space-between; align-items: center; }
.label-row output {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.range {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--blue);
  background: transparent;
}
.range-labels { display: flex; justify-content: space-between; margin-top: -2px; color: var(--muted); font-size: 9px; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 11px 0; }
.theme-options button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 5px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  transition: border-color .16s, color .16s, background .16s;
}
.theme-options button .icon { width: 19px; height: 19px; }
.theme-options button.is-active { color: var(--blue); background: var(--blue-soft); border-color: rgba(10, 143, 240, .25); font-weight: 600; }
.data-card { padding-top: 2px; padding-bottom: 2px; }
.data-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.data-row:last-of-type { border-bottom: 0; }
.data-row-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--blue);
  background: var(--blue-soft);
}
.data-row.danger .data-row-icon { color: #e74b52; background: rgba(231, 75, 82, .08); }
.data-row-icon .icon { width: 16px; height: 16px; }
.data-row > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.data-row strong { font-size: 12px; font-weight: 600; }
.data-row small { font-size: 9.5px; color: var(--muted); }
.data-row.danger strong { color: #e74b52; }
[data-theme="dark"] .data-row.danger strong { color: #ff898d; }
.data-note {
  display: flex;
  gap: 7px;
  padding: 10px;
  margin: 6px 0 10px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
}
.data-note .icon { width: 14px; height: 14px; flex: none; margin-top: 1px; color: var(--blue); }
.data-note p { margin: 0; font-size: 9.5px; line-height: 1.62; }
.data-note code { font-family: var(--mono); font-size: .95em; }
.settings-footnote { margin: 4px 0 10px; text-align: center; color: var(--muted); font-size: 9px; opacity: .7; }
.save-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
@supports not (background: color-mix(in srgb, #fff 90%, transparent)) {
  .save-bar { background: var(--surface); }
}
.primary-btn {
  width: 100%;
  height: 46px;
  border-radius: 23px;
  background: linear-gradient(135deg, #25c2ff, #0a8ff0);
  color: #fff;
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: .3px;
  box-shadow: 0 7px 20px rgba(10, 143, 240, .25);
  transition: transform .16s, opacity .16s;
}
.primary-btn:active { transform: scale(.985); }
.primary-btn:disabled { opacity: .6; }

/* ---------- Search ---------- */
.search-screen { background: var(--bg); }
.search-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.search-input-wrap {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 12px;
  background: var(--surface-2);
}
.search-input-wrap .icon { width: 17px; height: 17px; color: var(--muted); }
#searchInput {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
#searchInput:focus,
#searchInput:focus-visible { outline: none; box-shadow: none; }
.search-input-wrap:focus-within {
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(10, 143, 240, .1);
}
.search-input-wrap:focus-within .icon { color: var(--blue); }
#searchInput::-webkit-search-cancel-button { display: none; }
.search-clear { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.search-clear .icon { width: 13px; height: 13px; }
.search-body { flex: 1; overflow-y: auto; padding: 14px; }
.search-empty { text-align: center; padding: 66px 20px 20px; color: var(--muted); }
.search-empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.search-empty-icon .icon { width: 24px; height: 24px; }
.search-empty p { margin: 0; font-size: 11.5px; line-height: 1.6; }
.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result {
  width: 100%;
  padding: 12px 13px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  box-shadow: var(--shadow-sm);
}
.search-result:active { background: var(--surface-2); }
.search-result-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.search-result-role { display: flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 650; color: var(--blue); }
.search-result-role .mini-avatar { width: 18px; height: 18px; border-radius: 50%; overflow: hidden; flex: none; background: var(--surface-2); }
.search-result-role .mini-avatar svg,
.search-result-role .mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-result-role .mini-avatar.user-avatar { font-size: 9px; box-shadow: none; }
.search-result-role.is-user { color: #e8812f; }
.search-result-time { color: var(--muted); font-size: 9px; }
.search-result-snippet { color: var(--text-2); font-size: 11.5px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.search-result-snippet mark { background: rgba(255, 190, 50, .35); color: inherit; border-radius: 2px; padding: 0 1px; }
[data-theme="dark"] .search-result-snippet mark { background: rgba(255, 190, 50, .24); color: #ffe3a1; }
.search-count { margin: 2px 4px 10px; color: var(--muted); font-size: 10px; }
.flash { animation: flashBubble 1.45s ease; }
@keyframes flashBubble { 0%, 100% { box-shadow: 0 0 0 0 rgba(10, 143, 240, 0); } 22% { box-shadow: 0 0 0 4px rgba(10, 143, 240, .22); } }

/* ---------- Overlays ---------- */
.scrim {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(7, 18, 32, .42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn .18s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.action-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  padding: 7px 12px calc(10px + var(--safe-bottom));
  border-radius: 23px 23px 0 0;
  background: var(--surface);
  box-shadow: 0 -20px 50px rgba(7, 22, 43, .2);
  animation: sheetUp .24s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grabber { width: 36px; height: 4px; margin: 0 auto 6px; border-radius: 3px; background: var(--line-strong); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; }
.sheet-head h2 { margin: 0; font-size: 13px; font-weight: 650; color: var(--muted); }
.sheet-close { width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); }
.sheet-close .icon { width: 16px; height: 16px; }
.sheet-actions { display: flex; flex-direction: column; }
.sheet-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 8px;
  text-align: left;
  border-radius: 13px;
  color: var(--text);
  font-size: 13px;
}
.sheet-action:active { background: var(--surface-2); }
.sheet-action-icon {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--blue);
  background: var(--blue-soft);
}
.sheet-action-icon .icon { width: 17px; height: 17px; }
.sheet-action.danger { color: #e74b52; }
.sheet-action.danger .sheet-action-icon { color: #e74b52; background: rgba(231, 75, 82, .08); }
.sheet-action small { display: block; margin-top: 2px; color: var(--muted); font-size: 9.5px; }
.sheet-cancel {
  width: 100%;
  height: 43px;
  margin-top: 5px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.dialog-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 18, 32, .44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fadeIn .18s ease both;
}
.dialog {
  width: 100%;
  max-width: 320px;
  padding: 22px 20px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: dialogIn .22s cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.dialog-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 11px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #e74b52;
  background: rgba(231, 75, 82, .09);
}
.dialog-icon.is-primary { color: var(--blue); background: var(--blue-soft); }
.dialog-icon .icon { width: 22px; height: 22px; }
.dialog h2 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.dialog p { margin: 0 auto; max-width: 275px; color: var(--muted); font-size: 11.5px; line-height: 1.68; white-space: pre-line; }
.dialog-input-wrap { margin-top: 13px; }
.dialog-input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  text-align: center;
}
.dialog-input-wrap input:focus {
  background: var(--surface);
  border-color: rgba(10, 143, 240, .45);
  box-shadow: 0 0 0 3px rgba(10, 143, 240, .08);
}
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.dialog-actions.single { grid-template-columns: 1fr; }
.dialog-actions button { height: 41px; border-radius: 12px; font-size: 12.5px; font-weight: 600; }
.dialog-cancel { background: var(--surface-2); color: var(--text-2); }
.dialog-confirm { background: var(--blue); color: #fff; }
.dialog-confirm.is-danger { background: #ee5058; }
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(84px + var(--safe-bottom));
  z-index: 60;
  max-width: 84%;
  padding: 9px 15px;
  border-radius: 11px;
  background: rgba(18, 27, 40, .93);
  color: #fff;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  transform: translateX(-50%);
  animation: toastIn .22s ease both;
  pointer-events: none;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 7px); } to { opacity: 1; transform: translate(-50%, 0); } }
[data-theme="dark"] .toast { background: rgba(236, 243, 252, .94); color: #131a24; }

/* ---------- Responsive / desktop preview ---------- */
@media (min-width: 600px) and (min-height: 700px) {
  .app {
    height: min(900px, calc(100dvh - 32px));
    margin: 16px auto;
    border-radius: 32px;
    box-shadow: 0 40px 100px rgba(15, 38, 68, .22), 0 6px 24px rgba(15, 38, 68, .1);
    border: 1px solid rgba(255, 255, 255, .5);
  }
  [data-theme="dark"] .app { border-color: rgba(255, 255, 255, .08); box-shadow: 0 40px 100px rgba(0, 0, 0, .55); }
}
@media (max-width: 600px) {
  /* iOS Safari zooms any focused field below 16px; keep the layout steady. */
  #messageInput,
  .field input[type="text"],
  .field input[type="url"],
  .field input[type="password"],
  .field input[type="number"],
  .field textarea,
  #searchInput { font-size: 16px; }
}
@media (max-width: 370px) {
  .home-header { padding-left: 16px; padding-right: 16px; }
  .thread { padding-left: 13px; padding-right: 13px; }
  .composer-wrap { padding-left: 7px; padding-right: 7px; }
  .composer { gap: 2px; }
  .composer-btn { width: 34px; }
  .send-btn { min-width: 52px; padding: 0 11px; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
  .suggestions { gap: 7px; }
  .me-stats strong { font-size: 13px; }
  .avatar-preview { width: 60px; height: 60px; }
  .preset-thumb { width: 38px; height: 38px; }
  .preset-check { right: calc(50% - 25px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
:focus-visible { outline: 2px solid rgba(10, 143, 240, .6); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
