/* ==========================================================================
   Design System & Theme Variables
   ========================================================================== */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark Theme (Default) */
  --bg-main: #0c0f17;
  --bg-surface: #141923;
  --bg-surface-elevated: #1c2331;
  --bg-card: rgba(23, 29, 41, 0.75);
  --bg-card-hover: rgba(30, 38, 54, 0.9);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-focus: #6366f1;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --accent-aud: #a855f7;
  --accent-aud-bg: rgba(168, 85, 247, 0.12);
  --accent-ent: #f59e0b;
  --accent-ent-bg: rgba(245, 158, 11, 0.12);
  --accent-far: #3b82f6;
  --accent-far-bg: rgba(59, 130, 246, 0.12);
  --accent-maf: #06b6d4;
  --accent-maf-bg: rgba(6, 182, 212, 0.12);
  --accent-mgt: #ec4899;
  --accent-mgt-bg: rgba(236, 72, 153, 0.12);
  --accent-tax: #10b981;
  --accent-tax-bg: rgba(16, 185, 129, 0.12);

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --backdrop-blur: blur(14px);
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.14);
  --border-focus: #4f46e5;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   Navbar
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
  transition: var(--transition);
}

.nav-content {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 1.6rem;
  line-height: 1;
  background: var(--bg-surface-elevated);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hub-tag {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.brand-subtitle {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Search Bar */
.search-container {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-container input {
  width: 100%;
  padding: 0.6rem 2.5rem 0.6rem 2.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition);
}

.search-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface-elevated);
}

.search-kbd {
  position: absolute;
  right: 0.85rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.4rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 2.2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
}

/* Nav Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.admin-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.admin-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.admin-pill-btn.authenticated {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-surface);
  border-color: var(--primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ef4444;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.w-100 {
  width: 100%;
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.section-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.admin-controls-bar {
  display: flex;
  gap: 0.75rem;
}

/* ==========================================================================
   Subjects Grid (The 6 Modules)
   ========================================================================== */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.subject-card {
  position: relative;
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--subject-accent, var(--primary));
  opacity: 0.8;
  transition: var(--transition);
}

.subject-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.subject-card.active {
  border-color: var(--subject-accent, var(--primary));
  box-shadow: 0 0 0 2px var(--subject-accent, var(--primary));
}

.subject-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.subject-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--subject-bg, rgba(99, 102, 241, 0.12));
  color: var(--subject-accent, var(--primary));
}

.subject-code {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.subject-name {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.3;
}

.subject-card-bottom {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.subject-note-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.view-notes-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--subject-accent, var(--primary));
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Subject Specific Colors */
.subject-AUD339 { --subject-accent: var(--accent-aud); --subject-bg: var(--accent-aud-bg); }
.subject-ENT300 { --subject-accent: var(--accent-ent); --subject-bg: var(--accent-ent-bg); }
.subject-FAR320 { --subject-accent: var(--accent-far); --subject-bg: var(--accent-far-bg); }
.subject-MAF253 { --subject-accent: var(--accent-maf); --subject-bg: var(--accent-maf-bg); }
.subject-MGT269 { --subject-accent: var(--accent-mgt); --subject-bg: var(--accent-mgt-bg); }
.subject-TAX317 { --subject-accent: var(--accent-tax); --subject-bg: var(--accent-tax-bg); }

/* Quick Dropzone */
.quick-dropzone {
  margin-bottom: 2rem;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  background: var(--bg-surface);
  cursor: pointer;
  transition: var(--transition);
}

.quick-dropzone:hover, .quick-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.dropzone-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.dropzone-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
}

.dropzone-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.dropzone-text span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Notes Section & Filter Pills
   ========================================================================== */
.notes-section {
  margin-top: 1rem;
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.active-filter-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.count-pill {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-surface-elevated);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.filter-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.pill:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* Notes Cards Grid */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.note-card {
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.note-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.subject-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--subject-bg, rgba(99, 102, 241, 0.12));
  color: var(--subject-accent, var(--primary));
  border: 1px solid currentColor;
}

