/* === ScolaIA Desk === */

/* --- Design Tokens --- */
:root {
  --md-sys-color-primary: #6b4c3b;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d4b9a9;
  --md-sys-color-on-primary-container: #2f1e14;
  --md-sys-color-secondary: #8b7355;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #ece8e4;
  --md-sys-color-on-secondary-container: #2f1e14;
  --md-sys-color-tertiary: #7b6d45;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #d3a465;
  --md-sys-color-on-tertiary-container: #2f1e14;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-background: #f0ebe8;
  --md-sys-color-on-background: #2f2622;
  --md-sys-color-surface: #f0ebe8;
  --md-sys-color-on-surface: #2f2622;
  --md-sys-color-surface-container: #f5f2ef;
  --md-sys-color-surface-variant: #d4b9a9;
  --md-sys-color-on-surface-variant: #5e4d42;
  --md-sys-color-outline: #8b7355;
  --md-sys-color-outline-variant: #d8d0ca;
  --md-sys-color-surface-container-high: #ece8e4;
  --md-ref-typeface: 'Open Sans', system-ui, -apple-system, sans-serif;
  --md-sys-shape-corner-md: 16px;
  --md-sys-shape-corner-sm: 12px;
  --md-sys-shape-corner-lg: 24px;
  /* Neomorphic shadow tokens */
  --neo-shadow-sm: 5px 5px 10px rgba(107,76,59,0.25), -5px -5px 10px rgba(255,255,255,0.85);
  --neo-shadow-md: 8px 8px 16px rgba(107,76,59,0.28), -8px -8px 16px rgba(255,255,255,0.9);
  --neo-shadow-lg: 10px 10px 20px rgba(107,76,59,0.30), -10px -10px 20px rgba(255,255,255,0.92);
  --neo-shadow-xl: 14px 14px 28px rgba(107,76,59,0.30), -14px -14px 28px rgba(255,255,255,0.92);
  --neo-shadow-inset: inset 4px 4px 8px rgba(107,76,59,0.22), inset -4px -4px 8px rgba(255,255,255,0.8);
  --neo-shadow-inset-sm: inset 3px 3px 6px rgba(107,76,59,0.18), inset -3px -3px 6px rgba(255,255,255,0.75);
  --neo-shadow-pressed: inset 5px 5px 10px rgba(107,76,59,0.25), inset -5px -5px 10px rgba(255,255,255,0.85);
  /* Short aliases used by detail/form components */
  --md-primary: var(--md-sys-color-primary);
  --md-on-primary: var(--md-sys-color-on-primary);
  --md-surface-container: var(--md-sys-color-surface-container);
  --md-surface-container-high: var(--md-sys-color-surface-container-high);
  --md-on-surface: var(--md-sys-color-on-surface);
  --md-on-surface-variant: var(--md-sys-color-on-surface-variant);
  --md-outline-variant: var(--md-sys-color-outline-variant);
  --md-outline: var(--md-sys-color-outline);
  --md-tertiary: var(--md-sys-color-tertiary);
  --md-error: var(--md-sys-color-error);
  --md-shape-medium: var(--md-sys-shape-corner-md);
  --md-shape-small: var(--md-sys-shape-corner-sm);
}

