/* static/style.css */

/* --- THE DESIGN SYSTEM --- */
/* This is the heart of the new look. I've chosen a palette that's friendly
   and professional. The primary blue is trustworthy, the accent is energetic,
   and the neutrals are clean and ensure readability for all ages. */
:root {
  /* Pastel, kid-friendly theme */
  --topnav-h: 64px;
  --composer-h: 64px;
  /* Space reserved at the bottom so messages don't hide behind mic/composer */
  --bottom-ui-space: 120px; /* lighter default; we will also auto-lift mic when needed */
  --lift-distance: 160px;
  --primary-color: #3FD9F8; /* Light brand */
  --primary-hover: #2EBDE4;
  --accent-color: #FDE68A;  /* Soft yellow */
  --accent-hover: #FCD34D;

  --bg-light: #F8FAFC;
  --bg-white: #FFFFFF;

  --text-dark: #0F172A;
  --text-body: #334155;
  --text-light: #FFFFFF;
  --text-subtle: #94A3B8;

  --border-color: #E5E7EB;

  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.04);
  --shadow-md: 0 6px 12px rgba(2, 6, 23, 0.06);
  --shadow-lg: 0 12px 24px rgba(2, 6, 23, 0.08);

  --border-radius-md: 10px;
  --border-radius-lg: 18px;
  --border-radius-full: 9999px;

  /* Typography */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-heading: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  /* Back-compat alias for existing rules */
  --font-family: var(--font-body);
}

/* --- GLOBAL STYLES & RESETS --- */
/* This ensures a consistent base across all browsers. */
body {
  margin: 0;
  font-family: var(--font-family);
  background:
    radial-gradient(1200px 600px at -10% -20%, #E0F2FE 0%, rgba(224,242,254,0) 60%),
    radial-gradient(1000px 500px at 110% -10%, #FEF3C7 0%, rgba(254,243,199,0) 55%),
    var(--bg-light);
  color: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Generic container helper for page content */
.container { margin: 0 auto; padding: 1rem; }

/* --- GLOBAL BASELINE IMPROVEMENTS --- */
/* Consistent box sizing across the board */
*, *::before, *::after { box-sizing: border-box; }

/* Responsive media by default */
img, svg, video, canvas { max-width: 100%; height: auto; }

/* Make native form controls inherit typography */
button, input, select, textarea { font: inherit; color: inherit; }

/* Brand the native controls (checkbox/radio/progress) */
input[type="checkbox"], input[type="radio"], progress, meter { accent-color: var(--primary-color); }

/* Friendly, accessible link defaults */
a { color: var(--text-dark); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--primary-hover); }

/* Default size/alignment for Phosphor icons */
i.ph { font-size: 18px; line-height: 1; display: inline-block; }

/* Improve text selection contrast */
::selection { background: rgba(147, 197, 253, 0.35); color: #0f172a; }

/* Help user agents theme native UI in dark mode */
body { color-scheme: light; }
body[data-color-scheme="dark"] { color-scheme: dark; }

/* Headings use the display font */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

/* Fluid, sensible heading sizes */
h1 { font-size: clamp(2rem, 1.25rem + 2vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 1.05rem + 1.5vw, 2rem); }
h3 { font-size: clamp(1.25rem, 1rem + 1vw, 1.5rem); }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

/* Balance multi-line big headings for nicer wraps */
h1, h2 { text-wrap: balance; }

/* Accessible focus states */
*:focus-visible {
  outline: 3px solid rgba(35, 76, 181, 0.5);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Subtle custom scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #F1F5F9; }
*::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
*::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* --- HEADER & NAVIGATION (Khan-like) --- */
.topnav {
  height: var(--topnav-h);
  line-height: var(--topnav-h);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  background-color: #0f172a; /* deep navy */
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 0.95rem;
  color: #e2e8f0;
  text-decoration: none;
}
.brand span { font-family: var(--font-heading); font-weight: 800; letter-spacing: 0.2px; }
.brand:hover { color: #ffffff; }
.brand-mark { width: 28px; height: 28px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.25)); }

/* Global student picker in header */
.header-student-picker { margin-left: 10px; display: inline-flex; align-items: center; gap: 6px; }
.header-student-picker select {
  min-width: 180px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.1);
  color: #e5e7eb;
  padding: 4px 8px;
}
.header-student-picker select option { color: #0f172a; background: #ffffff; }

.main-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #e5e7eb;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.main-nav a:hover { color: #ffffff; background-color: rgba(255,255,255,0.06); }
.main-nav a.active { color: #ffffff; background-color: rgba(35,76,181,0.25); }

/* Hamburger for small screens */
.hamburger {
  display: none;
  background: transparent;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  flex-direction: column; /* stack lines vertically */
  gap: 4px; /* spacing between lines */
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #e5e7eb;
  border-radius: 2px;
}

/* Generic buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; border: 0; cursor: pointer; border-radius: 10px; padding: 10px 14px; text-decoration: none; }
.btn-pill { border-radius: 999px; }
.btn-block { width: 100%; }
.btn-primary { color: #0f172a; background: linear-gradient(180deg, #3FD9F8, #2EBDE4); box-shadow: 0 8px 14px rgba(35,76,181,0.25); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { color: #111827; background: linear-gradient(180deg, #fde68a, #fcd34d); }
.btn-subtle { color: #e5e7eb; background: rgba(255,255,255,0.08); }
.btn-subtle:hover { background: rgba(255,255,255,0.12); }

/* Generic inputs */
.input { width: 100%; padding: 0.875rem 1rem; border: 1px solid var(--border-color); border-radius: var(--border-radius-md); background: #fff; font-family: var(--font-family); font-size: 1rem; }
.input::placeholder { color: var(--text-subtle); }
.input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2); }
.input-underline { border: 0; border-bottom: 2px solid var(--border-color); border-radius: 0; padding-left: 0; }
.input-underline:focus { border-bottom-color: var(--primary-color); box-shadow: none; }


/* --- LOGIN PAGE --- */
/* A more welcoming and focused login screen with playful animations. */
.welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100vh;
  padding: 2rem;
  box-sizing: border-box;
}

.welcome-container .logo {
  animation: float 4s ease-in-out infinite;
}

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

.welcome-container h1 {
  font-size: 2.5rem;
  color: var(--text-dark);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.welcome-container p {
  font-size: 1.1rem;
  color: var(--text-body);
  max-width: 450px;
  margin-bottom: 2rem;
}

#loginForm {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 350px;
  gap: 1rem;
}

#loginForm input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
  background-color: #FFFFFF; /* force light background for readability */
  color: var(--text-dark);   /* ensure strong text contrast */
}
#loginForm input::placeholder {
  color: #64748b; /* slightly darker than subtle for better legibility */
}

