:root {
  --bg: #07080d;
  --bg-soft: #0b0d14;
  --surface: #10131c;
  --surface-2: #161a25;
  --surface-3: #1d2230;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eef1f8;
  --muted: #9299ae;
  --faint: #5f6579;
  --accent: #7c9cff;
  --accent-2: #a78bfa;
  --deepseek: #7c9cff;
  --antigravity: #ffb45c;
  --opencode: #4fd1a5;
  --danger: #ff6b7a;
  --ok: #4ade80;
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, monospace;
  --nav-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
html { background: var(--bg); overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(124, 156, 255, 0.13), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, rgba(167, 139, 250, 0.08), transparent 55%),
    var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  z-index: 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { width: 0; height: 0; }

#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }

.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--sat)) 18px 12px;
  background: linear-gradient(180deg, rgba(7, 8, 13, 0.94), rgba(7, 8, 13, 0.72) 70%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto;
  background: conic-gradient(from 210deg, #6d8cff, #a78bfa, #4fd1a5, #6d8cff);
  display: grid; place-items: center;
  box-shadow: 0 4px 18px rgba(124, 156, 255, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.brand-mark svg { width: 20px; height: 20px; color: #07101f; }
.brand-name { font-weight: 760; font-size: 18px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12); }
.live-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 122, 0.12); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  color: var(--muted); background: transparent; transition: background 0.15s, color 0.15s;
}
.icon-btn:hover, .icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- sections */
.content { padding: 0 16px calc(var(--nav-h) + 26px + var(--sab)); flex: 1; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin: 22px 2px 10px; }
.section-title::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, var(--border), transparent); }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden;
  padding: 18px; border-radius: 22px;
  background: linear-gradient(135deg, rgba(124, 156, 255, 0.18), rgba(167, 139, 250, 0.08) 55%, rgba(16, 19, 28, 0.9));
  border: 1px solid rgba(124, 156, 255, 0.22);
  margin-top: 4px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 190px; height: 190px;
  background: radial-gradient(circle, rgba(124, 156, 255, 0.35), transparent 65%);
  filter: blur(8px);
}
.hero-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: #b9c7ff; }
.hero-kicker svg { width: 15px; height: 15px; flex: 0 0 auto; }
.hero h2 { margin: 8px 0 6px; font-size: 20px; line-height: 1.25; letter-spacing: -0.02em; }
.hero p { margin: 0; color: #b6bdda; font-size: 13px; max-width: 92%; }
.hero-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 12px; font-weight: 650; font-size: 13.5px;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  transition: transform 0.12s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(135deg, #8aa6ff, #a78bfa); color: #08101f; border: 0; box-shadow: 0 8px 24px rgba(124, 156, 255, 0.28); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); }
.btn.danger { background: rgba(255, 107, 122, 0.12); color: #ffb3bb; border-color: rgba(255, 107, 122, 0.24); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- filters */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border);
  transition: all 0.15s;
}
.chip.active { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip-color, var(--accent)); }
.chip .count { font-size: 11px; color: var(--faint); background: rgba(255, 255, 255, 0.05); border-radius: 999px; padding: 1px 6px; }
.chip.active .count { color: #dfe6ff; background: rgba(124, 156, 255, 0.2); }

.searchbar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0 13px; height: 44px; margin: 4px 0 8px; }
.searchbar svg { width: 18px; height: 18px; color: var(--faint); flex: 0 0 auto; }
.searchbar input { flex: 1; background: transparent; border: 0; outline: 0; font-size: 14px; min-width: 0; }
.searchbar input::placeholder { color: var(--faint); }

/* ---------------------------------------------------------------- chat list */
.chat-list { display: flex; flex-direction: column; gap: 8px; }
.chat-card {
  position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 14px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); text-align: left; width: 100%;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.chat-card:active { transform: scale(0.988); background: var(--surface-2); }
.chat-card .provider-rail { width: 3px; align-self: stretch; border-radius: 4px; background: var(--pc); opacity: 0.85; flex: 0 0 auto; margin: -2px 0; }
.chat-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; background: var(--surface-2); background: color-mix(in srgb, var(--pc) 14%, var(--surface-2)); color: var(--pc); border: 1px solid color-mix(in srgb, var(--pc) 24%, transparent); }
.chat-icon svg { width: 19px; height: 19px; }
.chat-main { flex: 1; min-width: 0; }
.chat-top { display: flex; align-items: baseline; gap: 8px; }
.chat-title { font-weight: 650; font-size: 14.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; letter-spacing: -0.01em; }
.chat-time { font-size: 11px; color: var(--faint); flex: 0 0 auto; }
.chat-preview { margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; color: var(--faint); background: rgba(255, 255, 255, 0.045); border: 1px solid transparent; }
.pill.provider { color: var(--pc); background: rgba(255, 255, 255, 0.045); background: color-mix(in srgb, var(--pc) 10%, transparent); }
.pill.running { color: #bfe9ff; background: rgba(96, 190, 255, 0.12); }
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.spinner { width: 12px; height: 12px; border: 2px solid rgba(255, 255, 255, 0.18); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 46px 18px; color: var(--muted); }
.empty-icon { width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--faint); }
.empty-icon svg { width: 28px; height: 28px; }
.empty h3 { margin: 0 0 5px; color: var(--text); font-size: 16px; }
.empty p { margin: 0; font-size: 13px; }

