/* ══════════════════════════════════════════
   Cuaderna Design System
   Brand: Terracota + Warm tones
   Typography: IBM Plex Serif (headlines) + Inter (body)
   ══════════════════════════════════════════ */

:root {
  /* Brand palette */
  --terracota: #C0805D;
  --terracota-dark: #A06840;
  --terracota-light: #E8D0C0;
  --terracota-subtle: #F5E8DD;
  --rosa: #B87A8E;
  --aguamarina: #6BA5A3;
  --mostaza: #C6AA62;
  --azul-mineral: #4A7A8D;
  --ciruela: #9B6D7B;
  --verde-oliva: #6B8C73;

  /* Neutrals */
  --text: #2D2D3A;
  --text-light: #5C5C6E;
  --text-muted: #9B9BA8;
  --bg: #FDF8F4;
  --bg-warm: #F5EDE6;
  --bg-card: #FFFFFF;
  --white: #FFFFFF;
  --border: #E0D5CC;
  --border-light: #EDE6DE;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(45,45,58,0.04);
  --shadow-sm: 0 1px 4px rgba(45,45,58,0.06), 0 1px 2px rgba(45,45,58,0.04);
  --shadow: 0 4px 12px rgba(45,45,58,0.08), 0 1px 3px rgba(45,45,58,0.04);
  --shadow-lg: 0 8px 24px rgba(45,45,58,0.1), 0 2px 6px rgba(45,45,58,0.04);
  --shadow-xl: 0 16px 40px rgba(45,45,58,0.12);

  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout */
  --sidebar-width: 270px;
  --header-height: 60px;
  --content-max: 820px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
  font-family: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

a { color: var(--terracota); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--terracota-dark); }

img { max-width: 100%; height: auto; display: block; }

/* ── Buttons (CTA = Inter Bold 700) ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--terracota);
  color: var(--white);
  box-shadow: 0 1px 3px rgba(192,128,93,0.3);
}
.btn-primary:hover { background: var(--terracota-dark); box-shadow: 0 2px 6px rgba(192,128,93,0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-warm); border-color: var(--terracota-light); }

.btn-danger {
  background: #E8564F;
  color: var(--white);
}
.btn-danger:hover { background: #D04440; }

.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }

/* Back button = Inter Regular 400 (texto apoyo) */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 8px;
  transition: color var(--transition);
}
.btn-back:hover { color: var(--terracota); }

/* ── Forms (labels = Inter Medium 500) ── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
textarea, select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: all var(--transition);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--terracota);
  box-shadow: 0 0 0 3px rgba(192,128,93,0.12);
}

textarea { resize: vertical; min-height: 100px; }

.form-error {
  background: #FEF2F2;
  color: #B91C1C;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid #FECACA;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ══════════════════════════════════════════
   LOGIN PAGE — Split layout
   ══════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-split {
  display: flex;
  min-height: 100vh;
}

.login-brand-panel {
  flex: 1;
  background: var(--bg-warm);
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 60px;
  position: relative;
}

.login-brand-inner {
  max-width: 440px;
}

/* Logo image */
.login-logo {
  display: block;
  margin-bottom: 32px;
}

.logo-img {
  display: block;
  width: auto;
  object-fit: contain;
}

.logo-img-login {
  height: 90px;
}

.logo-img-sidebar {
  height: 36px;
}

.login-headline {
  font-family: 'IBM Plex Serif', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 16px;
}

.login-subheadline {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--text-light);
  line-height: 1.7;
}

.login-brand-footer {
  position: absolute;
  bottom: 32px;
  left: 60px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
}

.login-form-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.login-form-inner {
  width: 100%;
  max-width: 380px;
}

.login-form-title {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

/* Subtitulo login = Inter Regular 400 (texto apoyo) */
.login-form-subtitle {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-light);
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-form {
  background: var(--white);
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════ */
.app-page {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--terracota-dark);
  flex-shrink: 0;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-xs);
}

