/* ================================================================
   DAFFODIL INTERNATIONAL SCHOOL - E-LEARNING SYSTEM
   Design: Blue theme with white card widgets (matching screenshots)
   ================================================================ */

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

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #3B82F6;
  --primary-bg: #EFF6FF;
  --accent: #1E40AF;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --text-dark: #1E293B;
  --text-mid: #475569;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --bg: #F1F5F9;
  --white: #FFFFFF;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --card-shadow-hover: 0 8px 24px rgba(37,99,235,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 60px;
  --nav-h: 48px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── TOP HEADER ── */
.site-header {
  background: var(--white);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo img { height: 36px; }
.header-logo .logo-text {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.header-logo .logo-text span { display: block; color: var(--text-dark); }

.header-school-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 0.3px;
  text-align: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}
.header-user:hover { background: var(--primary-bg); }

.header-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  overflow: hidden;
}
.header-user .avatar img { width: 100%; height: 100%; object-fit: cover; }

.header-user .user-info { line-height: 1.3; }
.header-user .user-name { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.header-user .user-class { font-size: 11px; color: var(--text-light); }

.header-school-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary-bg);
}

.header-logout-form { margin: 0; }
.header-logout-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #FECACA;
  background: #FEF2F2;
  color: var(--danger);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.header-logout-btn:hover { background: var(--danger); color: var(--white); }

/* ── NAVIGATION BAR ── */
.site-nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 16px;
  position: sticky;
  top: var(--header-h);
  z-index: 99;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-mid);
  transition: all 0.2s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--primary-bg); color: var(--primary); }
.nav-link.active { background: var(--primary); color: var(--white); }
.nav-link svg, .nav-link i { font-size: 15px; }

.nav-dropdown { position: relative; }
.nav-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow-hover);
  min-width: 180px;
  z-index: 200;
  display: none;
  overflow: hidden;
}
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dark);
  transition: background 0.15s;
}
.dropdown-menu a:hover { background: var(--primary-bg); color: var(--primary); }

/* ── MAIN LAYOUT ── */
.main-content {
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── DASHBOARD GRID ── */
.dashboard-grid {
  display: grid;
  gap: 16px;
}
.dashboard-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.dashboard-row.two-col { grid-template-columns: 1fr 1fr; }
.dashboard-row.three-col { grid-template-columns: 1fr 1fr 1fr; }
.dashboard-row.col-6-3-3 { grid-template-columns: 6fr 3fr 3fr; }
.dashboard-row.col-3-6-3 { grid-template-columns: 3fr 6fr 3fr; }

/* ── WIDGET CARD ── */
.widget {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.widget:hover { box-shadow: var(--card-shadow-hover); }

.widget-header {
  background: var(--primary);
  color: var(--white);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.widget-header .widget-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.widget-header .widget-title .badge-p {
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
}

.widget-header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  opacity: 0.9;
}

.view-more-link {
  font-size: 12px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  transition: opacity 0.2s;
}
.view-more-link:hover { opacity: 0.7; }
.view-more-white { color: rgba(255,255,255,0.9); }
.view-more-white:hover { color: var(--white); }

.widget-body { padding: 16px; }

.widget-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  padding: 32px 16px;
}

/* ── TODAY CLASSES WIDGET ── */
.today-classes-widget .widget-header-info {
  font-size: 13px;
  opacity: 0.9;
}

.class-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
}
.class-card:last-child { margin-bottom: 0; }
.class-subject { font-weight: 600; font-size: 14px; }
.class-meta { font-size: 12px; color: var(--text-mid); margin-top: 4px; }

/* ── EXAM SCHEDULE WIDGET ── */
.exam-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.exam-carousel-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.exam-carousel-btn:hover { background: rgba(255,255,255,0.3); }

