:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --panel: #11161d;
  --panel-2: #171d26;
  --border: #273142;
  --text: #edf2f7;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent-2: #9333ea;
  --user: #1f2937;
  --assistant: #161b22;
  --danger: #f87171;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: radial-gradient(circle at top, #121826 0%, var(--bg) 55%);
  color: var(--text);
}
.hidden { display: none !important; }
.app-shell { min-height: 100vh; display: grid; place-items: center; padding: 18px; }
.login-card {
  width: min(420px, 100%);
  background: rgba(17,22,29,.9);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 70px rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  padding: 28px;
}
.workspace {
  width: min(1440px, 100%);
  height: min(92vh, 1100px);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: stretch;
}
.brand { font-size: 12px; text-transform: uppercase; letter-spacing: .24em; color: #c084fc; margin-bottom: 10px; }
h1 { margin: 0 0 10px; font-size: 28px; }
.muted, .sub { color: var(--muted); }
form { display: grid; gap: 12px; }
label { font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #0d1117;
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  resize: none;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.18); }
button {
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  padding: 13px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.ghost, .file-label {
  background: transparent;
  border: 1px solid var(--border);
}
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  color: var(--text);
}
#fileInput { display: none; }
.sidebar {
  width: 300px;
  background: rgba(17,22,29,.78);
  border: 1px solid rgba(39,49,66,.55);
  border-radius: 24px;
  box-shadow: 0 18px 70px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  transition: width .18s ease, opacity .18s ease;
}
.sidebar.collapsed {
  width: 62px;
}
.sidebar-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid rgba(39,49,66,.55);
}
.sidebar-search-wrap {
  padding: 12px;
  border-bottom: 1px solid rgba(39,49,66,.55);
}
.sidebar-search-wrap input {
  padding: 10px 12px;
}
.sidebar.collapsed .sidebar-title-wrap,
.sidebar.collapsed .project-list,
.sidebar.collapsed .new-project,
.sidebar.collapsed .sidebar-search-wrap {
  display: none;
}
.sidebar-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
}
.sidebar:not(.collapsed) .sidebar-toggle { transform: rotate(180deg); }
.project-list {
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 8px;
}
.project-item {
  border: 1px solid transparent;
  background: #0d1117;
  border-radius: 16px;
  padding: 10px;
  display: grid;
  gap: 8px;
}
.project-item.active {
  border-color: rgba(124,58,237,.65);
  background: rgba(124,58,237,.13);
}
.project-open {
  all: unset;
  cursor: pointer;
  display: grid;
  gap: 6px;
}
.project-actions {
  display: flex;
  gap: 8px;
}
.project-name { font-weight: 600; }
.project-meta { color: var(--muted); font-size: 12px; }
.mini {
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 12px;
}
.danger {
  border-color: rgba(248,113,113,.4) !important;
  color: #fca5a5;
}
.chat-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: rgba(17,22,29,.66);
  backdrop-filter: blur(10px);
}
.chat-shell.borderless {
  border: 0;
  border-radius: 26px;
  box-shadow: 0 18px 70px rgba(0,0,0,.22);
}
.topbar {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(39,49,66,.45);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.messages {
  padding: 22px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.message { display: flex; }
.message.user { justify-content: flex-end; }
.message { position: relative; }
.bubble {
  max-width: min(78ch, 84%);
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.5;
  border: 1px solid rgba(39,49,66,.5);
}
.message.user .bubble { background: rgba(31,41,55,.86); }
.message.assistant .bubble { background: rgba(22,27,34,.82); }
.loading-dots { display: inline-flex; align-items: center; gap: 4px; min-height: 1em; }
.loading-dots span { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); opacity: .25; animation: blink 1.1s infinite ease-in-out; }
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
.loading-dots span:nth-child(4) { animation-delay: .45s; }
@keyframes blink { 0%,80%,100%{opacity:.2;transform:translateY(0)} 40%{opacity:1;transform:translateY(-2px)} }
.composer {
  padding: 16px 22px 10px;
  border-top: 1px solid rgba(39,49,66,.45);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}
.composer-main { display: grid; gap: 10px; }
.composer-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drop-hint { color: var(--muted); font-size: 12px; }
.upload-list { display: flex; gap: 10px; flex-wrap: wrap; }
.upload-card {
  display: grid; gap: 8px; width: 160px; padding: 10px;
  border: 1px solid var(--border); border-radius: 14px; background: #0d1117;
}
.upload-meta { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.upload-meta strong { color: var(--text); font-size: 12px; word-break: break-word; }
.upload-progress { height: 6px; background: #1f2937; border-radius: 999px; overflow: hidden; }
.upload-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .12s linear; }
.upload-preview, .upload-preview-large {
  width: 100%; border-radius: 10px; border: 1px solid var(--border); object-fit: cover; background: #0a0d12;
}
.upload-preview { height: 100px; }
.upload-preview-large { max-width: 260px; max-height: 220px; }
.remove-upload { padding: 8px 10px; font-size: 12px; }
.sent-upload-list { display: grid; gap: 10px; margin-top: 10px; }
.sent-upload { display: grid; gap: 6px; }
.sent-upload-meta, .attachment-links { color: var(--muted); font-size: 12px; }
.attachment-links a { color: #c084fc; margin-right: 8px; }
.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.error { margin: 0; min-height: 22px; color: var(--danger); padding: 0 22px 18px; }
.chat-shell.dragging { box-shadow: 0 0 0 2px rgba(124,58,237,.65), 0 18px 70px rgba(0,0,0,.35); }
.bubble pre {
  overflow: auto; padding: 12px; background: #0d1117; border-radius: 12px; border: 1px solid var(--border);
}
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.bubble :is(p, ul, ol, pre, blockquote, h1, h2, h3, h4) { margin: 0 0 12px; }
.bubble :last-child { margin-bottom: 0; }
.bubble a { color: #c084fc; }
@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .sidebar { width: 100%; }
  .sidebar.collapsed { width: 100%; }
  .sidebar.collapsed .project-list, .sidebar.collapsed .new-project { display: grid; }
  .sidebar.collapsed .sidebar-title-wrap { display: block; }
}
@media (max-width: 720px) {
  .app-shell { padding: 0; }
  .workspace { min-height: 100vh; gap: 0; }
  .sidebar, .chat-shell.borderless, .login-card { border-radius: 0; }
  .chat-shell { min-height: 100vh; }
  .composer { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}