.user-info { display: flex; flex-direction: column; }
/* User name = Inter Medium 500 (subtitulo) */
.user-name { font-weight: 500; font-size: 13px; color: var(--text); }
/* User points = Inter Regular 400 (texto apoyo) */
.user-points {
  font-size: 11px;
  color: var(--terracota);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

/* Nav section labels = Inter Medium 500 uppercase */
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 16px 20px 6px;
  font-weight: 500;
}

/* Nav items = Inter Regular 400 (texto de apoyo) */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 400;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg); color: var(--terracota); border-left-color: var(--terracota-light); }
/* Nav item activo = Inter Medium 500 */
.nav-item.active { background: var(--terracota-subtle); color: var(--terracota-dark); font-weight: 500; border-left-color: var(--terracota); }

.nav-item svg { flex-shrink: 0; }

.nav-item .nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
}

/* Logout = Inter Regular 400 (texto apoyo) */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  padding: 8px 0;
  width: 100%;
  transition: color var(--transition);
}
.btn-logout:hover { color: #E8564F; }

/* ── Mobile header ── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 90;
  box-shadow: var(--shadow-xs);
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.mobile-menu-btn:hover { background: var(--bg-warm); }

.mobile-title {
  font-family: 'IBM Plex Serif', serif;
  font-weight: 700;
  font-size: 1.15rem;
}

.mobile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45,45,58,0.4);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.section { display: none; }
.section.active { display: block; }

.section-header { margin-bottom: 28px; }
/* Subtitulos = Inter Medium 500 */
.section-subtitle { color: var(--text-light); font-size: 15px; font-weight: 500; margin-top: 6px; line-height: 1.5; }

/* ══════════════════════════════════════════
   SEARCH BAR
   ══════════════════════════════════════════ */
.search-bar {
  position: relative;
  margin-bottom: 28px;
  max-width: 600px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 12px 18px;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}

.search-input-wrap:focus-within {
  border-color: var(--terracota);
  box-shadow: 0 0 0 4px rgba(192,128,93,0.1), var(--shadow-sm);
}

.search-input-wrap svg { color: var(--terracota-light); flex-shrink: 0; }
.search-input-wrap:focus-within svg { color: var(--terracota); }

.search-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  font-family: 'Inter', sans-serif;
  color: var(--text);
}

.search-input-wrap input::placeholder { color: var(--text-muted); }

.search-clear {
  background: var(--bg-warm);
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.search-clear:hover { background: var(--border); color: var(--text); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  z-index: 50;
}

.search-group { padding: 6px 0; }
.search-group + .search-group { border-top: 1px solid var(--border-light); }

.search-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 8px 16px 4px;
  font-weight: 700;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-item:hover { background: var(--bg); }

.search-item .nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Search result title = Inter Medium 500 (subtitulo) */
.search-item-title { font-size: 13px; font-weight: 500; color: var(--text); display: block; }
.search-item-meta { font-size: 11px; color: var(--text-muted); display: block; margin-top: 1px; }
.search-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ══════════════════════════════════════════
   MODULE GRID (HOME)
   ══════════════════════════════════════════ */
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.module-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  position: relative;
}
.module-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }

.module-card-img {
  height: 160px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
}

.module-card-color {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.module-card-body {
  padding: 18px 20px 20px;
}
.module-card-body h3 {
  font-size: 1.05rem;
  margin-bottom: 8px;
  line-height: 1.3;
}
.module-card-body p {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   MODULE DETAIL
   ══════════════════════════════════════════ */
.module-layout {
  display: flex;
  gap: 28px;
}

.submodule-sidebar {
  width: 240px;
  flex-shrink: 0;
}

.submodule-list { display: flex; flex-direction: column; gap: 4px; }

.submodule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-light);
  transition: all var(--transition);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}
.submodule-item:hover { background: var(--bg); color: var(--text); }
/* Submodule activo = Inter Medium 500 */
.submodule-item.active { background: var(--terracota-subtle); color: var(--terracota-dark); font-weight: 500; }

