:root {
  color-scheme: light;
  --sidebar-width: 260px;
  --topbar-height: 58px;
  --composer-max: 780px;
  --page-max: 790px;
  --bg: #ffffff;
  --sidebar: #f7f7f8;
  --sidebar-hover: #ececee;
  --line: #e5e5e5;
  --line-strong: #d9d9dc;
  --ink: #171717;
  --muted: #6b6b72;
  --soft: #f4f4f4;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(0, 0, 0, .12);
  --radius: 12px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.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; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); height: 100dvh; }
.sidebar { background: var(--sidebar); display: flex; flex-direction: column; min-width: 0; border-right: 1px solid rgba(0, 0, 0, .03); position: relative; z-index: 30; }
.sidebar-top { padding: 10px 10px 4px; }
.sidebar-brand-row { height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-brand { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 6px 8px; font-weight: 650; font-size: 14px; }
.brand-orb, .empty-logo { display: grid; place-items: center; background: var(--ink); color: white; font-weight: 750; letter-spacing: -.04em; }
.brand-orb { width: 28px; height: 28px; border-radius: 9px; font-size: 13px; }
.empty-logo { width: 44px; height: 44px; border-radius: 14px; font-size: 19px; margin: 0 auto 17px; }
.icon-button, .small-icon-button, .composer-icon, .send-button { display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; }
.icon-button { width: 38px; height: 38px; border-radius: 10px; }
.icon-button:hover, .small-icon-button:hover, .composer-icon:hover { background: var(--soft); }
.sidebar .icon-button:hover { background: var(--sidebar-hover); }
.sidebar-collapse { width: 34px; height: 34px; color: #52525a; }
.sidebar-action { width: 100%; min-height: 42px; border: 0; background: transparent; border-radius: 9px; padding: 9px 10px; display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: left; font-size: 14px; }
.sidebar-action svg { width: 19px; height: 19px; }
.sidebar-action:hover, .sidebar-action.primary:hover { background: var(--sidebar-hover); }
.sidebar-action.primary { margin-top: 4px; background: rgba(255,255,255,.6); font-weight: 590; }
.sidebar-nav { padding: 7px 10px 5px; display: grid; gap: 2px; }
.sidebar-nav a { min-height: 40px; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; font-size: 14px; }
.sidebar-nav a:hover { background: var(--sidebar-hover); }
.sidebar-nav svg { width: 18px; height: 18px; }
.sidebar-section { padding: 11px 10px 3px; }
.sidebar-section h2 { margin: 0 9px 7px; color: #4c4c52; font-size: 12px; font-weight: 650; }
.project-link { width: 100%; border: 0; background: transparent; border-radius: 9px; display: flex; align-items: center; gap: 9px; padding: 8px 9px; cursor: pointer; text-align: left; font-size: 13.5px; }
.project-link:hover { background: var(--sidebar-hover); }
.project-dot { width: 25px; height: 25px; display: grid; place-items: center; border: 1px solid #d9d9dd; border-radius: 7px; background: #fff; font-size: 11px; font-weight: 700; }
.chat-history-section { min-height: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; }
.small-icon-button { width: 28px; height: 28px; border-radius: 7px; color: var(--muted); }
.small-icon-button svg { width: 16px; height: 16px; }
.chat-history { overflow-y: auto; padding-bottom: 10px; scrollbar-width: thin; }
.history-item { width: 100%; display: flex; align-items: center; gap: 7px; padding: 8px 9px; border: 0; background: transparent; border-radius: 9px; text-align: left; cursor: pointer; font-size: 13.5px; }
.history-item:hover, .history-item.active { background: var(--sidebar-hover); }
.history-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-empty { margin: 5px 9px; color: #8a8a91; font-size: 12px; }
.sidebar-profile { padding: 8px 10px 11px; border-top: 1px solid rgba(0,0,0,.05); }
.profile-button { border: 0; background: transparent; width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) 20px; gap: 9px; align-items: center; padding: 7px; border-radius: 10px; text-align: left; cursor: pointer; }
.profile-button:hover { background: var(--sidebar-hover); }
.profile-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #9b51e0; color: #fff; font-size: 11px; font-weight: 700; }
.profile-copy { min-width: 0; display: grid; gap: 1px; }
.profile-copy strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: var(--muted); font-size: 11px; }
.profile-button > svg { width: 18px; height: 18px; color: #777; }

.main-panel { min-width: 0; position: relative; display: flex; flex-direction: column; height: 100dvh; background: #fff; }
.topbar { height: var(--topbar-height); flex: 0 0 var(--topbar-height); display: flex; align-items: center; justify-content: space-between; padding: 7px 12px 7px 14px; position: relative; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 2px; }
.mobile-menu { display: none; }
.model-trigger { min-height: 38px; padding: 8px 9px; border: 0; border-radius: 10px; background: transparent; display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 650; cursor: pointer; letter-spacing: -.02em; }
.model-trigger:hover { background: var(--soft); }
.model-trigger svg { width: 17px; height: 17px; stroke-width: 2.1; }

.conversation { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; padding: 28px 24px 190px; }
.empty-state { width: min(100%, 760px); margin: min(17vh, 150px) auto 0; text-align: center; }
.empty-state h1 { margin: 0; font-size: clamp(26px, 3vw, 32px); letter-spacing: -.035em; }
.empty-state > p { margin: 10px auto 26px; max-width: 590px; color: var(--muted); line-height: 1.55; font-size: 15px; }
.starter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.starter-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; min-height: 88px; padding: 14px 15px; cursor: pointer; color: #303038; line-height: 1.4; font-size: 13.5px; transition: border-color .15s ease, background .15s ease; }
.starter-card:hover { background: #fafafa; border-color: #cacacf; }
.starter-card strong { display: block; color: #111; margin-bottom: 4px; font-size: 13.5px; }

.message-list { width: min(100%, var(--page-max)); margin: 0 auto; display: grid; gap: 34px; }
.message { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 13px; align-items: start; }
.message.user { display: flex; justify-content: flex-end; }
.user-bubble { max-width: min(78%, 620px); background: #f4f4f4; border-radius: 19px; padding: 11px 15px; white-space: pre-wrap; line-height: 1.5; font-size: 15px; }
.assistant-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: #171717; color: white; font-size: 11px; font-weight: 750; }
.message-body { min-width: 0; padding-top: 2px; }
.message-body p { margin: 0 0 13px; line-height: 1.72; font-size: 15px; }
.message-body h3 { margin: 20px 0 8px; font-size: 15px; }
.answer-topline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.answer-model { color: #424249; font-size: 13px; font-weight: 650; }
.answer-effort { border: 1px solid var(--line); padding: 2px 7px; border-radius: 999px; color: var(--muted); font-size: 11px; }
.answer-section { margin-top: 17px; }
.answer-section > strong { display: block; font-size: 14px; margin-bottom: 8px; }
.answer-list { margin: 0; padding-left: 20px; display: grid; gap: 7px; }
.answer-list li { line-height: 1.55; font-size: 14.5px; }
.capability-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.capability-pills span { background: #f5f5f5; border: 1px solid #e8e8e8; border-radius: 999px; padding: 5px 9px; font-size: 12px; color: #3f3f46; }
.source-list { display: grid; gap: 7px; }
.source-link { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.source-link:hover { background: #fafafa; }
.source-index { width: 23px; height: 23px; border-radius: 7px; display: grid; place-items: center; background: #f0f0f0; color: #555; font-size: 11px; font-weight: 700; }
.source-copy { min-width: 0; display: grid; gap: 1px; }
.source-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.source-copy small { color: var(--muted); text-transform: capitalize; }
.message-actions { display: flex; align-items: center; gap: 3px; margin-top: 12px; color: #707078; }
.message-action { width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; cursor: pointer; }
.message-action:hover { background: var(--soft); }
.message-action svg { width: 17px; height: 17px; }
.typing { display: flex; gap: 5px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #999; animation: pulse 1.15s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .13s; }
.typing i:nth-child(3) { animation-delay: .26s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .35; transform: scale(.75); } 40% { opacity: 1; transform: scale(1); } }

.composer-zone { position: absolute; left: 0; right: 0; bottom: 0; z-index: 18; padding: 40px 20px 9px; background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 35%); pointer-events: none; }
.composer-inner { width: min(100%, var(--composer-max)); margin: 0 auto; pointer-events: auto; }
.attachment-list { display: flex; gap: 7px; flex-wrap: wrap; margin: 0 8px 7px; }
.attachment-chip { display: flex; align-items: center; gap: 7px; max-width: 250px; padding: 6px 8px 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,.05); font-size: 12px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button { border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0; color: #777; }
.attachment-chip svg { width: 14px; height: 14px; }
.composer { min-height: 104px; border: 1px solid var(--line-strong); background: #fff; border-radius: 27px; padding: 13px 12px 9px 15px; box-shadow: 0 2px 12px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.composer:focus-within { border-color: #c9c9ce; box-shadow: 0 3px 18px rgba(0,0,0,.10); }
.composer textarea { width: 100%; min-height: 38px; max-height: 160px; resize: none; border: 0; outline: none; padding: 2px 3px 6px; color: var(--ink); font-size: 16px; line-height: 1.5; background: transparent; }
.composer textarea::placeholder { color: #8a8a92; }
.composer-controls { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.composer-left-controls, .composer-right-controls { display: flex; align-items: center; gap: 4px; }
.composer-icon { width: 34px; height: 34px; border-radius: 50%; }
.composer-icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
.reasoning-trigger { border: 0; background: transparent; height: 34px; border-radius: 9px; padding: 0 7px; display: flex; align-items: center; gap: 4px; color: #66666d; cursor: pointer; font-size: 13px; }
.reasoning-trigger:hover { background: var(--soft); }
.reasoning-trigger svg { width: 14px; height: 14px; }
.send-button { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; }
.send-button:hover:not(:disabled) { background: var(--accent-strong); }
.send-button:disabled { background: #d9d9dd; cursor: default; }
.send-button svg { width: 18px; height: 18px; stroke-width: 2.2; }
.composer-note { margin: 7px 0 0; text-align: center; color: #85858c; font-size: 11px; }

.floating-menu { position: fixed; z-index: 80; min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 6px; }
.floating-menu[hidden] { display: none; }
.model-menu { top: 50px; left: calc(var(--sidebar-width) + 15px); width: 340px; }
.model-option { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 22px; gap: 10px; border: 0; background: transparent; padding: 10px 11px; border-radius: 9px; text-align: left; cursor: pointer; }
.model-option:hover { background: var(--soft); }
.model-option strong { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.model-option small { display: block; color: var(--muted); line-height: 1.35; margin-top: 3px; font-size: 12px; }
.model-badge { border: 1px solid var(--line); border-radius: 999px; padding: 2px 6px; color: #666; font-size: 10px; font-weight: 550; }
.model-check { display: grid; place-items: center; color: var(--accent); font-weight: 700; opacity: 0; }
.model-option.active .model-check { opacity: 1; }
.reasoning-menu { bottom: 135px; left: calc(50% - 345px); width: 260px; }
.reasoning-menu button, .more-menu button { width: 100%; border: 0; background: transparent; border-radius: 9px; padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; text-align: left; cursor: pointer; }
.reasoning-menu button:hover, .more-menu button:hover { background: var(--soft); }
.reasoning-menu button span:first-child { display: grid; gap: 2px; }
.reasoning-menu strong { font-size: 13px; }
.reasoning-menu small { color: var(--muted); font-size: 11px; }
.menu-check { color: var(--accent); opacity: 0; }
.reasoning-menu button.active .menu-check { opacity: 1; }
.more-menu { top: 50px; right: 13px; width: 220px; }
.more-menu button { justify-content: flex-start; gap: 9px; font-size: 13px; }
.more-menu svg { width: 17px; height: 17px; }
.danger-menu-item { color: var(--danger); }

.search-dialog { width: min(92vw, 610px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 20px 70px rgba(0,0,0,.22); }
.search-dialog::backdrop { background: rgba(0,0,0,.38); backdrop-filter: blur(2px); }
.search-dialog-shell { min-height: 360px; display: flex; flex-direction: column; }
.search-dialog-head { height: 58px; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 0 14px; border-bottom: 1px solid var(--line); }
.search-dialog-head svg { width: 20px; height: 20px; color: #666; }
.search-dialog-head input { border: 0; outline: 0; font-size: 15px; }
.search-dialog-head button { border: 1px solid var(--line); background: #fafafa; border-radius: 7px; padding: 3px 7px; color: #666; font-size: 11px; }
.search-results { padding: 8px; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.search-result { border: 0; background: transparent; border-radius: 9px; text-align: left; padding: 10px; cursor: pointer; display: grid; gap: 3px; }
.search-result:hover { background: var(--soft); }
.search-result strong { font-size: 13.5px; }
.search-result small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 38px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 145px; transform: translate(-50%, 12px); background: #242424; color: #fff; border-radius: 999px; padding: 8px 13px; font-size: 12px; opacity: 0; pointer-events: none; z-index: 100; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--sidebar-width)); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 12px 0 35px rgba(0,0,0,.13); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: grid; }
  .model-menu { left: 54px; }
  .reasoning-menu { left: 26px; bottom: 136px; }
  .conversation { padding-inline: 16px; }
}

@media (max-width: 620px) {
  .topbar { padding-inline: 7px; }
  .model-trigger { font-size: 16px; }
  .topbar-actions .icon-button { width: 36px; height: 36px; }
  .conversation { padding: 15px 13px 176px; }
  .empty-state { margin-top: 10vh; }
  .starter-grid { grid-template-columns: 1fr; }
  .starter-card:nth-child(n+4) { display: none; }
  .message-list { gap: 27px; }
  .message { grid-template-columns: 27px minmax(0, 1fr); gap: 10px; }
  .assistant-avatar { width: 27px; height: 27px; border-radius: 8px; }
  .user-bubble { max-width: 88%; }
  .composer-zone { padding: 35px 9px 7px; }
  .composer { min-height: 98px; border-radius: 24px; }
  .composer-note { font-size: 10px; }
  .model-menu { width: calc(100vw - 70px); max-width: 340px; }
}

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