.exam-card-inner {
  flex: 1;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.exam-date-box {
  text-align: center;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 56px;
}
.exam-date-box .day { font-size: 24px; font-weight: 700; line-height: 1; }
.exam-date-box .month { font-size: 12px; opacity: 0.9; }
.exam-info .subject { font-size: 15px; font-weight: 600; }
.exam-info .time { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.exam-info .unit { font-size: 12px; opacity: 0.75; margin-top: 2px; }

/* ── ATTENDANCE WIDGET ── */
.attendance-date { font-size: 13px; color: var(--text-mid); margin-bottom: 12px; }
.attendance-month { font-weight: 600; font-size: 14px; color: var(--text-dark); margin-bottom: 8px; }
.attendance-summary-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 16px;
}
.att-stat { display: flex; align-items: center; gap: 4px; }
.att-val { font-weight: 600; color: var(--text-dark); }

.attendance-totals {
  display: flex;
  gap: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.att-total-item { flex: 1; }
.att-total-item .label { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.att-total-item .value { font-size: 22px; font-weight: 700; }
.att-total-item.present .value { color: var(--success); }
.att-total-item.absent .value { color: var(--danger); }
.att-total-item.total .value { color: var(--primary); }

/* ── DIARY WIDGET ── */
.diary-date { font-size: 13px; color: var(--text-mid); margin-bottom: 10px; }
.diary-entry {
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.diary-entry .time { font-size: 12px; opacity: 0.85; margin-bottom: 4px; }
.diary-entry .desc { font-size: 13px; font-weight: 500; }

/* ── ASSIGNMENT WIDGET ── */
.assignment-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.assignment-item:last-child { border-bottom: none; }
.assignment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.assignment-date { font-size: 12px; color: var(--text-mid); }
.subject-badge {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary);
  color: var(--white);
}
.subject-badge.tamil { background: #7C3AED; }
.subject-badge.math { background: var(--primary); }
.subject-badge.science { background: var(--success); }
.assignment-title { font-size: 13px; color: var(--text-dark); font-weight: 500; }

/* ── EXAM RESULTS WIDGET ── */
.exam-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.exam-period { font-size: 13px; color: var(--text-mid); }
.exam-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dark);
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.result-subject { font-size: 13px; width: 80px; color: var(--text-dark); flex-shrink: 0; }
.result-bar-wrap { flex: 1; height: 10px; background: var(--border); border-radius: 10px; overflow: hidden; }
.result-bar { height: 100%; border-radius: 10px; transition: width 0.6s ease; }
.result-bar.good { background: var(--success); }
.result-bar.bad { background: var(--danger); }
.result-score { font-size: 12px; color: var(--text-mid); width: 54px; text-align: right; flex-shrink: 0; }

/* ── CLASS POSTER ── */
.poster-widget .widget-header { background: var(--primary-dark); }
.poster-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.poster-user { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.poster-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-bg); border: 2px solid var(--border); overflow: hidden; }
.poster-avatar img { width: 100%; height: 100%; object-fit: cover; }
.poster-name { font-size: 13px; font-weight: 600; }
.poster-role { font-size: 11px; color: var(--text-light); }
.poster-body { font-size: 13px; font-weight: 600; color: var(--text-dark); line-height: 1.6; margin-bottom: 10px; }
.poster-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.poster-tag { font-size: 11px; color: var(--primary); font-weight: 500; }
.poster-image { border-radius: var(--radius-sm); overflow: hidden; max-height: 180px; }
.poster-image img { width: 100%; height: 180px; object-fit: cover; }

/* ── ACHIEVEMENTS WIDGET ── */
.achievements-widget { overflow: hidden; }
.achievements-carousel-wrap { position: relative; }
.achievements-carousel {
  display: flex;
  gap: 12px;
  overflow: hidden;
  padding: 4px;
}
.achievement-card {
  flex: 0 0 calc(33.33% - 8px);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  transition: box-shadow 0.2s;
}
.achievement-card:hover { box-shadow: var(--card-shadow-hover); }
.achievement-medal {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 10px;
}
.achievement-medal .medal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}
.achievement-medal .rank-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.rank-1 { background: #FFD700; }
.rank-2 { background: #C0C0C0; }
.rank-3 { background: #CD7F32; }

.achievement-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.achievement-class { font-size: 11px; color: var(--text-light); margin-bottom: 8px; }
.achievement-event {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
}

.carousel-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  z-index: 10;
  transition: all 0.2s;
}
.carousel-nav-btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
.carousel-nav-btn.prev { left: -10px; }
.carousel-nav-btn.next { right: -10px; }

/* ── BIRTHDAYS WIDGET ── */
.birthday-section { margin-bottom: 12px; }
.birthday-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dark); margin-bottom: 8px; }
.birthday-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.birthday-item:last-child { border-bottom: none; }
.birthday-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.4); }
.birthday-avatar img { width: 100%; height: 100%; object-fit: cover; }
.birthday-info { flex: 1; }
.birthday-name { font-size: 13px; font-weight: 600; }
.birthday-class { font-size: 11px; opacity: 0.8; }
.wish-btn {
  border: 2px solid rgba(255,255,255,0.8);
  background: transparent;
  color: var(--white);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.wish-btn:hover { background: var(--white); color: var(--primary); }

.birthdays-widget .widget-header { background: var(--primary); }
.birthdays-widget .widget-body { background: var(--primary); color: var(--white); padding: 12px 16px; }

/* ── KATBOOK SUBJECTS PAGE ── */
.subjects-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.subject-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}
.subject-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-2px); }
.subject-cover {
  height: 180px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  padding: 12px;
}
.subject-cover img { max-height: 156px; object-fit: contain; }
.subject-card-body { padding: 14px; }
.subject-card-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.subject-progress-wrap { margin-bottom: 8px; }
.progress-bar-outer { height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-bar-inner { height: 100%; background: var(--primary); border-radius: 10px; transition: width 0.6s; }
.subject-progress-text {
  display: flex;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 3px;
}
.subject-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 8px;
}
.stat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.stat-dot.green { background: var(--success); }
.stat-dot.red { background: var(--danger); }