[data-theme="dark"] {
  --md-sys-color-primary: #d4b9a9;
  --md-sys-color-on-primary: #2f1e14;
  --md-sys-color-primary-container: #6b4c3b;
  --md-sys-color-on-primary-container: #f5f0ed;
  --md-sys-color-secondary: #d3a465;
  --md-sys-color-on-secondary: #2f1e14;
  --md-sys-color-secondary-container: #5e4d42;
  --md-sys-color-on-secondary-container: #f5f0ed;
  --md-sys-color-tertiary: #6c7f2d;
  --md-sys-color-on-tertiary: #040803;
  --md-sys-color-tertiary-container: #3c3525;
  --md-sys-color-on-tertiary-container: #f5f0ed;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-background: #1e1a17;
  --md-sys-color-on-background: #f5f0ed;
  --md-sys-color-surface: #1e1a17;
  --md-sys-color-on-surface: #f5f0ed;
  --md-sys-color-surface-container: #2e2723;
  --md-sys-color-surface-container-high: #3a322d;
  --md-sys-color-surface-variant: #5e4d42;
  --md-sys-color-on-surface-variant: #d4b9a9;
  --md-sys-color-outline: #d4b9a9;
  --md-sys-color-outline-variant: #5e4d42;
  --neo-shadow-sm: 4px 4px 8px rgba(0,0,0,0.3), -4px -4px 8px rgba(60,50,45,0.25);
  --neo-shadow-md: 6px 6px 12px rgba(0,0,0,0.35), -6px -6px 12px rgba(60,50,45,0.25);
  --neo-shadow-lg: 8px 8px 16px rgba(0,0,0,0.35), -8px -8px 16px rgba(60,50,45,0.25);
  --neo-shadow-xl: 12px 12px 24px rgba(0,0,0,0.35), -12px -12px 24px rgba(60,50,45,0.25);
  --neo-shadow-inset: inset 3px 3px 6px rgba(0,0,0,0.3), inset -3px -3px 6px rgba(60,50,45,0.2);
  --neo-shadow-inset-sm: inset 2px 2px 4px rgba(0,0,0,0.25), inset -2px -2px 4px rgba(60,50,45,0.2);
  --neo-shadow-pressed: inset 4px 4px 8px rgba(0,0,0,0.35), inset -4px -4px 8px rgba(60,50,45,0.25);
}

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

body {
  font-family: var(--md-ref-typeface);
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--md-sys-color-secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout --- */
.app-layout { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
  background: var(--md-sys-color-background);
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  box-shadow: var(--neo-shadow-sm);
  align-items: center;
  gap: 1.5rem;
  border-bottom: none;
  font-family: var(--md-ref-typeface);
}
.navbar-brand { display: flex; align-items: center; gap: 0.15rem; flex-shrink: 0; text-decoration: none; }
.navbar-logo { font-size: 1.25rem; line-height: 1; display: none; }
.brand-text { font-family: 'Audiowide', cursive; font-size: 1.35rem; color: #009999; letter-spacing: -0.02em; }
.brand-surname { font-family: 'Allura', cursive; font-size: 1.6rem; color: #fa0000; margin-left: 0.15rem; }
.navbar-title { display: none; }
.navbar-nav { display: flex; align-items: center; gap: 0.125rem; flex: 1; }

/* Nav links — unified for <a> and <button> */
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-radius: var(--md-sys-shape-corner-sm);
  color: var(--md-sys-color-on-surface-variant);
  font-family: var(--md-ref-typeface);
  font-weight: 500;
  font-size: 0.85rem;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.2s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(107,76,59,0.06); text-decoration: none; box-shadow: var(--neo-shadow-inset-sm); }
.nav-link.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--neo-shadow-inset-sm);
}

/* Dropdown button reset — must look identical to <a> nav-links */
.nav-link-dropdown {
  background: none;
  border: none;
  cursor: pointer;
  margin: 0;
}
.nav-caret { font-size: 0.6rem; margin-left: 0.25rem; opacity: 0.6; }

/* Nav dropdown menu */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--md-sys-color-surface-container-high);
  border: none;
  border-radius: var(--md-sys-shape-corner-md);
  box-shadow: var(--neo-shadow-lg);
  min-width: 160px;
  z-index: 200;
  padding: 0.25rem 0;
}
.nav-dropdown-item {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  transition: background 0.1s;
}
.nav-dropdown-item:hover {
  background: rgba(107,76,59,0.08);
  text-decoration: none;
}

