:root {
  --bg: #0f1117;
  --panel: #181b24;
  --panel-2: #1f2330;
  --border: #2a2f3d;
  --text: #e4e7ee;
  --muted: #8a92a6;
  --accent: #7aa2ff;
  --good: #4ec9a8;
  --bad: #ff7a7a;
  --found: #4ec9a8;
  --inter: #e2c54a;
  --adv: #ff7a7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.mode-switch button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  border-radius: 6px;
  margin-left: 0.4rem;
}

.mode-switch button.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--panel-2);
}

#app {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

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

#search {
  margin: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.filters {
  display: flex;
  gap: 0.5rem;
  padding: 0 0.75rem 0.75rem;
}

.filters select {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem;
  border-radius: 6px;
}

.concept-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.concept-list li {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.concept-list li:hover {
  background: var(--panel-2);
}

.concept-list li.selected {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
}

.concept-list .ci-term {
  font-weight: 600;
}

.concept-list .ci-summary {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.3rem;
  letter-spacing: 0.04em;
}

.badge.foundational {
  background: rgba(78, 201, 168, 0.15);
  color: var(--found);
}

.badge.intermediate {
  background: rgba(226, 197, 74, 0.15);
  color: var(--inter);
}

.badge.advanced {
  background: rgba(255, 122, 122, 0.15);
  color: var(--adv);
}

.badge.domain {
  background: rgba(122, 162, 255, 0.15);
  color: var(--accent);
}

.content {
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

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

.detail h2 {
  margin-top: 0;
}

.detail .summary {
  color: var(--muted);
  font-size: 1.05rem;
}

.detail section {
  margin-top: 1.5rem;
}

.detail section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.rel-group {
  margin-bottom: 0.75rem;
}

.rel-group .rel-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.chip {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 14px;
  margin: 0.2rem 0.3rem 0.2rem 0;
  cursor: pointer;
  font-size: 0.85rem;
}

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

.chip.missing {
  opacity: 0.5;
  cursor: default;
}

.formula {
  background: var(--panel-2);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin: 0.5rem 0;
}

.formula code {
  color: var(--accent);
}

.example {
  background: var(--panel-2);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin: 0.5rem 0;
}

/* Path mode */
.path-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.path-actions button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
}

.path-actions .know {
  border-color: var(--good);
  color: var(--good);
}

.path-actions .dont-know {
  border-color: var(--bad);
  color: var(--bad);
}

.path-progress {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.app-footer {
  padding: 0.4rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.8rem;
  color: var(--muted);
}

a {
  color: var(--accent);
}

.home-link {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(26, 29, 36, 0.92);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  backdrop-filter: blur(8px);
  transition: all 0.15s ease;
}

.home-link:hover {
  background: var(--card-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}
