/* ═══════════════════════════════════════════════════════════════
   CASA ACADEMY v2  —  Kid-friendly, Production-grade
   Font: Fredoka One (headers) + Nunito (body)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary:       #5B4FE9;
  --primary-light: #8B82F5;
  --primary-pale:  #EEF0FF;
  --secondary:     #FF6B9D;
  --secondary-pale:#FFF0F6;
  --success:       #00C896;
  --warning:       #FFBA00;
  --danger:        #FF4757;
  --info:          #17A8E0;
  --bg:            #F4F6FF;
  --surface:       #FFFFFF;
  --border:        #E8ECFF;
  --text:          #1E1B4B;
  --text-2:        #6B7280;
  --text-3:        #9CA3AF;
  --radius:        16px;
  --radius-sm:     10px;
  --shadow-sm:     0 2px 8px rgba(91,79,233,0.08);
  --shadow:        0 4px 20px rgba(91,79,233,0.12);
  --shadow-lg:     0 8px 40px rgba(91,79,233,0.18);
  --sidebar-w:     256px;
  --topbar-h:      56px;
  --transition:    0.22s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR LAYOUT ───────────────────────────────────────────── */
body.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  overflow-y: auto;
  transition: transform var(--transition);
  box-shadow: var(--shadow);
}

.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── SIDEBAR BRAND ────────────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1.5px solid var(--border);
  position: relative;
}
.brand-logo { font-size: 2rem; line-height: 1; }
.brand-name  {
  display: block;
  font-family: 'Fredoka One', cursive;
  font-size: 1.15rem;
  color: var(--primary);
  line-height: 1.2;
}
.brand-sub   { display: block; font-size: 0.72rem; color: var(--text-3); font-weight: 600; }
.sidebar-close {
  display: none;
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1.2rem; color: var(--text-2); cursor: pointer;
}

/* ── USER CARD ────────────────────────────────────────────────── */
.sidebar-user { padding: 14px 16px; border-bottom: 1.5px solid var(--border); }
.user-card-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  padding: 8px 10px; border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.user-card-link:hover { background: var(--primary-pale); }
.user-avatar-wrap { position: relative; flex-shrink: 0; }
.user-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary-light); }
.user-emoji-avatar {
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  display: flex; align-items: center; justify-content: center;
}
.user-status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--surface);
}
.user-name { font-weight: 800; font-size: 0.88rem; color: var(--text); line-height: 1.2; }
.user-role { font-size: 0.72rem; color: var(--text-3); font-weight: 600; text-transform: uppercase; }

/* ── NAV ITEMS ────────────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-section-label {
  font-size: 0.65rem; font-weight: 900; color: var(--text-3);
  letter-spacing: .08em; padding: 6px 8px 2px; margin-top: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 700; font-size: 0.88rem;
  text-decoration: none; cursor: pointer;
  transition: all var(--transition); border: none; background: none;
  position: relative; width: 100%;
}
.nav-item:hover { background: var(--primary-pale); color: var(--primary); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: 0 4px 12px rgba(91,79,233,0.3);
}
.nav-item.active .nav-icon { color: white; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; color: var(--text-3); }
.nav-badge {
  position: absolute; right: 10px;
  background: var(--secondary); color: white;
  font-size: 0.65rem; font-weight: 900; padding: 1px 6px;
  border-radius: 20px; min-width: 20px; text-align: center;
}
.nav-item-logout { color: var(--danger) !important; }
.nav-item-logout:hover { background: #FFF0F0 !important; }

/* ── SIDEBAR FOOTER ───────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1.5px solid var(--border);
  padding: 10px;
}

/* ── TOPBAR (mobile only) ─────────────────────────────────────── */
.topbar {
  display: none;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky; top: 0; z-index: 900;
  box-shadow: var(--shadow-sm);
}
.topbar-burger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
}
.topbar-burger span {
  display: block; width: 22px; height: 2.5px;
  background: var(--text); border-radius: 2px;
  transition: all 0.2s;
}
.topbar-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem; color: var(--primary); flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-msg-btn {
  position: relative; color: var(--text-2);
  text-decoration: none; font-size: 1.1rem;
}
.topbar-badge {
  position: absolute; top: -5px; right: -6px;
  background: var(--secondary); color: white;
  font-size: 0.6rem; padding: 1px 4px;
  border-radius: 20px; font-weight: 900;
}

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 999;
  backdrop-filter: blur(2px);
}

/* ── MAIN CONTENT ─────────────────────────────────────────────── */
.main-content { padding: 24px; flex: 1; }