/* User menu */
.navbar-user { position: relative; flex-shrink: 0; }
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 24px;
  transition: background 0.15s;
}
.user-menu-btn:hover { background: rgba(107,76,59,0.08); }
.user-name { font-size: 0.85rem; font-weight: 500; color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: var(--neo-shadow-sm);
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--md-sys-color-surface-container-high);
  border: none;
  border-radius: var(--md-sys-shape-corner-md);
  box-shadow: var(--neo-shadow-lg);
  min-width: 200px;
  z-index: 200;
  padding: 0.25rem 0;
}
.user-dropdown-header {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.user-dropdown-name { font-size: 0.9rem; font-weight: 600; color: var(--md-sys-color-on-surface); }
.user-dropdown-role { font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.user-dropdown-divider {
  height: 1px;
  background: var(--md-sys-color-outline-variant);
  margin: 0.25rem 0;
}
.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--md-ref-typeface);
  transition: background 0.1s;
}
.user-dropdown-item:hover {
  background: rgba(107,76,59,0.08);
  text-decoration: none;
}
.user-dropdown-logout { color: var(--md-sys-color-error, #ba1a1a); }

/* Alpine.js cloak */
[x-cloak] { display: none !important; }

.main-content { flex: 1; padding: 2rem; max-width: 1200px; margin: 0 auto; width: 100%; }

/* --- Auth Pages --- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--md-sys-color-background);
}
.auth-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--neo-shadow-xl);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--md-sys-color-on-surface); }
.auth-header p { color: var(--md-sys-color-on-surface-variant); margin-top: 0.5rem; font-size: 0.9rem; }
.auth-form { display: flex; flex-direction: column; gap: 1.25rem; }
.auth-footer { text-align: center; margin-top: 1.5rem; }
.auth-link { font-size: 0.85rem; color: var(--md-sys-color-secondary); }

/* --- Forms --- */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input, .form-group select, .form-group textarea {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.95rem;
  transition: box-shadow 0.2s;
  box-shadow: var(--neo-shadow-inset);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  box-shadow: var(--neo-shadow-pressed), 0 0 0 2px rgba(107,76,59,0.15);
}
.form-group input::placeholder { color: var(--md-sys-color-on-surface-variant); opacity: 0.6; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border: none;
  border-radius: 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  box-shadow: var(--neo-shadow-md);
}
.btn:hover { text-decoration: none; box-shadow: var(--neo-shadow-sm); }
.btn:active { box-shadow: var(--neo-shadow-pressed); }
.btn-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.btn-primary:hover { background: #5e432f; }
.btn-secondary {
  background: var(--md-sys-color-secondary);
  color: var(--md-sys-color-on-secondary);
}
.btn-secondary:hover { background: #7a6448; }
.btn-text {
  background: transparent;
  color: var(--md-sys-color-secondary);
  padding: 0.5rem 0.75rem;
  box-shadow: none;
}
.btn-text:hover { background: rgba(107,76,59,0.08); box-shadow: none; }
.btn-full { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; box-shadow: var(--neo-shadow-sm); }
.btn-sm:hover { box-shadow: var(--neo-shadow-inset-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* --- Alerts --- */
.alert {
  padding: 0.875rem 1.25rem;
  border-radius: var(--md-sys-shape-corner-sm);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  box-shadow: var(--neo-shadow-inset-sm);
}
.alert-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.alert-info {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.alert-info a { color: inherit; font-weight: 600; text-decoration: underline; }

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--md-sys-color-on-surface-variant); font-size: 0.9rem; width: 100%; }

/* --- Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-md);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--neo-shadow-md);
}
.stat-value { font-size: 2.5rem; font-weight: 700; color: var(--md-sys-color-primary); line-height: 1.2; }
.stat-label { font-size: 0.85rem; color: var(--md-sys-color-on-surface-variant); margin-top: 0.25rem; }

/* --- Quick Actions --- */
.quick-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* --- Tables --- */
.table-container { overflow-x: auto; border-radius: var(--md-sys-shape-corner-md); box-shadow: var(--neo-shadow-md); background: var(--md-sys-color-surface-container); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.data-table tbody tr:hover { background: rgba(107,76,59,0.04); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-draft { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }
.badge-validated { background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); }
.badge-published { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.badge-archived { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); opacity: 0.7; }
.badge-info { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* --- Card Grid --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.tdl-card {
  background: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border: none;
  box-shadow: var(--neo-shadow-md);
  transition: box-shadow 0.2s, transform 0.2s;
}
.tdl-card:hover { box-shadow: var(--neo-shadow-lg); transform: translateY(-2px); }
.tdl-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.tdl-card-header h3 { font-size: 1.1rem; font-weight: 600; }
.tdl-card-subject { font-size: 0.85rem; color: var(--md-sys-color-secondary); font-weight: 500; }
.tdl-card-desc { font-size: 0.9rem; color: var(--md-sys-color-on-surface-variant); flex: 1; }
.tdl-card-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--md-sys-color-on-surface-variant); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--md-sys-color-on-surface-variant);
}
.empty-state p { margin-bottom: 1rem; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; gap: 1rem; }
  .navbar-nav { display: none; }
  .main-content { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
/* ── Detail page ─────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-card {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.5rem;
  box-shadow: var(--neo-shadow-md);
}
.detail-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--md-on-surface);
  margin: 0 0 1rem;
}
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1rem;
}
.detail-list dt {
  color: var(--md-on-surface-variant);
  font-size: 0.85rem;
}
.detail-list dd {
  margin: 0;
  color: var(--md-on-surface);
  font-size: 0.85rem;
}
.detail-desc {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--md-on-surface-variant);
  line-height: 1.5;
}

/* ── Rounded cards ───────────────────────────────── */
.card-rounded {
  border: none;
  border-radius: var(--md-sys-shape-corner-lg);
  box-shadow: var(--neo-shadow-md);
}

/* ── File grid ──────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.file-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 0.75rem;
  background: var(--md-sys-color-surface);
  border: none;
  border-radius: var(--md-sys-shape-corner-md);
  text-decoration: none;
  color: var(--md-on-surface);
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--neo-shadow-sm);
}
.file-tile:hover {
  box-shadow: var(--neo-shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}
.file-tile-icon {
  font-size: 1.75rem;
  line-height: 1;
}
.file-tile-name {
  font-size: 0.8rem;
  font-weight: 500;
  word-break: break-all;
  line-height: 1.3;
}
.file-tile-type {
  font-size: 0.7rem;
  color: var(--md-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Danger button ──────────────────────────────── */
.btn-danger-outlined {
  color: var(--md-error);
  border: 2px solid var(--md-error);
  background: var(--md-sys-color-background);
  box-shadow: var(--neo-shadow-md);
}
.btn-danger-outlined:hover {
  background: var(--md-error);
  color: var(--md-on-primary);
  box-shadow: var(--neo-shadow-sm);
}
.btn-danger-outlined:active { box-shadow: var(--neo-shadow-pressed); }

/* ── Legacy file list (keep for compat) ─────────── */
.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  color: var(--md-on-surface);
  border-bottom: 1px solid var(--md-outline-variant);
}
.file-item:last-child { border-bottom: none; }
.file-icon { font-size: 1rem; }

/* ── Status actions ──────────────────────────────── */
.status-actions { padding: 0.25rem 0; }
.action-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.header-actions { display: flex; gap: 0.5rem; }
.action-cell { white-space: nowrap; }

/* ── Validation report ───────────────────────────── */
.validation-report { padding: 0.25rem 0; }
.alert-warning {
  background: color-mix(in srgb, var(--md-tertiary) 15%, transparent);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 0.75rem 1rem;
  color: var(--md-on-surface);
  font-size: 0.85rem;
  box-shadow: var(--neo-shadow-inset-sm);
}

/* ── Form card ───────────────────────────────────── */
.form-card {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 2rem;
  max-width: 600px;
  box-shadow: var(--neo-shadow-lg);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
}
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Button variants ─────────────────────────────── */
.btn-outlined {
  background: var(--md-sys-color-background);
  border: 2px solid var(--md-outline);
  color: var(--md-primary);
  box-shadow: var(--neo-shadow-md);
}
.btn-outlined:hover {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-color: var(--md-primary);
  box-shadow: var(--neo-shadow-sm);
}
.btn-outlined:active { box-shadow: var(--neo-shadow-pressed); }
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* ── Badge variants ──────────────────────────────── */
.badge-draft { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }
.badge-validated { background: color-mix(in srgb, var(--md-tertiary) 20%, transparent); color: var(--md-tertiary); }
.badge-published { background: color-mix(in srgb, var(--md-primary) 20%, transparent); color: var(--md-primary); }
.badge-archived { background: color-mix(in srgb, var(--md-error) 15%, transparent); color: var(--md-error); }
.badge-Draft { background: var(--md-surface-container-high); color: var(--md-on-surface-variant); }
.badge-Validated { background: color-mix(in srgb, var(--md-tertiary) 20%, transparent); color: var(--md-tertiary); }
.badge-Published { background: color-mix(in srgb, var(--md-primary) 20%, transparent); color: var(--md-primary); }
.badge-Archived { background: color-mix(in srgb, var(--md-error) 15%, transparent); color: var(--md-error); }

.text-muted { color: var(--md-on-surface-variant); font-size: 0.85rem; }

/* ── Student components ──────────────────────────── */

/* Package grid */
.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.package-card {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--neo-shadow-md);
  transition: box-shadow 0.2s, transform 0.2s;
}
.package-card:hover { box-shadow: var(--neo-shadow-lg); transform: translateY(-2px); }
.package-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.package-card-header h3 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--md-on-surface);
}
.package-desc {
  font-size: 0.85rem;
  color: var(--md-on-surface-variant);
  line-height: 1.5;
  flex: 1;
}
.package-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--md-on-surface-variant);
  margin-top: 0.5rem;
}
.package-card-actions {
  margin-top: 1rem;
}

