@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
  --ink:        #111827;
  --ink2:       #1F2937;
  --ink3:       #374151;
  --indigo:     #4F46E5;
  --indigo-lt:  #818CF8;
  --indigo-xlt: #EEF2FF;
  --indigo-dim: #4F46E520;
  --red-dark:   #1A0A0A;
  --red-accent: #EF4444;
  --green-dark: #0A1A0A;
  --green-accent:#4ADE80;
  --bg-page:    #F9FAFB;
  --bg-white:   #FFFFFF;
  --bg-soft:    #F3F4F6;
  --border:     #E5E7EB;
  --border-md:  #D1D5DB;
  --text-main:  #111827;
  --text-soft:  #6B7280;
  --text-xsoft: #9CA3AF;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:  0 12px 40px rgba(0,0,0,0.12);
  --safe-top:   env(safe-area-inset-top, 0px);
  --safe-bot:   env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
textarea, select, input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 99px; }

.t-serif { font-family: 'DM Serif Display', serif; }
.t-xs    { font-size: 0.7rem; }
.t-sm    { font-size: 0.8rem; }
.t-md    { font-size: 0.9rem; }
.t-lg    { font-size: 1.05rem; }
.t-xl    { font-size: 1.3rem; }
.t-2xl   { font-size: 1.7rem; }
.fw-4 { font-weight: 400; }
.fw-5 { font-weight: 500; }
.fw-6 { font-weight: 600; }
.c-indigo  { color: var(--indigo); }
.c-soft    { color: var(--text-soft); }
.c-xsoft   { color: var(--text-xsoft); }
.c-white   { color: #fff; }
.c-red     { color: var(--red-accent); }
.c-green   { color: var(--green-accent); }

.container { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 16px; }

/* NAV */
.app-nav {
  background: var(--ink);
  border-bottom: 2px solid var(--indigo);
  padding: calc(var(--safe-top) + 12px) 20px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 100;
}
.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem; color: #fff; letter-spacing: 0.01em;
}
.nav-back {
  background: none; border: none; color: var(--text-xsoft);
  font-size: 0.82rem; display: flex; align-items: center; gap: 4px; padding: 6px 0;
}
.nav-back:active { color: var(--indigo-lt); }

/* HERO */
.hero {
  background: var(--ink);
  padding: 22px 20px 26px;
  border-bottom: 2px solid var(--indigo);
}
.hero-inner { max-width: 680px; margin: 0 auto; }
.hero-greeting { font-size: 0.78rem; color: var(--text-xsoft); margin-bottom: 3px; }
.hero-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem; color: #fff; margin-bottom: 18px;
}
.hero-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.hero-stat {
  background: rgba(255,255,255,0.06);
  border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md); padding: 12px 10px; text-align: center;
}
.hero-stat-val {
  font-size: 1.4rem; font-weight: 500; color: var(--indigo-lt);
}
.hero-stat-lbl { font-size: 0.65rem; color: var(--text-xsoft); margin-top: 2px; }

