:root {
  color-scheme: dark;
  --bg: #101010;
  --sidebar: #171717;
  --surface: #202020;
  --surface-2: #2b2b2b;
  --surface-3: #343434;
  --line: #292929;
  --text: #ededed;
  --muted: #929292;
  --faint: #696969;
  --blue: #4e8cff;
  --blue-soft: #8db5ff;
  --danger: #ee8b8b;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: 350px minmax(0, 1fr); min-height: 100dvh; background: var(--bg); }
.app-shell.sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
.sidebar.collapsed { width: 72px; padding-left: 10px; padding-right: 10px; }
.sidebar.collapsed > :not(.sidebar-top) { display: none; }
.sidebar.collapsed .sidebar-top { padding-left: 9px; padding-right: 9px; }
.sidebar.collapsed .sidebar-top-actions .icon-button:not(#sidebar-collapse) { display: none; }
.sidebar { display: flex; flex-direction: column; min-height: 100dvh; padding: 20px 15px 14px; border-right: 1px solid var(--line); background: var(--sidebar); z-index: 20; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 9px 14px; }
.brand-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 9px; color: #eee; background: transparent; }
.brand-button:hover { background: #262626; }
.grok-symbol { display: block; position: relative; width: 23px; height: 23px; color: #f1f1f1; font-size: 0; }
.grok-symbol::before, .grok-symbol::after { content: ""; position: absolute; border: 2px solid currentColor; border-radius: 50%; transform: rotate(-34deg); }
.grok-symbol::before { inset: 2px 4px 4px 2px; border-right-color: transparent; }
.grok-symbol::after { inset: 5px 1px 1px 6px; border-left-color: transparent; }
.sidebar-top-actions { display: flex; align-items: center; gap: 6px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 9px; color: #a6a6a6; background: transparent; font-size: 19px; line-height: 1; }
.icon-button:hover { color: var(--text); background: #262626; }
.sidebar-top .close-sidebar { display: none; }
.new-chat-button { display: flex; align-items: center; gap: 12px; height: 48px; margin: 0 0 12px; padding: 0 15px; border-radius: 13px; color: #f0f0f0; background: #303030; font-size: 15px; font-weight: 600; text-align: left; }
.new-chat-button:hover { background: #3a3a3a; }
.nav-glyph { display: inline-grid; place-items: center; flex: 0 0 auto; width: 22px; color: #c9c9c9; font-size: 19px; line-height: 1; }
.history-search { display: none; align-items: center; gap: 8px; height: 38px; margin: 0 0 9px; padding: 0 11px; border: 1px solid #333; border-radius: 10px; color: var(--muted); background: #202020; }
.history-search.visible { display: flex; }
.history-search input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 13px; }
.history-search input::placeholder { color: #777; }
.primary-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 21px; }
.sidebar-nav-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 42px; padding: 0 12px; border-radius: 10px; color: #d1d1d1; background: transparent; font-size: 15px; text-align: left; }
.sidebar-nav-item:hover { background: #232323; color: #fff; }
.sidebar-nav-item.muted-nav { color: #9b9b9b; }
.nav-notice { width: 8px; height: 8px; margin-left: auto; border-radius: 50%; background: #628eff; }
.sidebar-group { margin-bottom: 16px; }
.sidebar-group-title { display: flex; align-items: center; justify-content: space-between; min-height: 31px; padding: 0 12px; color: #8f8f8f; font-size: 15px; font-weight: 600; }
.chevron-button { width: 25px; height: 25px; border-radius: 7px; color: #999; background: transparent; }
.chevron-button:hover { background: #262626; }
.chats-group { min-height: 0; flex: 1; overflow: hidden; }
.history-section-label { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 7px; color: #777; font-size: 12px; }
.text-button { padding: 2px 0; color: #777; background: transparent; font-size: 11px; }
.text-button:hover, .text-button.active { color: var(--blue-soft); }
.conversation-list { min-height: 0; height: calc(100% - 62px); overflow: auto; padding: 0 2px 2px; }
.conversation-list::-webkit-scrollbar { width: 5px; }
.conversation-list::-webkit-scrollbar-thumb { border-radius: 9px; background: #3a3a3a; }
.conversation-item { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 40px; margin-bottom: 1px; padding: 7px 10px; border-radius: 9px; color: #bdbdbd; background: transparent; text-align: left; }
.conversation-item:hover, .conversation-item.active { color: #f1f1f1; background: #252525; }
.conversation-item .conversation-icon { width: 17px; color: #8d8d8d; font-size: 14px; }
.conversation-item.active .conversation-icon { color: #d4d4d4; }
.conversation-item .conversation-copy { min-width: 0; flex: 1; }
.conversation-item strong { display: block; overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item small { display: block; margin-top: 3px; color: #777; font-size: 11px; }
.conversation-pin { color: #8aaeff; font-size: 10px; }
.empty-history { padding: 18px 12px; color: #6e6e6e; font-size: 13px; line-height: 1.5; }
.sidebar-footer { display: flex; flex-direction: column; gap: 1px; padding-top: 10px; border-top: 1px solid #282828; }
.sidebar-footer > .sidebar-nav-item { margin-bottom: 7px; }
.sidebar-action { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 37px; padding: 5px 9px; border-radius: 9px; background: transparent; text-align: left; }
.sidebar-action:hover { background: #232323; }
.sidebar-action > span:first-child { display: grid; place-items: center; width: 22px; height: 22px; color: #b8b8b8; font-size: 16px; }
.sidebar-action strong, .sidebar-action small { display: block; }
.sidebar-action strong { color: #cecece; font-size: 13px; font-weight: 500; }
.sidebar-action small { margin-top: 1px; color: #767676; font-size: 10px; }
.profile-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 9px 9px 2px; color: #d3d3d3; }
.profile-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; background: #1769bd; font-size: 15px; }
.profile-row strong, .profile-row small { display: block; }
.profile-row strong { font-size: 13px; font-weight: 500; }
.profile-row small { margin-top: 2px; color: #777; font-size: 10px; }

.main-panel { display: flex; flex-direction: column; min-width: 0; min-height: 100dvh; background: #101010; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 29px; background: #101010; }
.topbar-title { display: none; align-items: center; gap: 8px; max-width: 55vw; overflow: hidden; color: #d8d8d8; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #74dbad; }
.status-dot.busy { background: var(--blue); animation: pulse 1s infinite; }
.status-dot.offline { background: #e58d8d; }
.topbar-actions { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.topbar-control { display: inline-flex; align-items: center; gap: 8px; padding: 7px 0; color: #b9b9b9; background: transparent; font-size: 15px; }
.topbar-control:hover { color: #f1f1f1; }
.topbar-control:first-child { color: #c3c3c3; }
.topbar-control:first-child::first-letter { color: #9b9b9b; }
.menu-button { display: none; }
.mode-strip { display: none; }
.chat-stage { position: relative; min-height: 0; flex: 1; overflow-y: auto; padding: 0 24px 12px; scroll-behavior: smooth; }
.chat-stage::-webkit-scrollbar { width: 6px; }
.chat-stage::-webkit-scrollbar-thumb { border-radius: 9px; background: #303030; }
.welcome { display: flex; flex-direction: column; align-items: center; width: min(100%, 1000px); margin: 145px auto 0; text-align: center; }
.welcome h2 { margin: 0; color: #ededed; font-size: clamp(31px, 3vw, 43px); font-weight: 650; letter-spacing: -.035em; }
.welcome-copy { display: none; }
.welcome-orbit { display: none; }
.starter-grid { display: none; }
.message-list { display: flex; flex-direction: column; gap: 23px; width: min(100%, 920px); margin: 25px auto 0; }
.message { display: flex; align-items: flex-start; gap: 11px; animation: rise .2s ease-out; }
.message.user { justify-content: flex-end; }
.message-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; color: #111; background: #e7e7e7; font-size: 11px; font-weight: 700; }
.message.user .message-avatar { order: 2; color: #eee; background: #444; }
.message-bubble { max-width: min(700px, 84%); padding: 11px 14px; border-radius: 15px; color: #ddd; background: transparent; font-size: 14px; line-height: 1.6; }
.message.user .message-bubble { border-radius: 16px 16px 4px 16px; background: #292929; }
.message.assistant .message-bubble { border-radius: 4px 16px 16px 16px; background: #1c1c1c; }
.message-meta { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; color: #777; font-size: 10px; }
.message-meta .mode-tag { color: #aaa; }
.message-content p { margin: 0 0 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content code { padding: 2px 5px; border-radius: 4px; color: #ddd; background: #292929; font: 12px ui-monospace, monospace; }
.message-content pre { overflow-x: auto; margin: 9px 0 0; padding: 12px; border-radius: 9px; background: #111; color: #ddd; font: 12px/1.5 ui-monospace, monospace; }
.message-actions { display: flex; gap: 4px; margin-top: 7px; opacity: .7; }
.message-action { padding: 3px 6px; border-radius: 6px; color: #999; background: transparent; font-size: 10px; }
.message-action:hover { color: #fff; background: #303030; }
.attachment-card { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 7px 9px; border-radius: 8px; color: #bbb; background: #292929; font-size: 11px; }
.typing-indicator { display: flex; align-items: center; gap: 5px; width: min(100%, 920px); margin: 17px auto 0; color: #888; font-size: 11px; }
.typing-indicator span { width: 5px; height: 5px; border-radius: 50%; background: #aaa; animation: bounce 1.1s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: .15s; }.typing-indicator span:nth-child(3) { animation-delay: .3s; }
.typing-indicator label { margin-left: 4px; }
.hidden { display: none !important; }

.composer-wrap { width: min(100%, 1060px); margin: 0 auto; padding: 0 24px 38px; }
.attachment-tray { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.attachment-chip { display: flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid #3b3b3b; border-radius: 9px; color: #bbb; background: #242424; font-size: 11px; }
.attachment-chip button { color: #888; background: transparent; font-size: 14px; }
.composer-shell { min-height: 138px; padding: 19px 22px 14px; border: 1px solid #303030; border-radius: 25px; background: #211f1f; box-shadow: 0 3px 14px rgba(0,0,0,.14); }
.composer-shell:focus-within { border-color: #444; }
.composer-shell textarea { display: block; width: 100%; min-height: 65px; max-height: 160px; padding: 0; resize: none; border: 0; outline: 0; color: #e8e8e8; background: transparent; font-size: 18px; line-height: 1.45; }
.composer-shell textarea::placeholder { color: #919191; opacity: 1; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.composer-tools, .composer-actions { display: flex; align-items: center; gap: 11px; }
.tool-button { display: inline-flex; align-items: center; gap: 5px; min-width: 31px; min-height: 31px; padding: 5px; border-radius: 50%; color: #aaa; background: transparent; font-size: 13px; }
.tool-button:hover, .tool-button[aria-pressed="true"] { color: #eee; background: #303030; }
.build-tool { display: none; }
.mic-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.voice-tool span:last-child { display: none; }
.model-pill { padding: 5px 3px; color: #a8a8a8; background: transparent; font-size: 15px; }
.model-pill:hover { color: #eee; }
.send-button { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; color: #fff; background: var(--blue); font-size: 22px; font-weight: 700; box-shadow: 0 2px 13px rgba(78,140,255,.28); }
.wave-icon { width: 27px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2.4; }
.send-button:hover { background: #6b9eff; transform: translateY(-1px); }
.send-button:disabled { opacity: .5; transform: none; }
.promo-card { display: flex; align-items: center; gap: 15px; width: min(100%, 1000px); min-height: 88px; margin: 42px auto 0; padding: 14px 24px; border: 1px solid #303030; border-radius: 19px; background: #141414; }
.promo-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 49px; height: 49px; border-radius: 50%; color: #111; background: #f2f2f2; font-size: 24px; }
.promo-card strong { display: block; color: #eee; font-size: 17px; font-weight: 650; }
.promo-card p { margin: 3px 0 0; color: #a0a0a0; font-size: 14px; }
.promo-dismiss { margin-left: auto; padding: 8px 12px; color: #9e9e9e; background: transparent; font-size: 14px; }
.promo-dismiss:hover { color: #eee; }
.promo-upgrade { padding: 10px 16px; border-radius: 20px; color: #252525; background: #f1f1f1; font-size: 14px; }
.promo-upgrade:hover { background: #fff; }
.composer-note { display: none; }
.media-result { margin-top: 10px; overflow: hidden; border: 1px solid #333; border-radius: 13px; background: #161616; }
.media-result img, .media-result video { display: block; width: 100%; max-height: 430px; object-fit: contain; background: #0e0e0e; }
.media-result p { margin: 0; padding: 9px 11px; color: #999; font-size: 11px; }
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: min(360px, calc(100vw - 32px)); padding: 10px 13px; border: 1px solid #444; border-radius: 10px; color: #eee; background: #252525; box-shadow: 0 12px 45px rgba(0,0,0,.4); font-size: 12px; animation: rise .2s ease-out; }
.toast.error { border-color: #704646; color: #ffd8d8; }

/* The empty state is intentionally compact and centered like the reference UI. */
.main-panel:not(.has-conversation) .message-list:empty { display: none; }
.main-panel:not(.has-conversation) .chat-stage { flex: 0 0 auto; overflow: visible; }
.main-panel:not(.has-conversation) .composer-wrap { margin-top: 36px; }
.main-panel.has-conversation .welcome { display: none; }
.main-panel.has-conversation .promo-card { display: none; }
.main-panel.has-conversation .composer-wrap { padding-bottom: 18px; }
.main-panel.has-conversation .chat-stage { padding-top: 24px; }

@keyframes pulse { 50% { opacity: .45; transform: scale(.8); } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .promo-card { margin-top: 28px; }
}

@media (max-width: 720px) {
  body { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 87vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 24px 0 65px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-top .close-sidebar, .menu-button { display: grid; }
  .menu-button { display: grid; }
  .topbar { min-height: 56px; padding: 0 13px; }
  .topbar-title { display: flex; }
  .topbar-actions { gap: 8px; }
  .topbar-control { padding: 6px; font-size: 13px; }
  .topbar-control span { display: none; }
  .chat-stage { padding: 0 13px 9px; }
  .welcome { margin-top: 92px; }
  .welcome h2 { font-size: 30px; }
  .composer-wrap { padding: 0 12px calc(14px + env(safe-area-inset-bottom)); }
  .composer-shell { min-height: 122px; padding: 16px 16px 12px; border-radius: 20px; }
  .composer-shell textarea { min-height: 55px; font-size: 16px; }
  .composer-tools { gap: 5px; }
  .send-button { width: 44px; height: 44px; }
  .promo-card { gap: 10px; min-height: 75px; margin-top: 22px; padding: 11px 12px; border-radius: 15px; }
  .promo-avatar { width: 38px; height: 38px; font-size: 19px; }
  .promo-card strong { font-size: 14px; }
  .promo-card p { font-size: 11px; }
  .promo-dismiss { display: none; }
  .promo-upgrade { padding: 8px 10px; font-size: 11px; }
  .message-bubble { max-width: 88%; font-size: 13px; }
}

@media (max-width: 430px) {
  .promo-card { display: none; }
  .model-pill { font-size: 13px; }
}
