@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

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

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
  --bg-primary: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #21262d;
  --border: #30363d;
  --border-muted: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --tag-bg: #1f2937;
  --tag-text: #93c5fd;
  --confidence-shaky: #f85149;
  --confidence-solid: #e3b341;
  --confidence-can-teach: #3fb950;
  --confidence-unreviewed: #484f58;
  --radius: 8px;
  --radius-sm: 4px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* =====================================================
   BASE
   ===================================================== */
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =====================================================
   NAV
   ===================================================== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.nav-brand {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s;
}

.nav-link:hover {
  color: var(--text-primary);
}

/* =====================================================
   SITE MAIN
   ===================================================== */
.site-main {
  padding-top: 56px;
}

/* =====================================================
   PAGE HERO
   ===================================================== */
.page-hero {
  padding: 48px 24px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-hero h1 {
  font-size: 1.75rem;
  font-weight: 600;
}

.hero-sub {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 0.9375rem;
}

/* =====================================================
   CONTROLS BAR
   ===================================================== */
.controls-bar {
  position: sticky;
  top: 56px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  z-index: 90;
  max-width: 100%;
}

.controls-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* =====================================================
   FORM CONTROLS (search, selects)
   ===================================================== */
#search-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.875rem;
  font-family: var(--font);
  width: 220px;
  outline: none;
  transition: border-color 0.15s;
}

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

#search-input:focus {
  border-color: var(--accent);
}

#sort-select,
#confidence-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 32px 6px 12px;
  font-size: 0.875rem;
  font-family: var(--font);
  width: auto;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

#sort-select:focus,
#confidence-select:focus {
  border-color: var(--accent);
}

#sort-select option,
#confidence-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* =====================================================
   FILTER BAR
   ===================================================== */
.filter-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border-muted);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  padding: 3px 12px;
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

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

.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1117;
  font-weight: 500;
}

/* =====================================================
   QUEUE / VIEW-ALL BUTTONS
   ===================================================== */
#study-queue-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 4px 14px;
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  margin-left: auto;
  transition: all 0.15s;
}

#study-queue-btn:hover {
  border-color: var(--confidence-solid);
  color: var(--confidence-solid);
}

#view-all-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 4px 14px;
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
}

#view-all-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* =====================================================
   UTILITY
   ===================================================== */
.hidden {
  display: none !important;
}

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

.text-accent {
  color: var(--accent);
}

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

/* =====================================================
   CONTENT AREA
   ===================================================== */
.content-area {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* =====================================================
   TOPIC GROUPS
   ===================================================== */
.topic-group {
  margin-bottom: 40px;
}

.topic-group-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.card-count {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 8px;
  border-radius: 10px;
}

/* =====================================================
   CARD GRID
   ===================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
#empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* =====================================================
   FOOTER
   ===================================================== */
footer {
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
}

footer a {
  text-decoration: none;
}

/* =====================================================
   RESPONSIVE — mobile (max-width: 640px)
   ===================================================== */
@media (max-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  #search-input {
    width: 100%;
  }

  .controls-inner {
    flex-direction: column;
    align-items: stretch;
  }

  #sort-select,
  #confidence-select {
    width: 100%;
  }

  #study-queue-btn,
  #view-all-btn {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .page-hero {
    padding: 32px 16px 24px;
  }

  .page-hero h1 {
    font-size: 1.375rem;
  }

  .controls-bar {
    padding: 12px 16px;
  }

  .filter-bar {
    padding: 10px 16px;
  }

  .content-area {
    padding: 16px 16px 40px;
  }
}
