/* OSI-Bytes AI UI refresh 2026-07-17 */
/* ============================================================
   OSI-Bytes AI Workspace — UI design system
   ============================================================ */
:root {
  --bg: #020617;
  --bg-elevated: #0b1220;
  --bg-panel: rgba(15, 23, 42, 0.92);
  --bg-chat: #020617;
  --bg-input: rgba(15, 23, 42, 0.88);
  --bg-hover: rgba(30, 41, 59, 0.65);
  --line: rgba(148, 163, 184, 0.12);
  --line-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.12);
  --mint: #00ff9d;
  --orange: #ff9900;
  --orange-dim: rgba(255, 153, 0, 0.12);
  --red: #f87171;
  --green: #22c55e;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --sidebar-w: 300px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  /* legacy aliases used by older inline styles / API HTML */
  --brand-orange: var(--orange);
  --brand-orange-hover: #ffb84d;
  --brand-blue: var(--cyan);
  --brand-blue-hover: #67e8f9;
  --brand-gradient: linear-gradient(135deg, var(--orange) 0%, #ff5c00 100%);
  --bg-base: #020617;
  --border-color: rgba(148, 163, 184, 0.12);
  --border-light: rgba(148, 163, 184, 0.22);
  --text-main: #f1f5f9;
  --text-dark: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
html, body { overflow-x: hidden; max-width: 100vw; }
body {
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(34, 211, 238, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(255, 153, 0, 0.05), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  line-height: 1.5;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* Brand */
.brand-osi { color: var(--orange); font-weight: 900; letter-spacing: -0.02em; }
.brand-hyphen { color: var(--cyan); }
.brand-bytes { color: var(--text); font-weight: 400; }

/* Layout */
.ide-layout {
  display: flex;
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-width: 0;
  position: relative;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  z-index: 1000;
  min-height: 0;
}
.sidebar-top {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.sidebar-brand h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 2px;
}
.sidebar-user {
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-foot {
  flex-shrink: 0;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(2, 6, 23, 0.35);
}

/* Collapsible panels */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(2, 6, 23, 0.35);
  margin-bottom: 10px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
}
.panel-head:hover { background: var(--bg-hover); }
.panel-head .chev {
  color: var(--text-faint);
  transition: transform 0.2s ease;
  font-size: 0.7rem;
}
.panel.collapsed .chev { transform: rotate(-90deg); }
.panel.collapsed .panel-body { display: none; }
.panel-body { padding: 0 12px 12px; }

.sidebar-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  margin: 8px 0 5px;
  font-weight: 700;
}
.sidebar-label:first-child { margin-top: 0; }

.model-dropdown {
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 2px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 0.84rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.model-dropdown:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-dim);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 0 6px;
}
.section-head h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 800;
}
.section-head h3.accent { color: var(--orange); }

.add-btn {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--cyan);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
}
.add-btn:hover {
  background: var(--cyan-dim);
  border-color: var(--cyan);
}

.project-list {
  list-style: none;
  margin: 0 0 4px;
  max-height: 180px;
  overflow-y: auto;
}
.project-list.files-list {
  max-height: 140px;
  background: var(--orange-dim);
  border: 1px solid rgba(255, 153, 0, 0.18);
  border-radius: 10px;
  padding: 4px;
}
.project-list li,
.project-item {
  padding: 8px 10px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  margin-bottom: 2px;
  transition: 0.15s;
  font-size: 0.84rem;
  border: 1px solid transparent;
  cursor: pointer;
}
.project-list li:hover,
.project-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.project-list li.active,
.chat-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: rgba(34, 211, 238, 0.25);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--cyan);
}
.project-list li span.title,
.project-item .title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.proj-meta {
  display: block;
  font-size: 0.62rem;
  color: var(--text-faint);
  font-weight: 500;
  margin-top: 1px;
}
.action-group { display: flex; gap: 2px; align-items: center; flex-shrink: 0; opacity: 0.55; }
.project-list li:hover .action-group,
.chat-item.active .action-group { opacity: 1; }
.action-btn, .delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 5px;
  border-radius: 6px;
  font-size: 0.78rem;
  transition: 0.15s;
  line-height: 1;
}
.action-btn:hover { color: var(--cyan); background: var(--cyan-dim); }
.delete-btn:hover { background: rgba(248, 113, 113, 0.2); color: var(--red); }