/* ── TOAST ────────────────────────────────────────────────────── */
.toast-success {
  background: linear-gradient(135deg, var(--success), #00A87A);
  color: white; padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700; margin-bottom: 16px;
  animation: slideDown 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,200,150,0.3);
}
@keyframes slideDown { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #5B4FE9 0%, #FF6B9D 60%, #FFBA00 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.login-card {
  background: white;
  border-radius: 24px;
  padding: 42px;
  width: 100%;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: popIn 0.4s ease;
}
@keyframes popIn { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }
.login-logo { text-align: center; font-size: 3.5rem; }
.login-title {
  text-align: center;
  font-family: 'Fredoka One', cursive;
  font-size: 2rem; color: var(--primary);
  margin: 6px 0 2px;
}
.login-sub {
  text-align: center;
  color: var(--text-3);
  font-size: 0.88rem;
  margin-bottom: 24px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.login-card-header {
  text-align: center;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}
.login-card form {
  text-align: left;
}
.login-label {
  font-weight: 800;
  color: var(--text);
  font-size: 0.88rem;
  display: block;
  margin-bottom: 5px;
  text-align: left;
}
.login-input {
  width: 100%; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(91,79,233,0.12); }
.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; border: none; border-radius: var(--radius-sm);
  font-size: 1.05rem; font-weight: 800; cursor: pointer;
  transition: all var(--transition); margin-top: 6px;
  font-family: 'Fredoka One', cursive; letter-spacing: .5px;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(91,79,233,0.35); }
.login-footer { text-align: center; margin-top: 18px; color: var(--text-3); font-size: 0.82rem; }
/* Logo: flex + márgenes auto para centrar siempre (login y feed) */
.login-brand-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  margin: 0 0 14px;
  padding: 4px 0 8px;
  box-sizing: border-box;
}
.login-brand-img-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.login-brand-img {
  display: block;
  max-width: min(100%, 340px);
  width: auto;
  height: auto;
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
  object-fit: contain;
  object-position: center center;
}
.feed-welcome-simple .login-brand-img-shell {
  margin-top: 20px;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════
   FEED / POSTS
   ═══════════════════════════════════════════════════════════════ */

/* Welcome (no photo banner — keeps layout simple on mobile) */
.feed-welcome-simple {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 22px;
  max-width: 720px;
  padding: 20px 16px;
  background: linear-gradient(135deg, #eef2ff 0%, #f8f9ff 100%);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
}
.feed-welcome-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.9;
  text-align: center;
}
.feed-welcome-title {
  margin: 0 0 8px;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(1.35rem, 4vw, 1.95rem);
  color: var(--text);
  line-height: 1.2;
  word-wrap: break-word;
  text-align: center;
}
.feed-welcome-sub {
  margin: 0 auto;
  max-width: 36rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.45;
  text-align: center;
}

.feed-mood-section {
  text-align: center;
  margin: 15px auto 20px;
  max-width: min(100%, 960px);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.feed-mood-strip {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
  width: 100%;
  max-width: 960px;
}

/* Mood en sidebar: misma caja que create-card / filter-card, ancho alineado */
.feed-sidebar .feed-mood-section {
  display: block;
  margin: 0;
  max-width: none;
  width: 100%;
  text-align: center;
}
.create-card.mood-feed-card {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.mood-feed-heading {
  font-weight: 800;
  color: var(--text);
  margin: 0 0 12px;
  font-size: 0.9rem;
  text-align: center;
}
/* Mood chips dentro de la card (tamaños; el grid lo define .mood-btn-grid) */
.create-card.mood-feed-card .mood-chip {
  margin: 0;
  align-self: stretch;
}
.mood-feed-confirmation {
  margin-top: 12px;
  margin-bottom: 0;
  text-align: center;
}

.feed-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.topic-option-active { font-weight: 800; }

/* ── Sidebar panels ───────────────────────────────── */
.feed-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
  min-width: 0;
}

.topic-card {
  background: linear-gradient(135deg, var(--primary), #8B82F5);
  color: white; border-radius: var(--radius); padding: 18px;
}
.topic-badge { font-size: 0.72rem; font-weight: 900; opacity: 0.85; letter-spacing: .05em; text-transform: uppercase; }
.topic-title { font-family: 'Fredoka One', cursive; font-size: 1.2rem; margin: 6px 0 4px; }
.topic-desc { font-size: 0.85rem; opacity: 0.88; }
.topic-img { width: 100%; border-radius: 10px; margin-top: 10px; object-fit: cover; max-height: 120px; }
.btn-topic-replies {
  display: inline-block; margin-top: 10px;
  background: rgba(255,255,255,0.2); color: white;
  padding: 6px 14px; border-radius: 20px; font-size: 0.82rem; font-weight: 700;
  text-decoration: none; transition: background var(--transition);
}
.btn-topic-replies:hover { background: rgba(255,255,255,0.35); color: white; }

.create-card, .filter-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); border: 1.5px solid var(--border);
}
.create-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ctab {
  flex: 1; padding: 7px 0; border: 2px solid var(--border); background: none;
  border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 800;
  cursor: pointer; transition: all var(--transition); color: var(--text-2);
}
.ctab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border-color: transparent;
}
.create-textarea {
  width: 100%; min-height: 80px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-family: inherit; font-size: 0.9rem; resize: vertical; outline: none;
  transition: border-color var(--transition);
}
.create-textarea:focus { border-color: var(--primary); }
.create-select {
  width: 100%; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-family: inherit; font-size: 0.85rem; margin-top: 8px; outline: none;
  background: white; color: var(--text);
}
.btn-post {
  width: 100%; margin-top: 10px; padding: 11px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; border: none; border-radius: var(--radius-sm);
  font-family: 'Fredoka One', cursive; font-size: 1rem;
  cursor: pointer; transition: all var(--transition);
}
.btn-post:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