/* Progress bar */
.progress-bar {
  background: var(--md-surface-container-high);
  border-radius: 999px;
  height: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--neo-shadow-inset);
}
.progress-fill {
  background: var(--md-primary);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  min-width: 0;
}
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

/* Study navigation cards */
.study-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.study-nav-card {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--md-on-surface);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
  box-shadow: var(--neo-shadow-md);
}
.study-nav-card:hover {
  box-shadow: var(--neo-shadow-lg);
  transform: translateY(-2px);
  text-decoration: none;
}
.study-nav-icon { font-size: 2rem; }
.study-nav-title {
  font-weight: 600;
  font-size: 1rem;
}
.study-nav-desc {
  font-size: 0.85rem;
  color: var(--md-on-surface-variant);
}

/* Lesson list */
.lesson-list { display: flex; flex-direction: column; gap: 0.25rem; }
.lesson-item { border-radius: var(--md-shape-small); }
.lesson-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--md-on-surface);
  border-radius: var(--md-shape-small);
  transition: background 0.15s;
}
.lesson-link:hover { background: var(--md-surface-container-high); }
.lesson-number {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--md-primary);
  color: var(--md-on-primary);
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: var(--neo-shadow-sm);
}
.lesson-title { flex: 1; }
.lesson-units { font-size: 0.8rem; color: var(--md-on-surface-variant); }