.btn-outline {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  font-size: 0.8rem;
  display: block;
  width: 100%;
  transition: 0.15s;
  font-weight: 600;
  font-family: inherit;
}
.btn-outline:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--orange-dim);
}
.btn-outline.muted { color: var(--text-faint); border-color: var(--line); }
.btn-outline.muted:hover { color: var(--red); border-color: var(--red); }
.btn-outline.accent { border-color: rgba(255, 153, 0, 0.4); color: var(--orange); }

.ext-ai-disclaimer {
  font-size: 0.68rem;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 8px 9px;
  border-radius: 8px;
  margin-top: 8px;
  line-height: 1.4;
}
.tunnel-status-box {
  background: rgba(2, 6, 23, 0.5);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.78rem;
}
.tunnel-status-box .row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.tunnel-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tunnel-dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.tunnel-dot.off { background: var(--text-faint); }
.tunnel-meta {
  color: var(--text-muted);
  font-size: 0.68rem;
  margin: 6px 0 8px;
  white-space: pre-wrap;
  line-height: 1.35;
}
.tunnel-btn {
  display: block;
  width: 100%;
  margin: 0 0 6px;
  padding: 7px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--orange);
  border: 1px solid rgba(255, 153, 0, 0.35);
  border-radius: 8px;
  font-family: inherit;
}
.tunnel-btn:hover { background: var(--orange-dim); }
.tunnel-link {
  color: var(--cyan);
  font-size: 0.7rem;
  text-decoration: none;
}
.tunnel-link:hover { text-decoration: underline; }

/* ---------- Main chat ---------- */
#chat-wrapper {
  flex: 1;
  display: flex;
  position: relative;
  background: transparent;
  overflow: hidden;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 10;
  flex-shrink: 0;
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.header-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hamburger-btn {
  display: none;
  background: var(--bg-hover);
  border: 1px solid var(--line);
  color: var(--orange);
  font-size: 1.1rem;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  transition: 0.15s;
}
.hamburger-btn:hover { border-color: var(--orange); background: var(--orange-dim); }

.mode-pill, .status-chip {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  border: 1px solid rgba(255, 153, 0, 0.4);
  color: var(--orange);
  background: var(--orange-dim);
}
.status-chip {
  border-color: rgba(34, 211, 238, 0.35);
  color: var(--cyan);
  background: var(--cyan-dim);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.avatar.user {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  color: #041016;
}
.avatar.ai {
  background: var(--brand-gradient);
  color: #fff;
}

/* Chat log */
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 28px 0 180px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  min-height: 0;
}

.message-row {
  width: 100%;
  max-width: min(920px, 100%);
  display: flex;
  gap: 14px;
  margin: 0 auto 18px;
  padding: 0 20px;
  box-sizing: border-box;
  animation: fadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.message-row.user-row { flex-direction: row-reverse; }
.message-row.user-row .msg-content {
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(8, 145, 178, 0.08));
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 16px 16px 4px 16px;
}
.message-row.ai-row .msg-content {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
}

.msg-content {
  flex: 1;
  min-width: 0;
  line-height: 1.6;
  font-size: 0.98rem;
  color: var(--text);
  overflow-wrap: break-word;
  padding: 12px 14px;
  white-space: pre-wrap;
}

/* Empty / welcome */
.empty-state {
  margin: auto;
  max-width: 520px;
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}
.empty-state .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--brand-gradient);
  font-size: 1.6rem;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(255, 107, 0, 0.25);
}
.empty-state h2 {
  color: var(--text);
  font-size: 1.35rem;
  margin-bottom: 8px;
  font-weight: 800;
}
.empty-state p {
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 18px;
}
.suggest-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
}
.suggest-chip {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
  text-align: left;
  line-height: 1.35;
}
.suggest-chip:hover {
  border-color: var(--cyan);
  color: var(--text);
  background: var(--cyan-dim);
}
.suggest-chip strong {
  display: block;
  color: var(--text);
  font-size: 0.8rem;
  margin-bottom: 2px;
}

/* Code blocks */
.code-wrapper {
  margin: 12px 0;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  overflow: hidden;
  background: #01040d;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  max-width: 100%;
}
.code-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--cyan);
  font-weight: 700;
}
.code-wrapper pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.84rem;
  color: #e2e8f0;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.code-actions { display: flex; gap: 6px; }
