/* =========================================================
   LifeAssist AI — Dashboard Styles
   ========================================================= */

:root {
  /* Brand */
  --purple: #6C5CE7;
  --purple-dark: #5A4BD1;
  --purple-soft: #EFECFD;
  --green: #22C55E;
  --green-soft: #E4F9EC;
  --orange: #F97316;
  --orange-soft: #FEEDE1;
  --blue: #3B82F6;
  --blue-soft: #E7F0FE;

  /* Neutrals */
  --bg: #F5F6FB;
  --surface: #FFFFFF;
  --border: #ECEDF3;
  --text-primary: #16181D;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.08);

  /* Radii */
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  /* Sidebar */
  --sidebar-width: 250px;

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode palette */
body.dark-mode {
  --bg: #0F1117;
  --surface: #181B24;
  --border: #262A36;
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --purple-soft: #2A2456;
  --green-soft: #123723;
  --orange-soft: #3A2413;
  --blue-soft: #16273F;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  margin: 0;
  transition: background 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand-name, .stat-value, .welcome-title {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

/* Utility color classes */
.text-purple { color: var(--purple); }
.text-green { color: var(--green); }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue); }
.bg-purple { background: var(--purple); }
.bg-green { background: var(--green); }
.bg-orange { background: var(--orange); }
.bg-blue { background: var(--blue); }
.bg-purple-soft { background: var(--purple-soft); }
.bg-green-soft { background: var(--green-soft); }
.bg-orange-soft { background: var(--orange-soft); }
.bg-blue-soft { background: var(--blue-soft); }

/* =========================================================
   Layout Shell
   ========================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* =========================================================
   Sidebar
   ========================================================= */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface, #ffffff);
  border-right: 1px solid var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 32px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(108, 92, 231, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.brand-icon i {
  color: #6C5CE7;
}

.brand-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 17px;
  line-height: 1.1;
  color: var(--text-primary, #1e293b);
}

.brand-tag {
  font-size: 11.5px;
  color: var(--text-muted, #64748b);
  margin-top: 2px;
}

.sidebar-close {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--text-muted, #64748b);
  cursor: pointer;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.side-link i { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }

.side-link:hover {
  background: var(--bg, #f8fafc);
  color: var(--text-primary, #1e293b);
  transform: translateX(2px);
}

.side-link.active {
  background: #6C5CE7;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.35);
}

.side-link.active i { color: #ffffff !important; }

.side-link.active:hover { transform: none; }

.sidebar-footer {
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 16px;
  margin-top: auto;
}

.logout-btn, .logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  color: #E5484D;
  border: none;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.logout-btn i, .logout i { font-size: 17px; width: 20px; text-align: center; }

.logout-btn:hover, .logout:hover { background: #FEF2F2; color: #DC2626; transform: translateX(2px); }

/* =========================================================
   Main Content
   ========================================================= */
.main-content {
  flex: 1;
  padding: 28px 32px 40px;
  min-width: 0;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.topbar-welcome {
  display: flex;
  flex-direction: column;
  margin-right: auto;
}

.topbar-welcome .welcome-title {
  font-size: 21px;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-welcome .welcome-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 2px 0 0;
}

.topbar-date {
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.topbar-date i { color: var(--purple); }

.topbar-search {
  width: 240px;
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 18px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.topbar-search:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.12);
}

.topbar-search i { color: var(--text-muted); font-size: 15px; }

.topbar-search input {
  border: none;
  outline: none;
  background: transparent;
  padding: 11px 12px;
  width: 100%;
  font-size: 14px;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--text-secondary);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
  background: var(--purple-soft);
  color: var(--purple);
  transform: translateY(-2px);
}

.notif-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #EF4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

.notif-dropdown {
  position: absolute;
  top: 52px;
  right: 56px;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: var(--transition);
  z-index: 1050;
}

.notif-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notif-dropdown-header {
  font-weight: 700;
  font-size: 13.5px;
  padding: 8px 10px;
  color: var(--text-primary);
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.notif-item:hover { background: var(--bg); }

.notif-icon { font-size: 16px; margin-top: 2px; }

.notif-text { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.notif-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Welcome Section */
.welcome-section { margin-bottom: 24px; }

.welcome-title {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--text-primary);
}

.wave { display: inline-block; animation: wave 2.2s ease-in-out infinite; transform-origin: 70% 70%; }

@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
}

.welcome-subtitle {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: 0;
}

/* =========================================================
   Panels (shared card style)
   ========================================================= */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  transition: box-shadow 0.25s ease, transform 0.25s ease, background 0.3s ease;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text-primary);
}

.panel-title i { color: var(--purple); font-size: 15px; }

.panel-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.btn-link {
  border: none;
  background: none;
  color: var(--purple);
  font-weight: 600;
  font-size: 13px;
  transition: var(--transition);
}

.btn-link:hover { text-decoration: underline; }

/* =========================================================
   Statistics Cards
   ========================================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-icon-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-unit { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

.stat-goal {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 6px 0 12px;
}

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--bg);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================
   Middle Grid
   ========================================================= */
.middle-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  align-items: start;
}

/* Today's Plan */
.task-list { display: flex; flex-direction: column; gap: 6px; }

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.task-item:hover { background: var(--bg); }

.task-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.task-info { flex: 1; min-width: 0; }

.task-time { font-size: 11.5px; color: var(--text-muted); }

.task-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1px;
}

.task-item[data-done="true"] .task-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.task-status-btn {
  border: none;
  background: none;
  font-size: 21px;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

.task-item[data-done="true"] .task-status-btn { color: var(--green); }

.task-status-btn:hover { transform: scale(1.15); }

/* Weekly Chart */
.chart-panel { display: flex; flex-direction: column; }

.week-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  cursor: pointer;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.legend-item {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.chart-wrap { position: relative; height: 260px; }

/* AI Coach Panel */
.coach-panel { display: flex; flex-direction: column; }

.coach-header-actions { display: flex; gap: 6px; }

.icon-btn-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn-sm:hover { background: var(--purple-soft); color: var(--purple); }

.coach-prompt {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.coach-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.coach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  transition: var(--transition);
  width: 100%;
}

.coach-card:hover {
  border-color: var(--purple);
  background: var(--purple-soft);
  transform: translateX(3px);
}

.coach-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.coach-info { flex: 1; min-width: 0; }

.coach-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }

.coach-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 1px;
  line-height: 1.3;
}

.coach-arrow { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }

.btn-start-chat {
  width: 100%;
  border: 1.5px solid var(--purple);
  background: transparent;
  color: var(--purple);
  font-weight: 700;
  font-size: 13.5px;
  padding: 12px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  transition: var(--transition);
}

.btn-start-chat:hover {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.3);
}

/* =========================================================
   Bottom Grid
   ========================================================= */
.bottom-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr 0.85fr;
  gap: 20px;
  margin-bottom: 24px;
  align-items: stretch;
}

.workout-panel, .journal-panel, .recipe-panel { display: flex; flex-direction: column; }

/* Recent Workout */
.workout-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

.workout-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.workout-item:hover { background: var(--bg); }

.workout-thumb {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.workout-info { flex: 1; min-width: 0; }

.workout-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }

.workout-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.workout-delta { text-align: right; }

.delta-value { display: block; font-size: 12.5px; font-weight: 700; }

.delta-label { display: block; font-size: 10.5px; color: var(--text-muted); }

.btn-outline-full, .btn-outline-half, .btn-solid-full {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13px;
  padding: 11px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  margin-top: auto;
}

.btn-outline-full:hover, .btn-outline-half:hover {
  border-color: var(--purple);
  color: var(--purple);
  background: var(--purple-soft);
}

.btn-solid-full {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

.btn-solid-full:hover {
  background: var(--purple-dark);
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.3);
}

/* Journal */
.journal-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.journal-date { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

.mood-badge {
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.journal-preview {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 0 16px;
  flex: 1;
}

.journal-actions { display: flex; gap: 10px; margin-top: auto; }
.btn-outline-half { flex: 1; margin-top: 0; }

/* Recipe */
.recipe-image-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
  height: 130px;
}

.recipe-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.recipe-image-wrap:hover .recipe-image { transform: scale(1.08); }

.recipe-name { font-size: 14.5px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }

.recipe-stats {
  display: flex;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.recipe-stats i { color: var(--purple); margin-right: 3px; }

/* Motivation Card */
.motivation-panel {
  background: linear-gradient(160deg, #FFF7E8, #FDEFD8);
  border: 1px solid #F5E4BE;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: float 4s ease-in-out infinite;
}

body.dark-mode .motivation-panel {
  background: linear-gradient(160deg, #2A2416, #241F14);
  border-color: #3A331E;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.quote-icon {
  font-size: 34px;
  color: #E9C46A;
  opacity: 0.6;
  margin-bottom: 6px;
}

.motivation-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.motivation-quote {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* =========================================================
   Bottom Banner
   ========================================================= */
.bottom-banner {
  background: linear-gradient(120deg, #1E1B2E, #2B2650);
  border-radius: var(--radius-lg);
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-lg);
}

.banner-text {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-text i { color: #FBBF24; }

.rocket { display: inline-block; animation: rocket-bounce 1.6s ease-in-out infinite; }

@keyframes rocket-bounce {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(2px, -3px) rotate(8deg); }
}

.btn-set-goals {
  background: #fff;
  color: #1E1B2E;
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 11px 22px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-set-goals:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* =========================================================
   Mobile topbar / hamburger
   ========================================================= */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.hamburger-btn {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-primary);
  width: 40px;
}

.mobile-logo { display: flex; align-items: center; gap: 8px; }
.mobile-logo .logo-mark { width: 32px; height: 32px; font-size: 14px; border-radius: 9px; }
.mobile-logo-text { font-weight: 800; font-size: 15px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1025;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show { display: block; opacity: 1; }

/* =========================================================
   Animations
   ========================================================= */
.fade-up {
  animation: fadeUp 0.5s ease both;
}

.middle-grid.fade-up { animation-delay: 0.05s; }
.bottom-grid.fade-up { animation-delay: 0.1s; }
.bottom-banner.fade-up { animation-delay: 0.15s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Ripple */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out;
  pointer-events: none;
}

@keyframes rippleAnim {
  to { transform: scale(2.5); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1199px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .middle-grid { grid-template-columns: 1fr 1fr; }
  .coach-panel { grid-column: span 2; }
  .bottom-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1035;
  }
  .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; padding: 20px 18px 32px; }
  .mobile-topbar { display: flex; }
  .topbar-date { display: none !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
  .middle-grid { grid-template-columns: 1fr; }
  .coach-panel { grid-column: span 1; }
  .bottom-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .welcome-title { font-size: 21px; }
  .topbar { flex-wrap: wrap; }
  .topbar-search { order: 3; max-width: 100%; width: 100%; margin: 0; }
  .bottom-banner { flex-direction: column; align-items: flex-start; }
  .btn-set-goals { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 16px; }
}


/* =========================================================
   Study Hub — page specific styles
   ========================================================= */

:root {
  --coach-width: 336px;
}

/* Give the study hub a 3-column shell: sidebar | content | coach */
body.study-page .main-content {
  margin-right: var(--coach-width);
  transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content { position: relative; }

/* ---------- Streak widget (sidebar) ---------- */
.streak-card {
  background: linear-gradient(155deg, #FFF4E9, #FFE9D6);
  border: 1px solid #FBDCB8;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0;
}

body.dark-mode .streak-card {
  background: linear-gradient(155deg, #2C2013, #241B10);
  border-color: #3A2C17;
}

.streak-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.streak-fire { font-size: 26px; line-height: 1; }
.streak-number { font-size: 20px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.streak-label { font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }

.streak-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
}

.streak-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 13px;
  margin-bottom: 10px;
}

.streak-dots .done { color: #F97316; }
.streak-dots i:not(.done) { color: var(--text-muted); opacity: 0.4; }

.streak-msg { font-size: 11.5px; font-weight: 700; color: var(--text-primary); }

/* ---------- Live session bar ---------- */
.live-session-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(120deg, var(--purple), #8B5CF6);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(108,92,231,0.3);
}

.live-session-bar.active { display: flex; animation: fadeUp 0.35s ease; }

.live-session-info { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13.5px; }

.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #fff;
  animation: pulseDot 1.2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.live-session-time { font-variant-numeric: tabular-nums; background: rgba(255,255,255,0.18); padding: 3px 10px; border-radius: var(--radius-pill); }

.live-session-actions { display: flex; gap: 8px; }

.btn-live-action {
  border: 1.5px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  transition: var(--transition);
}

.btn-live-action:hover { background: rgba(255,255,255,0.25); }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-header-left { display: flex; align-items: center; gap: 14px; }

.page-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--purple), #A594F9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.page-title { font-size: 24px; font-weight: 800; margin: 0; color: var(--text-primary); }
.page-subtitle { font-size: 13.5px; color: var(--text-secondary); margin: 2px 0 0; }

.topbar-inline { align-items: center; gap: 12px; }
.topbar-inline .topbar-search { width: 220px; flex: none; margin: 0; }
.search-kbd {
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-family: inherit;
}

/* ---------- Action row ---------- */
.action-row { display: flex; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.btn-auto { width: auto; padding: 11px 20px; }

/* ---------- Subject cards ---------- */
.subjects-row-wrap { position: relative; margin-bottom: 22px; }

.subjects-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.subjects-row::-webkit-scrollbar { display: none; }

.subjects-scroll-btn {
  position: absolute;
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.subjects-scroll-btn:hover { color: var(--purple); transform: translateY(-50%) scale(1.08); }

.subject-card {
  position: relative;
  flex: 0 0 216px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
  cursor: pointer;
  transition: var(--transition);
}

.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.subject-card.selected { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(108,92,231,0.14), var(--shadow-lg); }

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

.subject-icon-circle {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}

.subject-menu-btn {
  border: none; background: none; color: var(--text-muted); font-size: 16px;
  width: 26px; height: 26px; border-radius: 50%; transition: var(--transition);
}
.subject-menu-btn:hover { background: var(--bg); color: var(--text-primary); }

.subject-name { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.subject-percent { font-size: 21px; font-weight: 800; margin-bottom: 10px; }

.subject-card .progress-track { margin-bottom: 10px; }

.subject-meta-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; }
.subject-chapters-count { color: var(--text-muted); font-weight: 600; }
.subject-status { font-weight: 700; }

.subject-card-menu {
  position: absolute;
  top: 46px;
  right: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 150px;
  z-index: 20;
  display: none;
}
.subject-card-menu.show { display: block; }
.subject-card-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: none; padding: 8px 10px; font-size: 12.5px;
  font-weight: 600; color: var(--text-primary); border-radius: 8px; transition: var(--transition);
}
.subject-card-menu button:hover { background: var(--bg); }
.subject-card-menu button.danger { color: #EF4444; }

/* ---------- Plan + Chart grid ---------- */
.plan-chart-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.35fr;
  gap: 20px;
  margin-bottom: 22px;
  align-items: start;
}

.plan-panel-study { display: flex; flex-direction: column; }

.plan-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 6px;
}
.plan-footer-item { flex: 1; }
.plan-footer-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.plan-footer-value { font-size: 14px; font-weight: 800; color: var(--text-primary); }

.goal-ring-wrap { position: relative; width: 46px; height: 46px; flex-shrink: 0; }
.goal-ring { width: 46px; height: 46px; transform: rotate(-90deg); }
.goal-ring-bg { fill: none; stroke: var(--border); stroke-width: 5; }
.goal-ring-fill {
  fill: none; stroke: var(--purple); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 163.36; stroke-dashoffset: 163.36;
  transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1);
}
.goal-ring-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; color: var(--text-primary);
}

.mt-2 { margin-top: 10px; }

/* Chart panel */
.chart-panel-study { display: flex; flex-direction: column; }
.week-tag { font-weight: 500; color: var(--text-muted); font-size: 13px; }
.chart-panel-study .chart-wrap { height: 230px; margin-bottom: 14px; }

.chart-stats-row { display: flex; gap: 12px; flex-wrap: wrap; }
.chart-stat { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; flex: 1; min-width: 150px; }
.chart-stat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.chart-stat-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.chart-stat-value { font-size: 14px; font-weight: 800; color: var(--text-primary); }

/* ---------- Tabs + Focus grid ---------- */
.tabs-focus-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 20px;
  margin-bottom: 22px;
  align-items: start;
}

.tabs-panel { padding-top: 12px; }

.study-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding: 0 4px;
  scrollbar-width: none;
}
.study-tabs::-webkit-scrollbar { display: none; }

.study-tab {
  border: none;
  background: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  position: relative;
  transition: var(--transition);
}
.study-tab:hover { color: var(--text-primary); }
.study-tab.active { color: var(--purple); }
.study-tab.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2.5px;
  background: var(--purple);
  border-radius: 2px 2px 0 0;
}

.tab-pane { display: none; animation: fadeUp 0.35s ease; }
.tab-pane.active { display: block; }

.tab-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab-subject-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.tab-subject-label strong { color: var(--text-primary); }

/* Chapters */
.chapter-list { display: flex; flex-direction: column; gap: 6px; }

.chapter-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  border: 1px solid transparent;
}
.chapter-item:hover { background: var(--bg); }
.chapter-item.in-progress { background: var(--purple-soft); border-color: rgba(108,92,231,0.25); }

.chapter-status-icon { font-size: 19px; flex-shrink: 0; width: 22px; text-align: center; }
.chapter-status-icon.completed { color: var(--green); }
.chapter-status-icon.in-progress-icon { color: var(--purple); }
.chapter-status-icon.locked { color: var(--text-muted); }

.chapter-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); flex: 0 0 190px; }
.chapter-item.locked .chapter-name { color: var(--text-muted); }

.chapter-progress-track { flex: 1; height: 7px; border-radius: var(--radius-pill); background: var(--bg); overflow: hidden; min-width: 80px; }
.chapter-progress-fill { height: 100%; border-radius: var(--radius-pill); background: var(--green); width: 0%; transition: width 1s ease; }
.chapter-item.in-progress .chapter-progress-fill { background: var(--purple); }

.chapter-percent { font-size: 12px; font-weight: 700; color: var(--text-primary); width: 38px; text-align: right; flex-shrink: 0; }
.chapter-status-text { font-size: 11.5px; font-weight: 600; color: var(--text-muted); width: 130px; text-align: right; flex-shrink: 0; }
.chapter-status-text.progress-text { color: var(--purple); }

.chapter-menu-btn { border: none; background: none; color: var(--text-muted); font-size: 16px; flex-shrink: 0; width: 24px; }
.chapter-menu-btn:hover { color: var(--text-primary); }

/* Notes */
.notes-search { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: var(--radius-pill); padding: 8px 14px; flex: 1; max-width: 260px; }
.notes-search i { color: var(--text-muted); font-size: 13px; }
.notes-search input { border: none; background: none; outline: none; font-size: 12.5px; width: 100%; color: var(--text-primary); }

.notes-actions { display: flex; gap: 8px; }

.btn-outline-sm, .btn-solid-sm {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-outline-sm:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.btn-solid-sm { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-solid-sm:hover { background: var(--purple-dark); }

.notes-list { display: flex; flex-direction: column; gap: 8px; }

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.note-item:hover { box-shadow: var(--shadow-sm); }

.note-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--purple-soft); color: var(--purple); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.note-body { flex: 1; min-width: 0; }
.note-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.note-preview { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.note-date { font-size: 10.5px; color: var(--text-muted); margin-top: 4px; }
.note-actions { display: flex; gap: 4px; flex-shrink: 0; }
.note-action-btn { border: none; background: none; color: var(--text-muted); width: 26px; height: 26px; border-radius: 8px; font-size: 13px; transition: var(--transition); }
.note-action-btn:hover { background: var(--bg); color: var(--purple); }
.note-action-btn.pinned { color: var(--orange); }

/* Flashcards */
.flashcards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.flashcard { perspective: 1200px; height: 140px; }
.flashcard-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.4,0.2,0.2,1);
  cursor: pointer;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.flashcard-face.back { transform: rotateY(180deg); background: var(--purple-soft); color: var(--purple-dark); }
.flashcard-face .fc-label { position: absolute; top: 8px; left: 10px; font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.flashcard.known { border: 2px solid var(--green); }
.flashcard.difficult { border: 2px solid #EF4444; }
.flashcard:not(.current) { display: none; }

.flashcard-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.flashcard-nav .btn-outline-sm { flex: 1; justify-content: center; }
.text-green { color: var(--green) !important; }

/* Quizzes */
.quiz-list { display: flex; flex-direction: column; gap: 10px; }
.quiz-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-md); transition: var(--transition);
}
.quiz-item:hover { box-shadow: var(--shadow-sm); }
.quiz-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.quiz-info { flex: 1; min-width: 0; }
.quiz-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.quiz-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* Mock test */
.mocktest-card { text-align: center; padding: 30px 20px; }
.mocktest-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--purple-soft); color: var(--purple);
  display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 16px;
}
.mocktest-card h3 { font-size: 17px; font-weight: 800; margin-bottom: 8px; color: var(--text-primary); }
.mocktest-card p { font-size: 13px; color: var(--text-secondary); max-width: 380px; margin: 0 auto 20px; line-height: 1.6; }

/* Revision plan */
.revision-list { display: flex; flex-direction: column; gap: 10px; }
.revision-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.revision-order { width: 26px; height: 26px; border-radius: 50%; background: var(--purple-soft); color: var(--purple); font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.revision-info { flex: 1; }
.revision-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.revision-reason { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* Resources */
.resources-list { display: flex; flex-direction: column; gap: 8px; }
.resource-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); transition: var(--transition); }
.resource-item:hover { box-shadow: var(--shadow-sm); }
.resource-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.resource-body { flex: 1; min-width: 0; }
.resource-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.resource-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.resource-actions { display: flex; gap: 4px; }

/* ---------- Focus Session ---------- */
.focus-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.focus-panel .panel-header { width: 100%; }
.focus-meta { font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 14px; }

.focus-ring-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto 18px; }
.focus-ring { width: 190px; height: 190px; transform: rotate(-90deg); }
.focus-ring-bg { fill: none; stroke: var(--bg); stroke-width: 10; }
.focus-ring-fill {
  fill: none; stroke: var(--purple); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 552.9; stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.focus-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 22px; }
.focus-time { font-size: 34px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; line-height: 1; }
.focus-status { font-size: 11px; color: var(--text-secondary); margin-top: 8px; line-height: 1.4; }

.focus-duration-select { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
.dur-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  transition: var(--transition);
}
.dur-btn:hover { border-color: var(--purple); color: var(--purple); }
.dur-btn.active { background: var(--purple); border-color: var(--purple); color: #fff; }

.focus-secondary-actions { display: flex; gap: 10px; width: 100%; margin-top: 10px; }
.focus-secondary-actions .btn-outline-half { margin-top: 0; }

.session-history-link { margin-top: 14px; }

/* ---------- AI Coach Sidebar (fixed right column) ---------- */
.coach-sidebar {
  width: var(--coach-width);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  padding: 28px 20px 20px 0;
  z-index: 1010;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, visibility 0.3s ease;
}

.coach-panel-fixed {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.coach-title-row { display: flex; align-items: center; gap: 10px; }
.coach-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), #A594F9);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 4px; }

.coach-body { flex: 1; overflow-y: auto; padding-right: 2px; }
.coach-body::-webkit-scrollbar { width: 4px; }
.coach-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.coach-greeting {
  background: var(--purple-soft);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.coach-quick-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.coach-action-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); text-align: left; transition: var(--transition); width: 100%;
}
.coach-action-card:hover { border-color: var(--purple); background: var(--purple-soft); transform: translateX(3px); }
.coach-action-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.coach-action-title { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.coach-action-desc { font-size: 10.5px; color: var(--text-muted); margin-top: 1px; }

.coach-recent-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 10px; }

.coach-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 12px;
  font-size: 12px;
}
.coach-search-bar i { color: var(--text-muted); }
.coach-search-bar input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-size: 12px;
  width: 100%;
}