/* Canvas */
.canvas-wrap { position: relative; }
#drawCanvas {
  width: 100%; border-radius: var(--radius-sm);
  border: 2px solid var(--border); cursor: crosshair; background: #fff;
  display: block;
}
.canvas-tools { margin-top: 6px; }
.color-strip { display: flex; gap: 5px; flex-wrap: wrap; }
.cpick {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15); cursor: pointer; padding: 0;
  transition: transform 0.1s;
}
.cpick:hover { transform: scale(1.3); }
.canvas-btn {
  padding: 3px 8px; border: 2px solid var(--border);
  border-radius: 8px; background: white; cursor: pointer; font-size: 0.8rem;
}

/* Photo upload */
.photo-upload-area {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; height: 110px; border: 2.5px dashed var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
  color: var(--text-2); font-size: 0.85rem; gap: 4px;
}
.photo-upload-area:hover { border-color: var(--primary); background: var(--primary-pale); }
.photo-drop-icon { font-size: 2rem; }

/* Filter */
.filter-title { font-weight: 800; color: var(--text); margin-bottom: 10px; font-size: 0.9rem; }
.filter-input, .filter-select {
  width: 100%; border: 2px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px;
  font-family: inherit; font-size: 0.85rem; margin-bottom: 7px; outline: none;
  background: white; color: var(--text);
}
.filter-input:focus, .filter-select:focus { border-color: var(--primary); }
.btn-filter {
  width: 100%; padding: 8px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm); font-weight: 800;
  cursor: pointer; font-size: 0.88rem;
}
.btn-clear-filter {
  display: block; text-align: center; margin-top: 6px;
  color: var(--text-3); font-size: 0.82rem; text-decoration: none;
}

/* ── POST CARDS ───────────────────────────────────── */
.feed-main { display: flex; flex-direction: column; gap: 16px; }

.post-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.post-card.post-flagged { border-color: #FFBA00; box-shadow: 0 0 0 2px rgba(255, 186, 0, 0.25); }
.post-card.post-concerning { border-color: var(--danger); }

.comment-row.comment-flagged .comment-bubble {
  border-color: #FFBA00;
  box-shadow: 0 0 0 2px rgba(255, 186, 0, 0.2);
}
.comment-flag-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
}

.post-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; }
.post-avatar { flex-shrink: 0; }
.avatar-photo-sm { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.avatar-emoji-sm {
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary-pale), var(--secondary-pale));
  display: flex; align-items: center; justify-content: center;
}
.post-meta { flex: 1; min-width: 0; }
.post-author { font-size: 0.9rem; color: var(--text); }
.post-time { font-size: 0.73rem; color: var(--text-3); }
.post-actions-top { display: flex; align-items: center; gap: 6px; }