/* ── KATBOOK READER ── */
.reader-layout { display: flex; height: calc(100vh - var(--header-h) - var(--nav-h)); overflow: hidden; }
.reader-sidebar {
  width: 280px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.reader-sidebar-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.reader-sidebar-header .title { font-weight: 600; font-size: 14px; }
.sidebar-actions { display: flex; gap: 8px; font-size: 12px; color: var(--primary); font-weight: 500; }
.sidebar-actions span { cursor: pointer; }
.sidebar-actions span:hover { text-decoration: underline; }
.sidebar-tree { overflow-y: auto; flex: 1; padding: 8px 0; }

.tree-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}
.tree-item:hover { background: var(--primary-bg); }
.tree-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 500; }
.tree-item.chapter { font-weight: 600; }
.tree-item.session { padding-left: 28px; }
.tree-item .progress-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  flex-shrink: 0;
}
.tree-item .progress-badge.done { background: var(--success); }
.tree-item .progress-badge.partial { background: var(--primary); }
.tree-item .progress-badge.zero { background: var(--success); }
.tree-item .expand-icon { color: var(--text-light); transition: transform 0.2s; }
.tree-item.open .expand-icon { transform: rotate(180deg); }

.reader-main {
  flex: 1;
  overflow-y: auto;
  background: var(--white);
  display: flex;
  flex-direction: column;
}
.reader-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}
.reader-breadcrumb { font-size: 14px; font-weight: 600; color: var(--text-dark); flex: 1; text-align: center; }
.reader-actions { display: flex; align-items: center; gap: 8px; }
.reader-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-dark);
}
.reader-btn:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.reader-btn.primary-btn { background: var(--primary); color: var(--white); border-color: var(--primary); }
.reader-btn.primary-btn:hover { background: var(--primary-dark); }

