/* Only things Tailwind CDN can't handle */

/* ─── Global refinements ─────────────────────── */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

* { transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }

/* ─── Auth overlay ───────────────────────────── */
.auth-card { animation: auth-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.auth-glow {
  position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 120px;
  background: radial-gradient(ellipse, hsl(var(--c-primary) / 0.15), transparent 70%);
  pointer-events: none;
}
@keyframes auth-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Pulse animation ────────────────────────── */
.status-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: hsl(142 71% 45%);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.25; transform: scale(0.75); }
}

/* ─── Connection dot ──────────────────────────── */
.dot-online {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block;
  background: hsl(142 71% 45%);
  box-shadow: 0 0 8px hsl(142 71% 45% / 0.35);
}
.dot-offline {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block;
  background: hsl(var(--c-muted-fg));
}

/* ─── Messages ────────────────────────────────── */
#messages {
  display: flex; flex-direction: column;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.msg {
  max-width: 72%;
  word-wrap: break-word; overflow-wrap: break-word;
  animation: msg-in 0.2s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: hsl(var(--c-msg-user));
  color: hsl(var(--c-fg));
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13.5px; line-height: 1.65;
}

.msg.agent {
  align-self: flex-start;
  background: hsl(var(--c-msg-agent));
  border: 1px solid hsl(var(--c-border));
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  font-size: 13.5px; line-height: 1.65;
}

.msg.system {
  align-self: center;
  background: hsl(var(--c-msg-system));
  color: hsl(var(--c-muted-fg));
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px; letter-spacing: 0.01em;
}

/* ─── Markdown ────────────────────────────────── */
.msg pre {
  background: hsl(var(--c-code-bg));
  border: 1px solid hsl(var(--c-border));
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg code {
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
  font-size: 12.5px;
}
.msg p code {
  background: hsl(var(--c-code-inline));
  padding: 2px 6px; border-radius: 4px;
  font-size: 12px; color: hsl(var(--c-primary));
}
.msg p { margin: 4px 0; }
.msg ul, .msg ol { padding-left: 20px; margin: 4px 0; }
.msg a { color: hsl(var(--c-primary)); text-decoration: none; }
.msg a:hover { text-decoration: underline; }
.msg blockquote { border-left: 2px solid hsl(var(--c-primary)); padding-left: 12px; color: hsl(var(--c-muted-fg)); margin: 8px 0; }
.msg table { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.msg th, .msg td { border: 1px solid hsl(var(--c-border)); padding: 6px 10px; }
.msg th { background: hsl(var(--c-muted)); }

/* ─── Tool bubbles ────────────────────────────── */
.tool-bubble {
  align-self: flex-start;
  width: 100%; max-width: 560px;
  background: hsl(var(--c-tool-bg));
  border: 1px solid hsl(var(--c-tool-border));
  border-radius: 10px;
  font-size: 13px;
  transition: border-color 0.25s, box-shadow 0.25s;
  animation: msg-in 0.2s ease-out;
}
.tool-bubble.active {
  border-color: hsl(var(--c-primary) / 0.5);
  box-shadow: 0 0 20px hsl(var(--c-primary) / 0.06);
}
.tool-bubble.done {
  border-color: hsl(var(--c-tool-border));
  transition: border-color 0.25s;
}

.tool-header {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  cursor: pointer; user-select: none;
  transition: background 0.1s;
  border-radius: 10px;
}
.tool-header:hover { background: hsl(var(--c-accent)); }

.tool-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: hsl(var(--c-muted-fg));
  flex-shrink: 0; transition: background 0.2s;
}
.tool-bubble.active .tool-dot {
  background: hsl(142 71% 45%);
  animation: pulse 1.4s ease-in-out infinite;
}
.tool-bubble.done .tool-dot {
  background: hsl(var(--c-muted-fg));
  animation: none;
}

.tool-label {
  color: hsl(var(--c-fg) / 0.7);
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
  font-size: 12px; flex: 1; min-width: 0;
}
.tool-label code {
  background: hsl(var(--c-code-inline));
  padding: 1px 5px; border-radius: 3px;
  font-size: 11.5px;
}
.tool-bubble.done .tool-label { color: hsl(var(--c-muted-fg)); }

.tool-chevron {
  color: hsl(var(--c-muted-fg));
  font-size: 10px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.tool-bubble.expanded .tool-chevron { transform: rotate(90deg); }

.tool-output {
  display: none;
  border-top: 1px solid hsl(var(--c-tool-border));
  max-height: 260px;
  overflow: hidden; overflow-y: auto;
  border-radius: 0 0 10px 10px;
}
.tool-bubble.expanded .tool-output { display: block; }

.tool-output pre {
  margin: 0; padding: 10px 14px;
  font-family: 'IBM Plex Mono', 'SF Mono', monospace;
  font-size: 11.5px; line-height: 1.55;
  color: hsl(var(--c-muted-fg));
  white-space: pre-wrap; word-break: break-all;
  background: none; border: none;
}

/* ─── File download ───────────────────────────── */
.file-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: hsl(var(--c-muted));
  border: 1px solid hsl(var(--c-border));
  border-radius: 8px; padding: 8px 12px; margin-top: 8px;
  color: hsl(var(--c-primary));
  text-decoration: none; font-size: 12.5px;
  transition: border-color 0.15s;
}
.file-download:hover { border-color: hsl(var(--c-primary)); }

/* ─── Project list items ──────────────────────── */
.project-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 7px;
  cursor: pointer; font-size: 13px;
  color: hsl(var(--c-muted-fg));
  transition: all 0.12s ease;
}
.project-item:hover { background: hsl(var(--c-accent)); color: hsl(var(--c-fg)); }
.project-item.active { background: hsl(var(--c-primary) / 0.12); color: hsl(var(--c-primary)); }

.project-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: hsl(var(--c-muted-fg)); flex-shrink: 0;
}
.project-item.active .project-dot {
  background: hsl(142 71% 45%);
  box-shadow: 0 0 6px hsl(142 71% 45% / 0.3);
}

/* ─── Sidebar ─────────────────────────────────── */
.sidebar-default { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.sidebar-action { position: relative; }
.sidebar-action::before {
  content: ''; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-radius: 2px;
  background: hsl(var(--c-primary)); opacity: 0; transition: all 0.15s;
}
.sidebar-action:hover::before { width: 3px; height: 14px; opacity: 1; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

@media (max-width: 768px) {
  .sidebar-default {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); z-index: 50;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar-default.open { transform: translateX(0); }
  #sidebar-toggle { display: block !important; }
  #sidebar-close { display: block !important; }
  .msg { max-width: 92%; }
}

/* Input wrapper */
.input-wrapper {
  box-shadow: 0 -2px 12px hsl(var(--c-bg) / 0.5);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--c-border)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--c-muted-fg)); }

#status-bar.hidden { display: none !important; }
::selection { background: hsl(var(--c-primary) / 0.25); }

/* ─── Light mode highlight.js override ────────── */
.light .hljs { background: hsl(var(--c-code-bg)) !important; }