#loginForm input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2);
}

/* Keep login inputs readable even when OS/browser is in dark mode */
body[data-color-scheme="dark"] #loginForm input {
  background-color: #FFFFFF;
  color: var(--text-dark);
  border-color: var(--border-color);
}

/* Improve readability for WebKit autofill/dark-mode theming */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-dark) !important;
  -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
  box-shadow: 0 0 0px 1000px #ffffff inset !important;
}

#loginForm button {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-md);
  background-color: var(--primary-color);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: var(--shadow-sm);
}

#loginForm button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.error-message {
  color: #DC2626; /* A strong red for errors */
  font-weight: 500;
}

/* --- REGISTER PAGE (match login look/feel) --- */
#registerForm {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 450px;
  gap: 1rem;
}

#registerForm input,
#registerForm select {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-sizing: border-box;
  background-color: #FFFFFF; /* match login readability */
  color: var(--text-dark);
  transition: all 0.2s ease-in-out;
}

#registerForm input::placeholder {
  color: #64748b; /* slightly darker for legibility */
}

#registerForm input:focus,
#registerForm select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2);
}

#registerForm button {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-md);
  background-color: var(--primary-color);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: var(--shadow-sm);
}

#registerForm button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}


/* --- DASHBOARD --- */
/* The dashboard cards are cleaner, with better spacing and hover effects. */
.dashboard {
  padding: 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-message {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.card, .kid-card {
  background-color: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  text-align: center;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.card-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #DBEAFE, #FEF3C7);
}
.card-icon svg {
  color: var(--primary-color);
}

.card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  color: var(--text-dark);
}

.card p {
  margin: 0 0 1.5rem 0;
  color: var(--text-body);
  flex-grow: 1; /* This makes cards in the same row equal height */
}

.card-button {
  display: inline-block;
  text-decoration: none;
  font-weight: 700;
  color: var(--text-light);
  background-color: var(--primary-color);
  padding: 0.625rem 1.25rem;
  border-radius: var(--border-radius-full); /* Pill shape */
  transition: all 0.2s ease-in-out;
}

.card-button:hover {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}


/* --- CHAT PAGE --- */
/* Major overhaul here: sidebar, main chat area, and the new subject bar. */
.chat-container {
  display: flex;
  height: calc(100vh - var(--topnav-h));
  max-width: 1400px;
  margin: 0 auto;
  background-color: var(--bg-white);
  box-shadow: var(--shadow-sm);
  border-left: none;
  border-right: none;
}

/* Sidebar for past chats */
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  background-color: var(--bg-light);
  padding: 1rem;
  border-right: 1px solid rgba(226, 232, 240, 0.8);
  overflow-y: auto;
  position: sticky;
  top: var(--topnav-h);
  height: calc(100vh - var(--topnav-h));
}

.chat-sidebar .close-btn { position: absolute; right: 8px; top: 8px; border: 0; background: rgba(2,6,23,0.06); color: #0f172a; width: 32px; height: 32px; border-radius: 8px; font-weight: 900; cursor: pointer; }
.chat-sidebar .close-btn:hover { background: rgba(2,6,23,0.1); }

.chat-sidebar h3, .sidebar-title {
  margin-top: 0;
  margin-bottom: 1rem;
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 800;
  padding-left: 0.25rem;
}

/* New Chat button styling (matches theme) */
.chat-sidebar .new-chat-button {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem 0;
  padding: 0.6rem 0.9rem;
  border: none;
  border-radius: var(--border-radius-full);
  background-color: var(--primary-color);
  color: var(--text-light);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.08s ease;
}
.chat-sidebar .new-chat-button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.chat-sidebar .new-chat-button:active {
  transform: translateY(0);
}

#sessionList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sessionList li a {
  display: block;
  padding: 0.75rem;
  text-decoration: none;
  color: var(--text-body);
  border-radius: var(--border-radius-md);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.2s, color 0.2s;
}

