:root {
  --bg: #f7f8fa;
  --bg-soft: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9edf3;
  --text: #111318;
  --text-2: #333944;
  --muted: #6b7280;
  --muted-2: #98a1af;
  --border: #e2e6ec;
  --border-strong: #cfd6e2;
  --accent: #0f9f7f;
  --accent-2: #13b892;
  --accent-ink: #ffffff;
  --accent-soft: #e6f7f1;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --user-bubble: #eef2f7;
  --code-bg: #11151d;
  --code-text: #e6edf3;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 8px 30px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 80px rgba(16, 24, 40, .14);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sidebar-w: 282px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #141821;
  --surface: #171b23;
  --surface-2: #1d222c;
  --surface-3: #252b37;
  --text: #f1f4f8;
  --text-2: #d4dae4;
  --muted: #9aa4b2;
  --muted-2: #6f7b8c;
  --border: #29303c;
  --border-strong: #3a4454;
  --accent: #2dd4a7;
  --accent-2: #5eead4;
  --accent-ink: #06231b;
  --accent-soft: #112a24;
  --danger: #f87171;
  --danger-soft: #2a1518;
  --user-bubble: #202733;
  --code-bg: #0b0e14;
  --code-text: #e6edf3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 10px 34px rgba(0, 0, 0, .35);
  --shadow-lg: 0 30px 90px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden, [hidden] { display: none !important; }
.mobile-only { display: none !important; }

::selection { background: rgba(15, 159, 127, .22); }

/* Boot */
.boot {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity .25s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot-mark, .brand-mark, .empty-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background:
    radial-gradient(circle at 30% 20%, #7dd3fc 0 18%, transparent 19%),
    radial-gradient(circle at 70% 80%, #34d399 0 18%, transparent 19%),
    linear-gradient(135deg, #6366f1, #0f9f7f);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 8px 24px rgba(15,159,127,.22);
  position: relative;
}
.boot-mark::after, .brand-mark::after, .empty-mark::after {
  content: ""; position: absolute; inset: 8px; border-radius: 6px;
  background: rgba(255,255,255,.9);
  clip-path: polygon(0 0, 100% 0, 100% 70%, 62% 70%, 44% 100%, 44% 70%, 0 70%);
  opacity: .92;
}
.boot-mark { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .75; } }

/* Brand */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-name { font-weight: 750; letter-spacing: -.02em; font-size: 18px; }
.brand-lg .brand-name { font-size: 22px; }

/* Auth */
.auth-view { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--bg); }
.auth-art {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  padding: 64px;
  background:
    radial-gradient(900px 600px at 15% 10%, rgba(99,102,241,.35), transparent 55%),
    radial-gradient(700px 500px at 80% 80%, rgba(15,159,127,.32), transparent 55%),
    linear-gradient(160deg, #0b1020 0%, #111827 45%, #071a17 100%);
  color: #f8fafc;
}
.auth-art::before {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at 40% 40%, #000, transparent 75%);
}
.auth-art-inner { position: relative; z-index: 2; max-width: 520px; width: 100%; }
.auth-art .brand { color: #fff; margin-bottom: 56px; }
.auth-art h1 { font-size: clamp(38px, 4.6vw, 62px); line-height: 1.06; letter-spacing: -.045em; margin: 0 0 24px; font-weight: 780; }
.auth-lead { color: rgba(248,250,252,.68); font-size: 17px; line-height: 1.75; max-width: 430px; margin: 0 0 34px; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; color: rgba(248,250,252,.82); font-size: 14.5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 5px rgba(52,211,153,.12); }
.auth-orbit { position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.1); pointer-events: none; }
.orbit-a { width: 560px; height: 560px; right: -240px; top: -180px; box-shadow: inset 0 0 80px rgba(99,102,241,.1); }
.orbit-b { width: 380px; height: 380px; left: -180px; bottom: -160px; border-color: rgba(52,211,153,.12); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--surface); }
.auth-card { width: min(420px, 100%); }
.auth-card-head h2 { font-size: 30px; letter-spacing: -.03em; margin: 0 0 8px; }
.auth-card-head p { color: var(--muted); margin: 0 0 28px; font-size: 14.5px; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 26px; }
.auth-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 22px; }
.auth-tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px 14px; border-radius: 9px; font-weight: 650; font-size: 14px; transition: .18s ease; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field input {
  height: 48px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg);
  padding: 0 14px; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); background: var(--surface); }
.field input::placeholder { color: var(--muted-2); }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; margin: 2px 0 14px; }
.btn { border: 0; border-radius: 12px; height: 46px; padding: 0 18px; font-weight: 680; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s ease, background .16s ease, opacity .16s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.auth-foot { margin: 18px 0 0; color: var(--muted-2); font-size: 12px; line-height: 1.7; text-align: center; }

/* App shell */
.app-shell { height: 100dvh; display: flex; overflow: hidden; background: var(--bg); }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); min-width: 0; height: 100dvh;
  display: flex; flex-direction: column; padding: 14px 12px;
  background: var(--bg-soft); border-right: 1px solid var(--border);
  transition: transform .22s ease;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 14px; }