/* CARDS */
.card {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-dark {
  background: var(--ink2);
  border: 0.5px solid var(--ink3);
  border-radius: var(--radius-lg);
}

/* ASIG CARD */
.asig-card {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex; text-decoration: none; color: inherit;
  margin-bottom: 10px; overflow: hidden;
  transition: box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.asig-card:active { box-shadow: none; }
.asig-stripe { width: 3px; flex-shrink: 0; }
.asig-body { flex: 1; padding: 13px 14px; min-width: 0; }
.asig-name {
  font-size: 0.92rem; font-weight: 500; color: var(--text-main);
  margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.asig-meta { font-size: 0.72rem; color: var(--text-xsoft); }
.asig-right {
  padding: 13px 12px; display: flex; flex-direction: column;
  align-items: flex-end; justify-content: space-between; flex-shrink: 0;
}
.asig-nota { font-size: 1rem; font-weight: 500; }
.asig-chevron { color: var(--border-md); font-size: 0.9rem; }

/* SALA CARDS */
.sala-card {
  border-radius: var(--radius-lg); padding: 18px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; border: 0.5px solid; width: 100%; text-align: left;
  transition: opacity 0.18s; -webkit-tap-highlight-color: transparent;
  margin-bottom: 10px;
}
.sala-card:active { opacity: 0.8; }
.sala-estudio { background: var(--ink2); border-color: var(--ink3); }
.sala-examen  { background: var(--red-dark); border-color: #3F1515; }
.sala-gym     { background: var(--green-dark); border-color: #14401A; }
.sala-icon {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.sala-icon-est { background: #1E1B4B; }
.sala-icon-exa { background: #2A0F0F; }
.sala-icon-gym { background: #0F2810; }
.sala-info { flex: 1; min-width: 0; }
.sala-name { font-size: 0.92rem; font-weight: 500; color: #F9FAFB; margin-bottom: 2px; }
.sala-desc { font-size: 0.75rem; color: var(--text-xsoft); line-height: 1.4; }
.sala-arrow { font-size: 1rem; flex-shrink: 0; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 22px; border-radius: var(--radius-md);
  font-size: 0.88rem; font-weight: 500; border: none;
  transition: all 0.18s; cursor: pointer; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-full { width: 100%; }
.btn-indigo  { background: var(--indigo); color: #fff; }
.btn-indigo:hover { background: #4338CA; }
.btn-dark    { background: var(--ink); color: #fff; }
.btn-ghost   { background: transparent; color: var(--indigo); border: 1px solid var(--indigo); }
.btn-ghost:hover { background: var(--indigo-dim); }
.btn-outline { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }
.btn-danger  { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.btn-sm { padding: 8px 14px; font-size: 0.78rem; border-radius: var(--radius-sm); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* FAB */
.fab {
  position: fixed; bottom: calc(24px + var(--safe-bot)); right: 20px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--indigo); color: #fff; border: none; font-size: 1.3rem;
  box-shadow: 0 4px 16px rgba(79,70,229,0.4);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.18s; z-index: 200;
}
.fab:active { transform: scale(0.92); }

/* FORMS */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-soft); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.88rem; color: var(--text-main); background: var(--bg-white);
  outline: none; transition: border-color 0.18s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--indigo);
}
.form-textarea { resize: vertical; line-height: 1.6; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-xsoft); }

/* FORM DARK */
.form-input-dark {
  width: 100%; padding: 12px 14px;
  background: var(--ink); border: 1px solid var(--ink3);
  border-radius: var(--radius-sm); color: #E5E7EB; font-size: 0.88rem;
  outline: none; transition: border-color 0.18s; margin-bottom: 12px;
}
.form-input-dark:focus { border-color: var(--indigo); }
.form-input-dark::placeholder { color: var(--ink3); }

/* BADGES */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.05em;
}
.badge-indigo { background: var(--indigo-xlt); color: #3730A3; }
.badge-green  { background: #D1FAE5; color: #065F46; }
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-gray   { background: var(--bg-soft); color: var(--text-soft); }

/* CHIPS */
.chip {
  padding: 7px 14px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--bg-white);
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
  transition: all 0.15s; color: var(--text-soft);
  -webkit-tap-highlight-color: transparent;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* OPT BUTTONS (chat) */
.opt-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: 99px; color: var(--text-soft); font-size: 0.82rem;
  padding: 8px 16px; cursor: pointer; transition: all 0.18s;
  font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent;
}
.opt-btn:hover, .opt-btn:active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.opt-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* PROGRESS */
.prog-wrap { background: var(--bg-soft); border-radius: 99px; height: 5px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; background: var(--indigo); transition: width 0.4s ease; }

/* NOTA CIRCLE */
.nota-circle {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 500; flex-shrink: 0;
}

/* SPINNER */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: currentColor; border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block; flex-shrink: 0;
}
.spinner-dark { border-color: rgba(0,0,0,0.1); border-top-color: var(--indigo); }
@keyframes spin { to { transform: rotate(360deg); } }

.dots-loader { display: inline-flex; gap: 4px; align-items: center; }
.dots-loader span {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; animation: dotpop 1.2s infinite;
}
.dots-loader span:nth-child(2) { animation-delay: 0.2s; }
.dots-loader span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotpop { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-5px)} }

/* TOAST */
#toast {
  position: fixed; bottom: calc(24px + var(--safe-bot)); left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 99px;
  font-size: 0.83rem; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 9999;
  transition: transform 0.3s ease; white-space: nowrap; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 300; display: none; align-items: flex-end;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--bg-white); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 22px 20px calc(28px + var(--safe-bot));
  width: 100%; animation: slideUp 0.28s ease;
  max-height: 90dvh; overflow-y: auto;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.modal-handle {
  width: 36px; height: 4px; background: var(--border-md);
  border-radius: 99px; margin: 0 auto 18px;
}
.modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem; margin-bottom: 18px; color: var(--text-main);
}

/* EMPTY STATE */
.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 48px 24px; gap: 10px;
}
.empty-icon { font-size: 2.8rem; opacity: 0.3; }
.empty-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem; color: var(--text-soft);
}
.empty-sub { font-size: 0.83rem; color: var(--text-xsoft); line-height: 1.6; max-width: 280px; }

/* SKELETON */
.skeleton {
  background: linear-gradient(90deg,#F3F4F6 25%,#E9EAEC 50%,#F3F4F6 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-md);
}
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }

/* CHAT */
.chat-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 300; display: none; flex-direction: column;
  justify-content: flex-end; backdrop-filter: blur(6px);
}
.chat-overlay.open { display: flex; }
.chat-sheet {
  background: var(--ink); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  height: 92dvh; display: flex; flex-direction: column;
  animation: slideUp 0.28s ease; overflow: hidden;
}
.chat-header {
  padding: 16px 20px 13px; border-bottom: 0.5px solid var(--ink3);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.chat-header-title { font-family: 'DM Serif Display', serif; font-size: 1rem; color: var(--indigo-lt); }
.chat-close { background: none; border: none; color: var(--text-xsoft); font-size: 1rem; cursor: pointer; padding: 4px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg-wrap { display: flex; flex-direction: column; gap: 6px; }
.msg-wrap.user-wrap { align-items: flex-end; }
.msg-label { font-size: 0.63rem; color: var(--ink3); padding: 0 4px; }
.bubble-socrates {
  background: var(--ink2); color: #D1D5DB;
  border: 0.5px solid var(--ink3);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 15px; font-size: 0.86rem; line-height: 1.6; max-width: 88%;
}
.bubble-user {
  background: var(--indigo); color: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 15px; font-size: 0.86rem; line-height: 1.5; max-width: 88%;
}
.options-row { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 4px; }
.color-opts-row { display: flex; gap: 12px; flex-wrap: wrap; padding: 4px; }
.color-opt-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer; transition: all 0.18s;
}
.color-opt-btn.selected { border-color: #fff; transform: scale(1.15); }
.typing-bubble {
  background: var(--ink2); border: 0.5px solid var(--ink3);
  border-radius: 4px 16px 16px 16px;
  padding: 12px 15px; display: inline-flex; gap: 5px; align-items: center;
}
.typing-bubble span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink3);
  animation: tdot 1.2s infinite;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot { 0%,60%,100%{transform:translateY(0);background:var(--ink3)} 30%{transform:translateY(-5px);background:var(--indigo-lt)} }
.chat-input-area {
  padding: 11px 15px calc(11px + var(--safe-bot));
  border-top: 0.5px solid var(--ink3); flex-shrink: 0; background: var(--ink); display: none;
}
.chat-input-area.visible { display: block; }
.chat-input-row { display: flex; gap: 9px; align-items: flex-end; }
.chat-textarea {
  flex: 1; background: var(--ink2); border: 1px solid var(--ink3);
  border-radius: 12px; padding: 10px 13px; color: #E5E7EB;
  font-size: 0.86rem; line-height: 1.5; outline: none;
  resize: none; max-height: 150px; min-height: 42px;
  transition: border-color 0.18s; font-family: 'Inter', sans-serif;
}
.chat-textarea:focus { border-color: var(--indigo); }
.chat-textarea::placeholder { color: var(--ink3); }
.chat-send {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--indigo); color: #fff; border: none;
  font-size: 1rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.18s;
}
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; }
.pdf-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--ink2); border: 1px solid var(--ink3);
  color: var(--text-xsoft); font-size: 0.95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pdf-btn:hover { border-color: var(--indigo); color: var(--indigo-lt); }
.prog-msg {
  background: var(--ink2); border: 0.5px solid var(--ink3);
  border-radius: 4px 16px 16px 16px; padding: 11px 15px;
  font-size: 0.82rem; color: var(--text-xsoft);
  display: flex; flex-direction: column; gap: 7px; max-width: 88%;
}
.prog-bar-mini { width: 100%; height: 3px; background: var(--ink3); border-radius: 99px; overflow: hidden; }
.prog-bar-mini-fill { height: 100%; background: var(--indigo); border-radius: 99px; transition: width 0.3s; }

/* BREAK CARD */
.break-card {
  background: #0A1A0A; border: 0.5px solid #14401A;
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 14px; display: none;
}
.break-card.visible { display: block; }
.break-title { font-size: 0.9rem; font-weight: 500; color: var(--green-accent); margin-bottom: 4px; }
.break-sub { font-size: 0.78rem; color: var(--text-xsoft); margin-bottom: 12px; line-height: 1.5; }
.break-options { display: flex; gap: 8px; flex-wrap: wrap; }
.break-opt {
  background: rgba(74,222,128,0.08); border: 0.5px solid #14401A;
  border-radius: 99px; padding: 6px 13px;
  font-size: 0.75rem; color: var(--green-accent); cursor: pointer; transition: all 0.2s;
}
.break-opt:hover { background: rgba(74,222,128,0.18); }

/* TIMER */
.timer-bar { background: var(--ink); border-bottom: 0.5px solid var(--ink3); padding: 9px 20px; display: none; }
.timer-bar.active { display: block; }
.timer-inner { max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.timer-display { font-size: 1.2rem; font-weight: 500; color: var(--indigo-lt); min-width: 52px; }
.timer-info { flex: 1; }
.timer-label { font-size: 0.72rem; color: var(--text-xsoft); }
.timer-sub { font-size: 0.65rem; color: var(--ink3); margin-top: 1px; }
.btn-timer-stop {
  background: #FEE2E2; color: #991B1B; border: none;
  padding: 5px 12px; border-radius: 99px; font-size: 0.72rem; font-weight: 500; cursor: pointer;
}

/* DAILY BRIEF PILL */
.brief-pill {
  background: var(--indigo-xlt); border: 0.5px solid #C7D2FE;
  border-radius: var(--radius-md); padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; margin-bottom: 16px; transition: all 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.brief-pill:active { opacity: 0.8; }
.brief-pill-icon { font-size: 1.1rem; flex-shrink: 0; }
.brief-pill-title { font-size: 0.85rem; font-weight: 500; color: #3730A3; }
.brief-pill-sub { font-size: 0.72rem; color: #6366F1; margin-top: 1px; }
.brief-pill-arrow { color: var(--indigo-lt); font-size: 0.9rem; margin-left: auto; flex-shrink: 0; }

/* FEEDBACK */
.feedback { border-radius: var(--radius-md); padding: 14px 16px; margin-top: 12px; animation: fadeUp 0.28s ease; }
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.fb-nota-row { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.fb-nota-label { font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; }
.fb-nota-concept { font-size: 0.9rem; font-weight: 500; }
.fb-section { margin-top: 9px; }
.fb-section-title { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 3px; }
.fb-text { font-size: 0.83rem; line-height: 1.6; color: var(--text-main); }

/* SESION ITEM */
.sesion-item {
  background: var(--bg-white); border: 0.5px solid var(--border);
  border-radius: var(--radius-md); padding: 13px 14px;
  margin-bottom: 8px; display: flex; align-items: flex-start;
  gap: 12px; box-shadow: var(--shadow-sm);
}
.sesion-badge {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; flex-shrink: 0;
}
.tipo-estudio { background: var(--indigo-xlt); }
.tipo-examen  { background: #FEE2E2; }
.sesion-body { flex: 1; min-width: 0; }
.sesion-titulo { font-size: 0.85rem; font-weight: 500; color: var(--text-main); margin-bottom: 2px; }
.sesion-meta { font-size: 0.72rem; color: var(--text-xsoft); }
.sesion-nota { font-size: 1.1rem; font-weight: 500; flex-shrink: 0; }

/* COLOR PALETTE */
.paletas { display: flex; gap: 10px; flex-wrap: wrap; }
.pal-opt {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid transparent; cursor: pointer; transition: all 0.15s;
}
.pal-opt.selected { border-color: var(--ink); transform: scale(1.15); }

/* UTILS */
.divider { height: 0.5px; background: var(--border); margin: 14px 0; }
.section-title { font-family: 'DM Serif Display', serif; font-size: 1rem; color: var(--text-main); margin-bottom: 12px; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--ink2); border-radius: 99px; padding: 5px 12px 5px 5px;
}
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--indigo);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 500; color: #fff; flex-shrink: 0;
}
.user-email { font-size: 0.72rem; color: var(--text-xsoft); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout { background: none; border: none; color: var(--ink3); font-size: 0.72rem; cursor: pointer; padding: 0; }
.btn-logout:hover { color: #EF4444; }

@media (max-width: 480px) {
  .container { padding: 0 12px; }
  .hero-stats { grid-template-columns: repeat(3,1fr); }
}

/* ── BOTTOM NAV ─────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  background: var(--bg-white);
  border-top: 0.5px solid var(--border);
  padding: 8px 0 calc(8px + var(--safe-bot));
  display: flex; align-items: center; justify-content: space-around;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; padding: 4px 12px; border-radius: var(--radius-md);
  transition: all 0.18s; border: none; background: none;
  -webkit-tap-highlight-color: transparent; min-width: 56px;
  text-decoration: none; color: inherit;
}
.nav-item:active { transform: scale(0.92); }
.nav-item-icon { font-size: 1.3rem; line-height: 1; }
.nav-item-label {
  font-size: 0.62rem; font-weight: 500; color: var(--text-xsoft);
  letter-spacing: 0.02em;
}
.nav-item.active .nav-item-label { color: var(--indigo); }
.nav-item.active .nav-item-icon { filter: none; }
.nav-item-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--indigo); margin-top: -2px;
  opacity: 0;
}
.nav-item.active .nav-item-dot { opacity: 1; }

/* ── MODO FICHA ─────────────────────────────────────────────────────── */
.ficha-wrap {
  max-width: 680px; margin: 0 auto;
  padding: 20px 16px 100px;
  display: none;
}
.ficha-wrap.active { display: block; }

.ficha-card {
  background: var(--bg-white); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px 24px;
  box-shadow: var(--shadow-md); min-height: 340px;
  display: flex; flex-direction: column;
}
.ficha-counter {
  font-size: 0.72rem; font-weight: 500; color: var(--text-xsoft);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.ficha-tipo-badge {
  display: inline-block; font-size: 0.64rem; font-weight: 600;
  padding: 3px 10px; border-radius: 99px; margin-bottom: 16px;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.ficha-pregunta {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem; color: var(--text-main);
  line-height: 1.65; margin-bottom: 20px; flex: 1;
  letter-spacing: -0.01em;
}
.ficha-answer-wrap { display: flex; flex-direction: column; gap: 10px; }
.ficha-textarea {
  width: 100%; min-height: 120px; padding: 13px 15px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 0.92rem; line-height: 1.7; color: var(--text-main);
  background: var(--bg-soft); outline: none; resize: none;
  transition: border-color 0.18s; font-family: 'Inter', sans-serif;
}
.ficha-textarea:focus { border-color: var(--indigo); background: var(--bg-white); }
.ficha-textarea::placeholder { color: var(--text-xsoft); }

.ficha-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.ficha-nav-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-white);
  font-size: 1.1rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.18s; flex-shrink: 0;
}
.ficha-nav-btn:hover { border-color: var(--indigo); color: var(--indigo); }
.ficha-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.ficha-progress {
  display: flex; gap: 4px; align-items: center; flex: 1; justify-content: center;
}
.ficha-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); transition: all 0.2s;
}
.ficha-dot.active { background: var(--indigo); transform: scale(1.2); }
.ficha-dot.done { background: var(--indigo); opacity: 0.4; }

/* ── MODO SELECTOR ──────────────────────────────────────────────────── */
.modo-selector {
  display: flex; gap: 8px; margin-bottom: 20px;
  background: var(--bg-soft); border-radius: var(--radius-md);
  padding: 4px;
}
.modo-btn {
  flex: 1; padding: 8px; border-radius: var(--radius-sm);
  border: none; background: transparent; font-size: 0.8rem;
  font-weight: 500; color: var(--text-soft); cursor: pointer;
  transition: all 0.18s; font-family: 'Inter', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.modo-btn.active {
  background: var(--bg-white); color: var(--indigo);
  box-shadow: var(--shadow-sm);
}

/* ── TIPOGRAFÍA MEJORADA PREGUNTAS ──────────────────────────────────── */
.q-text {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem; color: var(--text-main);
  line-height: 1.7; margin-bottom: 16px;
  letter-spacing: -0.01em;
}
.answer-textarea {
  font-size: 0.92rem; line-height: 1.75;
  letter-spacing: 0.01em; color: #374151;
}
.fb-text {
  font-size: 0.88rem; line-height: 1.75;
  color: #374151; letter-spacing: 0.01em;
}

/* Ajuste padding bottom para bottom nav */
.page-content { padding-bottom: calc(80px + var(--safe-bot)) !important; }

/* ── FIX TIPOGRAFÍA PREGUNTAS ── */
.ficha-pregunta {
  font-family: 'Inter', sans-serif !important;
  font-size: 1rem !important;
  font-weight: 400 !important;
  color: #374151 !important;
  line-height: 1.75 !important;
  letter-spacing: 0 !important;
}
.q-text {
  font-family: 'Inter', sans-serif !important;
  font-size: 0.95rem !important;
  font-weight: 400 !important;
  color: #374151 !important;
  line-height: 1.75 !important;
  letter-spacing: 0 !important;
}
.ficha-counter {
  font-size: 0.68rem !important;
  color: var(--text-xsoft) !important;
  font-weight: 400 !important;
  letter-spacing: 0.04em !important;
}
.q-num {
  font-size: 0.68rem !important;
  font-weight: 400 !important;
  color: var(--text-xsoft) !important;
  letter-spacing: 0.04em !important;
}

/* ── CARRUSEL ESTILO IG ── */
.carrusel-wrap {
  overflow: hidden;
  width: 100%;
  position: relative;
}
.carrusel-track {
  display: flex;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.carrusel-slide {
  min-width: 100%;
  padding: 0 16px;
}
.carrusel-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 12px 0 4px;
}
.carrusel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border-md);
  transition: all 0.25s;
}
.carrusel-dot.active {
  background: var(--indigo);
  width: 18px;
  border-radius: 3px;
}
.carrusel-dot.done {
  background: var(--indigo);
  opacity: 0.35;
}
.carrusel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  max-width: 680px;
  margin: 0 auto;
}
.carrusel-prom {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.carrusel-prom-val {
  font-size: 1rem;
  font-weight: 600;
  color: var(--indigo);
}
.carrusel-counter {
  font-size: 0.78rem;
  color: var(--text-xsoft);
}
.btn-finalizar-inline {
  background: var(--indigo); color: #fff; border: none;
  padding: 8px 18px; border-radius: var(--radius-md);
  font-weight: 500; font-size: 0.82rem; cursor: pointer;
}

/* ── HISTORIAS ESTILO IG ─────────────────────────────────────────────── */
.historias-wrap {
  background: var(--bg-white);
  border-bottom: 0.5px solid var(--border);
  padding: 14px 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.historias-wrap::-webkit-scrollbar { display: none; }

.historias-track {
  display: flex;
  gap: 16px;
  padding: 0 16px;
  width: max-content;
}

.historia-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 64px;
}

.historia-ring {
  width: 58px; height: 58px;
  border-radius: 50%;
  padding: 2.5px;
  background: conic-gradient(var(--ring-color, #E5E7EB) 0%, var(--ring-color, #E5E7EB) 100%);
  transition: transform 0.18s;
}
.historia-ring:active { transform: scale(0.92); }

.historia-ring.rojo {
  background: conic-gradient(#EF4444, #F97316, #EF4444);
}
.historia-ring.amarillo {
  background: conic-gradient(#F59E0B, #FCD34D, #F59E0B);
}
.historia-ring.verde {
  background: conic-gradient(#10B981, #34D399, #10B981);
}
.historia-ring.indigo {
  background: conic-gradient(var(--indigo), var(--indigo-lt), var(--indigo));
}
.historia-ring.gris {
  background: var(--border);
}

.historia-avatar {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2.5px solid var(--bg-white);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 600;
  color: var(--indigo); font-family: 'DM Serif Display', serif;
  overflow: hidden;
}

.historia-nueva .historia-avatar {
  background: var(--indigo-xlt);
  color: var(--indigo);
  font-size: 1.4rem;
  font-family: 'Inter', sans-serif;
}

.historia-label {
  font-size: 0.65rem;
  color: var(--text-soft);
  text-align: center;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}
.historia-sublabel {
  font-size: 0.6rem;
  color: var(--text-xsoft);
  text-align: center;
  margin-top: -3px;
}

/* ── PANTALLA DE CARGA ENTRETENIDA ──────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg-page);
  display: none; flex-direction: column;
  align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 24px) 0 calc(24px + var(--safe-bot));
}
.loading-screen.active { display: flex; }

.loading-header {
  text-align: center; padding: 0 20px;
}
.loading-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem; color: var(--indigo);
  margin-bottom: 6px;
}
.loading-status {
  font-size: 0.78rem; color: var(--text-xsoft);
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.loading-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--indigo);
  animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.loading-cards-wrap {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; width: 100%;
  padding: 20px 0;
}

.loading-cards-outer {
  overflow: hidden; width: 100%;
}
.loading-cards-track {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.loading-card-slide {
  min-width: 100%; padding: 0 20px;
}
.loading-card {
  background: var(--bg-white);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  min-height: 220px;
  display: flex; flex-direction: column;
  justify-content: space-between;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.loading-card-type {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-soft); margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}
.loading-card-type-dot {
  width: 5px; height: 5px; border-radius: 50%;
}
.loading-card-emoji {
  font-size: 2rem; margin-bottom: 10px;
}
.loading-card-text {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem; color: var(--text-main);
  line-height: 1.65; flex: 1;
}
.loading-card-source {
  font-size: 0.7rem; color: var(--text-xsoft);
  margin-top: 14px; border-top: 0.5px solid var(--border);
  padding-top: 10px;
}
.loading-card.tipo-curiosidad { border-color: #4F46E530; }
.loading-card.tipo-humor { border-color: #F59E0B30; }
.loading-card.tipo-noticia { border-color: #10B98130; }
.loading-card.tipo-tip { border-color: #818CF830; }

.loading-dots {
  display: flex; justify-content: center; gap: 5px; margin-top: 16px;
}
.loading-dot {
  height: 5px; border-radius: 3px;
  background: var(--border); transition: all 0.3s;
}
.loading-dot.active { background: var(--indigo); width: 16px; }
.loading-dot.inactive { width: 5px; }

.loading-progress {
  width: 100%; padding: 0 20px;
}
.loading-progress-bar {
  background: var(--border); border-radius: 99px; height: 3px;
  overflow: hidden; margin-bottom: 8px;
}
.loading-progress-fill {
  height: 100%; background: var(--indigo);
  border-radius: 99px; transition: width 0.5s ease;
}
.loading-progress-text {
  font-size: 0.72rem; color: var(--text-xsoft);
  text-align: center;
}

/* ── SIDEBAR LAYOUT ─────────────────────────────────────────────────── */
.app-layout {
  display: flex; min-height: 100dvh;
}

/* SIDEBAR */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200; transition: transform 0.3s ease;
}
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 0.5px solid var(--border);
}
.sidebar-logo-text {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem; color: var(--indigo);
}
.sidebar-logo-sub {
  font-size: 0.68rem; color: var(--text-xsoft); margin-top: 2px;
}
.sidebar-nav {
  flex: 1; padding: 12px 8px; overflow-y: auto;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  font-size: 0.85rem; font-weight: 400; color: var(--text-soft);
  cursor: pointer; text-decoration: none; transition: all 0.15s;
  border: none; background: none; width: 100%; text-align: left;
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-item:hover { background: var(--border); color: var(--text-main); }
.sidebar-item.active {
  background: var(--indigo-xlt); color: var(--indigo); font-weight: 500;
}
.sidebar-item-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-section {
  font-size: 0.62rem; font-weight: 600; color: var(--text-xsoft);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 12px 12px 4px; margin-top: 4px;
}
.sidebar-footer {
  padding: 12px 8px;
  border-top: 0.5px solid var(--border);
}

/* SIDEBAR COLAPSADO */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-logo-sub,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-item span:not(.sidebar-item-icon),
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-logo-text { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 9px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed + .main-content { margin-left: 56px; }
.sidebar.collapsed .sidebar-logo { padding: 20px 8px 16px; text-align: center; }

.btn-collapse {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  font-size: 0.85rem; color: var(--text-soft);
  cursor: pointer; border: none; background: none;
  font-family: 'Inter', sans-serif; transition: all 0.15s;
}
.btn-collapse:hover { background: var(--border); color: var(--text-main); }
.sidebar.collapsed .btn-collapse { justify-content: center; padding: 9px; }
.sidebar.collapsed .btn-collapse span:last-child { display: none; }
.collapse-icon { transition: transform 0.3s; font-size: 0.9rem; }
.sidebar.collapsed .collapse-icon { transform: rotate(180deg); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-md);
  cursor: pointer; transition: all 0.15s;
}
.sidebar-user:hover { background: var(--border); }
.sidebar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--indigo); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 600; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 0.78rem; font-weight: 500; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 0.65rem; color: var(--text-xsoft);
}

/* MAIN CONTENT */
.main-content {
  flex: 1; margin-left: 240px;
  min-height: 100dvh; display: flex; flex-direction: column;
}

/* MOBILE: solo phones — sidebar oculto, bottom nav visible */
@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 199; display: none;
  }
  .sidebar-overlay.open { display: block; }
  .bottom-nav { display: flex; }
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(var(--safe-top) + 10px) 16px 10px;
    background: var(--bg-white); border-bottom: 0.5px solid var(--border);
    position: sticky; top: 0; z-index: 100;
  }
  .mobile-header-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1rem; color: var(--text-main);
  }
  .btn-menu {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    border: 0.5px solid var(--border); background: var(--bg-white);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; cursor: pointer;
  }
}

/* TABLET iPad y superiores — sidebar visible */
@media (min-width: 641px) {
  .sidebar { transform: translateX(0) !important; }
  .main-content { margin-left: 240px; }
  .bottom-nav { display: none !important; }
  .mobile-header { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* DESKTOP */
@media (min-width: 1024px) {
  .sidebar { width: 260px; }
  .main-content { margin-left: 260px; }
}
