:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #161f30;
  --bg-card-hover: #1e293b;
  --border: #243247;
  --border-light: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-sub: #64748b;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Newsreader', 'Crimson Pro', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #0b0f19;
  font-weight: 800;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  letter-spacing: -0.5px;
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.brand-text .sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--bg-card);
  border-color: var(--border-light);
  color: var(--accent);
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: var(--bg-card);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.stat-lbl {
  font-size: 11px;
  color: var(--text-sub);
  text-transform: uppercase;
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-sub);
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.domain-pills {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.domain-pill-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.domain-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 11px;
}

.status-indicator::before {
  content: '';
  width: 6px;
  height: 6px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 36px;
  border-bottom: 1px solid var(--border);
  background-color: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.breadcrumbs .sep {
  color: var(--text-sub);
}

.level-badge {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.2);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
}

/* Content Views */
.content-view {
  display: none;
  padding: 36px;
}

.content-view.active {
  display: block;
}

/* Hero Card */
.hero-card {
  background: linear-gradient(135deg, #131c2d 0%, #172338 100%);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  gap: 32px;
  align-items: center;
  margin-bottom: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.hero-copy {
  flex: 1;
}

.badge-tag {
  display: inline-block;
  background-color: rgba(52, 211, 153, 0.15);
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.hero-copy h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
  letter-spacing: -0.5px;
}

.hero-copy p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
  max-width: 650px;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

.hero-formula {
  background-color: rgba(11, 15, 25, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  text-align: center;
  min-width: 280px;
}

.formula-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-sub);
  letter-spacing: 0.8px;
  display: block;
  margin-bottom: 8px;
}

.formula-math {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

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

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.panel-sub {
  font-size: 12px;
  color: var(--text-sub);
}

.domain-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.domain-bar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.domain-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
}

.bar-track {
  height: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  padding: 12px;
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.timeline-item-meta {
  font-size: 11px;
  color: var(--text-sub);
}

/* Classes & Queue Views */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
}

.view-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.4px;
}

.view-sub {
  font-size: 14px;
  color: var(--text-muted);
}

.classes-grid, .queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.class-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  cursor: pointer;
}

.class-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.class-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.class-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.class-domain-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.class-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 10px;
  line-height: 1.4;
}

.class-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  flex: 1;
}

.class-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* Reader View */
.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.reader-meta-pills {
  display: flex;
  gap: 8px;
}

.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.reader-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 36px;
  align-items: start;
}

.lecture-paper {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 56px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.8;
  color: #e2e8f0;
}

.lecture-paper h1 {
  font-family: var(--font-sans);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.6px;
  line-height: 1.3;
  color: #fff;
  margin-bottom: 24px;
}

.lecture-paper h2 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.lecture-paper h3 {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  color: #cbd5e1;
  margin-top: 24px;
  margin-bottom: 12px;
}

.lecture-paper p {
  margin-bottom: 20px;
}

.lecture-paper blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 20px;
  margin: 24px 0;
  background-color: rgba(56, 189, 248, 0.05);
  font-style: italic;
  color: #e0f2fe;
}

.lecture-paper hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

.lecture-paper pre {
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  overflow-x: auto;
  margin-bottom: 20px;
}

.lecture-paper details {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 16px 0 24px 0;
  font-family: var(--font-sans);
  font-size: 15px;
}

.lecture-paper summary {
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}

.lecture-paper details[open] summary {
  margin-bottom: 12px;
}

/* Citations Drawer */
.citations-sidebar {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  position: sticky;
  top: 90px;
}

.citations-header {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.citations-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.citations-sub {
  font-size: 11px;
  color: var(--text-sub);
}

.citations-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.citation-card {
  padding: 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.citation-card:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-light);
}

.citation-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: block;
  margin-bottom: 4px;
}

.citation-title:hover {
  text-decoration: underline;
}

.citation-meta {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.citation-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: #0b0f19;
}

.btn-primary:hover {
  background-color: #7dd3fc;
}

.btn-ghost {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border);
}

.btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.select-input, .text-input {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
}

.select-input:focus, .text-input:focus {
  border-color: var(--accent);
}

.full-width {
  width: 100%;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.btn-close {
  background: transparent;
  border: 0;
  color: var(--text-sub);
  font-size: 18px;
  cursor: pointer;
}

.btn-close:hover {
  color: var(--text-main);
}

.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.star-rating {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 6px;
}

.star-rating input {
  display: none;
}

.star-rating label {
  font-size: 24px;
  color: var(--border-light);
  cursor: pointer;
  transition: color 0.15s;
}

.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
  color: var(--warning);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 980px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .reader-layout {
    grid-template-columns: 1fr;
  }
  .citations-sidebar {
    position: static;
  }
  .hero-card {
    flex-direction: column;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