.content-area { flex: 1; min-width: 0; }

.content-list { display: flex; flex-direction: column; gap: 10px; }

.content-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.content-card:hover { box-shadow: var(--shadow-sm); border-color: var(--terracota-light); transform: translateX(4px); }

.content-card-thumb {
  width: 88px;
  height: 66px;
  border-radius: var(--radius-sm);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--bg-warm);
  flex-shrink: 0;
}

/* Content card title = Inter Medium 500 (subtitulo) */
.content-card-info h4 {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text);
}
.content-card-info p {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ══════════════════════════════════════════
   CONTENT DETAIL
   ══════════════════════════════════════════ */
.content-detail { max-width: var(--content-max); }

.content-detail h1 {
  font-size: 1.65rem;
  margin-bottom: 10px;
}

.content-detail .content-meta {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
  line-height: 1.6;
}

.content-detail .content-media {
  margin-bottom: 28px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.content-detail .content-media img { width: 100%; display: block; object-fit: contain; }
.content-detail .content-media iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: var(--radius-lg);
}

.content-detail .content-body {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}

.content-detail .content-body p { margin-bottom: 18px; }
.content-detail .content-body h2 { margin: 32px 0 14px; font-size: 1.3rem; }
.content-detail .content-body h3 { margin: 24px 0 10px; }
.content-detail .content-body ul, .content-detail .content-body ol { margin: 12px 0 18px 20px; }
.content-detail .content-body li { margin-bottom: 6px; line-height: 1.7; }
.content-detail .content-body pre {
  background: var(--bg-warm);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0;
}
.content-detail .content-body strong { color: var(--text); }
.content-detail .content-body em { color: var(--text-light); }

.content-attachments {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 2px solid var(--border-light);
}

.content-attachments h3 { margin-bottom: 14px; }

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid var(--border-light);
  transition: border-color var(--transition);
}
.attachment-item:hover { border-color: var(--terracota-light); }
/* Attachment link = Inter Bold 700 (CTA) */
.attachment-item a { color: var(--terracota); font-weight: 700; }
.attachment-item a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════
   COMMUNITY
   ══════════════════════════════════════════ */
.community-layout { display: flex; gap: 28px; }
.community-main { flex: 1; min-width: 0; }
.community-aside { width: 280px; flex-shrink: 0; }

.community-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.category-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--white);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
}
.filter-btn:hover { border-color: var(--terracota); color: var(--terracota); }
/* Filter activo = CTA = Inter Bold */
.filter-btn.active {
  background: var(--terracota);
  color: var(--white);
  border-color: var(--terracota);
}

.post-feed { display: flex; flex-direction: column; gap: 14px; }

.post-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.post-card:hover { box-shadow: var(--shadow-sm); border-color: var(--terracota-light); }

.post-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.post-card-header .post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--terracota-light), var(--terracota-subtle));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--terracota-dark);
  flex-shrink: 0;
}

.post-card-header .post-meta { display: flex; flex-direction: column; }
/* Post author = Inter Medium 500 (subtitulo) */
.post-card-header .post-author { font-weight: 500; font-size: 13px; color: var(--text); }
.post-card-header .post-date { font-size: 11px; color: var(--text-muted); }

/* Category badge = Inter Medium 500 */
.post-card-header .post-category {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 500;
}