.copy-btn, .preview-btn {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  transition: 0.15s;
}
.copy-btn:hover { background: var(--bg-hover); border-color: var(--cyan); color: var(--cyan); }
.preview-btn { border-color: rgba(255, 153, 0, 0.45); color: var(--orange); }
.preview-btn:hover { background: var(--orange); color: #0f172a; }

/* Input */
.input-wrapper {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: min(920px, 100%);
  padding: 0 20px;
  z-index: 10;
  box-sizing: border-box;
}
.input-box {
  background: var(--bg-input);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(34, 211, 238, 0.04);
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-box:focus-within {
  border-color: rgba(255, 153, 0, 0.55);
  box-shadow: var(--shadow), 0 0 0 3px var(--orange-dim);
}
.input-box textarea {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  resize: none;
  outline: none;
  max-height: 220px;
  min-height: 28px;
  padding: 4px 2px 10px;
  line-height: 1.5;
  width: 100%;
}
.input-box textarea::placeholder { color: var(--text-faint); }

.input-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.tools-left {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 7px 9px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: 0.15s;
  font-size: 1.05rem;
  font-family: inherit;
  line-height: 1;
}
.icon-btn:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-color: rgba(34, 211, 238, 0.2);
}
.icon-btn.active-tool {
  color: var(--red);
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}
.icon-btn .tool-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.send-btn {
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 6px 18px rgba(255, 107, 0, 0.3);
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(255, 107, 0, 0.45);
}
.send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.input-hint {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

/* Dropzone */
#dropzone {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(34, 211, 238, 0.08);
  border: 3px dashed var(--cyan);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  color: var(--cyan);
  font-weight: 800;
  backdrop-filter: blur(4px);
  border-radius: 0;
}

/* Overlay / mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 999;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Modal */
#project-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
#project-modal-backdrop.show { display: flex; }
.project-modal {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 22px;
  width: min(440px, 92vw);
  color: #e2e8f0;
  box-shadow: var(--shadow);
}
.project-modal h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
  font-weight: 800;
}
.project-modal label {
  font-size: 0.7rem;
  color: #94a3b8;
  display: block;
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.project-modal input,
.project-modal select,
.project-modal textarea {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  color: #fff;
  border-radius: 9px;
  padding: 9px 11px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.9rem;
}
.project-modal input:focus,
.project-modal select:focus,
.project-modal textarea:focus {
  outline: none;
  border-color: var(--cyan);
}
.project-modal .row-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  justify-content: flex-end;
}
.project-modal button {
  border: none;
  border-radius: 9px;
  padding: 9px 16px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
}
.project-modal .btn-cancel { background: #1e293b; color: #cbd5e1; }
.project-modal .btn-ok {
  background: linear-gradient(90deg, var(--cyan), var(--mint));
  color: #0f172a;
}
.move-pick button {
  display: block;
  width: 100%;
  text-align: left;
  margin: 4px 0;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 9px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.move-pick button:hover { border-color: var(--cyan); background: var(--cyan-dim); }

/* Typing */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--orange);
  margin-left: 3px;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
  border-radius: 1px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .hamburger-btn { display: inline-flex !important; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed !important;
    left: calc(-1 * var(--sidebar-w) - 20px) !important;
    top: 0 !important;
    height: 100% !important;
    height: 100dvh !important;
    width: min(var(--sidebar-w), 88vw) !important;
    max-width: min(var(--sidebar-w), 88vw) !important;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
  }
  .sidebar.active { left: 0 !important; }
  #chat-wrapper { width: 100% !important; margin-left: 0 !important; }
  .header { padding: 10px 12px !important; }
  .header-title { font-size: 0.95rem !important; }
  .message-row { padding: 0 12px; gap: 10px; }
  .input-wrapper { bottom: 12px; padding: 0 12px; }
  #chat-log { padding-bottom: 170px; }
}

@media (max-width: 600px) {
  .hide-mobile { display: none !important; }
  .input-toolbar { flex-wrap: wrap; }
  .tools-left { flex: 1; }
  .send-btn { flex: 1; min-width: 100px; }
  .msg-content { font-size: 0.95rem; }
  .suggest-grid { grid-template-columns: 1fr; }
  textarea, input, select { font-size: 16px !important; }
  .input-hint { display: none; }
  .status-chip { display: none; }
}

@media (min-width: 1400px) {
  .message-row, .input-wrapper { max-width: min(1040px, 72vw); }
}
@media (min-width: 1800px) {
  .message-row, .input-wrapper { max-width: min(1120px, 62vw); }
  :root { --sidebar-w: 320px; }
}

