@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #fafafd;
  --sidebar: #f3f3f8;
  --surface: #ffffff;
  --surface-soft: #f6f6fa;
  --surface-hover: #ececf3;
  --text: #20202a;
  --text-secondary: #707080;
  --text-muted: #9b9baa;
  --border: #e7e7ee;
  --border-strong: #dcdce6;
  --primary: #7057d9;
  --primary-dark: #5d45c3;
  --primary-soft: #eeeafd;
  --primary-faint: #f7f4ff;
  --danger: #d84f5f;
  --danger-soft: #fff0f1;
  --user-bubble: #efedf8;
  --code-bg: #22222c;
  --shadow-sm: 0 1px 2px rgba(28, 25, 43, .04), 0 4px 12px rgba(28, 25, 43, .03);
  --shadow-lg: 0 20px 60px rgba(28, 25, 43, .14), 0 2px 8px rgba(28, 25, 43, .06);
  --sidebar-width: 272px;
  --topbar-height: 68px;
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17171d;
  --sidebar: #111116;
  --surface: #202027;
  --surface-soft: #25252d;
  --surface-hover: #2c2c35;
  --text: #ededf3;
  --text-secondary: #aaaab8;
  --text-muted: #777785;
  --border: #303039;
  --border-strong: #3b3b46;
  --primary: #a18af1;
  --primary-dark: #b29cf8;
  --primary-soft: #302944;
  --primary-faint: #262231;
  --danger: #f07986;
  --danger-soft: #382328;
  --user-bubble: #302c40;
  --code-bg: #111116;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .12);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { font-family: var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { border: 0; background: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.fill-icon { fill: currentColor; stroke: none; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
kbd { font-family: var(--font); font-size: 10px; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; background: var(--surface); box-shadow: 0 1px 0 var(--border); }