.new-chat {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); display: flex; align-items: center; gap: 10px;
  padding: 0 12px; font-weight: 650; font-size: 14px; box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, background .16s ease;
}
.new-chat:hover { border-color: var(--border-strong); background: var(--surface-2); }
.new-chat svg { width: 18px; height: 18px; color: var(--muted); }
.new-chat kbd { margin-left: auto; font-family: var(--font); font-size: 11px; color: var(--muted-2); border: 1px solid var(--border); padding: 2px 5px; border-radius: 5px; }
.sidebar-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .02em; padding: 20px 10px 8px; }
.count { color: var(--muted-2); font-weight: 500; }
.conversation-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 2px 12px; display: flex; flex-direction: column; gap: 2px; }
.conv-item { display: flex; align-items: center; gap: 8px; border-radius: 10px; padding: 9px 9px 9px 10px; color: var(--text-2); font-size: 13.5px; text-decoration: none; cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%; min-width: 0; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.conv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 10.5px; color: var(--muted-2); flex: 0 0 auto; }
.conv-menu-btn { opacity: 0; border: 0; background: transparent; color: var(--muted); width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; flex: 0 0 24px; }
.conv-menu-btn svg { width: 15px; height: 15px; }
.conv-item:hover .conv-menu-btn, .conv-item.active .conv-menu-btn { opacity: 1; }
.conv-menu-btn:hover { background: var(--surface-3); color: var(--text); }
.conv-menu { position: fixed; z-index: 60; min-width: 132px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); padding: 5px; }
.conv-menu button { display: flex; width: 100%; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text-2); text-align: left; }
.conv-menu button:hover { background: var(--surface-2); }
.conv-menu button.danger { color: var(--danger); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 6px 2px; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.avatar { width: 31px; height: 31px; flex: 0 0 31px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 750; color: #fff; background: linear-gradient(135deg, #6366f1, #0f9f7f); }
.user-meta { display: grid; min-width: 0; line-height: 1.3; }
.user-meta strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 10.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: flex; gap: 2px; }
.icon-btn { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; transition: .15s ease; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
#theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] #theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100dvh; position: relative; }
.topbar {
  height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px); z-index: 10;
}
.topbar-title { display: grid; line-height: 1.2; min-width: 0; }
.topbar-title span { color: var(--muted-2); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.topbar-title strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.model-select { display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 9px 0 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); position: relative; }
.model-select:hover { border-color: var(--border-strong); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.model-select select { appearance: none; border: 0; outline: none; background: transparent; font-size: 12.5px; font-weight: 650; padding: 0 18px 0 1px; cursor: pointer; max-width: 150px; }
.model-select > svg { position: absolute; right: 8px; width: 13px; height: 13px; color: var(--muted-2); pointer-events: none; }
.chat-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.messages { width: min(820px, 100%); margin: 0 auto; padding: 30px 22px 18px; }
.empty-state { width: min(820px, 100%); margin: 0 auto; padding: clamp(40px, 10vh, 100px) 22px 20px; text-align: center; }
.empty-mark { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 22px; }
.empty-mark::after { inset: 12px; }
.empty-state h1 { font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -.035em; margin: 0 0 12px; font-weight: 750; }
.empty-state > p { color: var(--muted); margin: 0 auto 34px; font-size: 14.5px; max-width: 480px; line-height: 1.7; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.suggestion { display: flex; align-items: flex-start; gap: 12px; padding: 15px 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); transition: .16s ease; box-shadow: var(--shadow-sm); }
.suggestion:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.suggestion-icon { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 750; }
.suggestion span:last-child { display: grid; gap: 3px; }
.suggestion strong { font-size: 13.5px; }
.suggestion small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }

/* Messages */
.msg { display: flex; gap: 13px; margin: 0 0 26px; animation: rise .2s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 750; margin-top: 1px; }
.msg-assistant .msg-avatar { background: linear-gradient(135deg, #6366f1, #0f9f7f); color: #fff; }
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { max-width: min(78%, 620px); background: var(--user-bubble); border-radius: 18px 18px 5px 18px; padding: 11px 15px; }
.msg-user .msg-content { white-space: pre-wrap; word-break: break-word; }
.msg-body { min-width: 0; max-width: 100%; }
.msg-assistant .msg-body { flex: 1; padding-top: 3px; }
.msg-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 11.5px; color: var(--muted); }
.msg-meta strong { color: var(--text-2); font-size: 12px; }
.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s ease; margin-top: 6px; }
.msg:hover .msg-actions { opacity: 1; }
.msg-action { height: 26px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; padding: 0 7px; font-size: 11px; display: inline-flex; align-items: center; gap: 4px; }
.msg-action:hover { background: var(--surface-2); color: var(--text); }
.msg-action svg { width: 13px; height: 13px; }
.msg-error { color: var(--danger); background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 20%, transparent); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.stream-cursor { display: inline-block; width: 7px; height: 16px; margin-left: 2px; background: var(--accent); vertical-align: -3px; border-radius: 1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 13px; padding: 5px 0; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-2); animation: bounce 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Markdown */
.markdown { font-size: 15px; line-height: 1.78; color: var(--text); word-break: break-word; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 14px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 26px 0 12px; line-height: 1.35; letter-spacing: -.02em; }
.markdown h1 { font-size: 24px; }
.markdown h2 { font-size: 20px; }
.markdown h3 { font-size: 17px; }
.markdown h4 { font-size: 15px; }
.markdown ul, .markdown ol { margin: 0 0 14px; padding-left: 24px; }
.markdown li { margin: 5px 0; }
.markdown li > p { margin: 4px 0; }
.markdown blockquote { margin: 0 0 14px; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.markdown a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.markdown a:hover { border-bottom-color: var(--accent); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.markdown table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 13.5px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.markdown th { background: var(--surface-2); font-weight: 650; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: .9em; background: var(--surface-3); padding: 2px 5px; border-radius: 5px; }
.markdown pre { position: relative; margin: 0 0 16px; background: var(--code-bg); color: var(--code-text); border-radius: 12px; padding: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.06); }
.markdown pre code { display: block; padding: 15px 16px; overflow-x: auto; background: transparent; color: inherit; font-size: 12.5px; line-height: 1.65; }
.code-block { margin: 0 0 16px; border-radius: 12px; overflow: hidden; }
.code-block pre { margin: 0; border-radius: 0; border: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 34px; padding: 0 10px 0 14px; background: rgba(255,255,255,.05); color: #9aa4b2; font-size: 11px; border-bottom: 1px solid rgba(255,255,255,.06); }
.code-head button { border: 0; background: transparent; color: #9aa4b2; font-size: 11px; padding: 4px 7px; border-radius: 5px; }
.code-head button:hover { background: rgba(255,255,255,.08); color: #fff; }
.markdown pre code.hljs { background: transparent; padding: 15px 16px; }

/* Composer */
.composer-wrap { flex: 0 0 auto; padding: 0 22px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, var(--bg) 26%); }
.composer { width: min(820px, 100%); margin: 0 auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 22px; box-shadow: var(--shadow-md); padding: 13px 13px 9px 18px; transition: border-color .16s ease, box-shadow .16s ease; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), var(--shadow-md); }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 220px; resize: none; border: 0; outline: none; background: transparent; font-size: 15px; line-height: 1.6; padding: 2px 0; color: var(--text); }
.composer textarea::placeholder { color: var(--muted-2); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 5px; }
.composer-hint { color: var(--muted-2); font-size: 10.5px; }
.composer-hint kbd { font-family: var(--font); font-size: 10px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; }
.composer-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.send-btn { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; transition: .15s ease; }
.send-btn svg { width: 18px; height: 18px; stroke-width: 2.1; }
.send-btn:disabled { background: var(--surface-3); color: var(--muted-2); cursor: not-allowed; }
.send-btn:not(:disabled):hover { background: var(--accent-2); }
.stop-btn { height: 32px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 8px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; }
.stop-btn:hover { background: var(--surface-2); }
.stop-square { width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.composer-foot { text-align: center; color: var(--muted-2); font-size: 10.5px; margin: 8px 0 0; }

/* Modal / toast */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 12, .52); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: min(390px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px; }
.modal-card h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.02em; }
.modal-text { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 16px; }
.modal-input { width: 100%; height: 44px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px; background: var(--bg); outline: none; margin-bottom: 16px; }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions .btn { height: 38px; font-size: 13px; }
.toasts { position: fixed; z-index: 90; right: 18px; bottom: 18px; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 36px)); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 11px 13px; font-size: 12.5px; line-height: 1.5; animation: toastIn .2s ease both; }
.toast.error { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Sidebar overlay */
.mobile-overlay { position: fixed; inset: 0; z-index: 39; background: rgba(3, 6, 10, .48); backdrop-filter: blur(2px); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* Responsive */
@media (max-width: 900px) {
  .mobile-only { display: inline-grid !important; }
  .auth-view { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { min-height: 100dvh; }
  .auth-mobile-brand { display: flex; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { width: 100%; }
  .topbar { padding: 0 12px 0 10px; }
  .topbar-title strong { max-width: 38vw; }
  .messages { padding: 24px 14px 12px; }
  .empty-state { padding-top: 46px; }
  .suggestions { grid-template-columns: 1fr; }
  .composer-wrap { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
  .composer { border-radius: 18px; padding: 11px 10px 8px 14px; }
  .composer-hint { display: none; }
  .msg-user .msg-body { max-width: 88%; }
  .msg-actions { opacity: 1; }
  #share-btn { display: none; }
}

@media (max-width: 520px) {
  .auth-panel { padding: 28px 18px; }
  .auth-card-head h2 { font-size: 26px; }
  .empty-state h1 { font-size: 25px; }
  .empty-state > p { font-size: 13.5px; }
  .model-select select { max-width: 108px; }
  .topbar-title span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