@supports (padding: max(0px)) {
  .header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .input-wrapper { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
  .sidebar-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* Login page remnants */
body.login-page-body { flex-direction: column; height: auto; min-height: 100vh; overflow-y: auto; }
.hero { border-right: none; }
.login-container { min-width: 100%; }

/* ============================================================
   UI10 — light theme, compact density, markdown, stop control
   ============================================================ */

/* Header icon buttons */
.hdr-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
  padding: 0;
}
.hdr-btn:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

/* Stop generation */
.stop-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.45);
  padding: 10px 16px;
  border-radius: 11px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
  transition: 0.15s;
}
.stop-btn:hover {
  background: rgba(248, 113, 113, 0.22);
  border-color: var(--red);
}

/* Markdown content */
.msg-content.md {
  white-space: normal;
}
.msg-content.md p {
  margin: 0 0 0.65em;
  white-space: normal;
}
.msg-content.md p:last-child { margin-bottom: 0; }
.msg-content.md h1,
.msg-content.md h2,
.msg-content.md h3,
.msg-content.md h4,
.msg-content.md h5,
.msg-content.md h6 {
  color: var(--text);
  font-weight: 800;
  line-height: 1.25;
  margin: 0.85em 0 0.4em;
  letter-spacing: -0.02em;
}
.msg-content.md h1 { font-size: 1.35rem; }
.msg-content.md h2 { font-size: 1.2rem; }
.msg-content.md h3 { font-size: 1.08rem; color: var(--cyan); }
.msg-content.md h4 { font-size: 1rem; }
.msg-content.md ul,
.msg-content.md ol {
  margin: 0.4em 0 0.75em 1.15em;
  padding: 0;
}
.msg-content.md li {
  margin: 0.22em 0;
  line-height: 1.5;
}
.msg-content.md li::marker { color: var(--cyan); }
.msg-content.md hr {
  border: none;
  border-top: 1px solid var(--line-strong);
  margin: 0.9em 0;
}
.msg-content.md blockquote {
  margin: 0.5em 0;
  padding: 0.45em 0.85em;
  border-left: 3px solid var(--orange);
  background: var(--orange-dim);
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
}
.msg-content.md a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg-content.md a:hover { color: var(--brand-blue-hover); }
.msg-content.md strong { color: var(--text); font-weight: 800; }
.msg-content.md em { color: var(--text-muted); }
.msg-content.md code.md-inline,
.msg-content.md :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.18);
  color: var(--cyan);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

/* Compact (power-user) density — default */
body.density-compact {
  --sidebar-w: 268px;
}
body.density-compact .sidebar-top { padding: 10px 12px 8px; }
body.density-compact .sidebar-brand h2 { font-size: 1.1rem; }
body.density-compact .sidebar-scroll { padding: 8px 10px 12px; gap: 2px; }
body.density-compact .panel { margin-bottom: 6px; border-radius: 9px; }
body.density-compact .panel-head { padding: 7px 10px; font-size: 0.65rem; }
body.density-compact .panel-body { padding: 0 10px 8px; }
body.density-compact .sidebar-label { margin: 5px 0 3px; font-size: 0.62rem; }
body.density-compact .model-dropdown { padding: 6px 8px; font-size: 0.78rem; border-radius: 7px; }
body.density-compact .section-head { margin: 8px 0 4px; }
body.density-compact .project-list li,
body.density-compact .project-item { padding: 5px 8px; font-size: 0.78rem; margin-bottom: 1px; border-radius: 7px; }
body.density-compact .project-list { max-height: 150px; }
body.density-compact .project-list.files-list { max-height: 110px; }
body.density-compact .btn-outline { padding: 7px 8px; font-size: 0.74rem; border-radius: 7px; }
body.density-compact .sidebar-foot { padding: 8px 10px 10px; gap: 4px; }
body.density-compact .header { padding: 8px 14px; }
body.density-compact .header-title { font-size: 0.92rem; }
body.density-compact .mode-pill,
body.density-compact .status-chip { font-size: 0.62rem; padding: 3px 8px; }
body.density-compact #chat-log { padding: 16px 0 150px; }
body.density-compact .message-row { margin: 0 auto 10px; gap: 10px; padding: 0 14px; }
body.density-compact .msg-content { font-size: 0.9rem; padding: 8px 11px; line-height: 1.5; }
body.density-compact .avatar { width: 28px; height: 28px; font-size: 0.78rem; border-radius: 8px; }
body.density-compact .input-wrapper { bottom: 12px; padding: 0 14px; }
body.density-compact .input-box { padding: 8px 10px 8px; border-radius: 14px; }
body.density-compact .input-box textarea { font-size: 0.9rem; padding: 2px 2px 6px; }
body.density-compact .send-btn,
body.density-compact .stop-btn { padding: 8px 14px; font-size: 0.82rem; border-radius: 9px; }
body.density-compact .icon-btn { padding: 5px 7px; font-size: 0.95rem; }
body.density-compact .input-hint { margin-top: 5px; font-size: 0.6rem; }
body.density-compact .tunnel-status-box { padding: 7px; }
body.density-compact .empty-state { padding: 24px 16px; }
body.density-compact .empty-state h2 { font-size: 1.15rem; }
body.density-compact .suggest-chip { padding: 8px 10px; font-size: 0.72rem; }