#sessionList li a:hover {
  background-color: #E2E8F0; /* Subtle hover */
}
#sessionList li a.active {
  background-color: var(--primary-color);
  color: var(--text-light);
  font-weight: 700;
}

/* Main chat area containing the subject, window, and form */
.chat-main-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevents flexbox overflow issues */
}

/* NEW: Subject bar at the top of the chat */
.subject-bar {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6);
  background-color: var(--bg-white);
  position: sticky;
  top: 0;
  z-index: 5;
}

/* Subject bar layout: full-width on desktop; stacked on mobile via media query */
.subject-bar-row {
  display: grid;
  grid-template-columns: 1fr max-content;
  grid-auto-columns: 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
}
.subject-ctl {
  display: flex;
  flex-direction: column; /* Stack children vertically */
  gap: 4px; /* Adjust gap for vertical spacing */
  flex: 1;
  width: 100%;
  align-items: center; /* Center horizontally */
}
.student-ctl { display:flex; flex-direction:column; gap:4px; align-items:flex-end; }
.student-ctl .label { font-size: .85rem; font-weight:800; color:#64748b; }
.student-ctl select { min-width: 220px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius:10px; background:#fff; }
.subject-ctl .label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748b;
  margin-bottom: 4px; /* Add space below the label */
}
.subject-input {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  flex: 1;
}
.mobile-only { display: none; }

#subjectInput {
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1.125rem;
  font-family: var(--font-family);
  font-weight: 700;
  color: var(--text-dark);
  background: #F8FAFC;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  cursor: text;
}
/* Encourage interaction */
#subjectInput:hover {
  border-color: var(--primary-color);
  background: #EFF6FF;
  box-shadow: var(--shadow-md);
}
#subjectInput:not(textarea) { line-height: 1.2; }
textarea#subjectInput {
  display: block;
  line-height: 1.35;
  min-height: 2.8em; /* show ~2 lines by default */
  resize: none; /* keep layout stable */
  overflow: auto;
  width: 100%;
}
#subjectInput:focus {
  outline: none;
  border-color: var(--primary-color);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2);
}
#subjectInput::placeholder {
  color: var(--text-subtle);
  font-weight: 500;
}

.subject-help {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.9rem;
  color: #475569;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 6px 8px;
  border-radius: 8px;
}
.subject-help .emoji {
  font-size: 1.1rem;
  animation: sparkle 2s ease-in-out infinite;
}

/* The window where messages appear */
.chat-window {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column; /* messages begin right under subject */
  background-image:
    radial-gradient(circle at 20px 20px, rgba(203,213,225,0.25) 2px, transparent 2px);
  background-size: 22px 22px;
  scroll-padding-bottom: var(--bottom-ui-space); /* ensure last message isn't hidden under mic */
}

/* Create guaranteed space at the bottom of the message list so the mic/composer never overlap text */
#messages::after {
  content: "";
  display: block;
  height: calc(var(--bottom-ui-space) + 24px);
}

#messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem; /* Tighter gap between messages */
}

#messages li {
  display: flex;
  max-width: 80%;
  animation: slide-in 0.3s ease-out forwards;
  margin-top: 0.75rem;
  align-items: center;
  position: relative; /* For mascot positioning */
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#messages li span {
  padding: 0.75rem 1rem;
  border-radius: 18px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

.tutor-message {
  align-self: flex-start;
}
.tutor-message span {
  background-color: #F1F5F9;
  color: var(--text-dark);
  border-top-left-radius: 4px;
}

.user-message {
  align-self: flex-end;
}
.user-message span {
  background: linear-gradient(135deg, #BFDBFE, #FDE68A);
  color: #0f172a;
  border-top-right-radius: 4px;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* The form for sending messages */
.chat-form {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  gap: 0.75rem;
}

.input-wrapper {
  flex-grow: 1;
  position: relative;
}

#messageText {
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--border-color);
  padding: 0.75rem 3rem 0.75rem 1.25rem; /* Right padding for buttons */
  font-size: 1rem;
  font-family: var(--font-family);
  transition: all 0.2s ease-in-out;
}
#messageText:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2);
}
#messageText::placeholder {
  color: var(--text-subtle);
}

.chat-form .input-buttons {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.25rem;
}

.chat-form button {
  border: none;
  background-color: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease-in-out;
}
.chat-form button:hover {
  color: var(--text-body);
  background-color: #F1F5F9;
}

.chat-form button#sendButton {
  background-color: var(--primary-color);
  color: var(--text-light);
}
.chat-form button#sendButton:hover {
  background-color: var(--primary-hover);
}

.play-audio-btn {
  background-color: var(--accent-color);
  color: white;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  margin-left: 10px;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease-in-out;
  box-shadow: var(--shadow-sm);
}
.play-audio-btn:hover {
  background-color: var(--accent-hover);
  transform: scale(1.1);
}

.message-mascot {
    position: absolute;
    top: -42px; /* Float above the bubble */
    left: 10px;
    width: 48px; /* Bigger size */
    z-index: 2;
    pointer-events: none;
    transform-origin: bottom center;
}

/* --- PROFILE PAGE --- */
.profile-container {
  max-width: 600px;
  margin: 2rem auto;
  padding: 2.5rem;
  background-color: var(--bg-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

.profile-container h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text-dark);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-sizing: border-box;
  font-family: var(--font-family);
  background-color: #F8FAFC;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(35, 76, 181, 0.2);
  background-color: var(--bg-white);
}