/* Guided study layout */
.guided-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  min-height: 60vh;
}
@media (max-width: 768px) {
  .guided-layout { grid-template-columns: 1fr; }
}
.guided-sidebar {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.25rem;
  box-shadow: var(--neo-shadow-md);
}
.guided-sidebar h3 {
  font-size: 0.9rem;
  margin: 0 0 1rem;
  color: var(--md-primary);
}
.lesson-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.lesson-nav-item a {
  display: block;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--md-on-surface-variant);
  font-size: 0.85rem;
  border-radius: var(--md-shape-small);
}
.lesson-nav-item.active a {
  color: var(--md-on-surface);
  background: var(--md-surface-container-high);
  font-weight: 500;
}
.unit-nav {
  list-style: none;
  padding: 0.25rem 0 0 1.5rem;
  margin: 0;
}
.unit-nav li {
  font-size: 0.8rem;
  padding: 0.25rem 0;
  color: var(--md-on-surface-variant);
}
.unit-nav li.current {
  color: var(--md-primary);
  font-weight: 500;
}
.guided-content {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 2rem;
  box-shadow: var(--neo-shadow-md);
}
.unit-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
}
.unit-objectives {
  font-size: 0.85rem;
  color: var(--md-on-surface-variant);
  margin-bottom: 1rem;
}
.unit-objectives ul { margin: 0.25rem 0 0 1.5rem; padding: 0; }
.markdown-content {
  line-height: 1.7;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.content-area { min-height: 200px; }

/* Chat */
.chat-container {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  display: flex;
  flex-direction: column;
  height: 60vh;
  box-shadow: var(--neo-shadow-lg);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.chat-message { display: flex; }
.chat-message.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: var(--md-sys-shape-corner-md);
  font-size: 0.9rem;
  line-height: 1.5;
}
.chat-message.assistant .chat-bubble {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  box-shadow: var(--neo-shadow-sm);
}
.chat-message.user .chat-bubble {
  background: var(--md-primary);
  color: var(--md-on-primary);
  box-shadow: var(--neo-shadow-sm);
}
.chat-input-area {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: none;
  background: var(--md-sys-color-background);
  border-radius: 0 0 var(--md-sys-shape-corner-lg) var(--md-sys-shape-corner-lg);
}
.chat-input-area textarea,
.chat-input-area input {
  box-shadow: var(--neo-shadow-inset);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 0.6rem 1rem;
  background: var(--md-sys-color-background);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--md-on-surface);
  flex: 1;
}
.chat-input-area textarea:focus,
.chat-input-area input:focus {
  outline: none;
  box-shadow: var(--neo-shadow-pressed);
}

