:root {
  --bg: #0d1117;
  --sidebar-bg: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-green: #3fb950;
  --active-bg: #1f2937;
  --card-bg: #161b22;
  --code-bg: #161b22;
  --topbar-bg: #010409;
  --danger: #f85149;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

body,
button,
input,
textarea {
  color: inherit;
  font: inherit;
}

code,
pre,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

#app {
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 12px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
}

.topbar-left {
  gap: 8px;
  min-width: 0;
}

.topbar-center {
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.topbar-right {
  gap: 12px;
}

.logo {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  text-decoration: none;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--sidebar-bg);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.menu-toggle:hover {
  border-color: var(--accent);
}

.search-wrap {
  position: relative;
  width: min(420px, 100%);
}

.search-input {
  width: 100%;
  height: 34px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 34px 0 12px;
  outline: none;
}

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

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 11px;
  pointer-events: none;
}

.topbar-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}

.topbar-link:hover {
  color: var(--accent);
}

.main {
  display: flex;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-body {
  padding: 8px 0;
  flex: 1;
}

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

.sidebar-footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}

.sidebar-footer-link:hover {
  color: var(--accent);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  min-width: 0;
}

.content-inner {
  max-width: 860px;
  margin: 0 auto;
}

.error-banner {
  background: rgba(248, 81, 73, 0.12);
  color: #ffb3ad;
  border: 1px solid rgba(248, 81, 73, 0.35);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.category {
  margin-top: 4px;
}

.category-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.category-header:hover {
  color: var(--text);
}

.category-arrow {
  color: var(--text-muted);
  font-size: 11px;
}

.agent-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.agent-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.agent-caret {
  color: var(--text-muted);
  width: 12px;
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
}

.agent-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-count {
  color: var(--text-muted);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 6px;
}

.file-list {
  padding: 2px 0 6px;
}

.file-row {
  width: 100%;
  display: block;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  text-align: left;
  font-size: 12px;
  padding: 6px 12px 6px 32px;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.file-row:hover {
  background: var(--active-bg);
  color: var(--text);
}

.file-row.active {
  background: var(--active-bg);
  color: var(--accent);
  border-left-color: var(--accent);
}

.file-row-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  min-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  padding: 24px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  padding-bottom: 10px;
}

.breadcrumb-text {
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-text strong {
  color: var(--text);
  font-weight: 600;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--sidebar-bg);
  color: var(--text-muted);
  border-radius: var(--radius);
  height: 28px;
  padding: 0 8px;
  cursor: pointer;
  font-size: 12px;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.copy-toast {
  color: var(--accent-green);
  font-size: 12px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.copy-toast.visible {
  opacity: 1;
}

.md-content {
  color: var(--text);
}

.md-content h1 {
  font-size: 1.9em;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.md-content h2 {
  font-size: 1.4em;
  margin: 28px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.65);
}

.md-content h3 {
  font-size: 1.1em;
  margin: 24px 0 12px;
  color: var(--accent);
}

.md-content h4,
.md-content h5 {
  color: var(--text-muted);
  margin: 18px 0 10px;
}

.md-content p {
  line-height: 1.7;
  margin: 0 0 16px;
}

.md-content code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.88em;
}

.md-content pre {
  margin: 0 0 16px;
}

.md-content pre > code {
  display: block;
  padding: 16px;
  overflow-x: auto;
  border-radius: 6px;
  font-size: 0.85em;
  line-height: 1.6;
}

.md-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 16px;
}

.md-content th,
.md-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.md-content th {
  background: var(--sidebar-bg);
}

.md-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.md-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 16px;
  padding: 8px 16px;
  color: var(--text-muted);
  font-style: italic;
}

.md-content a {
  color: var(--accent);
  text-decoration: none;
}

.md-content a:hover {
  text-decoration: underline;
}

.md-content ul,
.md-content ol {
  padding-left: 24px;
  margin: 0 0 16px;
}

.md-content li + li {
  margin-top: 6px;
}

.md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.md-content strong {
  color: var(--text);
}

.search-header {
  margin-bottom: 16px;
}

.search-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.search-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.search-results {
  display: grid;
  gap: 12px;
}

.search-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  box-shadow: none;
}

.search-card:hover {
  border-color: rgba(88, 166, 255, 0.45);
  background: rgba(22, 27, 34, 0.9);
}

.search-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge.core {
  border-color: rgba(63, 185, 80, 0.4);
  color: #7ee787;
}

.badge.project {
  border-color: rgba(88, 166, 255, 0.4);
  color: #79c0ff;
}

.badge.codex {
  border-color: rgba(255, 166, 87, 0.4);
  color: #ffb86b;
}

.search-file {
  font-weight: 600;
  font-size: 13px;
}

.search-path {
  color: var(--text-muted);
  font-size: 12px;
}

.search-excerpt {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 13px;
}

.search-excerpt mark {
  background: #f2cc60;
  color: #111;
  border-radius: 2px;
  padding: 0 2px;
}

.no-results {
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.loading-skeleton {
  display: grid;
  gap: 12px;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  animation: pulse 1.3s ease-in-out infinite;
}

.skeleton-line.h1 {
  height: 24px;
  width: 58%;
  margin-bottom: 6px;
}

.skeleton-line.w90 { width: 90%; }
.skeleton-line.w85 { width: 85%; }
.skeleton-line.w78 { width: 78%; }
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w62 { width: 62%; }
.skeleton-line.w55 { width: 55%; }

@keyframes pulse {
  0%,
  100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.mobile-overlay {
  display: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 768px) {
  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    padding: 0 10px;
    gap: 8px;
  }

  .logo {
    font-size: 14px;
  }

  .search-wrap {
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .topbar-right .topbar-link {
    font-size: 12px;
  }

  .content {
    padding: 20px 16px 28px;
  }

  .sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
    max-width: min(86vw, 320px);
    width: 260px;
  }

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

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 48px 0 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 150;
  }

  .main.sidebar-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .search-shortcut {
    display: none;
  }

  .breadcrumb {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}