.post-card h3 { font-size: 1rem; margin-bottom: 8px; }
.post-card .post-body-preview {
  font-size: 13px;
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Post footer = Inter Regular 400 (texto apoyo) */
.post-card-footer {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.post-card-footer span { display: flex; align-items: center; gap: 5px; }

/* Post detail */
.post-detail { max-width: 720px; }
.post-detail .post-full-header { margin-bottom: 24px; }
.post-detail h1 { font-size: 1.5rem; margin-bottom: 8px; }
.post-detail .post-full-body {
  font-size: 15px;
  line-height: 1.85;
  margin-bottom: 28px;
  white-space: pre-wrap;
}

.post-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 28px;
}

.like-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-light);
}
/* Like = CTA = Inter Bold */
.like-btn:hover { border-color: #E8564F; color: #E8564F; }
.like-btn.liked { background: #FEF2F2; border-color: #E8564F; color: #E8564F; }

.comments-section h3 { margin-bottom: 18px; }

.comment-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.comment-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.comment-content { flex: 1; }
/* Comment author = Inter Medium 500 */
.comment-author { font-weight: 500; font-size: 13px; }
.comment-date { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.comment-body { font-size: 13px; margin-top: 4px; line-height: 1.6; color: var(--text-light); }

.comment-form {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: flex-end;
}
.comment-form textarea { min-height: 60px; flex: 1; }

/* Leaderboard */
.leaderboard-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
}
.leaderboard-card h3 { margin-bottom: 14px; font-size: 1rem; }

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-size: 13px;
}

.leaderboard-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.leaderboard-item:nth-child(1) .leaderboard-rank { background: var(--mostaza); color: var(--white); }
.leaderboard-item:nth-child(2) .leaderboard-rank { background: var(--text-muted); color: var(--white); }
.leaderboard-item:nth-child(3) .leaderboard-rank { background: var(--terracota); color: var(--white); }

/* Leaderboard name = Inter Regular 400, pts = Inter Bold 700 */
.leaderboard-name { flex: 1; font-weight: 400; }
.leaderboard-pts { font-weight: 700; color: var(--terracota); font-size: 12px; }

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
}

.pagination button {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.pagination button:hover { border-color: var(--terracota); color: var(--terracota); }
.pagination button.active { background: var(--terracota); color: var(--white); border-color: var(--terracota); }

/* ══════════════════════════════════════════
   ADMIN
   ══════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-light);
}

/* Admin tabs = Inter Medium 500 (subtitulo), activo = Bold en color */
.admin-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--terracota); border-bottom-color: var(--terracota); font-weight: 700; }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-light);
}

.admin-table th, .admin-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

/* Table header = Inter Medium 500 (subtitulo) */
.admin-table th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.admin-table tr:hover td { background: var(--bg); }

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

.color-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

/* Badges = Inter Medium 500 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 500;
}
.badge-admin { background: var(--terracota-subtle); color: var(--terracota-dark); }
.badge-user { background: var(--bg-warm); color: var(--text-light); }
.badge-active { background: #ECFDF5; color: #059669; }
.badge-inactive { background: #FEF2F2; color: #DC2626; }

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45,45,58,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
  background: var(--white);
  border: 1px solid var(--border);
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-warm); color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
}

/* ══════════════════════════════════════════
   ASSISTANT
   ══════════════════════════════════════════ */
.assistant-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--terracota);
  color: var(--white);
  border: none;
  box-shadow: var(--shadow-lg), 0 0 0 4px rgba(192,128,93,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 150;
}
.assistant-btn:hover { background: var(--terracota-dark); transform: scale(1.08); box-shadow: var(--shadow-xl), 0 0 0 6px rgba(192,128,93,0.2); }