/* Materials grid */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.material-card {
  background: var(--md-surface-container);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--neo-shadow-md);
  transition: box-shadow 0.2s, transform 0.2s;
}
.material-card:hover { box-shadow: var(--neo-shadow-lg); transform: translateY(-2px); }
.material-icon { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }
.material-card h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.material-card p { font-size: 0.85rem; color: var(--md-on-surface-variant); margin: 0 0 1rem; }

/* Material preview (admin) */
.material-preview {
  background: var(--md-sys-color-surface-container, #f5f2ef);
  border-radius: var(--md-sys-shape-corner-md);
  padding: 1rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--neo-shadow-inset-sm);
}
.material-preview-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.material-preview-content {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--md-sys-color-on-surface-variant, #5e4d42);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 200px;
  overflow: hidden;
  position: relative;
}
.material-preview-content::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--md-sys-color-surface-container, #f5f2ef));
}

/* Student material viewer */
.material-viewer {
  background: var(--md-sys-color-surface-container, #f5f2ef);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 2rem;
  line-height: 1.8;
  font-size: 0.95rem;
  max-width: 800px;
  box-shadow: var(--neo-shadow-lg);
}
.material-viewer h2 { font-size: 1.3rem; margin: 1.5rem 0 0.75rem; color: var(--md-sys-color-primary, #6b4c3b); }
.material-viewer h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; color: var(--md-sys-color-on-surface, #2f2622); }
.material-viewer p { margin: 0 0 0.75rem; }
.material-viewer ul, .material-viewer ol { margin: 0 0 0.75rem; padding-left: 1.5rem; }

.material-not-available {
  text-align: center;
  padding: 2rem;
  color: var(--md-sys-color-on-surface-variant, #5e4d42);
}
.material-not-available span { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

/* Alert info */
.alert-info {
  background: color-mix(in srgb, var(--md-primary) 12%, transparent);
  border: none;
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 0.75rem 1rem;
  color: var(--md-on-surface);
  font-size: 0.9rem;
  box-shadow: var(--neo-shadow-inset-sm);
}

/* HTMX indicator — hidden by default, shown when htmx fires request */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* Small inline spinner */
.spinner-sm {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--md-outline-variant, #ccc);
  border-top-color: var(--md-primary, #1a73e8);
  border-radius: 50%;
  animation: spin-sm 0.7s linear infinite;
}
@keyframes spin-sm {
  to { transform: rotate(360deg); }
}

/* ========================================================
   Landing / Login page
   ======================================================== */
.landing-body {
  margin: 0;
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  color: #2f2622;
  background: #f0ebe8;
}

/* --- Landing Navbar --- */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 68px;
  background: #f0ebe8;
  box-shadow: var(--neo-shadow-sm);
}
.landing-brand {
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.landing-login-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.25rem;
  border: 2px solid #6b4c3b;
  border-radius: 20px;
  background: #f0ebe8;
  color: #6b4c3b;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--neo-shadow-md);
}
.landing-login-toggle:hover {
  background: #6b4c3b;
  color: #fff;
  box-shadow: var(--neo-shadow-sm);
}
.landing-login-toggle:active {
  box-shadow: var(--neo-shadow-pressed);
}

/* --- Login Modal --- */
.login-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(47,38,34,0.45);
  align-items: center;
  justify-content: center;
}
.login-modal-overlay.open {
  display: flex;
}
.login-modal-card {
  position: relative;
  background: #f0ebe8;
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--neo-shadow-xl);
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: #8b7355;
  cursor: pointer;
  line-height: 1;
}
.login-modal-close:hover { color: #6b4c3b; }
.login-modal-card h2 {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 1.5rem;
  color: #2f2622;
}
.login-modal-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.lm-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5e4d42;
  margin-bottom: 0.35rem;
}
.lm-field input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f0ebe8;
  color: #2f2622;
  box-sizing: border-box;
  transition: box-shadow 0.2s;
  box-shadow: var(--neo-shadow-inset);
}
.lm-field input:focus {
  outline: none;
  box-shadow: var(--neo-shadow-pressed), 0 0 0 2px rgba(107,76,59,0.15);
}
.lm-submit {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 20px;
  background: #6b4c3b;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 0.25rem;
  transition: all 0.2s;
  box-shadow: var(--neo-shadow-md);
}
.lm-submit:hover { background: #5e432f; box-shadow: var(--neo-shadow-sm); }
.lm-submit:active { box-shadow: var(--neo-shadow-pressed); }
.lm-footer {
  text-align: center;
  margin-top: 1.25rem;
}
.lm-footer a {
  font-size: 0.85rem;
  color: #8b7355;
  text-decoration: none;
}
.lm-footer a:hover { color: #6b4c3b; text-decoration: underline; }

/* --- Landing Main --- */
.landing-main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* --- Hero Section --- */
.landing-hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: #f8f5f3;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--neo-shadow-lg);
}
.hero-content {
  flex: 1;
  min-width: 0;
}
.hero-content h1 {
  font-size: 2.8rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: #2f2622;
  line-height: 1.1;
}
.hero-logo {
  max-width: 320px;
  height: auto;
  margin-bottom: 1rem;
}
.hero-subtitle {
  font-size: 1.05rem;
  color: #5e4d42;
  line-height: 1.6;
  margin: 0 0 1.5rem;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.hero-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.75rem;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  border: 2px solid transparent;
  box-shadow: var(--neo-shadow-md);
}
.hero-btn:active { box-shadow: var(--neo-shadow-pressed); }
.hero-btn-primary {
  background: #6b4c3b;
  color: #fff;
  border-color: #6b4c3b;
}
.hero-btn-primary:hover { background: #5e432f; border-color: #5e432f; box-shadow: var(--neo-shadow-sm); }
.hero-btn-outline {
  background: #f8f5f3;
  color: #6b4c3b;
  border-color: #6b4c3b;
}
.hero-btn-outline:hover { background: #6b4c3b; color: #fff; box-shadow: var(--neo-shadow-sm); }
.hero-illustration {
  flex: 1;
  display: flex;
  justify-content: center;
}
.hero-illustration img {
  max-width: 100%;
  border-radius: 16px;
  height: auto;
}

/* --- Feature Cards --- */
.landing-features {
  background: #f8f5f3;
  border-radius: 24px;
  padding: 3rem 2.5rem;
  box-shadow: var(--neo-shadow-lg);
}
.features-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 2rem;
  color: #2f2622;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.feature-card {
  background: #ece8e4;
  border-radius: 20px;
  padding: 2rem 1.5rem;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--neo-shadow-md);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--neo-shadow-lg); }
.feature-icon-wrap {
  color: #6b4c3b;
  margin-bottom: 1rem;
}
.feature-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #2f2622;
}
.feature-card p {
  font-size: 0.9rem;
  color: #5e4d42;
  line-height: 1.5;
  margin: 0;
}

/* --- Landing Responsive --- */
@media (max-width: 768px) {
  .landing-hero {
    flex-direction: column;
    padding: 2rem 1.5rem;
    text-align: center;
  }
  .hero-content h1 { font-size: 2rem; }
  .hero-logo { max-width: 240px; }
  .hero-actions { justify-content: center; }
  .hero-illustration img { max-width: 80%; }
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .landing-features { padding: 2rem 1.5rem; }
  .landing-nav { padding: 0 1rem; }
}