.study-conversations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.study-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.study-history-item:hover {
  border-color: var(--purple);
  background: var(--surface);
}
.study-history-item.active {
  background: var(--purple-soft);
  border-color: var(--purple);
}
.study-history-item i {
  color: var(--purple);
  font-size: 14px;
}
.history-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.history-title-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-details span {
  font-size: 10px;
  color: var(--text-muted);
}
.history-item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}
.study-history-item:hover .history-item-actions {
  opacity: 1;
}
.history-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 4px;
  cursor: pointer;
}
.history-action-btn:hover {
  color: var(--purple);
}

.history-empty {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 12px 6px;
}

.coach-recent-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; padding: 9px 4px; border-radius: var(--radius-sm); transition: var(--transition);
  text-align: left;
}
.coach-recent-item:hover { background: var(--bg); }
.coach-recent-item i { color: var(--purple); font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.recent-item-title { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.recent-item-time { font-size: 10.5px; color: var(--text-muted); }

.view-all-chats { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }

.coach-thread { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

/* Chat Msg & Markdown Rendering */
.chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: msgPop 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-msg.user-msg {
  flex-direction: row-reverse;
}
.chat-msg .bot-avatar, .chat-msg .user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.chat-msg .bot-avatar { background: var(--purple); color: #fff; }
.chat-msg .user-avatar { background: var(--blue-soft); color: var(--blue); }

.msg-bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-primary);
  max-width: 88%;
}
.user-msg .msg-bubble {
  background: var(--purple-soft);
  border-color: rgba(108, 92, 231, 0.15);
  border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
}

.msg-text-body p { margin-bottom: 6px; }
.msg-text-body p:last-child { margin-bottom: 0; }
.msg-text-body h1, .msg-text-body h2, .msg-text-body h3, .msg-text-body h4 {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--purple);
  margin-top: 8px;
  margin-bottom: 4px;
}
.msg-text-body ul, .msg-text-body ol {
  padding-left: 18px;
  margin-bottom: 6px;
}
.msg-text-body li { margin-bottom: 2px; }
.msg-text-body blockquote {
  border-left: 3px solid var(--purple);
  padding-left: 8px;
  margin: 6px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Code block wrapper */
.code-block-wrapper {
  background: #1e1e2e;
  border-radius: 8px;
  overflow: hidden;
  margin: 8px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  font-size: 11px;
  color: #a6adc8;
}
.code-copy-btn {
  background: none;
  border: none;
  color: #a6adc8;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.code-copy-btn:hover { color: #fff; }
.code-block-wrapper pre {
  margin: 0;
  padding: 10px;
  background: transparent;
  color: #cdd6f4;
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
}

/* Table wrapper */
.table-scroll-wrapper {
  overflow-x: auto;
  margin: 8px 0;
}
.table-scroll-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table-scroll-wrapper th, .table-scroll-wrapper td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.table-scroll-wrapper th {
  background: var(--surface);
  font-weight: 700;
}

/* Message Actions */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.2s;
}
.chat-msg:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px;
  cursor: pointer;
}
.msg-action-btn:hover { color: var(--purple); }

/* Thinking / Typing Msg */
.thinking-msg .msg-bubble {
  background: var(--purple-soft);
  border-color: rgba(108, 92, 231, 0.2);
}

.coach-input-row {
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 12px;
}
.coach-input-row input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 10px 16px; font-size: 12.5px; outline: none; background: var(--bg); color: var(--text-primary);
}
.coach-input-row input:focus { border-color: var(--purple); }
.coach-send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; transition: var(--transition);
}
.coach-send-btn:hover { background: var(--purple-dark); }