.pill-teacher, .pill-topic {
  display: inline-block; font-size: 0.68rem; font-weight: 800;
  padding: 2px 8px; border-radius: 20px; margin-left: 4px;
}
.pill-teacher { background: linear-gradient(135deg, var(--success), #00A87A); color: white; }
.pill-topic   { background: var(--primary-pale); color: var(--primary); }

.post-body { padding: 10px 16px; }
.post-text { font-size: 0.95rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; }
/* Centered frame: full photo visible (contain), no forced wide strip on desktop */
.post-media {
  margin-top: 12px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #eef1fb;
  border-radius: var(--radius-sm);
  overflow: hidden;
  line-height: 0;
}
.post-image {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: min(65vh, 520px);
  margin: 0;
  object-fit: contain;
  object-position: center center;
  border-radius: 0;
  cursor: pointer;
}
/* Wide screens: more vertical room + width cap so panoramas are not a thin cropped strip */
@media (min-width: 769px) {
  .post-media {
    overflow: visible;
    padding: 6px 0 10px;
  }
  .post-image {
    max-width: min(100%, 960px);
    max-height: min(78vh, 720px);
    object-fit: contain;
    object-position: center top;
  }
}

.post-footer {
  padding: 8px 16px 12px; border-top: 1.5px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.btn-reaction {
  background: none; border: 2px solid var(--border);
  border-radius: 20px; padding: 5px 14px; font-size: 0.88rem;
  font-weight: 700; cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; gap: 5px;
}
.btn-reaction:hover { background: var(--primary-pale); border-color: var(--primary-light); }
.btn-reaction.reacted { background: #FFF8E1; border-color: var(--warning); }
.flag-badge {
  font-size: 0.72rem; font-weight: 800;
  background: #FFF3CD; color: #B7791F;
  padding: 3px 10px; border-radius: 20px;
}
.btn-icon-del {
  background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 0.85rem; opacity: 0.6; transition: opacity var(--transition);
  padding: 4px;
}
.btn-icon-del:hover { opacity: 1; }

/* ── COMMENTS ──────────────────────────────────────── */
.comments-section { padding: 10px 16px 14px; background: #FAFBFF; border-top: 1.5px solid var(--border); }
.comment-row { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.comment-emoji { font-size: 1.1rem; flex-shrink: 0; }
.comment-bubble {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px 12px 12px 2px; padding: 7px 12px;
  flex: 1; font-size: 0.88rem;
}
.comment-bubble strong { display: block; font-size: 0.78rem; color: var(--primary); margin-bottom: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 6px; }
.comment-input {
  flex: 1; padding: 8px 12px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 0.88rem; outline: none;
  transition: border-color var(--transition);
}
.comment-input:focus { border-color: var(--primary); }
.btn-comment-send {
  padding: 8px 14px; background: var(--primary); color: white;
  border: none; border-radius: var(--radius-sm); font-weight: 800;
  cursor: pointer; font-size: 0.85rem; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   PROGRESS PAGE
   ═══════════════════════════════════════════════════════════════ */
.progress-page { max-width: 860px; }

.progress-hero {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius); padding: 20px 24px;
  color: white; margin-bottom: 20px;
}
.hero-photo, .hero-emoji {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; border: 3px solid rgba(255,255,255,0.5);
}
.hero-emoji { font-size: 2.2rem; display: flex; align-items: center; justify-content: center; }
.progress-hero-name { font-family: 'Fredoka One', cursive; font-size: 1.5rem; }
.progress-hero-sub  { opacity: 0.85; font-size: 0.85rem; }
.streak-badge {
  margin-left: auto; background: rgba(255,255,255,0.2);
  padding: 8px 16px; border-radius: 20px;
  font-weight: 800; font-size: 0.9rem; white-space: nowrap;
}

.section-title { font-family: 'Fredoka One', cursive; font-size: 1.15rem; color: var(--text); margin-bottom: 12px; }

.progress-goals { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1.5px solid var(--border); margin-bottom: 20px; }
.goals-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.goal-card { display: flex; flex-direction: column; gap: 6px; }
.goal-label { font-size: 0.82rem; font-weight: 800; color: var(--text-2); display: flex; justify-content: space-between; }
.goal-target { font-size: 0.75rem; color: var(--text-3); font-weight: 600; }
.goal-bar-wrap { height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; }
.goal-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 99px; }
.goal-bar.weekly  { background: linear-gradient(90deg, var(--success), #00A87A); }
.goal-bar.monthly { background: linear-gradient(90deg, var(--secondary), #E91E8C); }
.goal-numbers { display: flex; justify-content: space-between; font-size: 0.78rem; }
.goal-count { color: var(--text-2); font-weight: 600; }
.goal-pct { font-weight: 800; color: var(--primary); }
.goal-done { color: var(--success) !important; }

.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card-v2 {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm); display: flex; gap: 14px; align-items: center;
}
.stat-icon-v2 { font-size: 2rem; flex-shrink: 0; }
.stat-name { font-weight: 800; color: var(--text); font-size: 0.88rem; margin-bottom: 8px; }
.stat-row { display: flex; gap: 16px; }
.stat-col { text-align: center; }
.stat-num { font-family: 'Fredoka One', cursive; font-size: 1.4rem; color: var(--primary); line-height: 1; }
.stat-period { font-size: 0.68rem; color: var(--text-3); font-weight: 700; text-transform: uppercase; }

.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card { background: var(--surface); border-radius: var(--radius); padding: 18px; border: 1.5px solid var(--border); box-shadow: var(--shadow-sm); }
.chart-title { font-weight: 800; font-size: 0.88rem; color: var(--text-2); margin-bottom: 12px; }

/* ═══════════════════════════════════════════════════════════════
   ADMIN DASHBOARD
   ═══════════════════════════════════════════════════════════════ */
.dashboard-page { max-width: 1100px; }

.kpi-row { display: grid; grid-template-columns: repeat(6,1fr); gap: 12px; margin-bottom: 20px; }
.kpi-card {
  border-radius: var(--radius); padding: 16px 12px; text-align: center;
  color: white; box-shadow: var(--shadow-sm);
}
.kpi-purple { background: linear-gradient(135deg,var(--primary),var(--primary-light)); }
.kpi-blue   { background: linear-gradient(135deg,#17A8E0,#0D8BB4); }
.kpi-green  { background: linear-gradient(135deg,var(--success),#00A87A); }
.kpi-yellow { background: linear-gradient(135deg,var(--warning),#E5A800); }
.kpi-red    { background: linear-gradient(135deg,var(--danger),#C0002F); }
.kpi-gray   { background: linear-gradient(135deg,#9CA3AF,#6B7280); }
.kpi-icon   { font-size: 1.5rem; }
.kpi-num    { font-family: 'Fredoka One', cursive; font-size: 1.8rem; line-height: 1.1; }
.kpi-label  { font-size: 0.7rem; opacity: 0.88; font-weight: 700; text-transform: uppercase; }

.dashboard-topic-banner {
  background: linear-gradient(135deg, var(--primary-pale), #E8F5E9);
  border: 1.5px solid var(--primary-light); border-radius: var(--radius-sm);
  padding: 12px 18px; display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 10px;
}
.dashboard-topic-banner-first { margin-bottom: 16px; margin-top: 0; }
.dashboard-topic-banner strong { display: block; font-size: 1.15rem; margin-top: 2px; }
.dashboard-topic-fallback-hint {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 6px;
  max-width: 520px;
  line-height: 1.35;
}
.dashboard-topic-fallback-hint a { color: var(--primary); font-weight: 800; }
.dashboard-topic-label { font-size: 0.75rem; font-weight: 900; color: var(--primary); text-transform: uppercase; }
.btn-sm-topic {
  padding: 5px 14px; background: var(--primary); color: white;
  border-radius: 20px; font-size: 0.78rem; font-weight: 800; text-decoration: none;
  white-space: nowrap;
}
.dashboard-no-topic {
  display: block; text-align: center; padding: 14px;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-3); text-decoration: none; margin-bottom: 20px; font-weight: 700;
  transition: all var(--transition);
}
.dashboard-no-topic:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }

.dashboard-section { background: var(--surface); border-radius: var(--radius); padding: 20px; border: 1.5px solid var(--border); margin-bottom: 20px; }
.dashboard-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dashboard-section-header h3 { font-family: 'Fredoka One', cursive; font-size: 1.1rem; }
.btn-view-all { font-size: 0.82rem; font-weight: 800; color: var(--primary); text-decoration: none; }

.students-table-wrap { overflow-x: auto; }
.students-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.students-table th {
  background: var(--primary-pale); color: var(--primary);
  font-weight: 900; font-size: 0.72rem; text-transform: uppercase;
  padding: 8px 10px; text-align: left; white-space: nowrap;
}
.students-table td { padding: 9px 10px; border-bottom: 1.5px solid var(--border); }
.students-table tr:last-child td { border-bottom: none; }
.students-table tr.row-alert td { background: #FFF5F5; }
.th-progress { min-width: 120px; }

.student-name-cell { display: flex; align-items: center; gap: 8px; }
.table-photo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.table-emoji { font-size: 1.2rem; }
.count-ok  { color: var(--success); font-weight: 800; }
.count-low { color: var(--danger); font-weight: 800; }
.mini-bar-wrap { height: 6px; background: var(--border); border-radius: 99px; margin-bottom: 2px; min-width: 80px; }
.mini-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 99px; }
.mini-pct { font-size: 0.72rem; color: var(--text-3); }
.alert-dot { font-size: 0.9rem; }
.btn-table-view {
  font-size: 0.78rem; font-weight: 800; color: var(--primary);
  text-decoration: none; padding: 3px 10px;
  background: var(--primary-pale); border-radius: 20px;
  transition: background var(--transition);
}
.btn-table-view:hover { background: var(--primary); color: white; }

.dashboard-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-panel { background: var(--surface); border-radius: var(--radius); padding: 18px; border: 1.5px solid var(--border); }
.panel-title { font-family: 'Fredoka One', cursive; font-size: 1rem; margin-bottom: 12px; }

.recent-post-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1.5px solid var(--border); font-size: 0.85rem;
}
.recent-post-row:last-child { border-bottom: none; }
.recent-post-body { flex: 1; min-width: 0; overflow: hidden; }
.recent-post-body strong { margin-right: 4px; font-size: 0.82rem; color: var(--primary); }
.recent-post-body span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-post-meta { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.flagged-row { background: #FFF8E1; }

.recent-user-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1.5px solid var(--border); font-size: 0.88rem;
}
.recent-user-row:last-child { border-bottom: none; }

.pill-role { font-size: 0.68rem; font-weight: 800; padding: 2px 8px; border-radius: 20px; }
.pill-teacher { background: linear-gradient(135deg, var(--success), #00A87A); color: white; }
.pill-admin   { background: linear-gradient(135deg, var(--danger), #C0002F); color: white; }
.pill-student { background: var(--primary-pale); color: var(--primary); }

.btn-add-student {
  display: block; text-align: center; margin-top: 12px;
  padding: 8px; background: var(--primary); color: white;
  border-radius: var(--radius-sm); font-weight: 800; font-size: 0.85rem;
  text-decoration: none; transition: all var(--transition);
}
.btn-add-student:hover { background: var(--primary-light); }

.mood-alert-banner {
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border: 1.5px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mood-alert-banner strong { color: #92400E; }

.feed-moderation-block-banner {
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #e74c3c;
  background: linear-gradient(135deg, #FEE2E2, #FECACA);
  color: #7f1d1d;
  font-size: 0.92rem;
  line-height: 1.45;
  box-sizing: border-box;
}

.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.dashboard-grid-2 .dashboard-section { margin-bottom: 0; }

.recent-posts-list { padding: 0 4px; }
.recent-post-avatar { flex-shrink: 0; }
.recent-post-snippet {
  display: block;
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-users-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.recent-users-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1.5px solid var(--border);
  font-size: 0.88rem;
}
.recent-users-list li:last-child { border-bottom: none; }

.text-muted-dashboard { color: var(--text-3); font-size: 0.88rem; padding: 8px 0; }
.td-action { max-width: 320px; font-size: 0.82rem; line-height: 1.35; }
.text-muted-small { color: var(--text-3); font-size: 0.78rem; white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════════
   MOOD WIDGET (Home Feed)
   ═══════════════════════════════════════════════════════════════ */
.mood-widget-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.mood-widget-premium {
  padding: 22px 20px 20px;
  border: none;
  background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
  box-shadow: 0 8px 32px rgba(30, 91, 184, 0.12), 0 0 0 1px rgba(30, 91, 184, 0.08);
  border-radius: 20px;
  max-width: 960px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.mood-widget-title {
  font-weight: 800;
  font-size: 1.05rem;
  text-align: center;
  margin: 0 0 18px;
  color: var(--text);
  font-family: 'Fredoka One', cursive;
  letter-spacing: 0.02em;
}
/* Rejilla 3×3: id + !important para que no la pise caché vieja ni estilos de terceros */
#mood-feed-grid.mood-btn-grid,
.mood-btn-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-auto-rows: minmax(98px, auto);
  grid-auto-flow: row !important;
  /* Separación filas / columnas (escritorio); en móvil lo baja el @media max-width:768 */
  gap: 40px 40px;
  width: 100% !important;
  max-width: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  justify-items: stretch;
  align-items: stretch;
}
button.mood-chip,
.mood-chip {
  cursor: pointer;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  /* Emoji siempre en la misma franja superior en las 3 columnas (evita saltos si la etiqueta ocupa 1 o 2 líneas) */
  justify-content: flex-start;
  gap: 6px;
  padding: 10px 6px 10px;
  min-height: 0;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 14px;
  border: 2px solid rgba(30, 91, 184, 0.14);
  background: linear-gradient(165deg, #ffffff 0%, #f0f6ff 100%);
  box-shadow: 0 4px 14px rgba(30, 91, 184, 0.07);
  font-family: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.mood-chip:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(30, 91, 184, 0.14);
  border-color: rgba(30, 91, 184, 0.35);
}
.mood-chip-selected {
  border-color: #1e5bb8 !important;
  background: linear-gradient(165deg, #eef4ff 0%, #e0edff 100%) !important;
  box-shadow: 0 8px 24px rgba(30, 91, 184, 0.22), 0 0 0 3px rgba(30, 91, 184, 0.15) !important;
}
.mood-chip-emoji {
  font-size: clamp(1.45rem, 5.5vw, 2.05rem);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 2.5rem;
  min-height: 2.5rem;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}
.mood-chip-label {
  font-weight: 800;
  font-size: clamp(0.55rem, 2.2vw, 0.68rem);
  line-height: 1.12;
  text-align: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 2.55em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  box-sizing: border-box;
  color: #374151;
  letter-spacing: 0.02em;
  word-break: break-word;
  hyphens: auto;
}
@media (min-width: 769px) {
  #mood-feed-grid.mood-btn-grid,
  .mood-btn-grid {
    grid-auto-rows: minmax(92px, auto);
    gap: 40px 40px;
  }
  .create-card.mood-feed-card .mood-chip {
    padding: 11px 5px 9px;
  }
  .create-card.mood-feed-card .mood-chip-emoji {
    font-size: clamp(1.55rem, 4.2vw, 1.95rem);
    height: 2.35rem;
    min-height: 2.35rem;
  }
  .create-card.mood-feed-card .mood-chip-label {
    font-size: clamp(0.58rem, 1.8vw, 0.66rem);
  }
}
.mood-confirmation {
  color: var(--text-3);
  font-size: 0.78rem;
  text-align: center;
  margin-top: 12px;
  margin-bottom: 0;
}
.mood-confirmation-premium {
  margin-top: 18px;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.12), rgba(30, 91, 184, 0.08));
  border-radius: 12px;
  font-weight: 700;
  color: var(--text-2);
  font-size: 0.85rem;
}
/* Legacy mood buttons (if any) */
.mood-btn {
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  border-radius: 1rem;
  border: 3px solid var(--border);
  background: white;
  transition: all 0.2s;
  min-width: 76px;
  text-align: center;
  font-family: inherit;
}
.mood-btn.mood-btn-selected {
  border-color: #3b82f6;
  background: #eff6ff;
}
.mood-btn-emoji { font-size: 1.75rem; line-height: 1; }
.mood-btn-label {
  font-weight: 800;
  font-size: 0.72rem;
  margin-top: 4px;
  color: #374151;
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGES / CHAT
   ═══════════════════════════════════════════════════════════════ */
.chat-header {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); padding: 12px 16px;
  border-radius: var(--radius); border: 1.5px solid var(--border);
  margin-bottom: 14px;
}
.chat-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; min-height: 380px; max-height: 520px; overflow-y: auto;
  border: 1.5px solid var(--border);
}
.chat-bubble-wrap-mine  { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.chat-bubble-wrap-theirs { display: flex; justify-content: flex-start; margin-bottom: 10px; gap: 8px; align-items: flex-end; }
.chat-bubble {
  max-width: 70%; padding: 10px 14px; border-radius: 18px;
}
.chat-bubble.mine   { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.theirs { background: var(--primary-pale); color: var(--text); border-bottom-left-radius: 4px; }
.chat-text { font-size: 0.92rem; }
.chat-time { font-size: 0.7rem; opacity: 0.65; margin-top: 3px; }
.chat-input-area { display: flex; gap: 10px; margin-top: 12px; }
.chat-input {
  flex: 1; padding: 10px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 0.92rem; outline: none;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--primary); }
.btn-send {
  padding: 10px 20px; background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white; border: none; border-radius: var(--radius-sm);
  font-weight: 800; cursor: pointer; white-space: nowrap; font-size: 0.9rem;
}

.chat-composer { margin-top: 12px; }
.chat-emoji-picker-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px;
}
.btn-emoji-palette-toggle {
  font-size: 1.5rem; line-height: 1; width: 44px; height: 44px;
  border-radius: 50%; border: 2px solid var(--border); background: var(--primary-pale);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, border-color var(--transition);
}
.btn-emoji-palette-toggle:hover { transform: scale(1.08); border-color: var(--primary); }
.btn-emoji-palette-toggle[aria-expanded="true"] {
  border-color: var(--primary); background: var(--surface); box-shadow: var(--shadow-sm);
}
.chat-emoji-hint { font-size: 0.78rem; color: var(--text-3); font-weight: 600; }
.chat-emoji-palette {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 220px; overflow-y: auto; overflow-x: hidden;
  padding: 12px; margin-bottom: 10px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}
.chat-emoji-palette[hidden] { display: none !important; }
.chat-emoji-cell {
  font-size: 1.55rem; line-height: 1;
  width: 44px; height: 44px; padding: 0; margin: 0;
  border: 2px solid transparent; border-radius: 50%;
  background: var(--primary-pale);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.12s, border-color 0.12s;
  font-family: inherit;
}
.chat-emoji-cell:hover {
  transform: scale(1.12); border-color: var(--primary);
  background: var(--surface);
}

.post-emoji-composer {
  margin-bottom: 10px;
}

.inbox-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); margin-bottom: 8px;
  text-decoration: none; color: inherit;
  transition: all var(--transition);
}
.inbox-item:hover { border-color: var(--primary-light); background: var(--primary-pale); transform: translateX(4px); }
.inbox-avatar { font-size: 2rem; }
.inbox-photo  { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.inbox-name   { font-weight: 800; font-size: 0.9rem; }
.inbox-sub    { font-size: 0.75rem; color: var(--text-3); }

/* ═══════════════════════════════════════════════════════════════
   PROFILE
   ═══════════════════════════════════════════════════════════════ */
.profile-page { max-width: 520px; }
.profile-photo-wrap { text-align: center; margin-bottom: 20px; position: relative; }
.profile-photo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 4px solid var(--primary); }
.profile-emoji-big {
  width: 100px; height: 100px; border-radius: 50%; font-size: 3rem;
  background: linear-gradient(135deg, var(--primary-pale), var(--secondary-pale));
  display: flex; align-items: center; justify-content: center; margin: 0 auto;
  border: 4px solid var(--primary);
}
.photo-edit-btn {
  display: block; margin: 8px auto 0; font-size: 0.82rem;
  color: var(--primary); font-weight: 700; cursor: pointer;
  background: none; border: none;
}

.avatar-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.av-opt input { display: none; }
.av-emoji {
  font-size: 1.8rem; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-pale); border: 3px solid transparent;
  cursor: pointer; transition: all 0.15s;
}
.av-opt input:checked + .av-emoji { border-color: var(--primary); transform: scale(1.15); }
.av-opt:hover .av-emoji { transform: scale(1.08); }

.form-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; border: 1.5px solid var(--border); box-shadow: var(--shadow-sm);
}
.form-label-v2 { font-weight: 800; font-size: 0.85rem; color: var(--text); display: block; margin-bottom: 5px; }
.form-control-v2 {
  width: 100%; padding: 10px 12px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 0.92rem; outline: none;
  transition: border-color var(--transition); margin-bottom: 14px;
}
.form-control-v2:focus { border-color: var(--primary); }
.btn-save {
  width: 100%; padding: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; border: none; border-radius: var(--radius-sm);
  font-family: 'Fredoka One', cursive; font-size: 1rem; cursor: pointer;
  transition: all var(--transition);
}
.btn-save:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

/* ═══════════════════════════════════════════════════════════════
   TOPIC CREATE
   ═══════════════════════════════════════════════════════════════ */
.topic-form-card { max-width: 600px; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */
.empty-feed { text-align: center; padding: 60px 24px; color: var(--text-3); }
.empty-icon { font-size: 4rem; margin-bottom: 12px; }
.empty-feed h3 { font-family: 'Fredoka One', cursive; font-size: 1.4rem; color: var(--text-2); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(3,1fr); }
  .feed-layout { grid-template-columns: 260px 1fr; gap: 14px; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile  (Gmail-style sidebar)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Sidebar off-screen, slides in */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close  { display: block; }
  .sidebar-overlay.open { display: block; }

  /* Main takes full width */
  .main-wrapper { margin-left: 0; }

  /* Topbar visible */
  .topbar { display: flex; }

  /* Main content — more breathing room on phones */
  .main-content { padding: 18px 16px 24px; }
  .feed-welcome-simple {
    padding: 18px 14px;
    margin-bottom: 18px;
  }
  .feed-layout { grid-template-columns: 1fr; gap: 20px; }
  .feed-main { gap: 20px; }
  .feed-sidebar { position: static; gap: 18px; }
  .create-card, .filter-card { padding: 18px 16px; }
  .topic-card { padding: 20px 16px; }
  .post-header { padding: 16px 16px 0; gap: 12px; }
  .post-body { padding: 12px 16px 14px; }
  .post-footer { padding: 12px 16px 14px; gap: 12px; }
  .post-image { max-height: min(58vh, 440px); }
  /* Mood en create-card: 3×3 explícito en móvil (misma especificidad alta que escritorio) */
  .feed-mood-section {
    max-width: 100% !important;
    margin-left: auto;
    margin-right: auto;
    align-items: stretch;
    width: 100%;
  }
  .feed-mood-strip {
    max-width: 100%;
    width: 100%;
    justify-content: center;
    margin-bottom: 20px;
  }
  #mood-feed-grid.mood-btn-grid,
  .mood-btn-grid {
    grid-auto-rows: minmax(102px, auto);
    gap: 18px 14px;
  }
  .create-card.mood-feed-card .mood-chip {
    padding: 12px 5px 10px;
  }
  .create-card.mood-feed-card .mood-chip-emoji {
    font-size: clamp(1.65rem, 10vw, 2.45rem);
    height: 2.75rem;
    min-height: 2.75rem;
  }
  .create-card.mood-feed-card .mood-chip-label {
    font-size: clamp(0.56rem, 2.8vw, 0.74rem);
    min-height: 2.55em;
  }

  /* Feed becomes single column */

  /* Grids collapse */
  .goals-grid     { grid-template-columns: 1fr; }
  .stats-grid     { grid-template-columns: 1fr; }
  .charts-row     { grid-template-columns: 1fr; }
  .kpi-row        { grid-template-columns: repeat(2,1fr); }
  .dashboard-two-col { grid-template-columns: 1fr; }
  .dashboard-grid-2 { grid-template-columns: 1fr; }

  .progress-hero { flex-wrap: wrap; }
  .streak-badge  { margin-left: 0; }

  .students-table-wrap { overflow-x: auto; }

  /* AI Alert History: hide recipient email on phones — less cramped, data unchanged in DB */
  .alerts-history-table th.alert-col-to,
  .alerts-history-table td.alert-col-to {
    display: none;
  }
}

@media (max-width: 400px) {
  .kpi-row { grid-template-columns: repeat(2,1fr); }
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }
