/* ibhax — Design System */

:root {
  --bg-primary: #0B0D12;
  --bg-secondary: #0F1117;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(15, 17, 23, 0.8);

  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-emerald-glow: rgba(16, 185, 129, 0.15);
  --accent-cyan-glow: rgba(6, 182, 212, 0.15);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;

  --border: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(16, 185, 129, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(16, 185, 129, 0.2);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 240px;
  --topbar-height: 60px;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── Layout ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 110;
  transition: transform var(--transition);
  transform: translateX(-100%);
}

.sidebar.open {
  transform: translateX(0);
}

.main-content {
  margin-left: 0;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.no-sidebar .main-content {
  margin-left: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
  min-width: 0;
}

.page-content {
  flex: 1;
  padding: 16px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

@media (min-width: 1024px) {
  .sidebar {
    transform: translateX(0);
  }
  .main-content {
    margin-left: var(--sidebar-width);
  }
  .topbar {
    padding: 0 24px;
    gap: 16px;
  }
  .page-content {
    padding: 32px;
  }
}

/* ─── Sidebar Components ─── */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 8px 20px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 450;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: var(--accent-emerald);
  background: var(--accent-emerald-glow);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-emerald);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition), box-shadow var(--transition);
  position: relative;
}

.card:hover {
  background: linear-gradient(135deg, rgba(16,185,129,0.03), transparent),
              var(--bg-card-hover);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Typography ─── */
.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-emerald { background: var(--accent-emerald-glow); color: var(--accent-emerald); }
.badge-cyan { background: var(--accent-cyan-glow); color: var(--accent-cyan); }
.badge-muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 20px rgba(16,185,129,0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(16,185,129,0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ─── Inputs ─── */
.input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

select.input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select.input option {
  background: #13151c;
  color: var(--text-primary);
}

textarea.input {
  resize: vertical;
  font-family: inherit;
}

.input::placeholder { color: var(--text-muted); }

.input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px var(--accent-emerald-glow);
}

/* ─── Progress Bar ─── */
.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Tags ─── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: default;
}

.tag:hover {
  background: var(--accent-emerald-glow);
  color: var(--accent-emerald);
  border-color: var(--border-accent);
}

/* ─── Grid ─── */
.grid-2,
.grid-3,
.grid-4,
.grid-auto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-auto { gap: 20px; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ─── Divider ─── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ─── Command Palette ─── */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}

.cmd-palette {
  width: 600px;
  max-width: 90vw;
  background: #13151c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0,0,0,0.8);
  overflow: hidden;
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

.cmd-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  font-size: 14px;
}

.cmd-item:hover, .cmd-item.selected {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.cmd-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cmd-kbd {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.kbd {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--text-muted);
  font-size: 11px;
  font-family: monospace;
  border: 1px solid var(--border);
}

/* ─── Chat (legacy container) ─── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height) - 64px);
}

.chat-input-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  transition: border-color var(--transition);
}

.chat-input-wrap:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px var(--accent-emerald-glow);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.6;
}

.chat-textarea::placeholder { color: var(--text-muted); }

/* Typing animation */
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─── Animations ─── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(16,185,129,0.2); }
  50% { box-shadow: 0 0 24px rgba(16,185,129,0.5); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-fade-up { animation: fade-up 0.4s ease both; }
.animate-fade-in { animation: fade-in 0.3s ease both; }
.animate-slide-left { animation: slide-in-left 0.4s ease both; }
.animate-glow { animation: glow-pulse 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }

/* ─── Timeline ─── */
.timeline-line {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent-emerald), var(--accent-cyan), transparent);
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-primary);
  box-shadow: 0 0 8px rgba(16,185,129,0.4);
  flex-shrink: 0;
}

/* ─── Note/Garden ─── */
.note-stage-seedling { border-left: 3px solid #f59e0b; }
.note-stage-growing { border-left: 3px solid var(--accent-cyan); }
.note-stage-evergreen { border-left: 3px solid var(--accent-emerald); }

/* ─── Code Blocks ─── */
pre {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

code {
  font-family: 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  font-size: 0.9em;
}

p code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-cyan);
}

/* ─── Prose (rendered markdown) ─── */
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--text-primary);
  font-weight: 700;
  margin: 1.5em 0 0.5em;
}
.prose h1 { font-size: 1.8em; }
.prose h2 { font-size: 1.4em; }
.prose h3 { font-size: 1.2em; }
.prose p { margin: 0.75em 0; color: var(--text-secondary); }
.prose ul, .prose ol { padding-left: 1.5em; color: var(--text-secondary); }
.prose li { margin: 0.25em 0; }
.prose a { color: var(--accent-emerald); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose blockquote {
  border-left: 3px solid var(--accent-emerald);
  padding-left: 16px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 1em 0;
}

/* ─── Status dots ─── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-active { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.status-paused { background: #f59e0b; }
.status-completed { background: var(--accent-cyan); }

/* ─── Skeleton loading ─── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Map ─── */
#adventures-map {
  height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ─── Misc utilities ─── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded { border-radius: var(--radius-sm); }
.cursor-pointer { cursor: pointer; }

/* ─── Prose Content (blog articles) ─── */
.prose-content h1 {
  font-size: 28px;
  font-weight: 800;
  margin: 48px 0 16px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.3;
}
.prose-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 40px 0 14px;
  color: var(--text-primary);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.3px;
  line-height: 1.35;
}
.prose-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 32px 0 10px;
  color: var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4;
}
.prose-content h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text-primary);
  font-style: italic;
  line-height: 1.4;
}
.prose-content h2:first-child { margin-top: 0; }
.prose-content p {
  margin: 0 0 18px;
  line-height: 1.85;
}
.prose-content ul, .prose-content ol {
  margin: 0 0 20px;
  padding-left: 24px;
}
.prose-content ul { list-style-type: disc; }
.prose-content ol { list-style-type: decimal; }
.prose-content li {
  margin-bottom: 8px;
  line-height: 1.75;
}
.prose-content li::marker {
  color: var(--accent-emerald);
}
.prose-content strong {
  color: var(--text-primary);
  font-weight: 600;
}
.prose-content em {
  color: var(--text-secondary);
}
.prose-content blockquote {
  border-left: 3px solid var(--accent-emerald);
  padding: 12px 20px;
  margin: 24px 0;
  color: var(--text-muted);
  font-style: italic;
  background: rgba(16,185,129,0.04);
  border-radius: 0 8px 8px 0;
  line-height: 1.7;
}
.prose-content blockquote p:last-child { margin-bottom: 0; }
.prose-content pre {
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
  font-size: 13px;
  line-height: 1.7;
  position: relative;
}
.prose-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  background: rgba(255,255,255,0.07);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--accent-cyan);
}
.prose-content pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.prose-content a {
  color: var(--accent-emerald);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(16,185,129,0.4);
  transition: all 0.15s;
}
.prose-content a:hover {
  color: var(--accent-cyan);
  text-decoration-color: var(--accent-cyan);
}
.prose-content img {
  max-width: 100%;
  border-radius: 10px;
  margin: 24px 0;
  border: 1px solid var(--border);
}
.prose-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.prose-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}
.prose-content th, .prose-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.prose-content th {
  background: rgba(255,255,255,0.05);
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.prose-content td {
  color: var(--text-secondary);
}
.prose-content tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ─── Pygments Syntax Highlighting (Monokai) ─── */
.prose-content .codehilite {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
}
.prose-content .codehilite pre { background: transparent; border: none; padding: 0; margin: 0; }
.prose-content .codehilite code { background: none; padding: 0; color: #F8F8F2; }
.codehilite .hll { background-color: #49483e }
.codehilite { background: #0d1117; color: #F8F8F2 }
.codehilite .c { color: #6a737d } .codehilite .ch { color: #6a737d }
.codehilite .cm { color: #6a737d } .codehilite .cp { color: #6a737d }
.codehilite .cpf { color: #6a737d } .codehilite .c1 { color: #6a737d }
.codehilite .cs { color: #6a737d }
.codehilite .k { color: #ff7b72 } .codehilite .kc { color: #79c0ff }
.codehilite .kd { color: #ff7b72 } .codehilite .kn { color: #ff7b72 }
.codehilite .kp { color: #79c0ff } .codehilite .kr { color: #ff7b72 }
.codehilite .kt { color: #79c0ff }
.codehilite .s { color: #a5d6ff } .codehilite .sa { color: #a5d6ff }
.codehilite .sb { color: #a5d6ff } .codehilite .sc { color: #a5d6ff }
.codehilite .dl { color: #a5d6ff } .codehilite .sd { color: #a5d6ff }
.codehilite .s2 { color: #a5d6ff } .codehilite .se { color: #79c0ff }
.codehilite .sh { color: #a5d6ff } .codehilite .si { color: #a5d6ff }
.codehilite .sx { color: #a5d6ff } .codehilite .sr { color: #a5d6ff }
.codehilite .s1 { color: #a5d6ff } .codehilite .ss { color: #a5d6ff }
.codehilite .m { color: #79c0ff } .codehilite .mb { color: #79c0ff }
.codehilite .mf { color: #79c0ff } .codehilite .mh { color: #79c0ff }
.codehilite .mi { color: #79c0ff } .codehilite .mo { color: #79c0ff }
.codehilite .il { color: #79c0ff }
.codehilite .na { color: #79c0ff } .codehilite .nb { color: #ffa657 }
.codehilite .nc { color: #ffa657 } .codehilite .nd { color: #d2a8ff }
.codehilite .ne { color: #ffa657 } .codehilite .nf { color: #d2a8ff }
.codehilite .nl { color: #79c0ff } .codehilite .nn { color: #ffa657 }
.codehilite .nt { color: #7ee787 } .codehilite .nv { color: #ffa657 }
.codehilite .o { color: #ff7b72 } .codehilite .ow { color: #ff7b72 }
.codehilite .p { color: #F8F8F2 }
.codehilite .gd { color: #ffa198; background-color: rgba(248,81,73,0.1) }
.codehilite .gi { color: #7ee787; background-color: rgba(46,160,67,0.1) }
.codehilite .err { color: #ffa198 }

/* ─── AI Generation Loading Overlay ─── */
.ai-generate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.ai-generate-overlay.active {
  display: flex;
}

.ai-generate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  max-width: 90vw;
  width: 420px;
  text-align: center;
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
}

.ai-generate-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.ai-generate-step {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  min-height: 22px;
}

.ai-generate-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
}

.ai-progress-ring {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
}

.ai-progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ai-progress-ring circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.ai-progress-ring circle:first-child {
  stroke: var(--bg-card-hover);
}

.ai-progress-ring circle:last-child {
  stroke: var(--accent-emerald);
  stroke-dasharray: 126;
  stroke-dashoffset: 100;
  animation: ai-ring-spin 1.5s linear infinite;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
}

@keyframes ai-ring-spin {
  0% { stroke-dashoffset: 126; }
  50% { stroke-dashoffset: 32; }
  100% { stroke-dashoffset: 126; }
}

.ai-progress-track {
  height: 4px;
  background: var(--bg-card-hover);
  border-radius: 2px;
  overflow: hidden;
}

.ai-progress-bar {
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
  border-radius: 2px;
  animation: ai-progress-shuttle 2s ease-in-out infinite;
}

@keyframes ai-progress-shuttle {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive enhancements — mobile-first
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Viewport scaling */
html { -webkit-text-size-adjust: 100%; }

img, video, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Mobile menu button */
.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-menu-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 105;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

@media (min-width: 1024px) {
  .mobile-menu-btn,
  .sidebar-overlay { display: none; }
}

/* Fluid typography for headings */
.page-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
}

.page-subtitle {
  font-size: clamp(0.875rem, 2vw, 0.9375rem);
}

.stat-value {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
}

.prose-content h1 {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
}

.prose-content h2 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

.prose-content h3 {
  font-size: clamp(1rem, 2.5vw, 1.125rem);
}

/* Touch-friendly minimum sizes */
button, .btn, .nav-item, a, input, textarea, select {
  min-height: 44px;
}

.btn-icon, .nav-item svg, .cmd-item-icon {
  min-width: 24px;
  min-height: 24px;
}

/* Responsive chat layout */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  /* 100dvh tracks the actually-visible height on mobile (address bar excluded);
     100vh is kept as fallback for old browsers. */
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  margin: -16px;
  overflow: hidden;
}

.chat-sidebar {
  display: none;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-direction: column;
  overflow: hidden;
}

.chat-sidebar.open {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 120;
  width: 85%;
  max-width: 320px;
  height: 100vh;
  height: 100dvh;
}

.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-messages-inner {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
}

.chat-input-inner {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}

.chat-bubble {
  max-width: 92%;
  padding: 12px 14px;
  font-size: 0.9375rem;
}

@media (min-width: 640px) {
  .chat-messages { padding: 20px 24px; }
  .chat-input-area { padding: 14px 24px; }
  .chat-bubble { max-width: 85%; }
}

@media (min-width: 768px) {
  .chat-bubble { max-width: 80%; }
}

@media (min-width: 1024px) {
  .chat-layout {
    grid-template-columns: 260px 1fr;
    height: calc(100vh - var(--topbar-height) - 32px);
    margin: -32px;
  }
  .chat-sidebar {
    display: flex;
    position: static;
    width: auto;
    max-width: none;
    height: auto;
  }
  .chat-messages { padding: 24px 32px; }
  .chat-input-area { padding: 16px 32px; }
}

@media (min-width: 1400px) {
  .chat-messages-inner { max-width: 900px; }
  .chat-input-inner { max-width: 900px; }
}

/* Tables overflow on small screens */
.prose-content table,
.chat-prose table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

/* Prevent long words / URLs breaking layout */
.chat-prose, .prose-content, .page-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Topbar responsive tweaks */
.topbar h1 {
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.topbar-search {
  flex: 1;
  min-width: 0;
  max-width: 360px;
}

@media (max-width: 639px) {
  .topbar-search { max-width: none; }
  .topbar .cmd-hint { display: none; }
}

.topbar-userlinks { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@media (max-width: 639px) {
  .topbar { height: auto; min-height: var(--topbar-height); flex-wrap: wrap; padding: 8px 12px; }
  .topbar-userlinks { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .topbar-userlinks .btn { font-size: 11px; padding: 4px 8px; white-space: nowrap; }
}

/* Modal responsive sizing */
#agent-modal > div,
.modal-panel {
  width: 94%;
  max-width: 640px;
  max-height: 88vh;
  padding: 20px;
}

@media (min-width: 768px) {
  #agent-modal > div,
  .modal-panel {
    width: 90%;
    padding: 28px;
  }
}

/* Suggested prompt grid */
.suggested-prompts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 480px) {
  .suggested-prompts { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .suggested-prompts { gap: 12px; }
}

/* Utility: show/hide per breakpoint */
.hide-mobile { display: none; }

@media (min-width: 640px) {
  .hide-mobile { display: block; }
  .show-mobile { display: none; }
}

/* Chat mobile-only header & toggle */
.chat-mobile-header,
.chat-toggle-btn { display: none; }

@media (max-width: 1023px) {
  .chat-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .chat-toggle-btn {
    display: inline-flex;
  }
}

/* Utility: horizontal scroll containers */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

/* Utility: responsive form rows */
.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr 80px; }
  .form-row-2.equal { grid-template-columns: repeat(2, 1fr); }
}

/* Agent dropdown positioning fix on small screens */
#agent-dropdown {
  left: 0;
  right: auto;
  min-width: 240px;
  max-width: calc(100vw - 32px);
}

@media (max-width: 399px) {
  #agent-dropdown { min-width: 220px; }
}

/* Prevent horizontal overflow from long words/URLs/images on blog pages */
.blog-card-item, .blog-card-item * { overflow-wrap: anywhere; }
.blog-card-item img, .prose-content img, .prose-content video, .prose-content iframe, .prose-content table { max-width: 100%; }
.prose-content { overflow-wrap: anywhere; }
.prose-content pre { overflow-x: auto; white-space: pre-wrap; }
.prose-content a { word-break: break-word; }

.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary, #0F1117);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  z-index: 200;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.user-menu.open { display: block; }
.user-menu-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}
.user-menu-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.user-menu-item.locked { opacity: 0.65; }
.user-menu-sep { border-top: 1px solid var(--border); margin: 6px 4px; }


/* ─── Typography polish ─── */
h1, h2, h3, h4, h5, h6,
.page-title, .section-title, .logo-text, .card-title {
  font-family: 'Inter Tight', 'Inter', -apple-system, sans-serif;
}

h1, h2, h3 { text-wrap: balance; }

.prose-content h1, .prose-content h2, .prose-content h3 {
  letter-spacing: -0.02em;
  font-weight: 700;
}

.card .section-title { letter-spacing: -0.01em; }

@media (max-width: 639px) {
  .badge { font-size: 9px; padding: 2px 8px; letter-spacing: 0.4px; }
  .tag { font-size: 10px; padding: 2px 7px; }
}