.app-shell { display: flex; width: 100%; height: 100%; height: 100dvh; }
.sidebar { width: var(--sidebar-width); height: 100%; background: var(--sidebar); border-right: 1px solid var(--border); padding: 20px 14px 14px; display: flex; flex-direction: column; flex: 0 0 auto; z-index: 30; transition: transform .28s ease, width .28s ease; }
.brand-row { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 5px 0 7px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 20px; font-weight: 600; letter-spacing: -.5px; }
.brand b { color: var(--primary); font-weight: 700; }
.brand-mark { width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #9680ed, #6449c6); box-shadow: 0 5px 14px rgba(112,87,217,.25); }
.brand-mark svg { width: 19px; height: 19px; stroke-width: 1.6; }
.icon-button { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 9px; color: var(--text-secondary); transition: background .18s, color .18s, transform .18s; }
.icon-button:hover { background: var(--surface-hover); color: var(--text); }
.icon-button:active { transform: scale(.94); }
.icon-button svg { width: 18px; height: 18px; }
.sidebar-close { width: 30px; height: 30px; }
.new-chat-button, .search-button { display: flex; align-items: center; justify-content: space-between; width: 100%; border-radius: 10px; padding: 0 12px; height: 43px; font-size: 13px; font-weight: 500; }
.new-chat-button { color: #fff; background: var(--text); box-shadow: var(--shadow-sm); margin-bottom: 8px; }
html[data-theme="dark"] .new-chat-button { background: var(--primary); }
.new-chat-button:hover { transform: translateY(-1px); opacity: .92; }
.new-chat-button > span, .search-button > span { display: flex; align-items: center; gap: 10px; }
.new-chat-button svg, .search-button svg { width: 17px; height: 17px; }
.new-chat-button kbd { background: rgba(255,255,255,.1); color: rgba(255,255,255,.6); border-color: rgba(255,255,255,.12); box-shadow: none; }
.search-button { color: var(--text-secondary); }
.search-button:hover { background: var(--surface-hover); color: var(--text); }
.history-label { margin: 25px 12px 9px; color: var(--text-muted); font-size: 11px; font-weight: 600; letter-spacing: .4px; }
.conversation-list { min-height: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.history-group-label { color: var(--text-muted); font-size: 10px; padding: 12px 12px 6px; }
.conversation-item { display: flex; align-items: center; position: relative; border-radius: 9px; margin: 2px 0; }
.conversation-open { width: 100%; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 34px 10px 11px; border-radius: 9px; text-align: left; color: var(--text-secondary); font-size: 12.5px; }
.conversation-open svg { width: 16px; height: 16px; opacity: .75; }
.conversation-open span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item:hover { background: var(--surface-hover); }
.conversation-item.active { background: var(--surface-hover); }
.conversation-item.active .conversation-open { color: var(--text); font-weight: 500; }
.conversation-more { position: absolute; right: 5px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; opacity: 0; color: var(--text-secondary); }
.conversation-more:hover { background: var(--border); }
.conversation-more svg { width: 16px; height: 16px; }
.conversation-item:hover .conversation-more, .conversation-item.active .conversation-more { opacity: 1; }
.empty-history { text-align: center; color: var(--text-muted); font-size: 12px; padding: 28px 10px; line-height: 1.7; }
.sidebar-bottom { margin-top: auto; padding-top: 14px; }
.inspiration-card { display: flex; align-items: center; gap: 9px; margin: 0 2px 12px; padding: 12px 10px; border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(120deg, var(--primary-faint), var(--surface)); cursor: default; }
.inspiration-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--primary-soft); color: var(--primary); }
.inspiration-icon svg { width: 16px; height: 16px; }
.inspiration-card strong { display: block; font-size: 11.5px; font-weight: 600; }
.inspiration-card p { margin: 3px 0 0; font-size: 10px; color: var(--text-muted); }
.inspiration-arrow { width: 14px; height: 14px; margin-left: auto; color: var(--text-muted); }
.profile-button { width: 100%; display: flex; align-items: center; text-align: left; gap: 10px; padding: 9px 8px; border-radius: 11px; }
.profile-button:hover { background: var(--surface-hover); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #594532; background: linear-gradient(140deg, #f2ddc4, #dcbf9f); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.profile-copy { display: flex; flex-direction: column; gap: 2px; }
.profile-copy strong { font-size: 12px; font-weight: 600; }
.profile-copy small { color: var(--text-muted); font-size: 10px; }
.profile-button > svg { margin-left: auto; width: 17px; height: 17px; color: var(--text-muted); }
.sidebar-backdrop { display: none; }
.app-shell.sidebar-collapsed .sidebar { width: 0; padding-left: 0; padding-right: 0; border-right: 0; overflow: hidden; }
.app-shell.sidebar-collapsed .mobile-menu { display: inline-grid; margin-left: -7px; }
.conversation-context { position: fixed; width: 160px; }
.conversation-context button { width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; text-align: left; font-size: 11px; }
.conversation-context button:hover { background: var(--surface-soft); }
.conversation-context button svg { width: 15px; height: 15px; color: var(--text-secondary); }
.conversation-context button.danger { color: var(--danger); }
.conversation-context button.danger svg { color: var(--danger); }

.main-panel { min-width: 0; flex: 1; height: 100%; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.topbar { height: var(--topbar-height); flex: 0 0 auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid transparent; position: relative; z-index: 20; }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 5px; }
.topbar-left { position: relative; }
.mobile-menu { display: none; }
.model-selector { height: 38px; display: flex; align-items: center; gap: 8px; border-radius: 10px; padding: 0 10px; font-size: 13px; font-weight: 600; }
.model-selector:hover, .model-selector[aria-expanded="true"] { background: var(--surface-hover); }
.model-selector > svg { width: 15px; height: 15px; color: var(--text-muted); }
.model-dot { width: 7px; height: 7px; border-radius: 50%; background: #65b888; box-shadow: 0 0 0 3px rgba(101,184,136,.12); }
.conversation-title { color: var(--text-muted); font-size: 12px; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.dropdown { position: absolute; display: none; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-lg); z-index: 50; animation: pop-in .16s ease; }
.dropdown.open { display: block; }
.model-dropdown { top: 44px; left: 0; width: 300px; }
.dropdown-heading { padding: 7px 9px 8px; color: var(--text-muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.model-option { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; border-radius: 9px; padding: 10px 9px; }
.model-option:hover { background: var(--surface-soft); }
.model-option-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.model-option-icon svg { width: 17px; height: 17px; }
.purple { color: #7659d6; background: #f0ebff; }
.blue { color: #4b7fc4; background: #eaf3ff; }
.green { color: #378e75; background: #e5f6f0; }
html[data-theme="dark"] .purple { background: #352c4a; }
html[data-theme="dark"] .blue { background: #233346; }
html[data-theme="dark"] .green { background: #203a34; }
.model-option > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.model-option strong { font-size: 12px; font-weight: 600; }
.model-option small { color: var(--text-muted); font-size: 10px; }
.option-check { width: 16px; height: 16px; margin-left: auto; color: var(--primary); opacity: 0; }
.model-option.selected .option-check { opacity: 1; }
.more-wrap { position: relative; }
.more-dropdown { top: 42px; right: 0; width: 190px; }
.more-dropdown button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; font-size: 12px; text-align: left; }
.more-dropdown button:hover { background: var(--surface-soft); }
.more-dropdown svg { width: 16px; height: 16px; color: var(--text-secondary); }
.more-dropdown .danger { color: var(--danger); }
.more-dropdown .danger svg { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 5px; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.welcome-view { min-height: 100%; max-width: 850px; margin: 0 auto; padding: clamp(45px, 9vh, 100px) 28px 34px; display: flex; flex-direction: column; align-items: center; animation: fade-up .5s ease both; }
.welcome-symbol { width: 74px; height: 74px; position: relative; display: grid; place-items: center; margin-bottom: 25px; }
.welcome-symbol::before { content: ''; position: absolute; inset: 4px; border-radius: 24px; transform: rotate(10deg); background: linear-gradient(145deg, #a791ed, #7057d9); box-shadow: 0 16px 40px rgba(112,87,217,.23); }
.welcome-symbol svg { position: relative; width: 34px; height: 34px; color: #fff; z-index: 2; stroke-width: 1.35; }
.orb { position: absolute; border-radius: 50%; filter: blur(1px); z-index: 3; }
.orb-one { width: 15px; height: 15px; right: -2px; top: 4px; background: #e3b5d2; border: 3px solid var(--bg); }
.orb-two { width: 11px; height: 11px; left: 1px; bottom: 7px; background: #a7d9d0; border: 3px solid var(--bg); }
.welcome-eyebrow { margin: 0 0 11px; font-size: 9px; font-weight: 600; letter-spacing: 2.5px; color: var(--primary); }
.welcome-view h1 { margin: 0; text-align: center; font-size: clamp(27px, 3vw, 35px); line-height: 1.35; letter-spacing: -1.3px; font-weight: 600; }
.welcome-subtitle { margin: 13px 0 36px; font-size: 13px; color: var(--text-secondary); letter-spacing: .1px; }
.suggestion-grid { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.suggestion-card { display: flex; align-items: center; gap: 13px; min-height: 78px; padding: 15px; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-sm); transition: transform .2s, border-color .2s, box-shadow .2s; }
.suggestion-card:hover { transform: translateY(-2px); border-color: #d7cfee; box-shadow: 0 8px 24px rgba(50,40,80,.07); }
.suggestion-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; }
.suggestion-icon svg { width: 19px; height: 19px; }
.peach { color: #b86f52; background: #fff0e8; }
.mint { color: #428d7d; background: #e8f7f2; }
.lilac { color: #8665c7; background: #f1ebfc; }
.sky { color: #4c82ad; background: #eaf4fb; }
html[data-theme="dark"] .peach { background: #3d2e29; }
html[data-theme="dark"] .mint { background: #233b35; }
html[data-theme="dark"] .lilac { background: #322a42; }
html[data-theme="dark"] .sky { background: #243542; }
.suggestion-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.suggestion-copy strong { font-size: 12px; font-weight: 600; }
.suggestion-copy small { font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-arrow { margin-left: auto; width: 15px; height: 15px; color: var(--text-muted); transform: rotate(45deg); opacity: 0; transition: opacity .2s, transform .2s; }
.suggestion-card:hover .suggestion-arrow { opacity: 1; transform: rotate(45deg) translateY(-2px); }

.message-list { max-width: 800px; margin: 0 auto; padding: 24px 28px 36px; }
.message-row { display: flex; margin-bottom: 30px; animation: fade-up .25s ease; }
.user-row { justify-content: flex-end; padding-left: 16%; }
.user-message-wrap { max-width: 80%; display: flex; flex-direction: column; align-items: flex-end; }
.user-bubble { padding: 11px 16px; background: var(--user-bubble); border-radius: 17px 17px 4px 17px; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.message-time { font-size: 9px; color: var(--text-muted); margin-top: 5px; opacity: 0; transition: opacity .2s; }
.user-message-wrap:hover .message-time { opacity: 1; }
.ai-row { gap: 12px; align-items: flex-start; }
.ai-avatar { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #9c87e9, #6d53ce); box-shadow: 0 4px 12px rgba(112,87,217,.18); }
.ai-avatar svg { width: 17px; height: 17px; stroke-width: 1.5; }
.ai-message-wrap { flex: 1; min-width: 0; padding-top: 3px; }
.ai-content { color: var(--text); font-size: 13.5px; line-height: 1.85; word-break: break-word; }
.ai-content > :first-child { margin-top: 0; }
.ai-content > :last-child { margin-bottom: 0; }
.ai-content p { margin: 0 0 13px; }
.ai-content strong { font-weight: 600; }
.ai-content h2, .ai-content h3 { font-size: 15px; line-height: 1.5; margin: 22px 0 9px; font-weight: 600; }
.ai-content h3::before { content: ''; display: inline-block; width: 3px; height: 13px; border-radius: 3px; background: var(--primary); margin-right: 8px; vertical-align: -1px; }
.ai-content ul, .ai-content ol { padding-left: 21px; margin: 7px 0 15px; }
.ai-content li { padding-left: 3px; margin: 5px 0; }
.ai-content li::marker { color: var(--primary); }
.inline-code { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: .9em; padding: 2px 5px; border-radius: 5px; background: var(--surface-hover); color: var(--primary-dark); }
.code-block { margin: 15px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--code-bg); }
.code-header { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: #a9a9b7; background: rgba(255,255,255,.035); border-bottom: 1px solid rgba(255,255,255,.07); font-size: 10px; text-transform: lowercase; }
.code-copy { display: flex; align-items: center; gap: 5px; color: #b9b9c6; font-size: 10px; padding: 4px; }
.code-copy:hover { color: #fff; }
.code-copy svg { width: 13px; height: 13px; }
.code-block pre { margin: 0; padding: 16px; overflow-x: auto; color: #e6e2f1; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; font-size: 12px; line-height: 1.7; tab-size: 2; }
.message-actions { display: flex; align-items: center; gap: 2px; margin-top: 9px; opacity: .65; transition: opacity .2s; }
.ai-row:hover .message-actions { opacity: 1; }
.message-action { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--text-muted); }
.message-action:hover { background: var(--surface-hover); color: var(--text); }
.message-action.active { color: var(--primary); background: var(--primary-soft); }
.message-action svg { width: 14px; height: 14px; }
.response-label { margin-left: 5px; color: var(--text-muted); font-size: 9px; }
.typing-row { max-width: 800px; margin: 0 auto; padding: 0 28px 35px; display: flex; gap: 12px; }
.typing-content { display: flex; align-items: center; gap: 10px; padding-top: 5px; color: var(--text-secondary); font-size: 12px; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots i { width: 4px; height: 4px; background: var(--primary); border-radius: 50%; animation: typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }

.composer-area { flex: 0 0 auto; padding: 10px 24px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--bg) 18%); position: relative; z-index: 10; }
.composer { max-width: 800px; margin: 0 auto; padding: 13px 14px 10px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: 0 8px 32px rgba(35,29,57,.07), 0 1px 3px rgba(35,29,57,.04); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: #c6bae9; box-shadow: 0 8px 32px rgba(72,52,135,.09), 0 0 0 3px rgba(112,87,217,.06); }
.composer textarea { display: block; width: 100%; min-height: 29px; max-height: 170px; padding: 1px 3px 8px; resize: none; border: none; outline: none; background: transparent; color: var(--text); font-size: 13.5px; line-height: 1.65; overflow-y: auto; }
.composer textarea::placeholder { color: var(--text-muted); }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-tools { display: flex; align-items: center; gap: 5px; }
.tool-button { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; color: var(--text-secondary); }
.tool-button:hover { background: var(--surface-soft); color: var(--text); }
.tool-button svg { width: 17px; height: 17px; }
.tool-pill { height: 31px; padding: 0 9px; display: flex; align-items: center; gap: 5px; border-radius: 8px; color: var(--text-secondary); font-size: 10.5px; border: 1px solid transparent; }
.tool-pill:hover { background: var(--surface-soft); }
.tool-pill svg { width: 15px; height: 15px; }
.tool-pill.active { color: var(--primary-dark); background: var(--primary-soft); border-color: rgba(112,87,217,.12); }
.send-wrap { display: flex; align-items: center; gap: 10px; }
.input-hint { font-size: 9px; color: var(--text-muted); white-space: nowrap; }
.send-button { width: 33px; height: 33px; display: grid; place-items: center; border-radius: 10px; background: var(--text); color: var(--bg); transition: transform .15s, opacity .15s, background .15s; }
.send-button svg { width: 17px; height: 17px; stroke-width: 2; }
.send-button:hover:not(:disabled) { transform: translateY(-1px); }
.send-button:disabled { opacity: .2; cursor: default; }
.send-button.generating { background: var(--primary); color: #fff; opacity: 1; }
.disclaimer { text-align: center; margin: 8px 0 0; color: var(--text-muted); font-size: 9px; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 0 10px; }
.message-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; }
.message-attachments .attachment-chip { background: var(--surface); }
.attachment-chip { display: flex; align-items: center; gap: 7px; max-width: 210px; height: 32px; padding: 0 7px 0 9px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-soft); font-size: 10px; color: var(--text-secondary); }
.attachment-chip > svg { width: 14px; height: 14px; color: var(--primary); }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { width: 20px; height: 20px; display: grid; place-items: center; color: var(--text-muted); padding: 0; }
.attachment-chip button svg { width: 12px; height: 12px; }

.modal-backdrop { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(20,18,28,.4); backdrop-filter: blur(6px); z-index: 100; animation: fade-in .18s ease; }
.modal-backdrop.open { display: flex; }
.dialog { width: 100%; max-width: 500px; padding: 25px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: dialog-in .22s ease; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 25px; }
.dialog-header h2 { margin: 4px 0 0; font-size: 20px; font-weight: 600; letter-spacing: -.5px; }
.dialog-eyebrow { color: var(--primary); font-size: 8px; font-weight: 600; letter-spacing: 1.8px; }
.dialog-header .icon-button { margin-top: -7px; margin-right: -8px; }
.setting-section { margin-bottom: 24px; }
.setting-section h3, .setting-row h3 { margin: 0 0 5px; font-size: 12px; font-weight: 600; }
.setting-section > p, .setting-row p { margin: 0; color: var(--text-muted); font-size: 10px; line-height: 1.5; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.theme-options button { height: 77px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; position: relative; border: 1px solid var(--border); border-radius: 11px; color: var(--text-secondary); font-size: 10px; }
.theme-options button:hover { background: var(--surface-soft); }
.theme-options button.active { border-color: var(--primary); background: var(--primary-faint); color: var(--primary); }
.theme-options button > svg { width: 20px; height: 20px; }
.theme-options button i { display: none; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }
.theme-options button.active i { display: block; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 0; border-top: 1px solid var(--border); }
.switch { width: 38px; height: 22px; padding: 2px; border-radius: 20px; background: var(--border-strong); transition: background .2s; flex: 0 0 auto; }
.switch span { display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: transform .2s; }
.switch.active { background: var(--primary); }
.switch.active span { transform: translateX(16px); }
.danger-zone { padding-bottom: 8px; }
.outline-danger { border: 1px solid var(--border); color: var(--danger); padding: 7px 13px; border-radius: 8px; font-size: 10px; }
.outline-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.settings-note { display: flex; align-items: center; gap: 7px; padding: 11px; border-radius: 9px; background: var(--surface-soft); color: var(--text-muted); font-size: 9px; margin-top: 17px; }
.settings-note svg { width: 14px; height: 14px; color: var(--primary); }
.small-dialog { max-width: 390px; }
.small-dialog .dialog-header { margin-bottom: 18px; }
.small-dialog .dialog-header h2 { font-size: 17px; }
.field-label { display: block; font-size: 10px; color: var(--text-secondary); margin-bottom: 7px; }
.text-field { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 12px; outline: none; }
.text-field:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.secondary-button, .primary-button, .danger-button { padding: 9px 16px; border-radius: 9px; font-size: 11px; font-weight: 500; }
.secondary-button { border: 1px solid var(--border); background: var(--surface); }
.secondary-button:hover { background: var(--surface-soft); }
.primary-button { color: #fff; background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.danger-button { color: #fff; background: var(--danger); }
.confirm-dialog { text-align: center; padding: 29px; }
.confirm-icon { width: 45px; height: 45px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); }
.confirm-icon svg { width: 20px; height: 20px; }
.confirm-dialog h2 { margin: 0 0 9px; font-size: 17px; }
.confirm-dialog p { margin: 0; color: var(--text-secondary); font-size: 11px; line-height: 1.6; }
.confirm-dialog .dialog-actions { justify-content: center; }

.search-modal { width: 100%; max-width: 570px; max-height: min(620px, 80vh); align-self: flex-start; margin-top: 8vh; background: var(--surface); border: 1px solid var(--border); border-radius: 17px; box-shadow: var(--shadow-lg); overflow: hidden; animation: dialog-in .2s ease; }
.search-input-row { display: flex; align-items: center; gap: 11px; height: 59px; padding: 0 17px; border-bottom: 1px solid var(--border); }
.search-input-row > svg { color: var(--text-muted); width: 19px; height: 19px; }
.search-input-row input { min-width: 0; flex: 1; height: 100%; border: none; outline: none; color: var(--text); background: transparent; font-size: 13px; }
.search-input-row input::placeholder { color: var(--text-muted); }
.search-results { max-height: 430px; min-height: 170px; overflow-y: auto; padding: 8px; }
.search-placeholder { padding: 45px 20px; text-align: center; color: var(--text-muted); font-size: 11px; }
.search-placeholder svg { display: block; width: 26px; height: 26px; margin: 0 auto 12px; opacity: .55; }
.search-result { width: 100%; display: flex; align-items: flex-start; gap: 11px; padding: 11px; text-align: left; border-radius: 10px; }
.search-result:hover, .search-result.selected { background: var(--surface-soft); }
.search-result > svg { width: 17px; height: 17px; margin-top: 2px; color: var(--text-muted); }
.search-result > span { min-width: 0; }
.search-result strong { display: block; font-size: 12px; font-weight: 500; margin-bottom: 4px; }
.search-result small { display: block; color: var(--text-muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result mark { color: var(--primary); background: var(--primary-soft); border-radius: 2px; }
.search-footer { height: 37px; display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 0 14px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 9px; }
.search-footer span { display: flex; align-items: center; gap: 4px; }
.search-footer kbd { font-size: 9px; padding: 1px 4px; }
.toast-region { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 10px 15px; border-radius: 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 11px; animation: toast-in .25s ease; }
.toast svg { width: 15px; height: 15px; color: var(--primary); }
.toast.error svg { color: var(--danger); }
.toast.leaving { animation: toast-out .2s ease forwards; }

@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .35; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(5px) scale(.97); } }

@media (min-width: 1100px) {
  .sidebar { padding-left: 17px; padding-right: 17px; }
  .topbar { padding: 0 30px; }
}

@media (max-width: 800px) {
  :root { --topbar-height: 58px; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(310px, 86vw); transform: translateX(-105%); box-shadow: var(--shadow-lg); padding-top: max(17px, env(safe-area-inset-top)); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,18,28,.32); backdrop-filter: blur(2px); z-index: 25; opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s; }
  .app-shell.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  .mobile-menu { display: inline-grid; margin-left: -7px; }
  .sidebar-close { display: grid; }
  .topbar { padding: 0 13px; border-bottom-color: var(--border); background: var(--bg); }
  .model-selector { font-size: 12px; padding: 0 7px; }
  .conversation-title { display: none; }
  .topbar-actions { gap: 0; }
  .topbar-actions .icon-button { width: 33px; }
  .model-dropdown { width: min(300px, calc(100vw - 26px)); }
  .welcome-view { justify-content: center; padding: 25px 20px 28px; }
  .welcome-symbol { width: 64px; height: 64px; margin-bottom: 22px; }
  .welcome-symbol::before { border-radius: 21px; }
  .welcome-symbol svg { width: 30px; height: 30px; }
  .welcome-view h1 { font-size: 27px; }
  .welcome-subtitle { margin-bottom: 30px; }
  .suggestion-grid { gap: 9px; }
  .suggestion-card { padding: 12px; min-height: 75px; gap: 10px; }
  .suggestion-icon { width: 34px; height: 34px; }
  .suggestion-copy small { max-width: 190px; }
  .message-list { padding: 20px 18px 28px; }
  .message-row { margin-bottom: 25px; }
  .typing-row { padding: 0 18px 28px; }
  .composer-area { padding: 8px 12px max(9px, env(safe-area-inset-bottom)); }
  .composer { padding: 11px 11px 9px; border-radius: 16px; }
  .input-hint { display: none; }
  .disclaimer { margin-top: 6px; }
  .toast-region { bottom: 105px; }
}

@media (max-width: 520px) {
  .welcome-view { justify-content: flex-start; padding-top: clamp(45px, 8vh, 72px); }
  .welcome-eyebrow { font-size: 8px; }
  .welcome-view h1 { font-size: 25px; letter-spacing: -.9px; }
  .welcome-subtitle { font-size: 12px; margin-top: 11px; }
  .suggestion-grid { grid-template-columns: 1fr; gap: 8px; }
  .suggestion-card { min-height: 62px; border-radius: 12px; padding: 10px 12px; }
  .suggestion-copy { gap: 3px; }
  .suggestion-copy strong { font-size: 11px; }
  .suggestion-copy small { font-size: 10px; max-width: none; }
  .suggestion-arrow { display: none; }
  .user-row { padding-left: 9%; }
  .user-message-wrap { max-width: 92%; }
  .user-bubble, .ai-content { font-size: 13px; }
  .ai-row { gap: 9px; }
  .ai-avatar { width: 27px; height: 27px; border-radius: 8px; }
  .ai-avatar svg { width: 15px; height: 15px; }
  .message-list { padding-left: 13px; padding-right: 13px; }
  .typing-row { padding-left: 13px; }
  .message-actions { opacity: .85; }
  .tool-pill { padding: 0 7px; }
  .tool-pill svg { width: 14px; height: 14px; }
  .tool-pill span { font-size: 10px; }
  .composer-tools { gap: 2px; }
  .composer textarea { font-size: 16px; min-height: 28px; }
  .dialog { padding: 21px; border-radius: 17px; }
  .modal-backdrop { padding: 14px; }
  .search-modal { margin-top: 4vh; max-height: 82vh; }
  .theme-options button { height: 70px; }
  .settings-note { line-height: 1.5; }
}

@media (max-height: 700px) and (min-width: 521px) {
  .welcome-view { padding-top: 25px; }
  .welcome-symbol { width: 58px; height: 58px; margin-bottom: 17px; }
  .welcome-subtitle { margin-bottom: 22px; }
  .suggestion-card { min-height: 65px; }
}

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

.profile-button.compact { padding: 6px 8px; margin-top: 5px; }
.profile-button.compact .user-avatar { width: 29px; height: 29px; border-radius: 8px; display: grid; place-items: center; }
.profile-button.compact .user-avatar svg { width: 15px; height: 15px; }
.auth-dialog { max-width: 760px; padding: 0; display: grid; grid-template-columns: 0.9fr 1fr; overflow: hidden; }
.auth-visual { position: relative; overflow: hidden; padding: 34px 31px; color: #fff; background: linear-gradient(150deg,#322a4b,#61489b 74%,#6f56b3); display: flex; flex-direction: column; gap: 14px; }
.auth-visual-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.14); }
.auth-visual-mark svg { width: 22px; height: 22px; }
.auth-visual strong { font-size: 25px; letter-spacing: -1px; display: block; line-height: 1.25; }
.auth-visual p { margin: 0; color: #cfc3e9; font-size: 12px; line-height: 1.7; }
.auth-decoration i { position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.auth-decoration i:first-child { width: 300px; height: 300px; right: -105px; bottom: -105px; }
.auth-decoration i:last-child { width: 170px; height: 170px; right: -35px; bottom: -35px; }
.auth-body { padding: 25px; }
.auth-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-soft); border-radius: 10px; margin-bottom: 21px; }
.auth-tabs button { flex: 1; height: 33px; border-radius: 7px; color: var(--text-secondary); font-size: 11px; }
.auth-tabs button.active { color: var(--text); background: var(--surface); box-shadow: 0 1px 4px rgba(30,25,50,.08); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; }
.auth-form .text-field { height: 44px; margin-bottom: 11px; }
.auth-error { min-height: 16px; margin: 3px 0 7px; color: var(--danger); font-size: 9px; line-height: 1.5; }
.auth-submit { height: 44px; }
.auth-agree { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 9px; margin: 2px 0 6px; }
.auth-agree input { width: 13px; height: 13px; accent-color: var(--primary); }
.account-card { display: flex; align-items: center; gap: 13px; padding: 13px; margin: 4px 0 19px; border-radius: 12px; background: var(--surface-soft); }
.account-card strong { display: block; font-size: 13px; }
.account-card small { display: block; color: var(--text-muted); font-size: 9px; margin-top: 4px; }
.user-avatar.large { width: 46px; height: 46px; font-size: 16px; }
.account-actions { justify-content: space-between; }
@media (max-width: 700px) { .auth-dialog { grid-template-columns: 1fr; } .auth-visual { display: none; } .auth-body { padding: 20px; } }

.attachment-chip.uploading { opacity: .55; }
.attachment-chip a { display: grid; place-items: center; width: 20px; height: 20px; color: var(--text-muted); }
.attachment-chip a svg { width: 12px; height: 12px; }
.empty-model { padding: 14px 11px; color: var(--text-muted); font-size: 11px; }