.reader-content { padding: 30px 48px; flex: 1; font-size: 15px; line-height: 1.8; color: var(--text-dark); max-width: 820px; margin: 0 auto; width: 100%; }
.reader-content p { margin-bottom: 16px; }
.reader-content .highlight { background: #FEF08A; padding: 1px 2px; border-radius: 2px; }
.reader-content .highlight.orange { background: #FED7AA; }
.reader-content .highlight.blue { background: #BFDBFE; }

.reader-nav-btns {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
}

/* ── KATBOOK TOP NAV ── */
.katbook-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.katbook-book-info { display: flex; align-items: center; gap: 10px; }
.katbook-book-info .cover { width: 36px; height: 44px; border-radius: 4px; object-fit: cover; }
.katbook-book-info .book-details .book-series { font-size: 10px; font-weight: 700; color: var(--primary); text-transform: uppercase; }
.katbook-book-info .book-details .book-title { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.katbook-school { font-weight: 700; font-size: 14px; text-align: center; flex: 1; line-height: 1.2; }

.katbook-lang-select select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--white);
}

.katbook-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.katbook-tool-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
  position: relative;
}
.katbook-tool-btn:hover { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
.katbook-tool-btn .tooltip {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-dark);
  color: var(--white);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.katbook-tool-btn:hover .tooltip { opacity: 1; }

.katbook-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.katbook-search input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  width: 200px;
}

/* ── SELECTION TOOLBAR (floating, fixed to viewport) ── */
.selection-toolbar {
  position: fixed;
  background: #1E293B;
  color: var(--white);
  border-radius: 8px;
  padding: 7px 14px;
  display: none;
  gap: 10px;
  font-size: 12px;
  z-index: 9999;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  pointer-events: auto;
  transition: opacity 0.15s;
}
.selection-toolbar.visible { display: flex; }
.sel-btn {
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 5px;
  transition: background 0.15s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
}
.sel-btn:hover { background: rgba(255,255,255,0.18); }
.sel-sep { opacity: 0.25; font-size: 14px; }

/* Highlighted text mark */
mark.katbook-highlight { border-radius: 3px; padding: 1px 0; }
mark.katbook-highlight.yellow { background: #FEF08A; color: inherit; }
mark.katbook-highlight.green { background: #BBF7D0; color: inherit; }
mark.katbook-highlight.blue { background: #BFDBFE; color: inherit; }
mark.katbook-highlight.pink { background: #FBCFE8; color: inherit; }

/* Note sticky */
.note-sticky {
  position: absolute;
  background: #FEF9C3;
  border: 1px solid #FDE047;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 200px;
  max-width: 280px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 800;
  cursor: move;
}
.note-sticky .note-close {
  position: absolute;
  top: 4px; right: 8px;
  font-size: 16px;
  cursor: pointer;
  color: #92400E;
  background: none;
  border: none;
  line-height: 1;
}

/* Highlight picker */
.highlight-picker {
  position: fixed;
  background: white;
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  z-index: 9998;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
}
.hl-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.hl-swatch:hover { border-color: #334155; transform: scale(1.2); }
.hl-swatch.yellow { background: #FEF08A; }
.hl-swatch.green  { background: #BBF7D0; }
.hl-swatch.blue   { background: #BFDBFE; }
.hl-swatch.pink   { background: #FBCFE8; }

/* ── AI SEARCH PANEL ── */
.ai-panel {
  width: 380px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--white);
  flex-shrink: 0;
}
.ai-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-panel-title { font-size: 13px; font-weight: 600; }
.ai-chat-area { flex: 1; overflow-y: auto; padding: 12px; }
.ai-chat-input-wrap {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.ai-chat-input-wrap textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  resize: none;
  height: 60px;
  font-family: inherit;
}
.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo img { height: 70px; }
.login-school { text-align: center; font-size: 18px; font-weight: 700; color: var(--text-dark); margin-bottom: 4px; }
.login-subtitle { text-align: center; font-size: 13px; color: var(--text-light); margin-bottom: 28px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.btn-login {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
  margin-top: 8px;
}
.btn-login:hover { background: var(--primary-dark); }

.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-mid);
}
.auth-switch a { color: var(--primary); font-weight: 700; }
.auth-switch a:hover { text-decoration: underline; }
.signup-page { padding: 32px 16px; height: auto; min-height: 100vh; }
.signup-card { max-width: 560px; }
.auth-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #1D4ED8, #3B82F6);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  color: white;
  font-weight: 900;
  font-size: 22px;
}
.signup-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.signup-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.errorlist {
  list-style: none;
  color: var(--danger);
  font-size: 12px;
  margin-top: 5px;
}

.profile-page { max-width: 900px; margin: 10px auto; }
.profile-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.profile-banner {
  height: 130px;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
}
.profile-content { padding: 0 32px 32px; }
.profile-avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 5px solid var(--white);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 34px;
  font-weight: 700;
  margin-top: -56px;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.profile-heading h1 { font-size: 25px; }
.profile-heading p { color: var(--text-light); margin-top: 4px; }
.profile-logout-btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  background: var(--danger);
  color: var(--white);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.profile-logout-btn:hover { background: #B91C1C; }
.profile-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}
.profile-detail {
  background: var(--bg);
  border-radius: 9px;
  padding: 15px;
}
.profile-detail span {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  margin-bottom: 5px;
}
.profile-detail strong { font-size: 14px; }

@media (max-width: 700px) {
  .header-school-name, .header-user .user-info, .header-logout-btn span { display: none; }
  .header-logout-btn { padding: 9px 11px; }
  .form-row, .profile-details { grid-template-columns: 1fr; }
  .profile-content { padding: 0 20px 24px; }
  .profile-heading { align-items: flex-start; flex-direction: column; }
}

/* ── ALERTS / MESSAGES ── */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: var(--success); border: 1px solid #BBF7D0; }

/* ── FOOTER ── */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  background: var(--white);
  margin-top: 24px;
}
.site-footer a { color: var(--primary); font-weight: 500; }

/* ── K-SMACC CHAT BUTTON ── */
.ksmacc-btn {
  position: fixed;
  bottom: 0;
  right: 0;
  background: var(--text-dark);
  color: var(--white);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  z-index: 900;
  border-radius: 12px 0 0 0;
  box-shadow: -2px -2px 10px rgba(0,0,0,0.15);
  transition: background 0.2s;
}
.ksmacc-btn:hover { background: var(--primary); }
.ksmacc-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 14px; }

/* ── UTILITIES ── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .dashboard-row.two-col { grid-template-columns: 1fr; }
  .dashboard-row.three-col { grid-template-columns: 1fr 1fr; }
  .dashboard-row.col-6-3-3 { grid-template-columns: 1fr; }
  .dashboard-row.col-3-6-3 { grid-template-columns: 1fr; }
  .reader-layout { flex-direction: column; height: auto; }
  .reader-sidebar { width: 100%; height: 250px; }
  .main-content { padding: 12px; }
  .achievement-card { flex: 0 0 calc(50% - 6px); }
}

@media (max-width: 600px) {
  .header-school-name { display: none; }
  .site-nav { overflow-x: auto; justify-content: flex-start; gap: 2px; }
  .nav-link { font-size: 12px; padding: 6px 10px; }
  .dashboard-row { grid-template-columns: 1fr; }
  .achievement-card { flex: 0 0 100%; }
}