/* ---------- Danger button variant ---------- */
.btn-danger-solid { background: #EF4444 !important; border-color: #EF4444 !important; }
.btn-danger-solid:hover { background: #DC2626 !important; }

/* ---------- Modal theming ---------- */
.modal-content {
  background: var(--surface);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.form-label { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); }
.form-control, .form-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.form-control:focus, .form-select:focus {
  background: var(--bg); color: var(--text-primary);
  border-color: var(--purple); box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}
.session-summary { display: flex; gap: 10px; margin-bottom: 18px; }
.session-summary-item { flex: 1; background: var(--bg); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.ss-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.ss-value { font-size: 16px; font-weight: 800; color: var(--text-primary); }
.btn-lg-start { padding: 13px; font-size: 14.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1350px) {
  .plan-chart-grid { grid-template-columns: 1fr; }
  .tabs-focus-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1199px) {
  :root { --coach-width: 300px; }
}

@media (max-width: 991px) {
  body.study-page .main-content { margin-right: 0; }
  .coach-sidebar {
    position: static;
    width: 100%;
    padding: 0 18px 24px;
  }
  .coach-panel-fixed { height: auto; max-height: 520px; }
  .app-shell { flex-direction: column; }
  .subject-card { flex: 0 0 200px; }
}

@media (max-width: 767px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .action-row { flex-direction: column; }
  .btn-auto { width: 100%; }
  .chart-stats-row { flex-direction: column; }
  .chapter-item { flex-wrap: wrap; }
  .chapter-name { flex: 1 1 100%; }
  .chapter-status-text { width: auto; text-align: left; }
}

/* ---------- AI Study Coach Minimize States & Floating Icon ---------- */

/* Smoothly transitions the chatbot's slide-out and layout resizing */
body.study-page.coach-minimized .main-content {
  margin-right: 0;
}

body.coach-minimized .coach-sidebar {
  transform: translateX(120%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Floating AI assistant icon styles */
.ai-floating-icon {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), #A594F9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
  cursor: grab;
  z-index: 2000;
  user-select: none;
  touch-action: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-floating-icon:active {
  cursor: grabbing;
}

.ai-floating-icon-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Pulse animation */
.ai-floating-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.6);
  animation: floatingPulse 2s infinite;
  pointer-events: none;
}

@keyframes floatingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.6);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(108, 92, 231, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(108, 92, 231, 0);
  }
}

.ai-floating-icon:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.5);
}

@media (max-width: 991px) {
  body.coach-minimized .coach-sidebar {
    transform: none;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
    overflow: hidden;
  }
}

/* ---------- Empty State Styling ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  width: 100%;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  color: var(--purple);
  margin-bottom: 12px;
  animation: emptyStateFloat 3s ease-in-out infinite;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  max-width: 280px;
  margin: 0 auto;
}

@keyframes emptyStateFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
