:root {
  color-scheme: dark;
  --bg: #050b11;
  --panel: #07111a;
  --panel-2: #0a1722;
  --line: rgba(151, 191, 218, .11);
  --line-strong: rgba(151, 191, 218, .19);
  --text: #edf7fc;
  --muted: #91a9ba;
  --soft: #647f92;
  --accent: #61d7ff;
  --accent-2: #85f0c6;
  --danger: #ff8f98;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.app-shell { min-height: 100vh; background: radial-gradient(circle at 75% 20%, rgba(38, 125, 159, .09), transparent 33%), radial-gradient(circle at 30% 80%, rgba(71, 169, 135, .045), transparent 30%), #050b11; }
.eyebrow, .sidebar-label, .topbar-kicker, .private-label, .version-label { font-size: 9px; letter-spacing: .16em; font-weight: 800; color: var(--soft); }
.brand-mark { width: 38px; height: 38px; border: 1px solid rgba(97, 215, 255, .25); border-radius: 12px; display: grid; grid-template-columns: 1fr 1fr; place-items: center; background: linear-gradient(145deg, rgba(97,215,255,.08), rgba(133,240,198,.025)); box-shadow: inset 0 0 22px rgba(97,215,255,.035); }
.brand-mark span { font-size: 9px; font-weight: 900; color: var(--accent); }
.brand-mark.large { width: 62px; height: 62px; border-radius: 18px; margin-bottom: 24px; }
.brand-mark.large span { font-size: 14px; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); border: 1px solid var(--line-strong); border-radius: 22px; padding: 42px; background: rgba(7,17,26,.88); box-shadow: 0 32px 100px rgba(0,0,0,.45); backdrop-filter: blur(18px); }
.login-card h1 { margin: 7px 0 8px; font-size: 30px; letter-spacing: -.04em; }
.login-copy { margin: 0 0 28px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.login-form { display: grid; gap: 15px; }
.login-form label span { display: block; margin-bottom: 7px; font-size: 10px; color: var(--muted); }
.login-form input, .modal input { width: 100%; border: 1px solid var(--line-strong); background: rgba(4,12,18,.72); color: var(--text); border-radius: 11px; padding: 12px 13px; outline: none; }
.login-form input:focus, .modal input:focus { border-color: rgba(97,215,255,.55); box-shadow: 0 0 0 3px rgba(97,215,255,.07); }
.primary-button { border: 0; background: linear-gradient(135deg, #52c9ef, #65dabc); color: #061019; border-radius: 10px; min-height: 40px; padding: 0 16px; font-size: 11px; font-weight: 850; }
.primary-button.full { width: 100%; margin-top: 3px; }
.form-error { margin: -2px 0 0; color: var(--danger); font-size: 10px; }
.security-note { text-align: center; color: #4e687b; font-size: 9px; margin: 22px 0 0; }

.workspace { height: 100vh; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: rgba(6, 15, 23, 0.95); backdrop-filter: blur(20px); display: flex; min-height: 0; flex-direction: column; padding: 20px 14px 16px; position: relative; z-index: 20; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 18px; }
.brand-lockup { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-lockup strong { display: block; font-size: 13px; letter-spacing: -.01em; }
.brand-lockup span { display: block; margin-top: 3px; color: var(--soft); font-size: 10px; }
.new-chat-button { width: 100%; min-height: 45px; padding: 0 14px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong); border-radius: 12px; background: rgba(14, 31, 45, .68); font-size: 12px; font-weight: 700; transition: background .15s, border-color .15s; }
.new-chat-button:hover { background: rgba(20,43,60,.82); border-color: rgba(97,215,255,.28); }
.plus { font-size: 20px; font-weight: 300; color: var(--accent); margin-top: -2px; }
.search-wrap { margin-top: 10px; min-height: 38px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: rgba(5,14,21,.55); color: var(--soft); }
.search-wrap input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 10px; }
.search-wrap input::placeholder { color: #50697a; }
.sidebar-label { margin: 22px 10px 9px; }
.thread-list { display: flex; flex: 1; min-height: 0; overflow-y: auto; flex-direction: column; gap: 3px; scrollbar-width: thin; }
.thread-item { display: grid; grid-template-columns: minmax(0,1fr) 28px; align-items: center; gap: 4px; border-radius: 10px; padding-left: 11px; transition: background .14s; }
.thread-item:hover { background: rgba(123,175,210,.07); }
.thread-item.active { background: rgba(97,215,255,.09); }
.thread-open { min-width: 0; border: 0; background: transparent; text-align: left; padding: 10px 0; cursor: pointer; }
.thread-open strong { display: block; font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-open span { display: block; margin-top: 4px; font-size: 10px; color: var(--soft); }
.thread-delete { border: 0; background: transparent; color: transparent; font-size: 17px; border-radius: 7px; cursor: pointer; height: 28px; }
.thread-item:hover .thread-delete, .thread-item.active .thread-delete { color: var(--soft); }
.thread-delete:hover { background: rgba(255,143,152,.08); color: var(--danger) !important; }
.thread-empty { padding: 20px 10px; color: #526b7d; font-size: 10px; text-align: center; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 14px 5px 0; }
.connection-card { display: flex; align-items: center; gap: 10px; }
.connection-card strong { display: block; font-size: 11px; }
.connection-card span:not(.status-dot) { display: block; margin-top: 3px; color: var(--soft); font-size: 9px; max-width: 235px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 7px; height: 7px; border-radius: 99px; background: #64798a; box-shadow: 0 0 0 3px rgba(100,121,138,.08); flex: 0 0 auto; }
.status-dot.online { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(133,240,198,.09), 0 0 14px rgba(133,240,198,.35); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(255,143,152,.08); }
.version-label { margin-top: 11px; font-size: 8px; letter-spacing: .08em; color: #4b6578; }
.private-label { margin-top: 7px; color: #455f72; font-size: 8px; }

.main-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 72px minmax(0,1fr) auto; }
.topbar { border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: rgba(5,12,18,.72); backdrop-filter: blur(18px); position: relative; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-stack { min-width: 0; }
.topbar-kicker { color: var(--soft); font-size: 8px; }
.thread-title-button { border: 0; background: transparent; display: flex; gap: 7px; align-items: center; padding: 0; max-width: min(50vw,650px); color: var(--text); }
.thread-title-button h2 { margin: 4px 0 0; font-size: 15px; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title-button > span { color: transparent; font-size: 11px; margin-top: 4px; }
.thread-title-button:hover > span { color: var(--soft); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.top-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.secondary-button, .icon-button { border: 1px solid var(--line); background: rgba(15,30,42,.58); border-radius: 9px; min-height: 34px; padding: 0 11px; font-size: 10px; color: var(--muted); }
.icon-button { width: 34px; padding: 0; font-size: 18px; }
.secondary-button:hover, .icon-button:hover { color: var(--text); border-color: var(--line-strong); }

.chat-stage { min-height: 0; overflow-y: auto; position: relative; scroll-behavior: smooth; }
.empty-state { min-height: 100%; width: min(820px,calc(100% - 40px)); margin: 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 48px 0 64px; }
.core-orbit { position: relative; width: 96px; height: 96px; display: grid; place-items: center; margin-bottom: 28px; }
.orbit-center { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; border: 1px solid rgba(97,215,255,.35); background: rgba(97,215,255,.07); font-weight: 900; font-size: 12px; box-shadow: 0 0 40px rgba(97,215,255,.08); }
.orbit-ring { position: absolute; border: 1px solid rgba(97,215,255,.16); border-radius: 50%; }
.orbit-ring.one { inset: 8px; }
.orbit-ring.two { inset: 0 20px; transform: rotate(56deg); border-color: rgba(133,240,198,.14); }
.empty-state h1 { margin: 8px 0 10px; font-size: clamp(28px,4vw,44px); letter-spacing: -.05em; }
.empty-state > p:not(.eyebrow) { max-width: 620px; color: var(--muted); line-height: 1.65; font-size: 13px; }
.prompt-grid { margin-top: 30px; width: min(700px,100%); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.prompt-card { border: 1px solid var(--line); background: rgba(10,23,34,.58); border-radius: 14px; padding: 15px 16px; text-align: left; transition: border-color .16s, background .16s, transform .16s; }
.prompt-card:hover { border-color: rgba(97,215,255,.3); background: rgba(14,31,44,.72); transform: translateY(-1px); }
.prompt-card strong { display: block; font-size: 12px; }
.prompt-card span { display: block; margin-top: 5px; color: var(--soft); font-size: 10px; }

.messages { width: min(940px,calc(100% - 44px)); margin: 0 auto; padding: 32px 0 62px; display: grid; gap: 30px; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 12px; animation: fadeUp .18s ease-out; }
.message.user { grid-template-columns: minmax(0,1fr); justify-items: end; }
.message-avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid rgba(97,215,255,.22); background: rgba(97,215,255,.06); color: var(--accent); font-weight: 900; font-size: 9px; }
.message-body { min-width: 0; max-width: 800px; }
.message-label-row { min-height: 20px; margin: 0 0 5px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.message-label { color: var(--soft); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.message-action { border: 0; background: transparent; color: #5c7688; font-size: 9px; padding: 3px 4px; }
.message-action:hover { color: var(--accent); }
.message-content { color: #dcebf5; font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; }
.message-content p { margin: 0 0 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h2, .message-content h3, .message-content h4, .message-content h5 { margin: 20px 0 8px; color: #f1f9fd; line-height: 1.3; letter-spacing: -.02em; }
.message-content h2 { font-size: 19px; }.message-content h3 { font-size: 17px; }.message-content h4, .message-content h5 { font-size: 15px; }
.message-content ul, .message-content ol { margin: 8px 0 14px; padding-left: 22px; }
.message-content li { margin: 5px 0; }
.message-content blockquote { margin: 12px 0; border-left: 2px solid rgba(97,215,255,.45); padding: 4px 0 4px 13px; color: #a9c0cf; }
.message-content code { border: 1px solid rgba(151,191,218,.14); background: rgba(11,25,35,.8); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace,SFMono-Regular,Consolas,monospace; font-size: .9em; }
.message-content pre { margin: 13px 0; border: 1px solid var(--line); background: #03080c; border-radius: 11px; padding: 14px; overflow-x: auto; }
.message-content pre code { border: 0; background: transparent; padding: 0; font-size: 12px; line-height: 1.55; white-space: pre; }
.message.user .message-body { max-width: min(720px,88%); border: 1px solid rgba(97,215,255,.18); background: rgba(24,50,68,.52); border-radius: 17px 17px 5px 17px; padding: 12px 15px; }
.message.user .message-label-row { display: none; }
.message.user .message-content { color: #f0f8fd; white-space: pre-wrap; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin: 1px 0 8px; }
.message-attachment { border: 1px solid var(--line); background: rgba(11,25,36,.65); border-radius: 8px; padding: 5px 8px; color: #8ba6b8; font-size: 9px; }
.message-status { margin-top: 8px; color: #6e8799; font-size: 9px; font-style: italic; }
.typing-caret::after { content: ""; display: inline-block; width: 6px; height: 14px; margin-left: 3px; vertical-align: -2px; background: var(--accent); animation: blink .8s infinite; }

.composer-wrap { padding: 8px 24px 16px; background: linear-gradient(180deg,rgba(5,11,17,0),rgba(5,11,17,.94) 24%); }
.attachment-tray { width: min(940px,100%); margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 7px; }
.attachment-chip { max-width: 270px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: rgba(9,22,32,.92); border-radius: 10px; padding: 7px 8px 7px 10px; }
.attachment-chip > div { min-width: 0; }
.attachment-chip strong { display: block; font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip span { display: block; margin-top: 2px; color: var(--soft); font-size: 8px; }
.attachment-chip button { border: 0; background: transparent; color: var(--soft); font-size: 15px; }
.attachment-chip button:hover { color: var(--danger); }
.composer { width: min(940px,100%); margin: 0 auto; display: grid; grid-template-columns: 36px minmax(0,1fr) 42px; align-items: end; gap: 7px; border: 1px solid var(--line-strong); border-radius: 17px; background: rgba(10,23,34,.94); padding: 9px; box-shadow: 0 14px 50px rgba(0,0,0,.22); }
.composer textarea { resize: none; max-height: 180px; min-height: 32px; padding: 7px 5px 5px; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.45; font-size: 13px; }
.composer textarea::placeholder { color: #5d7485; }
.composer-tool { width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: #6e899b; font-size: 22px; font-weight: 300; }
.composer-tool:hover { background: rgba(97,215,255,.07); color: var(--accent); }
.send-button, .stop-button { width: 40px; height: 40px; border: 0; border-radius: 12px; display: grid; place-items: center; font-size: 20px; font-weight: 900; }
.send-button { background: linear-gradient(135deg,#52c9ef,#65dabc); color: #061019; }
.stop-button { background: rgba(255,143,152,.13); border: 1px solid rgba(255,143,152,.24); color: var(--danger); font-size: 13px; }
.send-button:disabled, .composer-tool:disabled { opacity: .35; }
.composer-note { width: min(940px,100%); margin: 7px auto 0; color: #4c6475; text-align: center; font-size: 9px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.6); backdrop-filter: blur(5px); }
.modal { width: min(430px,100%); border: 1px solid var(--line-strong); border-radius: 17px; background: #08131d; padding: 20px; box-shadow: 0 32px 90px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.modal h3 { margin: 4px 0 0; font-size: 17px; }
.modal-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 94px; transform: translateX(-50%); border: 1px solid var(--line-strong); background: rgba(9,22,32,.96); color: #dcebf5; border-radius: 10px; padding: 9px 13px; font-size: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.35); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 0%,48% { opacity: 1; } 49%,100% { opacity: 0; } }

@media (max-width: 900px) { .top-status { display: none; } }
@media (max-width: 780px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px,88vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 28px 0 80px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.52); z-index: 15; }
  .topbar { padding: 0 14px; }
  .topbar-actions { gap: 6px; }
  .secondary-button { padding: 0 8px; }
  .messages { width: calc(100% - 28px); padding-top: 24px; }
  .message { grid-template-columns: 30px minmax(0,1fr); gap: 9px; }
  .message-avatar { width: 30px; height: 30px; }
  .message.user .message-body { max-width: 94%; }
  .empty-state { width: calc(100% - 28px); padding-top: 36px; justify-content: flex-start; }
  .prompt-grid { grid-template-columns: 1fr; }
  .composer-wrap { padding: 8px 12px 12px; }
  .login-card { padding: 32px 24px; }
}
@media (max-width: 520px) {
  .topbar-actions #exportThread { display: none; }
  .topbar-actions #logout { font-size: 0; width: 34px; padding: 0; }
  .topbar-actions #logout::after { content: "↪"; font-size: 16px; }
  .prompt-card:nth-child(n+3) { display: none; }
  .composer-note { display: none; }
}