#profileForm button {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-md);
  background-color: var(--primary-color);
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}
#profileForm button:hover {
  background-color: var(--primary-hover);
}

.save-message {
  text-align: center;
  margin-top: 1rem;
  color: var(--primary-hover);
  font-weight: 500;
  opacity: 0;
  transition: opacity .3s ease;
}

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

/* Student dropdown row */
.student-picker {
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 8px;
  align-items: center;
}
.student-picker select#studentSelect {
  min-height: 44px;
  font-weight: 700;
  background: #fff;
  border-radius: 12px;
}
.student-picker #addStudentBtn {
  padding: 10px 12px;
  white-space: nowrap;
}

/* Account vs Student separation */
.profile-context { display:flex; justify-content:center; margin-bottom: 0.5rem; }
.context-badge { display:inline-flex; align-items:center; gap:6px; font-weight:800; padding:6px 10px; border-radius:999px; font-size:.85rem; border:1px solid var(--border-color); }
.badge-account { background:#ecfeff; color:#0e7490; border-color:#a5f3fc; }
.badge-student { background:#fef3c7; color:#92400e; border-color:#fde68a; }

.profile-card { margin: 1.25rem 0; padding:1.25rem; border:1px solid var(--border-color); border-radius: 12px; background:#fff; box-shadow: var(--shadow-sm); }
.profile-card.account { border-left: 6px solid #06b6d4; }
.profile-card.student { border-left: 6px solid #f59e0b; }
.profile-card h2 { margin-top:0; display:flex; align-items:center; gap:8px; }
.profile-card .form-actions { display:flex; flex-direction:column; gap:8px; align-items:flex-start; }

.profile-card.student.dimmed { opacity: .85; filter: saturate(.95); }
.profile-card.account.dimmed { opacity: .85; filter: saturate(.95); }

.profile-card.student.active { box-shadow: var(--shadow-md); outline: 3px solid rgba(245, 158, 11, 0.25); }
.profile-card.account.active { box-shadow: var(--shadow-md); outline: 3px solid rgba(6, 182, 212, 0.25); }

.context-inline-note { font-size:.9rem; color:#475569; margin: 0 0 0.5rem 0; }

.personalizations-help, .parents-portal, .learning-profile-display {
  margin-top: 2.5rem;
  padding: 1.5rem;
  background-color: var(--bg-light);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
}
.personalizations-help h2, .parents-portal h2, .learning-profile-display h2 {
    margin-top: 0;
    color: var(--text-dark);
}
.personalizations-help code {
    background-color: #E2E8F0;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.form-group small {
    font-size: 0.875rem;
    color: var(--text-subtle);
    margin-top: 0.25rem;
    display: block;
}
input:disabled {
    background: #F1F5F9;
    cursor: not-allowed;
    opacity: 0.7;
}

.learning-profile-display .quiz-summary-card {
    background: linear-gradient(135deg, #EFF6FF, #FEF3C7);
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
    border: 1px solid rgba(0,0,0,0.05);
}

/* Add Student modal */
.profile-modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.profile-modal-card {
  background: #fff; color: var(--text-dark);
  width: 100%; max-width: 420px; border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 16px 16px 14px;
}
.readonly-row { display:flex; align-items:center; justify-content: space-between; gap: 8px; }
.readonly-row #gradeDisplay { font-weight: 700; }
.inline-edit { display:grid; grid-template-columns: 1fr max-content; gap: 8px; align-items:center; }
.quiz-summary-card h4 { margin-top: 0; color: #1E40AF; }
.policy-highlights { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.policy-item { display: flex; align-items: center; gap: 0.5rem; background: rgba(255,255,255,0.5); padding: 0.5rem 0.75rem; border-radius: 999px; }
.policy-item i { color: #1D4ED8; }

.quiz-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.quiz-detail-card {
    background: #FFFFFF;
    padding: 1rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}
.quiz-detail-card h5 { margin-top: 0; color: var(--text-dark); }
.quiz-detail-card ul { padding-left: 1.25rem; margin: 0; }

.score-item {
    display: grid;
    grid-template-columns: 100px 1fr 50px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.score-label { font-weight: 500; }
.score-bar-container { background: #E2E8F0; height: 8px; border-radius: 999px; overflow: hidden; }
.score-bar { height: 100%; border-radius: 999px; }
.score-bar.low { background: #F87171; }
.score-bar.medium { background: #FBBF24; }
.score-bar.high { background: #34D399; }
.score-band { font-weight: 600; text-transform: capitalize; }
.score-band.low { color: #B91C1C; }
.score-band.medium { color: #B45309; }
.score-band.high { color: #047857; }

/* --- RECORDING MODAL --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-content {
  text-align: center;
  color: var(--text-light);
}

/* Simple toast utility */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #111827;
  color: #f8fafc;
  border-radius: 12px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  z-index: 2000;
}
@media (prefers-color-scheme: light) {
  .toast { background: #0f172a; color: #e5e7eb; }
}

.stop-btn {
  margin-top: 18px;
  background: #ef4444;
  color: #fff;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 999px;
  font-size: 22px;
  box-shadow: 0 6px 18px rgba(239,68,68,.35);
  cursor: pointer;
}
.stop-btn:hover { filter: brightness(1.05); }
.stop-btn:active { transform: translateY(1px); }

.mic-icon-container {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background-color: var(--accent-color);
  display: flex;
  justify-content: center;
  align-items: center;
  animation: pulse-mic 1.5s infinite;
  box-shadow: var(--shadow-lg);
}
/* --- UTILITIES & ANIMATIONS --- */
@keyframes float {
	0%, 100% { transform: translateY(0px); }
	50% { transform: translateY(-15px); }
}

@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-mic {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 20px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
}
.typing-indicator span {
    height: 8px;
    width: 8px;
    background-color: var(--text-subtle);
    border-radius: 50%;
    margin: 0 2px;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* --- PARENTS PAGE --- */
.parents-actions {
  margin: 1rem 0;
  display: flex;
  gap: 10px;
}
.parents-actions button, .parents-actions a.button-link {
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}
.parents-actions button.secondary {
  background: #6B7280;
}

.parents-summary-list {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.parents-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  border-left: 5px solid transparent;
}
.parents-card.safe { border-left-color: #10B981; }
.parents-card.danger { border-left-color: #EF4444; }
.parents-card .meta { font-size: 0.9rem; color: #6B7280; margin-bottom: 6px; }
.parents-card .title { font-weight: 700; margin-bottom: 6px; }
.parents-card .reason { font-size: 0.95rem; color: #374151; }

/* Gentle notices and gating banners */
.notice-card { border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; background: #f8fafc; }
.notice-banner { margin: 8px 12px; padding: 12px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; color: #7c2d12; }

#recordButton.is-recording {
  color: #EF4444; /* Red-500 */
  background-color: #FEF2F2; /* Red-50 */
}

/* --- PARENT REPORT RENDERER --- */
.parent-report {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 0.75rem;
  font-family: var(--font-body);
}
.parent-report .report-header {
  display: grid;
  gap: 6px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.parent-report .report-title { font-weight: 800; font-size: 1rem; }
.parent-report .chips { display: flex; gap: 8px; flex-wrap: wrap; }
.parent-report .chip {
  font-size: 0.82rem; padding: 6px 10px; border-radius: 999px; background: #eef2ff; color: #3730a3; box-shadow: 0 1px 0 rgba(2,6,23,0.06);
}
.parent-report .chip.ok { background: #ecfeff; color: #155e75; }
.parent-report .chip.great { background: #ecfdf5; color: #065f46; }
.parent-report .chip.warn { background: #fff7ed; color: #9a3412; }
.parent-report .chip.danger { background: #fef2f2; color: #991b1b; }
.parent-report .why { color: #334155; font-size: 0.9rem; }
.parent-report h2 { font-size: 1.05rem; margin: 0.75rem 0 0.35rem; color: #0b3b5e; }
.parent-report h3 { font-size: 1rem; margin: 0.6rem 0 0.3rem; }
.parent-report p { margin: 0.4rem 0; line-height: 1.5; }
.parent-report ul { margin: 0.4rem 0 0.6rem 1.2rem; }
.parent-report .kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px; padding: 6px 10px; background: #f8fafc; border-radius: 8px; margin: 6px 0; }
.parent-report .kv .k { font-weight: 700; color: #334155; }
.parent-report .kv .v { color: #0f172a; }

/* Banner flair */
.parent-report .fancy-banner {
  background: linear-gradient(120deg, #eef2ff 0%, #e0f2fe 40%, #fff7ed 100%);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(2,6,23,0.05);
}

/* Subcards to soften sections */
.parent-report .subcard {
  background: #fafafa;
  border: 1px solid #eaeaea;
  border-radius: 14px;
  padding: 10px 12px;
  margin: 10px 0;
  box-shadow: 0 1px 0 rgba(2,6,23,0.04);
}

/* --- BIG MIC: Kid-first voice UI --- */
:root {
  --brand-1: #3FD9F8;
  --brand-2: #234CB5;
  --accent: #ff9f59;
  --ok: #56c288;
  --ink: #24324a;
  --bg: #fff7fb;
  --white: #ffffff;
  --shadow-strong: 0 14px 44px rgba(36, 50, 74, 0.25);
}

.big-mic-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  gap: 6px;
  z-index: 1000;
  width: min(92vw, 560px);
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
.big-mic-wrap.hide-into-composer { opacity: 0; pointer-events: none; transform: translate(-50%, 20px) scale(0.85); }
.big-mic-wrap.peek { opacity: 1; transform: translate(-50%, -8px) scale(0.96); }

.big-mic-wrap.lift { transform: translate(-50%, calc(-1 * var(--lift-distance))); }
.big-mic-wrap.lift .big-mic { transform: scale(.92); }

/* Side decorations instead of tall floating banner */
.fun-side { position: absolute; bottom: 60px; width: 64px; height: 120px; pointer-events: none; opacity: .85; }
.fun-left { left: -8px; }
.fun-right { right: -8px; }

.confetti circle {
  fill: var(--accent);
  opacity: 0.8;
  animation: drift 6s ease-in-out infinite;
}
.confetti circle:nth-child(2) { fill: #5be7a9; animation-delay: .4s; }
.confetti circle:nth-child(3) { fill: #ff7aa2; animation-delay: .8s; }
.confetti circle:nth-child(4) { fill: #ffd166; animation-delay: 1.2s; }
.confetti circle:nth-child(5) { fill: #76a9ff; animation-delay: 1.6s; }
.confetti circle:nth-child(6) { fill: #9b87f5; animation-delay: 2s; }

@keyframes drift {
  0%,100% { transform: translateY(0) }
  50% { transform: translateY(-12px) }
}

.big-mic {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: clamp(88px, 18vw, 132px);
  height: clamp(88px, 18vw, 132px);
  border-radius: 999px;
  border: none;
  color: var(--white);
  background: radial-gradient(60% 60% at 40% 35%, #8ae0ff, #5ea8ff),
              conic-gradient(from 210deg, var(--brand-1), var(--brand-2), var(--brand-1));
  box-shadow: 0 16px 44px rgba(36, 50, 74, 0.35), inset 0 0 0 6px rgba(255,255,255,0.55);
  position: relative;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, filter .2s ease;
  isolation: isolate;
}

.big-mic .mic-icon {
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.25));
}

.big-mic .rings .ring {
  position: absolute;
  inset: -8px;
  border-radius: 999px;
  border: 4px solid rgba(35,76,181,.45);
  transform: scale(0.8);
  opacity: 0;
  animation: pulse 2.2s ease-out infinite;
  z-index: -1;
}

.big-mic .rings .r2 { animation-delay: .5s; }
.big-mic .rings .r3 { animation-delay: 1s; }

@keyframes pulse {
  0% { transform: scale(.8); opacity: 0.6; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.big-mic:hover { transform: translateY(-2px) scale(1.02); }
.big-mic:active { transform: scale(.98); }

.big-mic.recording {
  background: conic-gradient(from 0deg, #ff7aa2, #ffbe5c, #ff7aa2);
  animation: throb 1s ease-in-out infinite;
  box-shadow: 0 18px 60px rgba(255, 122, 162, 0.45);
}

@keyframes throb {
  0%,100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

/* Hide floating hint to save vertical space on mobile */
.mic-hint { display: none; }

.mic-hint .sparkle { animation: sparkle 1.8s ease-in-out infinite; }
@keyframes sparkle {
  0%,100% { transform: rotate(0deg) scale(1); opacity: .9 }
  50% { transform: rotate(12deg) scale(1.15); opacity: 1 }
}

/* Remove toggle-composer visuals (composer always visible) */
.toggle-composer { display: none !important; }

.composer {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr max-content;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 10px 10px;
  box-shadow: var(--shadow-sm);
  transform-origin: bottom;
  transition: grid-template-rows .2s ease, opacity .2s ease, transform .2s ease, max-height .2s ease;
  backdrop-filter: blur(2px);
}

.composer.collapsed { opacity: 1; transform: none; max-height: none; padding: 10px; pointer-events: auto; }

.composer input {
  border: 2px solid rgba(36,50,74,.08);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  background: #f8fafc;
  min-width: 0; /* prevent overflow into the send button column */
  height: 48px;
  box-sizing: border-box;
}

.composer button {
  border: none;
  background: linear-gradient(135deg, #234CB5, #3FD9F8);
  color: #fff;
  font-weight: 800;
  border-radius: 12px;
  padding: 0 14px;
  height: 48px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .08s ease, filter .2s ease;
}
.composer button:hover { filter: brightness(1.05); }
.composer button:active { transform: translateY(2px); }

/* Make room above the mic/composer without creating a huge gap */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-window {
    padding-bottom: calc(var(--bottom-ui-space) + env(safe-area-inset-bottom));
  }
}
@supports not (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-window {
    padding-bottom: var(--bottom-ui-space);
  }
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
  /* Slightly more reserve on small screens to account for larger tap targets */
  :root { --bottom-ui-space: 160px; --lift-distance: 180px; }
  .hamburger { display: inline-flex; }
  .main-nav {
    position: absolute;
    right: 8px;
    top: calc(var(--topnav-h) + 8px); /* small offset below header */
    background: #0f172a;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    padding: 10px;
    display: none;
    z-index: 120;
    min-width: 200px; /* comfortable width */
    box-shadow: 0 12px 24px rgba(2,6,23,0.35);
  }
  .main-nav.open { display: block; }
  .main-nav ul { display: grid; gap: 8px; }
  .main-nav a { padding: 12px 14px; display: block; }
  .header-student-picker select { min-width: 140px; }
  .dashboard { padding: 0.75rem; }
  .welcome-message { font-size: 1.75rem; }
  
  .chat-container { flex-direction: column; height: calc(100vh - var(--topnav-h)); }
  /* Slide-in sidebar on mobile */
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: var(--topnav-h);
    height: calc(100vh - var(--topnav-h));
    width: 80vw;
    max-width: 360px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid rgba(226, 232, 240, 0.8);
    border-bottom: none;
    box-shadow: 8px 0 28px rgba(2,6,23,0.22);
    z-index: 1002; /* above mic and composer */
    background: var(--bg-white);
    overflow-y: auto;
  }
  .chat-sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex !important; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,0.45); backdrop-filter: blur(2px); z-index: 1001; }
  .sidebar-backdrop[hidden] { display: none; }
  .chat-window { padding: 0.75rem; }
  .subject-bar { padding: 0.4rem 0.75rem; }
  /* Stack Previous Chats button above subject on narrow screens */
  .subject-bar-row { grid-template-columns: 1fr; gap: 6px; }
  .mobile-only { justify-self: start; }
  .chat-form { padding: 0.5rem 0.75rem; }
  #messages li { max-width: 90%; }

  .profile-container {
      margin: 1rem auto;
      padding: 1.5rem;
      border-radius: 0;
      box-shadow: none;
  }
}

/* Extra-small screens: shrink the big mic and tighten composer */
@media (max-width: 480px) {
  .big-mic { width: clamp(72px, 22vw, 96px); height: clamp(72px, 22vw, 96px); }
  .composer input { height: 44px; }
  .composer button { height: 44px; }
  :root { --bottom-ui-space: 180px; --lift-distance: 200px; }
}

/* Mic summon tab */
.mic-summon-tab {
  position: fixed;
  left: 50%;
  bottom: calc(6px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 999;
  background: #34d399;
  color: #0f172a;
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 28px;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(16,185,129,.35);
}
.mic-summon-tab[hidden] { display: none !important; }
.mic-summon-tab:hover { filter: brightness(1.05); }

/* --- QUIZ PAGE --- */
.quiz-page h1 { margin-bottom: 0.25rem; }
.quiz-page > p { margin-top: 0; color: #475569; }

/* Make the quiz card content left-aligned and comfortable */
.quiz-page .card {
  text-align: left;
  align-items: stretch;
  gap: 12px;
}
.quiz-page #quizForm.card { padding: 1.25rem 1.5rem; }

/* Sections spacing */
.quiz-page section { margin-top: 0.75rem; }
.quiz-page h2 { font-size: 1.1rem; margin: 0 0 0.35rem 0; color: #0b3b5e; }

/* Likert items layout: question on left, control on right */
.quiz-page #likertItems > .form-group {
  display: grid;
  grid-template-columns: 1fr max-content;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed #e2e8f0;
}
.quiz-page #likertItems > .form-group:last-child { border-bottom: 0; }
.quiz-page #likertItems label { margin: 0; font-weight: 600; color: var(--text-dark); }
.quiz-page #likertItems select {
  min-width: 84px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

/* Scenario choices: big, tappable pills */
.quiz-page .choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.quiz-page .choices label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
  position: relative;
  min-height: 40px;
  padding-left: 42px; /* room for custom radio */
}
.quiz-page .choices label:hover { background: #eff6ff; border-color: #c7d2fe; }
/* Hide native radio; keep it accessible */
.quiz-page .choices input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
/* Custom radio visuals */
.quiz-page .choices label::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.quiz-page .choices label::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--primary-color);
  transform: translateY(-50%) scale(0);
  transition: transform .15s ease;
}
/* Visual select state. :has has wide modern support; JS also adds .selected for broader coverage */
.quiz-page .choices label.selected,
.quiz-page .choices label:has(input:checked) {
  background: #dbeafe;
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
}
.quiz-page .choices label.selected::before,
.quiz-page .choices label:has(input:checked)::before {
  border-color: var(--primary-color);
}
.quiz-page .choices label.selected::after,
.quiz-page .choices label:has(input:checked)::after {
  transform: translateY(-50%) scale(1);
}

/* Form footer alignment */
.quiz-page #quizForm > .form-actions { justify-content: flex-start; }
.quiz-page #quizMessage { min-height: 1.25rem; }

/* Make sure content isn't tight to the edges on small screens */
@media (max-width: 768px) {
  .quiz-page { padding-left: 0.5rem; padding-right: 0.5rem; }
  .quiz-page #likertItems > .form-group { grid-template-columns: 1fr; gap: 8px; }
  .quiz-page #likertItems select { width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
  .quiz-page .choices label { flex: 1 1 100%; justify-content: space-between; }
}
.brand-logo{background-image:url('/static/logo-fun.svg');background-repeat:no-repeat;background-position:center;background-size:contain}

/* Chat page: consolidated enhancements */
.chat-container {
    position: relative;
    isolation: isolate;
    background:
        radial-gradient(800px 400px at 120% -10%, rgba(16, 170, 255, 0.10), transparent 60%),
        radial-gradient(700px 350px at -10% 0%, rgba(255, 99, 132, 0.10), transparent 60%);
}

.chat-sidebar {
    background: rgba(255, 255, 255, 0.76);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-window {
    background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* Messages list */
#messages {
    list-style: none;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#messages:empty {
    min-height: 240px;
    display: grid;
    place-items: center;
}

#messages:empty::before {
    content: "Start by choosing a subject above or say \201CHi\201D to begin!";
    color: rgba(0, 0, 0, 0.58);
    font-size: 0.95rem;
    text-align: center;
}

#messages > li {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78));
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    padding: 10px 12px;
    max-width: min(78ch, 92%);
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#messages > li:nth-child(even) {
    margin-left: auto;
    background: linear-gradient(180deg, rgba(16, 170, 255, 0.14), rgba(16, 170, 255, 0.10));
    border-color: rgba(16, 170, 255, 0.22);
}

#messages > li.from-user,
#messages > li.user,
#messages > li[data-role="user"] {
    margin-left: auto;
    background: linear-gradient(180deg, rgba(16, 170, 255, 0.14), rgba(16, 170, 255, 0.10));
    border-color: rgba(16, 170, 255, 0.22);
}

#messages > li.from-bot,
#messages > li.bot,
#messages > li[data-role="assistant"],
#messages > li[data-role="system"] {
    margin-right: auto;
}

/* Subject input styling */
.subject-input {
    min-height: 56px;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.subject-input:focus {
    outline: none;
    border-color: rgba(92, 52, 235, 0.5);
    box-shadow: 0 0 0 4px rgba(92, 52, 235, 0.14), inset 0 1px 2px rgba(0, 0, 0, 0.04);
    background-color: rgba(92, 52, 235, 0.02);
}

/* Suggestion chips */
.subject-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.subject-suggestions .chip {
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72));
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.85rem;
    color: inherit;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 80ms ease, box-shadow 120ms ease;
}

.subject-suggestions .chip:hover { transform: translateY(-1px); }
.subject-suggestions .chip:active { transform: translateY(0); }
.subject-suggestions .chip:focus-visible {
    outline: 3px solid rgba(16, 170, 255, 0.5);
    outline-offset: 2px;
}

/* Buttons inside chat page: gently enhance */
.chat-container .btn.btn-primary {
    background: linear-gradient(135deg, #5c34eb, #10aaff);
    color: #fff;
    border: 0;
    box-shadow: 0 8px 22px rgba(16, 170, 255, 0.22);
}
.chat-container .btn.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 10px 28px rgba(16, 170, 255, 0.28);
}

/* Big mic polish */
.big-mic {
    background: linear-gradient(135deg, #5c34eb, #10aaff);
    color: #fff;
    border: 0;
    box-shadow: 0 30px 60px rgba(16, 170, 255, 0.32);
}

.big-mic .ring { border-color: rgba(16, 170, 255, 0.28); }
.big-mic .rings .ring { animation: ripple 2.4s infinite; }
.big-mic .rings .r2 { animation-delay: 0.5s; }
.big-mic .rings .r3 { animation-delay: 1s; }

@keyframes ripple {
    0% { transform: scale(0.6); opacity: 0.65; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Keyboard hints and scroll-to-bottom */
.chat-container .kbd-hints {
    display: flex;
    gap: 12px;
    align-items: center;
    color: rgba(0, 0, 0, 0.54);
    font-size: 0.82rem;
    margin-top: 6px;
    padding: 0 6px;
}
.chat-container .kbd-hints kbd {
    background: rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.82em;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.4);
}
.chat-container .kbd-hints .or { opacity: 0.5; padding: 0 2px; }

.scroll-bottom {
    position: fixed;
    right: 20px;
    bottom: 132px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #5c34eb, #10aaff);
    color: #fff;
    border: 0;
    box-shadow: 0 10px 24px rgba(16, 170, 255, 0.25);
    cursor: pointer;
    z-index: 30;
}
.scroll-bottom:hover { filter: brightness(1.05); }
.scroll-bottom i { font-size: 20px; line-height: 1; }

/* Composer polish */
.chat-container #composer {
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.chat-container #composer .input {
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 10px;
}
.chat-container #composer .input:focus {
    border-color: rgba(92, 52, 235, 0.5);
    box-shadow: 0 0 0 3px rgba(92, 52, 235, 0.12);
}

/* Sidebar session list polish */
.chat-sidebar #sessionList {
    list-style: none;
    margin: 12px 8px 16px 8px;
    padding: 0;
    display: grid;
    gap: 8px;
}
.chat-sidebar #sessionList > li {
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    transition: transform 80ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.chat-sidebar #sessionList > li:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
}

/* Recording modal polish */
#recordingModal .modal-content {
    background: linear-gradient(180deg, rgba(92, 52, 235, 0.9), rgba(16, 170, 255, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 16px;
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.28);
}
#recordingModal .stop-btn {
    background: #ff4d6d;
    color: #fff;
    border: 0;
    border-radius: 999px;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    box-shadow: 0 10px 22px rgba(255, 77, 109, 0.45);
}
#recordingModal .stop-btn:hover { filter: brightness(1.05); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .big-mic .rings .ring { animation: none; }
    #messages { scroll-behavior: auto; }
}

@media (max-width: 720px) {
    #messages { padding: 12px; }
    #messages > li { max-width: 92%; }
    .scroll-bottom { right: 14px; bottom: 112px; width: 40px; height: 40px; }
}

/* Chat page: keyboard hints visibility */
.chat-container .kbd-hints { opacity: 0; transition: opacity 180ms ease; pointer-events: none; }
.chat-container .kbd-hints.visible { opacity: 0.9; }

/* --- Mascot visuals: robothead.webp sprite (visual-only override) --- */
.talking-robot {
  width: 56px;
  aspect-ratio: 512 / 417;
  display: inline-block;
  background: url("/static/robothead.webp") left center / 200% 100% no-repeat;
  background-color: transparent;
}
.talking-robot.is-talking { animation: robot-talk-frames 320ms steps(2) infinite alternate; }
@keyframes robot-talk-frames { from { background-position: 0% 50%; } to { background-position: 195% 50%; } }

/* Size variants preserved */
.robot-tiny  { width: 28px; }
.robot-small { width: 56px; }
.robot-large { width: 160px; }

/* Hide any legacy decorative overlays */
.talking-robot::before,
.talking-robot::after { content: none !important; display: none !important; }
.talking-robot .mouth { display: none !important; }

/* Optional pointer on hover */
.talking-robot:hover { cursor: pointer; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .talking-robot.is-talking { animation-duration: 1.2s; }
}