/* ---------------------------------------------------------------- nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-around;
  height: calc(var(--nav-h) + var(--sab)); padding: 6px 10px var(--sab);
  background: rgba(9, 11, 17, 0.86); border-top: 1px solid var(--border);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--faint); font-size: 10.5px; font-weight: 600; padding: 6px 0 4px; position: relative; transition: color 0.15s; max-width: 120px; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--text); }
.nav-item.active::before { content: ""; position: absolute; top: -7px; width: 22px; height: 3px; border-radius: 99px; background: linear-gradient(90deg, #8aa6ff, #a78bfa); box-shadow: 0 0 12px rgba(124, 156, 255, 0.6); }
.nav-item .badge { position: absolute; top: 3px; right: calc(50% - 20px); min-width: 15px; height: 15px; border-radius: 99px; background: var(--accent); color: #07101f; font-size: 9px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + var(--sab)); z-index: 35;
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(140deg, #8aa6ff, #a78bfa); color: #07101f;
  box-shadow: 0 12px 34px rgba(124, 156, 255, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 25px; height: 25px; }

/* ---------------------------------------------------------------- chat view */
.chat-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.chat-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: calc(9px + var(--sat)) 12px 9px;
  background: rgba(8, 10, 16, 0.86); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.chat-header .chat-icon { width: 36px; height: 36px; border-radius: 11px; }
