/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Sidebar */
  --sb:        #0F172A;
  --sb-hover:  #1E293B;
  --sb-active: #1E3A5F;
  --sb-text:   #94A3B8;
  --sb-active-text: #E2E8F0;
  --sb-border: rgba(255,255,255,0.06);

  /* Page */
  --bg:      #F1F5F9;
  --surface: #FFFFFF;
  --border:  #E2E8F0;

  /* Typography */
  --text:       #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  /* Brand */
  --primary:       #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-ring:  rgba(37,99,235,0.25);

  /* Danger */
  --danger:       #DC2626;
  --danger-hover: #B91C1C;
  --danger-light: #FEF2F2;

  /* Radii */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full:9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 20px rgba(0,0,0,.08), 0 4px 8px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.12);

  --sidebar-w: 252px;
  --header-h:  62px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--sb);
  -webkit-font-smoothing: antialiased;
}

/* ── Login Screen ─────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo-img {
  width: 200px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.optional { color: var(--text-light); font-weight: 400; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

textarea { resize: vertical; min-height: 64px; }
select { cursor: pointer; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 40px; }
.toggle-pw {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-light);
  display: flex; align-items: center; padding: 4px;
}
.toggle-pw:hover { color: var(--text-muted); }

.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid #FECACA;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: #E9EEF5; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }
.btn-sm   { padding: 6px 10px; font-size: 12px; }

/* ── Icon buttons ────────────────────────────────────────────────────────── */
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background .12s, color .12s;
  text-decoration: none;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ── Dashboard Shell ─────────────────────────────────────────────────────── */
#dashboard {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--sb);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sb);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--sb-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 18px 12px;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 140px;
  height: auto;
  display: block;
}

.sidebar-search {
  padding: 0 12px 12px;
  flex-shrink: 0;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  transition: border-color .15s;
}
.search-wrap:focus-within {
  border-color: rgba(37,99,235,.5);
  background: rgba(255,255,255,.1);
}

.search-icon { color: var(--sb-text); flex-shrink: 0; }

.search-wrap input {
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
  color: #E2E8F0;
  font-size: 13px;
  width: 100%;
  padding: 0;
}
.search-wrap input::placeholder { color: #64748B; }

/* Sidebar nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.nav-section { margin-bottom: 4px; }

.nav-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
  padding: 12px 18px 6px;
}

.sidebar-nav ul { list-style: none; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  cursor: pointer;
  border-radius: 0;
  color: var(--sb-text);
  font-size: 13.5px;
  transition: background .1s, color .1s;
  user-select: none;
}
.nav-item:hover { background: var(--sb-hover); color: #CBD5E1; }
.nav-item.active {
  background: var(--sb-active);
  color: var(--sb-active-text);
  font-weight: 500;
}

.nav-count {
  font-size: 11px;
  background: rgba(255,255,255,.1);
  color: var(--sb-text);
  padding: 1px 7px;
  border-radius: var(--r-full);
  font-weight: 500;
  flex-shrink: 0;
}
.nav-item.active .nav-count {
  background: rgba(37,99,235,.3);
  color: #93C5FD;
}

.add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  background: none;
  border: none;
  color: #475569;
  font-size: 12.5px;
  cursor: pointer;
  font-family: var(--font);
  width: 100%;
  transition: color .12s;
}
.add-btn:hover { color: #94A3B8; }

.add-subject-form {
  padding: 8px 12px;
}
.add-subject-form input {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: #E2E8F0;
  font-size: 13px;
  padding: 7px 10px;
  margin-bottom: 8px;
}
.add-subject-form input::placeholder { color: #475569; }
.add-subject-form input:focus {
  border-color: var(--primary);
  background: rgba(255,255,255,.1);
  box-shadow: none;
}
.add-subject-actions { display: flex; gap: 6px; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: #E2E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748B;
}

.logout-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.logout-btn:hover { background: rgba(220,38,38,.15); color: #EF4444; }

/* ── Main Area ───────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 16px 0 0 16px;
  overflow: hidden;
  margin: 8px 8px 8px 0;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.header-left h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
}

.result-count {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.view-btn {
  padding: 6px 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: background .1s, color .1s;
}
.view-btn.active { background: var(--surface); color: var(--text); }
.view-btn:not(.active):hover { background: rgba(0,0,0,.03); }

/* ── Files Container ─────────────────────────────────────────────────────── */
.files-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Loading */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
  padding: 80px 0;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 0;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  background: var(--border);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  margin-bottom: 4px;
}

.empty-state h4 { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state p  { font-size: 13px; }

/* ── File Grid ───────────────────────────────────────────────────────────── */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.file-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.file-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #CBD5E1;
  transform: translateY(-1px);
}

.file-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 0;
}

.file-type-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
}

.file-card-body {
  padding: 10px 12px 8px;
  flex: 1;
}