.note-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.tag-pill {
  font-size: 0.72rem;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

/* Loading & Empty States */
.loading-state, .empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-medium);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

/* ==========================================================================
   Reader Modal & Markdown Styles
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.reader-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.reader-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  background: var(--bg-card);
}

.reader-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.4rem 0;
  line-height: 1.3;
}

.reader-submeta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.reader-submeta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reader-layout {
  display: flex;
  overflow-y: auto;
  padding: 2rem;
  gap: 2rem;
}

.markdown-body {
  flex: 1;
  font-size: 1.02rem;
  color: var(--text-primary);
  line-height: 1.75;
}

/* Markdown Element Styling */
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  color: var(--text-primary);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.markdown-body h1 { font-size: 1.7rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.5rem; }
.markdown-body h2 { font-size: 1.35rem; }
.markdown-body h3 { font-size: 1.15rem; }

.markdown-body p { margin-bottom: 1.1rem; }
.markdown-body ul, .markdown-body ol { margin-bottom: 1.2rem; padding-left: 1.7rem; }
.markdown-body li { margin-bottom: 0.35rem; }

.markdown-body hr {
  border: 0;
  height: 1px;
  background: var(--border-subtle);
  margin: 2rem 0;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1.25rem;
  margin: 1.2rem 0;
  background: var(--bg-surface-elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

/* GitHub Alert Callouts */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  border-left: 4px solid var(--callout-color, var(--primary));
  background: var(--callout-bg, var(--bg-surface-elevated));
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--callout-color, var(--primary));
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.callout-note { --callout-color: #3b82f6; --callout-bg: rgba(59, 130, 246, 0.1); }
.callout-tip { --callout-color: #10b981; --callout-bg: rgba(16, 185, 129, 0.1); }
.callout-important { --callout-color: #8b5cf6; --callout-bg: rgba(139, 92, 246, 0.1); }
.callout-warning { --callout-color: #f59e0b; --callout-bg: rgba(245, 158, 11, 0.1); }
.callout-caution { --callout-color: #ef4444; --callout-bg: rgba(239, 68, 68, 0.1); }

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.markdown-body th, .markdown-body td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown-body th {
  background: var(--bg-surface-elevated);
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.88rem;
}

.markdown-body tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Code Blocks */
.markdown-body pre {
  background: #181b24;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: var(--bg-surface-elevated);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  color: #e06c75;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* Table of Contents */
.reader-toc {
  width: 240px;
  position: sticky;
  top: 0;
  align-self: flex-start;
  padding-left: 1.5rem;
  border-left: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.toc-title {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.reader-toc a {
  display: block;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.3rem 0;
  line-height: 1.3;
  transition: var(--transition);
}

.reader-toc a:hover {
  color: var(--primary);
  transform: translateX(2px);
}

/* ==========================================================================
   Editor Modal (Admin Only)
   ========================================================================== */
.editor-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1150px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem 1.75rem;
  overflow: hidden;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group input, .form-group select {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0.45rem 0.75rem;
}

.toolbar-group {
  display: flex;
  gap: 0.35rem;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

.editor-view-tabs {
  display: flex;
  gap: 0.25rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
}

.editor-split-body {
  display: flex;
  height: 420px;
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  height: 100%;
  overflow-y: auto;
}

.write-pane textarea {
  width: 100%;
  height: 100%;
  padding: 1.25rem;
  background: var(--bg-main);
  border: none;
  resize: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}

.write-pane textarea:focus {
  outline: none;
}

.preview-pane {
  padding: 1.25rem;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
}

.editor-footer {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-buttons {
  display: flex;
  gap: 0.75rem;
}

/* ==========================================================================
   Modals (Upload, Auth, Guide)
   ========================================================================== */
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.guide-card {
  max-width: 680px;
}

.modal-body {
  padding: 1.5rem 1.75rem;
}

.modal-hint {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.modal-footer {
  padding: 1rem 1.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-surface-elevated);
}

/* Upload Drop Area */
.upload-drop-area {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--bg-surface-elevated);
  cursor: pointer;
  transition: var(--transition);
}

.upload-drop-area:hover, .upload-drop-area.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.file-icon {
  width: 44px;
  height: 44px;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.selected-file-info {
  margin-top: 0.75rem;
  padding: 0.4rem 0.8rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.auth-error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.auth-active-box {
  text-align: center;
  padding: 1rem 0;
}

.active-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #10b981;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* API Guide Modal Code Blocks */
.api-step {
  margin-bottom: 1.25rem;
}

.api-step h4 {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--text-primary);
}

.code-box {
  background: #181b24;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.url-highlight { color: #61afef; }
.pwd-highlight { color: #e5c07b; }

.supported-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.supported-tags code {
  background: var(--bg-surface-elevated);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--primary);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

.footer-content {
  max-width: 1280px;
  margin: 0 auto;
}

.subjects-inline {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-md);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 768px) {
  .nav-content {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .search-container {
    order: 3;
    max-width: 100%;
    width: 100%;
  }

  .subjects-grid, .notes-grid {
    grid-template-columns: 1fr;
  }

  .reader-layout {
    flex-direction: column;
    padding: 1.25rem;
  }

  .reader-toc {
    display: none; /* Hide TOC on mobile for clean reading */
  }

  .editor-split-body {
    flex-direction: column;
  }

  .form-row {
    flex-direction: column;
  }
}

/* ==========================================================================
   LaTeX Math (KaTeX) Styling
   ========================================================================== */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.85rem 1rem;
  margin: 1.4rem 0 !important;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  text-align: center;
}

.katex {
  font-size: 1.1em;
  text-rendering: auto;
}

.tool-latex-btn {
  color: var(--primary) !important;
  background: rgba(99, 102, 241, 0.1) !important;
  border: 1px solid rgba(99, 102, 241, 0.3) !important;
  border-radius: 4px;
  font-weight: 700;
}

.tool-latex-btn:hover {
  background: rgba(99, 102, 241, 0.2) !important;
}

/* ==========================================================================
   Document Format Badges (PDF, PPTX, DOCX, Markdown)
   ========================================================================== */
.badges-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.type-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-md {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.badge-pdf {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-pptx {
  background: rgba(249, 115, 22, 0.15);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.badge-docx {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

/* Filter Controls Group */
.filter-controls-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-end;
}

.type-filter-group {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.type-pill svg {
  width: 14px;
  height: 14px;
}

.type-pill:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.type-pill.active {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.accepted-formats-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* ==========================================================================
   PDF Interactive Viewer Layout
   ========================================================================== */
.reader-pdf-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 75vh;
  background: var(--bg-main);
}

.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
}

.pdf-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pdf-toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.pdf-iframe {
  width: 100%;
  flex: 1;
  min-height: 70vh;
  border: none;
  background: #1e1e24;
}

/* ==========================================================================
   Microsoft Office Online Viewer Layout (PPTX & DOCX)
   ========================================================================== */
.reader-office-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 75vh;
  background: var(--bg-main);
}

.office-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  gap: 1rem;
}

.office-file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.office-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 120, 212, 0.15);
  color: #0078d4;
  border: 1px solid rgba(0, 120, 212, 0.35);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.office-brand-badge svg {
  width: 14px;
  height: 14px;
}

.office-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.office-toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.office-local-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(59, 130, 246, 0.1);
  border-bottom: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.85rem 1.5rem;
  color: var(--text-primary);
  font-size: 0.84rem;
}

.office-local-notice .notice-icon {
  width: 18px;
  height: 18px;
  color: var(--info);
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.office-local-notice strong {
  display: block;
  color: var(--info);
  margin-bottom: 0.2rem;
}

.office-local-notice p {
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.office-iframe {
  width: 100%;
  flex: 1;
  min-height: 70vh;
  border: none;
  background: #ffffff;
}