.chat-head-main { flex: 1; min-width: 0; }
.chat-head-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 999px; font-size: 11.5px; font-weight: 650; color: #cbd4ff; background: rgba(124, 156, 255, 0.12); border: 1px solid rgba(124, 156, 255, 0.2); max-width: 138px; flex: 0 0 auto; }
.model-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn svg { width: 13px; height: 13px; flex: 0 0 auto; }
@media (max-width: 430px) {
  .chat-header { gap: 7px; padding-left: 9px; padding-right: 9px; }
  .chat-header .icon-btn { width: 34px; height: 34px; }
  .chat-header .chat-icon { width: 32px; height: 32px; border-radius: 9px; }
  .model-btn { max-width: 108px; padding: 0 8px; font-size: 10.5px; }
  .chat-head-title { font-size: 14px; }
}

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 14px 18px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.msg-row { display: flex; flex-direction: column; max-width: 92%; min-width: 0; animation: appear 0.22s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.msg-row.user { align-self: flex-end; align-items: flex-end; }
.msg-row.assistant, .msg-row.tool, .msg-row.error { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 11px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.user .bubble { background: linear-gradient(135deg, #829fff, #9f86f7); color: #081120; border-bottom-right-radius: 6px; font-weight: 500; box-shadow: 0 6px 20px rgba(124, 156, 255, 0.2); }
.assistant .bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.assistant .bubble.streaming { border-color: rgba(124, 156, 255, 0.24); }
.msg-meta { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--faint); margin: 4px 4px 0; }
.msg-model { color: #8fa4e6; }
.msg-row.error .bubble { background: rgba(255, 107, 122, 0.1); border: 1px solid rgba(255, 107, 122, 0.22); color: #ffb3bb; font-size: 13px; }
.tool-row { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 11px; border-radius: 11px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-family: var(--mono); }
.tool-row svg { width: 13px; height: 13px; color: var(--faint); flex: 0 0 auto; }
.tool-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.md { min-width: 0; overflow-wrap: anywhere; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; line-height: 1.25; font-size: 16px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code.inline { font-family: var(--mono); font-size: 0.88em; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; color: #d8e0ff; }
.md pre { position: relative; margin: 8px 0; padding: 12px 13px; background: #090b11; border: 1px solid var(--border); border-radius: 11px; overflow-x: auto; max-width: 100%; }
.md pre code { font-family: var(--mono); font-size: 12px; line-height: 1.55; color: #c7d2ef; white-space: pre; }
.md pre .copy-code { position: absolute; top: 6px; right: 6px; font-size: 10px; color: var(--faint); background: var(--surface-3); border-radius: 6px; padding: 3px 7px; opacity: 0; transition: opacity 0.15s; }
.md pre:hover .copy-code { opacity: 1; }
.md blockquote { margin: 6px 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--accent); color: var(--muted); }
.md a { color: #9db4ff; text-decoration: underline; text-underline-offset: 2px; }
.md strong { color: #fff; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.typing { display: inline-flex; gap: 3px; align-items: center; height: 18px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.cursor::after { content: "▍"; color: var(--accent); animation: cursor 1s steps(2) infinite; margin-left: 1px; }
@keyframes cursor { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- composer */
.composer-wrap {
  position: sticky; bottom: 0; z-index: 31;
  padding: 7px 12px calc(10px + var(--sab));
  background: linear-gradient(180deg, transparent, rgba(8, 10, 16, 0.92) 22%, rgba(8, 10, 16, 0.98));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.composer {
  display: flex; align-items: flex-end; gap: 7px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 20px; padding: 6px 6px 6px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s;
}
.composer:focus-within { border-color: rgba(124, 156, 255, 0.45); box-shadow: 0 10px 34px rgba(124, 156, 255, 0.12); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  padding: 8px 0 7px; max-height: 150px; min-height: 24px; font-size: 14.5px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--faint); }
.composer.with-attach { padding-left: 8px; }
.attach-btn { color: var(--faint); flex: 0 0 auto; align-self: center; }
.attach-btn svg { width: 19px; height: 19px; }
.attach-strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 2px; }
.attach-strip:not(:empty) { padding-bottom: 6px; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; max-width: 220px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 12px; padding: 4px 6px 4px 4px; }
.attach-thumb { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.attach-thumb.placeholder { display: grid; place-items: center; background: var(--surface-3); color: var(--faint); }
.attach-thumb.placeholder svg { width: 16px; height: 16px; }
.attach-name { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.attach-remove { color: var(--faint); display: grid; place-items: center; flex: 0 0 auto; padding: 3px; }
.attach-remove svg { width: 14px; height: 14px; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.msg-attach-thumb { max-width: 150px; max-height: 150px; border-radius: 10px; border: 1px solid var(--border); }
.msg-attach-file { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: #cfd6ee; background: rgba(255, 255, 255, 0.06); border-radius: 9px; padding: 4px 8px; }
.msg-attach-file svg { width: 13px; height: 13px; }
.send-btn {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(140deg, #8aa6ff, #a78bfa); color: #07101f; transition: opacity 0.15s, transform 0.12s;
}
.send-btn:active { transform: scale(0.92); }
.send-btn[disabled] { opacity: 0.3; }
.send-btn svg { width: 19px; height: 19px; }
.composer-hint { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 0; font-size: 10.5px; color: var(--faint); flex-wrap: nowrap; }
.composer-hint > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delegate-link { display: inline-flex; align-items: center; gap: 4px; color: #9db4ff; font-weight: 600; white-space: nowrap; flex: 0 0 auto; }
.delegate-link svg { width: 12px; height: 12px; }

/* ---------------------------------------------------------------- delegation */
.delegation-card {
  align-self: stretch; max-width: 100%; margin: 2px 0;
  border: 1px solid rgba(124, 156, 255, 0.2); border-radius: 15px;
  background: linear-gradient(160deg, rgba(124, 156, 255, 0.08), rgba(16, 19, 28, 0.6));
  overflow: hidden;
}
.delegation-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.delegation-head .chat-icon { width: 30px; height: 30px; border-radius: 9px; }
.delegation-head .chat-icon svg { width: 15px; height: 15px; }
.delegation-title { flex: 1; min-width: 0; }
.delegation-title b { display: block; font-size: 12.5px; color: #dfe6ff; }
.delegation-title span { display: block; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delegation-body { padding: 10px 12px; font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 240px; overflow-y: auto; }
.delegation-body .md { color: var(--text); font-size: 13px; }
.delegation-body .md p { margin-bottom: 6px; }
.delegation-status { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; background: rgba(124, 156, 255, 0.12); color: #b9c7ff; }
.delegation-status.done { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.delegation-status.error { background: rgba(255, 107, 122, 0.12); color: #ffb3bb; }

/* ---------------------------------------------------------------- sheet/modal */
.overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(3, 5, 9, 0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative;
  width: 100%; max-width: 560px; max-height: 86vh; max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 8px 0 calc(12px + var(--sab));
  animation: slideup 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
.sheet-close { position: absolute; top: 10px; right: 12px; z-index: 3; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.sheet-close svg { width: 15px; height: 15px; }
@keyframes slideup { from { transform: translateY(30px); opacity: 0.6; } }
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.16); margin: 2px auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 18px 10px; }
.sheet-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.sheet-body { overflow-y: auto; padding: 0 14px; }
.sheet-footer { padding: 12px 18px 4px; }
.modal { width: calc(100% - 36px); max-width: 420px; margin: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; padding: 20px; animation: pop 0.2s; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.overlay.center { align-items: center; }

.segmented { display: flex; gap: 4px; padding: 4px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 13px; margin: 4px 0 12px; }
.segmented button { flex: 1; height: 34px; border-radius: 9px; font-size: 12.5px; font-weight: 650; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.segmented .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--chip-color); }

.model-list { display: flex; flex-direction: column; gap: 2px; }
.model-item { display: flex; align-items: center; gap: 11px; padding: 11px 10px; border-radius: 12px; text-align: left; width: 100%; }
.model-item:hover, .model-item:active { background: var(--surface-2); }
.model-item.selected { background: rgba(124, 156, 255, 0.1); }
.model-item .mi-main { flex: 1; min-width: 0; }
.model-item .mi-name { font-weight: 600; font-size: 13.5px; }
.model-item .mi-desc { font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-item .mi-check { color: var(--accent); width: 18px; height: 18px; }
.model-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); padding: 14px 10px 5px; }
.quota { font-size: 9.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: rgba(74, 222, 128, 0.12); color: #86efac; }
.quota.out { background: rgba(255, 107, 122, 0.12); color: #ffb3bb; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; height: 44px; border-radius: 12px; background: var(--bg-soft);
  border: 1px solid var(--border); padding: 0 12px; outline: 0; font-size: 14px;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: rgba(124, 156, 255, 0.45); }
.field .hint { font-size: 10.5px; color: var(--faint); margin-top: 5px; line-height: 1.4; }

/* ---------------------------------------------------------------- settings */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; margin-bottom: 10px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.card-title svg { width: 17px; height: 17px; color: var(--muted); }
.setting-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.setting-row > svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); }
.setting-row:first-of-type { border-top: 0; padding-top: 0; }
.setting-main { flex: 1; min-width: 0; }
.setting-name { font-size: 13.5px; font-weight: 600; }
.setting-desc { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.setting-value { font-size: 12px; color: var(--muted); font-family: var(--mono); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.provider-card { display: flex; align-items: center; gap: 11px; padding: 12px; border-radius: 14px; background: var(--bg-soft); border: 1px solid var(--border); margin-bottom: 8px; }
.provider-card .chat-icon { width: 36px; height: 36px; }
.provider-card .pc-main { flex: 1; min-width: 0; }
.provider-card .pc-name { font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.provider-card .pc-detail { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.1); }
.avatar { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border-strong); object-fit: cover; background: var(--surface-3); }
.switch { width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: background 0.2s; flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #c7cde0; transition: transform 0.2s, background 0.2s; }
.switch.on { background: rgba(124, 156, 255, 0.4); border-color: rgba(124, 156, 255, 0.5); }
.switch.on::after { transform: translateX(18px); background: #fff; }
.token-box { display: flex; gap: 6px; align-items: center; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.token-box span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-soft { font-size: 10px; font-weight: 650; color: var(--muted); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; }
.warn { display: flex; gap: 9px; padding: 11px 12px; border-radius: 12px; background: rgba(255, 180, 92, 0.08); border: 1px solid rgba(255, 180, 92, 0.18); color: #f3cf9d; font-size: 11.5px; line-height: 1.45; }
.warn svg { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.account-hero { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.account-hero .avatar { width: 52px; height: 52px; }
.account-name { font-size: 16px; font-weight: 700; }
.account-email { font-size: 12px; color: var(--muted); }
.account-plan { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- connect */
.connect-screen { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px calc(24px + var(--sab)); }
.connect-card { width: 100%; max-width: 410px; }
.connect-logo { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px; background: conic-gradient(from 210deg, #6d8cff, #a78bfa, #4fd1a5, #6d8cff); display: grid; place-items: center; box-shadow: 0 16px 50px rgba(124, 156, 255, 0.35); }
.connect-logo svg { width: 40px; height: 40px; color: #07101f; }
.connect-card h1 { text-align: center; margin: 0 0 6px; font-size: 28px; letter-spacing: -0.03em; }
.connect-card .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }
.code-input { height: 58px !important; text-align: center; font: 700 26px/1 var(--mono) !important; letter-spacing: 12px; padding-left: 12px !important; }
.connect-note { font-size: 11px; color: var(--faint); text-align: center; line-height: 1.5; margin-top: 14px; }
.connect-error { color: #ffb3bb; font-size: 12px; text-align: center; margin-top: 10px; min-height: 18px; }
.manual-link { display: block; text-align: center; margin-top: 16px; font-size: 12px; color: var(--faint); }

/* ---------------------------------------------------------------- toast */
.toasts { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + var(--sab)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast { background: rgba(28, 33, 46, 0.96); border: 1px solid var(--border-strong); color: var(--text); font-size: 12.5px; padding: 10px 14px; border-radius: 12px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4); animation: toastin 0.2s; max-width: 100%; text-align: center; }
.toast.error { background: rgba(58, 22, 28, 0.97); border-color: rgba(255, 107, 122, 0.3); color: #ffc2c8; }
.toast.ok { background: rgba(16, 44, 32, 0.97); border-color: rgba(74, 222, 128, 0.25); color: #b9f6cd; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- misc */
.offline-banner { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 9px 12px; border-radius: 11px; background: rgba(255, 107, 122, 0.08); border: 1px solid rgba(255, 107, 122, 0.2); color: #ffb3bb; font-size: 11.5px; }
.offline-banner svg { width: 15px; height: 15px; flex: 0 0 auto; }
.loading-screen { min-height: 100dvh; display: grid; place-items: center; }
.loading-mark { width: 46px; height: 46px; border-radius: 15px; background: conic-gradient(from 210deg, #6d8cff, #a78bfa, #4fd1a5, #6d8cff); display: grid; place-items: center; animation: breathe 1.6s ease-in-out infinite; }
.loading-mark svg { width: 25px; height: 25px; color: #07101f; }
@keyframes breathe { 50% { transform: scale(0.92); opacity: 0.75; } }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (min-width: 760px) {
  .content { max-width: 720px; margin: 0 auto; width: 100%; }
  .messages { max-width: 820px; margin: 0 auto; width: 100%; }
  .composer-wrap { max-width: 820px; margin: 0 auto; width: 100%; }
  .bottom-nav { max-width: 520px; margin: 0 auto; border-radius: 22px 22px 0 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .topbar { max-width: 820px; margin: 0 auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