.file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
  margin-bottom: 6px;
}

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

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  font-weight: 500;
}
.tag-subject { background: var(--primary-light); color: var(--primary); }
.tag-age     { background: #F0FDF4; color: #15803D; }

.file-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.file-size {
  font-size: 11.5px;
  color: var(--text-light);
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── File List ───────────────────────────────────────────────────────────── */
.files-list-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.files-list-table thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
}

.files-list-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.files-list-table tbody tr:last-child { border-bottom: none; }
.files-list-table tbody tr:hover { background: #F8FAFC; }

.files-list-table tbody td {
  padding: 11px 14px;
  font-size: 13.5px;
  vertical-align: middle;
}

.list-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: flex-end;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: slide-up .2s ease;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@keyframes slide-up { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-large { max-width: 860px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Drop Zone ───────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color .15s, background .15s;
  cursor: default;
  margin-bottom: 16px;
}
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-title { font-size: 14px; font-weight: 500; color: var(--text); }
.drop-sub   { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }

/* File queue */
.file-queue {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}

.drop-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.scan-status  { font-size: 12.5px; color: var(--primary); margin-top: 4px; }

.queue-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px;
}
.fq-name-wrap { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fq-path {
  font-size: 11px; color: var(--text-light);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.file-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  flex-wrap: wrap;
}
.file-queue-item:last-child { border-bottom: none; }
.file-queue-item:hover { background: var(--bg); }

.fq-info {
  display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;
}
.fq-meta {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end;
}
.fq-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fq-size { color: var(--text-muted); font-size: 12px; flex-shrink: 0; }
.fq-remove {
  width: 22px; height: 22px; border-radius: 4px; border: none; background: none;
  color: var(--text-light); cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .1s, color .1s;
}
.fq-remove:hover { background: var(--danger-light); color: var(--danger); }

.fq-select {
  padding: 3px 6px; font-size: 11px; border-radius: 4px; border: 1.5px solid var(--border);
  color: var(--text); background: var(--bg); cursor: pointer; max-width: 130px;
}
.fq-select:focus { border-color: var(--primary); outline: none; }

.ai-tag {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 600;
  color: #6366F1; background: #EEF2FF;
  padding: 2px 7px; border-radius: var(--r-full);
  white-space: nowrap;
}
.ai-tag svg { flex-shrink: 0; }

.ai-loading {
  font-size: 10.5px; color: var(--text-light);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ opacity:.5 } 50%{ opacity:1 } }

.upload-meta { margin-top: 4px; }

/* Progress */
.progress-wrap {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  width: 0%;
  transition: width .2s ease;
}
.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* ── Preview Body ────────────────────────────────────────────────────────── */
.preview-body {
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F8FAFC;
  min-height: 400px;
}

.preview-body iframe,
.preview-body embed {
  width: 100%; height: 600px; border: none; display: block;
}

.preview-body img {
  max-width: 100%; max-height: 600px; object-fit: contain; display: block;
}

.preview-body video {
  width: 100%; max-height: 540px; display: block; background: #000;
}

.preview-body audio {
  width: 100%; padding: 40px 24px;
}

.preview-unsupported {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.preview-unsupported h4 { color: var(--text); margin-bottom: 6px; font-size: 15px; }

/* Text / code file preview */
.text-preview {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  padding: 24px;
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #F8FAFC;
  overflow-x: auto;
  tab-size: 2;
}

/* ── Resource Type Badges ────────────────────────────────────────────────── */
.res-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }

.res-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-full);
  letter-spacing: .02em;
}
.res-experiment    { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.res-vocabulary    { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.res-parental      { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }

/* ── Type Toggle Buttons (upload queue) ──────────────────────────────────── */
.type-toggle {
  font-size: 10.5px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
}
.type-toggle:hover    { border-color: #94A3B8; color: var(--text); }
.type-toggle.active   { font-weight: 600; }
.type-toggle.active.exp   { background: #FFF7ED; color: #C2410C; border-color: #FED7AA; }
.type-toggle.active.vocab { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }
.type-toggle.active.par   { background: #F0FDF4; color: #15803D; border-color: #BBF7D0; }

/* ── Folder / Subfolder View ─────────────────────────────────────────────── */
.folder-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.folder-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.folder-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.folder-card-icon { color: #94A3B8; }
.folder-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.folder-card-count { font-size: 12px; color: var(--text-muted); }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb-sep { color: var(--text-light); }

/* ── Floating Upload Button ──────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(37,99,235,.45);
  transition: background .15s, transform .15s, box-shadow .15s;
  z-index: 40;
}
.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(37,99,235,.55);
}
.fab:active { transform: scale(.97); }

/* ── Drag overlay ────────────────────────────────────────────────────────── */
.drag-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(37,99,235,.08);
  border: 3px dashed var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  opacity: 0; transition: opacity .15s;
}
.drag-overlay.active { opacity: 1; }
.drag-overlay-inner {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.drag-overlay-inner p { font-size: 15px; font-weight: 600; color: var(--primary); margin-top: 8px; }

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── Section Toggle (Resources / Lesson Plans) ───────────────────────────── */
.section-toggle {
  display: flex;
  margin: 8px 12px 8px;
  background: rgba(255,255,255,.06);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.section-tab {
  flex: 1;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--sb-text);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.section-tab.active {
  background: var(--primary);
  color: #fff;
}
.section-tab:not(.active):hover {
  background: rgba(255,255,255,.08);
  color: #CBD5E1;
}

/* ── Lesson Plan tags ────────────────────────────────────────────────────── */
.tag-term { background: #F5F3FF; color: #6D28D9; }
.tag-week { background: #FFF7ED; color: #C2410C; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Chat Panel ──────────────────────────────────────────────────────────── */
.chat-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 299;
  display: none;
  backdrop-filter: blur(1px);
}
.chat-overlay.visible { display: block; }

.chat-panel {
  position: fixed;
  top: 0; right: -420px;
  width: 400px; height: 100%;
  background: var(--surface);
  box-shadow: -6px 0 32px rgba(0,0,0,.13);
  z-index: 300;
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
}
.chat-panel.open { right: 0; }

.chat-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 600; color: var(--text);
  flex: 1;
}
.chat-panel-title svg { color: #6366F1; }

.chat-close-btn {
  width: 28px; height: 28px;
  border: none; background: none;
  cursor: pointer; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light); flex-shrink: 0;
  transition: background .15s, color .15s;
}
.chat-close-btn:hover { background: var(--bg); color: var(--text-muted); }

.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 16px; display: flex;
  flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}

/* Welcome screen */
.chat-welcome {
  text-align: center; padding: 20px 12px 8px;
}
.chat-welcome-icon { font-size: 26px; margin-bottom: 8px; }
.chat-welcome h4 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.chat-welcome p  { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 16px; }
.chat-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.chat-suggestion {
  font-size: 12px; padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-full); background: var(--bg);
  cursor: pointer; color: var(--text-muted);
  transition: background .15s, border-color .15s, color .15s;
  font-family: var(--font);
}
.chat-suggestion:hover {
  background: #EEF2FF; border-color: #6366F1; color: #4F46E5;
}

/* Message bubbles */
.chat-msg { display: flex; flex-direction: column; max-width: 86%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.ai   { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px; line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.ai .chat-bubble {
  background: var(--bg); color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble p              { margin: 0 0 6px; }
.chat-bubble p:last-child   { margin-bottom: 0; }
.chat-bubble strong         { font-weight: 600; }
.chat-bubble em             { font-style: italic; }
.chat-bubble code           { font-family: 'SF Mono', monospace; background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.chat-bubble pre            { background: rgba(0,0,0,.06); padding: 10px; border-radius: 8px; overflow-x: auto; margin: 4px 0; }
.chat-bubble pre code       { background: none; padding: 0; }
.chat-bubble ul, .chat-bubble ol { margin: 4px 0; padding-left: 20px; }
.chat-bubble li             { margin: 2px 0; }
.chat-bubble h4, .chat-bubble h5 { font-size: 13.5px; font-weight: 600; margin: 6px 0 3px; }

/* Typing indicator */
.chat-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 11px 15px;
  background: var(--bg); border-radius: 14px;
  border-bottom-left-radius: 4px; width: fit-content;
}
.chat-typing span {
  width: 7px; height: 7px;
  background: var(--text-light); border-radius: 50%;
  animation: chatDot 1.2s ease-in-out infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.chat-input-area {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-input {
  flex: 1; font-family: var(--font); font-size: 13.5px;
  padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  resize: none; outline: none;
  max-height: 120px; overflow-y: auto;
  line-height: 1.45; color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--primary); }
.chat-input::placeholder { color: var(--text-light); }

.chat-send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  border: none; border-radius: var(--r-md);
  background: var(--primary); color: #fff;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-send-btn:hover:not(:disabled)   { background: var(--primary-hover); }
.chat-send-btn:disabled { background: var(--border); color: var(--text-light); cursor: not-allowed; }

/* Header button */
.chat-toggle-btn {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--text-muted);
}
.chat-toggle-btn:hover { color: var(--text); }

@media (max-width: 640px) {
  .chat-panel { width: 100%; right: -100%; }
  .chat-panel.open { right: 0; }
}

/* ── Generate Modal ────────────────────────────────────────────────────────── */
.format-option {
  display: flex;
  flex: 1;
  cursor: pointer;
}
.format-option input[type="radio"] { display: none; }
.format-label {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.format-option input[type="radio"]:checked + .format-label {
  border-color: #6366F1;
  background: #f5f3ff;
}
.format-label:hover { border-color: #a5b4fc; }
.format-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.format-name { font-size: 12.5px; font-weight: 500; color: var(--text); }