/* Comfortable density */
body.density-comfortable {
  --sidebar-w: 300px;
}

/* ---------- Light theme ---------- */
html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.92);
  --bg-chat: #f8fafc;
  --bg-input: rgba(255, 255, 255, 0.95);
  --bg-hover: rgba(15, 23, 42, 0.05);
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --cyan: #0891b2;
  --cyan-dim: rgba(8, 145, 178, 0.1);
  --mint: #059669;
  --orange: #ea580c;
  --orange-dim: rgba(234, 88, 12, 0.1);
  --red: #dc2626;
  --green: #16a34a;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
  --brand-orange: var(--orange);
  --brand-blue: var(--cyan);
  --brand-gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  --bg-base: #f1f5f9;
  --border-color: rgba(15, 23, 42, 0.08);
  --border-light: rgba(15, 23, 42, 0.14);
  --text-main: #0f172a;
  --text-dark: #0f172a;
}
html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 80% 50% at 100% -10%, rgba(8, 145, 178, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(234, 88, 12, 0.05), transparent 45%),
    var(--bg);
  color: var(--text);
}
html[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.95);
  border-right-color: var(--line);
}
html[data-theme="light"] .header {
  background: rgba(248, 250, 252, 0.9);
}
html[data-theme="light"] .input-box {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .message-row.user-row .msg-content {
  background: linear-gradient(145deg, rgba(8, 145, 178, 0.12), rgba(8, 145, 178, 0.05));
  border-color: rgba(8, 145, 178, 0.25);
}
html[data-theme="light"] .message-row.ai-row .msg-content {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
html[data-theme="light"] .code-wrapper {
  background: #0f172a;
  border-color: #1e293b;
}
html[data-theme="light"] .code-header {
  background: #1e293b;
  color: #22d3ee;
}
html[data-theme="light"] .code-wrapper pre { color: #e2e8f0; }
html[data-theme="light"] .model-dropdown {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
}
html[data-theme="light"] .panel {
  background: rgba(248, 250, 252, 0.9);
}
html[data-theme="light"] .project-list li.active,
html[data-theme="light"] .chat-item.active {
  background: var(--cyan-dim);
  color: var(--cyan);
}
html[data-theme="light"] .project-list.files-list {
  background: var(--orange-dim);
}
html[data-theme="light"] .sidebar-foot {
  background: rgba(241, 245, 249, 0.8);
}
html[data-theme="light"] .suggest-chip {
  background: #fff;
  border-color: var(--line-strong);
}
html[data-theme="light"] .empty-state .badge {
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.2);
}
html[data-theme="light"] .project-modal {
  background: #fff;
  color: #0f172a;
  border-color: #cbd5e1;
}
html[data-theme="light"] .project-modal input,
html[data-theme="light"] .project-modal select,
html[data-theme="light"] .project-modal textarea {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}
html[data-theme="light"] .brand-bytes { color: #0f172a; }
html[data-theme="light"] .typing-cursor { background: var(--orange); }
html[data-theme="light"] .msg-content.md code.md-inline {
  background: rgba(8, 145, 178, 0.08);
  border-color: rgba(8, 145, 178, 0.2);
  color: #0e7490;
}
html[data-theme="light"] #dropzone {
  background: rgba(8, 145, 178, 0.08);
}
html[data-theme="light"] .avatar.user {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #fff;
}
