:root {
  --bg: #0b0e14;
  --panel: #11151f;
  --panel-2: #161b27;
  --panel-3: #1b2231;
  --border: #232a39;
  --border-soft: #1c2331;
  --text: #e8edf7;
  --muted: #8b95a8;
  --muted-2: #667085;
  --accent: #5eead4;
  --accent-2: #38bdf8;
  --accent-ink: #042f2e;
  --danger: #fb7185;
  --warning: #fbbf24;
  --user: #1d4ed8;
  --radius: 16px;
  --sidebar-w: 288px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.hidden { display: none !important; }

#app {
  display: flex;
  height: 100dvh;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0d111a;
  border-right: 1px solid var(--border);
  z-index: 50;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111a;
  font-weight: 800;
  font-size: 13px;
}

.brand-text { font-size: 15px; }
.brand-text span { color: var(--accent); }

.new-chat-btn {
  margin: 6px 12px 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.new-chat-btn:hover { background: var(--panel-3); border-color: #34405a; }
.new-chat-btn .plus { color: var(--accent); font-size: 17px; line-height: 1; }

.sidebar-section-label {
  padding: 8px 16px 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  padding: 2px 4px;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--panel-3); }

.chat-title {
  flex: 1;
  min-width: 0;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item:not(.active) .chat-title { color: #c4ccda; }

.chat-actions {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity .15s;
}
.chat-item:hover .chat-actions,
.chat-item:focus-within .chat-actions { opacity: 1; }

.chat-action {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.chat-action:hover { background: #252d3d; color: var(--text); }
.chat-action.danger:hover { color: var(--danger); }

.chat-rename {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #0b111b;
  color: var(--text);
  outline: none;
  font-size: 13.5px;
}

.empty-chats {
  padding: 18px 14px;
  color: var(--muted-2);
  font-size: 12.5px;
  line-height: 1.6;
}

.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-footer-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.side-action {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.side-action:hover { color: var(--text); border-color: #34405a; background: var(--panel-2); }

.local-badge {
  flex: 1;
  text-align: center;
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(94, 234, 212, .08);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible { display: block; }

.topbar {
  flex: 0 0 auto;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 14, 20, .82);
  backdrop-filter: blur(10px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #cdd5e3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--border); }

.model-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.model-pill:hover { border-color: #34405a; color: var(--text); }

.model-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, .12);
}
.model-pill[data-status="loading"] .dot {
  background: var(--warning);
  animation: pulse 1.1s infinite;
}
.model-pill[data-status="ready"] .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, .15);
}
.model-pill[data-status="error"] .dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, .15);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.toggle-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle-pill input {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  margin: 0;
}
.toggle-pill:has(input:checked) {
  color: var(--accent);
  border-color: rgba(94, 234, 212, .35);
  background: rgba(94, 234, 212, .07);
}

.gpu-warning {
  margin: 12px 18px 0;
  padding: 11px 14px;
  border: 1px solid rgba(251, 113, 133, .35);
  border-radius: 12px;
  background: rgba(251, 113, 133, .08);
  color: #fecdd3;
  font-size: 13px;
  line-height: 1.5;
}
.gpu-warning strong { color: #fda4af; }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px 18px 10px;
  scroll-behavior: smooth;
}

.messages {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 12px;
}

.welcome {
  position: relative;
  width: min(760px, 100%);
  margin: 4vh auto 0;
  padding: 28px 24px;
  text-align: center;
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  background:
    radial-gradient(600px 220px at 50% -40%, rgba(56, 189, 248, .14), transparent 70%),
    var(--panel);
  overflow: hidden;
}

.welcome-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  top: -190px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(94, 234, 212, .18), transparent 65%);
  pointer-events: none;
}

.welcome-eyebrow {
  position: relative;
  display: inline-block;
  padding: 5px 10px;
  border: 1px solid rgba(94, 234, 212, .25);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(94, 234, 212, .06);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.welcome h1 {
  position: relative;
  margin: 16px 0 6px;
  font-size: clamp(30px, 5vw, 42px);
  letter-spacing: -.045em;
  line-height: 1.05;
}
.welcome h1 span { color: var(--accent); }

.welcome-sub {
  position: relative;
  max-width: 540px;
  margin: 0 auto 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.welcome-chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.chip {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: #c4ccda;
  font-size: 12.5px;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { background: var(--panel-3); border-color: #3a4760; color: var(--text); }

.welcome-note {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.6;
}
.welcome-note strong { color: #b8c2d3; }

.message {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.03em;
  user-select: none;
}
.message.assistant .avatar {
  background: linear-gradient(135deg, rgba(94, 234, 212, .2), rgba(56, 189, 248, .15));
  color: var(--accent);
  border: 1px solid rgba(94, 234, 212, .25);
}
.message.user .avatar {
  background: #1e3a8a;
  color: #dbeafe;
  border: 1px solid #2b4b9e;
}

.msg-content {
  min-width: 0;
  max-width: calc(100% - 42px);
  display: flex;
  flex-direction: column;
}
.message.user .msg-content { align-items: flex-end; }

.bubble {
  position: relative;
  min-width: 0;
  border-radius: 16px;
  padding: 12px 15px;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  max-width: 82%;
  background: linear-gradient(135deg, #1e40af, #1d4ed8);
  color: #f8fbff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 8px 24px rgba(29, 78, 216, .16);
}

.message.assistant .bubble {
  width: 100%;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}

.user-text {
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 14.5px;
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.message-images:last-child { margin-bottom: 0; }

.chat-image {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .16);
  cursor: zoom-in;
  background: #0b0e14;
}

.assistant-content { min-width: 0; }

.thinking-block {
  margin-bottom: 11px;
  border: 1px solid #263147;
  border-radius: 10px;
  background: #0d131e;
  overflow: hidden;
}

.thinking-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  cursor: pointer;
  list-style: none;
  color: #9fb0c8;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary:hover { background: rgba(255, 255, 255, .025); }

.thinking-chevron {
  color: var(--muted-2);
  transition: transform .18s;
}
.thinking-block[open] .thinking-chevron { transform: rotate(180deg); }

.thinking-text {
  padding: 0 12px 12px;
  color: #9aa8bd;
  font-size: 12.5px;
  line-height: 1.62;
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, .045);
  padding-top: 10px;
}

.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  height: 20px;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typing {
  0%, 80%, 100% { transform: translateY(0); opacity: .4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.copy-msg {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(17, 21, 31, .85);
  color: var(--muted-2);
  font-size: 10px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.message.assistant:hover .copy-msg { opacity: 1; }
.copy-msg:hover { color: var(--text); }

.markdown {
  font-size: 14.5px;
  line-height: 1.7;
  color: #dfe6f2;
}
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }

.markdown p { margin: 0 0 10px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  margin: 18px 0 8px;
  line-height: 1.3;
  letter-spacing: -.02em;
  color: #f0f5ff;
}
.markdown h1 { font-size: 1.45em; }
.markdown h2 { font-size: 1.25em; }
.markdown h3 { font-size: 1.08em; }

.markdown ul, .markdown ol { margin: 8px 0 12px; padding-left: 22px; }
.markdown li { margin: 3px 0; }
.markdown li > p { margin: 0 0 4px; }

.markdown a { color: var(--accent-2); text-decoration: none; }
.markdown a:hover { text-decoration: underline; }

.markdown blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid rgba(94, 234, 212, .45);
  background: rgba(94, 234, 212, .045);
  border-radius: 0 8px 8px 0;
  color: #b6c2d4;
}

.markdown code:not(pre code) {
  padding: 2px 5px;
  border-radius: 5px;
  background: #0b1018;
  border: 1px solid #202a3b;
  font-family: var(--mono);
  font-size: .88em;
  color: #a5f3fc;
}

.markdown table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.markdown th { background: var(--panel-2); color: #d7e0ee; }

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.code-block {
  position: relative;
  margin: 12px 0;
}

.code-block pre {
  margin: 0;
  padding: 14px 14px;
  border: 1px solid #1e2635;
  border-radius: 11px;
  background: #090d14 !important;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}
.code-block pre code {
  padding: 0;
  background: transparent !important;
  border: 0;
  font-size: inherit;
}

.copy-code {
  position: absolute;
  top: 7px;
  right: 7px;
  padding: 3px 7px;
  border: 1px solid #263147;
  border-radius: 6px;
  background: #121824;
  color: #8b95a8;
  font-size: 10px;
  opacity: 0;
  transition: opacity .15s;
}
.code-block:hover .copy-code { opacity: 1; }
.copy-code:hover { color: var(--text); }

.composer-wrap {
  flex: 0 0 auto;
  padding: 10px 18px 16px;
  background: linear-gradient(180deg, transparent, var(--bg) 28%);
}

.attachment-strip {
  width: min(860px, 100%);
  margin: 0 auto 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 1px 4px;
}

.attachment {
  position: relative;
  flex: 0 0 auto;
  width: 76px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
}
.attachment img {
  display: block;
  width: 100%;
  height: 62px;
  object-fit: cover;
  background: #0a0e16;
}
.attachment-label {
  padding: 4px 5px;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attachment-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}
.attachment-remove:hover { background: var(--danger); }

.composer {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: #3b4d6b;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .3), 0 0 0 3px rgba(94, 234, 212, .05);
}
.composer.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, .1);
}

.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 220px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 9px 3px;
  font-size: 14.5px;
  line-height: 1.5;
}
.composer textarea::placeholder { color: #5e6a7d; }

.attach-btn { font-size: 17px; transform: rotate(-18deg); }

.send-btn {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111a;
  font-size: 19px;
  font-weight: 800;
  transition: filter .15s, transform .12s;
}
.send-btn:hover { filter: brightness(1.07); }
.send-btn:active { transform: scale(.96); }

.stop-btn {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(251, 113, 133, .35);
  border-radius: 12px;
  background: rgba(251, 113, 133, .1);
  color: #fecdd3;
  font-size: 12px;
  font-weight: 700;
}
.stop-btn:hover { background: rgba(251, 113, 133, .17); }

.composer-hint {
  width: min(860px, 100%);
  margin: 7px auto 0;
  text-align: center;
  color: #566174;
  font-size: 10.5px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.drawer-backdrop.visible { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  width: min(400px, 92vw);
  display: flex;
  flex-direction: column;
  background: #0e121b;
  border-left: 1px solid var(--border);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  box-shadow: -24px 0 60px rgba(0, 0, 0, .35);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.drawer-head h2 {
  margin: 3px 0 0;
  font-size: 18px;
  letter-spacing: -.02em;
}
.drawer-eyebrow {
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: #c4ccda;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-value { color: var(--accent); font-family: var(--mono); font-size: 12px; }

.field input[type="number"],
.field input[type="text"],
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-weight: 400;
  font-size: 13px;
}
.field input:focus, .field textarea:focus { border-color: #3b4d6b; }
.field textarea { resize: vertical; min-height: 100px; line-height: 1.55; }

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.hint {
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel);
  cursor: pointer;
}
.toggle-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.toggle-title { font-size: 13px; font-weight: 700; }

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.btn:hover { background: var(--panel-3); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111a;
}
.btn.ghost { background: transparent; color: var(--muted); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 7, 12, .8);
  backdrop-filter: blur(9px);
}

.loading-card {
  width: min(540px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.loading-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.loading-head h2 {
  margin: 0 0 3px;
  font-size: 19px;
  letter-spacing: -.025em;
}
.load-status {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
.load-status.error { color: var(--danger); }

.spinner {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid #232c3c;
  border-top-color: var(--accent);
  animation: spin .85s linear infinite;
}
.spinner.done { animation: none; border-color: var(--accent); }
.spinner.error { animation: none; border-color: var(--danger); }

@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #1c2433;
  overflow: hidden;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.progress-meta strong { color: var(--accent); font-family: var(--mono); }

.file-progress {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #0b1018;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 10.5px;
  color: var(--muted);
}
.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
}
.file-pct { flex: 0 0 auto; color: var(--accent); font-family: var(--mono); }

.loading-hint { margin: 14px 0 0; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 7, 12, .74);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .42);
}
.modal-card h3 { margin: 0 0 7px; font-size: 17px; letter-spacing: -.02em; }
.modal-desc { margin: 0 0 16px; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }

.form-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(251, 113, 133, .1);
  color: #fda4af;
  font-size: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .88);
  backdrop-filter: blur(4px);
}
.lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font-size: 16px;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .16); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 200;
  transform: translate(-50%, 18px);
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #161d2a;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(251, 113, 133, .45); color: #fecdd3; }
.toast.info { border-color: rgba(56, 189, 248, .4); color: #bae6fd; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2a3345;
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3b4760; background-clip: content-box; }

.mobile-only { display: none; }

@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-103%);
    transition: transform .24s cubic-bezier(.22, .8, .3, 1);
    box-shadow: 24px 0 60px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: translateX(0); }

  .topbar { padding: 8px 12px; }
  .chat-scroll { padding: 18px 12px 6px; }
  .composer-wrap { padding: 8px 12px 12px; }

  .model-pill span:last-child {
    max-width: 92px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .welcome { margin-top: 10px; padding: 22px 16px; }
  .message.user .bubble { max-width: 90%; }
  .copy-msg { opacity: 1; }
}

@media (max-width: 520px) {
  .toggle-pill span { display: none; }
  .toggle-pill { padding: 7px; }
  .model-pill { padding: 7px 8px; }
  .chat-image { width: 78px; height: 78px; }
  .welcome-chips { gap: 6px; }
  .chip { font-size: 11.5px; padding: 7px 10px; }
  .composer-hint { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