.assistant-panel {
  display: none;
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 500px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  flex-direction: column;
  z-index: 150;
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.assistant-panel.active { display: flex; }

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.assistant-header h3 { font-size: 0.95rem; }

.assistant-close {
  background: var(--white);
  border: 1px solid var(--border);
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.assistant-close:hover { background: var(--bg-warm); }

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.assistant-msg {
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  max-width: 85%;
}

.assistant-msg.assistant {
  background: var(--white);
  color: var(--text);
  align-self: flex-start;
  box-shadow: var(--shadow-xs);
}

.assistant-msg.user {
  background: var(--terracota);
  color: var(--white);
  align-self: flex-end;
}

.assistant-input {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border-light);
  background: var(--white);
}
.assistant-input input { flex: 1; }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ══════════════════════════════════════════
   RESPONSIVE — Mobile-first touch optimization
   Touch targets: min 44px (WCAG/iOS HIG)
   Mobile body: 16px minimum
   Spacing: 8px+ between touch targets
   ══════════════════════════════════════════ */

/* ── Tablet (< 1024px) ── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .mobile-header { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: calc(var(--header-height) + 20px);
  }

  /* Grid 2 columns tablet */
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  /* Module detail: submodules as horizontal scroll */
  .module-layout { flex-direction: column; }
  .submodule-sidebar { width: 100%; }
  .submodule-list {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .submodule-item {
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 44px; /* Touch target */
    padding: 10px 16px;
  }

  /* Community stacks */
  .community-layout { flex-direction: column; }
  .community-aside { width: 100%; }

  /* Assistant full width on tablet */
  .assistant-panel {
    width: calc(100% - 32px);
    right: 16px;
    bottom: 84px;
    height: 60vh;
  }

  /* Login responsive */
  .login-split { flex-direction: column; }
  .login-brand-panel {
    padding: 40px 24px 32px;
    min-height: auto;
  }
  .login-brand-inner { max-width: 100%; }
  .login-headline { font-size: 1.3rem; }
  .login-brand-footer { display: none; }
  .login-form-panel { padding: 24px; }

  /* Admin tables: horizontal scroll */
  .admin-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table thead, .admin-table tbody, .admin-table tr { display: table; width: 100%; table-layout: auto; }
  .admin-table thead { display: table-header-group; }
  .admin-table tbody { display: table-row-group; }
}

/* ── Mobile (< 640px) ── */
@media (max-width: 640px) {
  /* Typography scaling: 16px minimum for readability */
  body { font-size: 16px; }

  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }

  /* Main content: more padding for thumb comfort */
  .main-content { padding: 16px; padding-top: calc(var(--header-height) + 16px); }

  /* Mobile header: touch-friendly */
  .mobile-header { height: 56px; padding: 0 12px; }
  .mobile-menu-btn { min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

  /* Grid 1 column */
  .module-grid { grid-template-columns: 1fr; gap: 14px; }
  .module-card-img { height: 160px; }
  .module-card-body { padding: 16px; }
  .module-card-body h3 { font-size: 1.1rem; }
  .module-card-body p { font-size: 14px; }

  /* Search bar full width */
  .search-bar { max-width: 100%; }
  .search-input-wrap { padding: 12px 16px; }
  .search-input-wrap input { font-size: 16px; } /* Prevent iOS zoom on focus */
  .search-results { max-height: 50vh; }
  .search-item { padding: 12px 16px; min-height: 44px; }

  /* Forms: prevent iOS zoom + touch-friendly */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="url"], textarea, select {
    font-size: 16px; /* Prevents iOS zoom on focus */
    padding: 12px 14px;
    min-height: 44px; /* Touch target */
  }
  .form-group label { font-size: 14px; margin-bottom: 8px; }
  .form-row { grid-template-columns: 1fr; }

  /* Buttons: touch-friendly minimum 44px height */
  .btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }
  .btn-lg { min-height: 48px; padding: 12px 24px; font-size: 16px; }
  .btn-small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .btn-back { min-height: 44px; font-size: 14px; }

  /* Filter buttons: touch-friendly */
  .filter-btn { min-height: 40px; padding: 8px 16px; font-size: 13px; }
  .category-filters { gap: 8px; }

  /* Content cards: touch-friendly */
  .content-card { padding: 14px; min-height: 48px; }
  .content-card-thumb { width: 72px; height: 54px; }
  .content-card-info h4 { font-size: 15px; }
  .content-card-info p { font-size: 13px; }

  /* Content detail: mobile reading */
  .content-detail .content-body { font-size: 16px; line-height: 1.8; }
  .content-detail .content-body h2 { font-size: 1.2rem; margin: 24px 0 12px; }
  .content-detail .content-body pre { font-size: 12px; padding: 12px; }
  .content-detail h1 { font-size: 1.35rem; }

  /* Community: touch targets and readability */
  .community-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .post-card { padding: 16px; }
  .post-card h3 { font-size: 1.05rem; }
  .post-card .post-body-preview { font-size: 14px; }
  .post-card-header .post-avatar { width: 40px; height: 40px; } /* Bigger on mobile */
  .post-card-header .post-author { font-size: 14px; }

  /* Like button: touch target */
  .like-btn { min-height: 44px; padding: 10px 18px; font-size: 14px; }

  /* Post detail: mobile reading */
  .post-detail .post-full-body { font-size: 16px; line-height: 1.8; }

  /* Comments: stack form on mobile */
  .comment-form { flex-direction: column; gap: 10px; }
  .comment-form textarea { min-height: 80px; }
  .comment-form .btn { width: 100%; }
  .comment-body { font-size: 14px; }
  .comment-author { font-size: 14px; }
  .comment-avatar { width: 34px; height: 34px; }

  /* Pagination: touch targets */
  .pagination button { min-height: 40px; min-width: 40px; padding: 8px 12px; font-size: 14px; }
  .pagination { gap: 8px; }

  /* Leaderboard: touch-friendly rows */
  .leaderboard-item { padding: 12px 0; min-height: 44px; font-size: 14px; }
  .leaderboard-rank { width: 28px; height: 28px; font-size: 12px; }

  /* Attachments: touch targets */
  .attachment-item { min-height: 48px; padding: 12px 14px; font-size: 14px; }

  /* Admin: mobile-friendly */
  .admin-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-tab { min-height: 44px; padding: 10px 16px; white-space: nowrap; font-size: 14px; }
  .admin-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .admin-actions { gap: 8px; }
  .admin-actions .btn { min-height: 36px; }

  /* Modal: fullscreen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .modal-close { width: 40px; height: 40px; font-size: 20px; } /* Touch target */
  .modal-header { padding: 16px; position: sticky; top: 0; z-index: 1; }
  .modal-body { padding: 16px; }

  /* Assistant: fullscreen on mobile */
  .assistant-panel {
    width: 100%;
    height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  .assistant-btn { width: 52px; height: 52px; bottom: 16px; right: 16px; }
  .assistant-close { width: 36px; height: 36px; } /* Touch target */
  .assistant-input { padding: 12px; }
  .assistant-input input { font-size: 16px; min-height: 44px; } /* Prevent zoom */
  .assistant-msg { font-size: 14px; padding: 12px 14px; }

  /* Login mobile */
  .login-brand-panel { padding: 28px 20px 20px; }
  .logo-img-login { height: 70px; }
  .login-headline { font-size: 1.15rem; }
  .login-form-panel { padding: 20px; }
  .login-form { padding: 20px; }
  .login-form-title { font-size: 1.3rem; }

  /* Section headers */
  .section-header { margin-bottom: 20px; }
  .section-subtitle { font-size: 14px; }

  /* Empty state */
  .empty-state { padding: 32px 16px; }
}

/* ── Small phones (< 380px) ── */
@media (max-width: 380px) {
  .main-content { padding: 12px; padding-top: calc(var(--header-height) + 12px); }
  h1 { font-size: 1.3rem; }
  .module-card-img { height: 140px; }
  .post-card { padding: 14px; }
  .login-brand-panel { padding: 24px 16px 16px; }
  .logo-img-login { height: 55px; }
  .login-headline { font-size: 1.05rem; }
  .login-subheadline { font-size: 13px; }
}

/* ── Utility ── */
.hidden { display: none !important; }
.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* ── Focus states for accessibility ── */
.btn:focus-visible, .nav-item:focus-visible, .filter-btn:focus-visible,
.submodule-item:focus-visible, .admin-tab:focus-visible, .pagination button:focus-visible {
  outline: 2px solid var(--terracota);
  outline-offset: 2px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
