/* ========================================================= 
   Alma — CPPA Chat UI (sin pantalla Teacher)
   Paleta Alma (#F58220) + neutrales claros
========================================================= */

/* -------- Variables de tema -------- */
:root{
  --bg:#f7f8fa;
  --surface:#ffffff;
  --surface-2:#f5f7fb;
  --border:#e6e8ed;
  --text:#0f172a;
  --muted:#64748b;
  --muted-2:#94a3b8;

  --brand:#F58220;
  --brand-600:#e46f0a;
  --brand-50:#fff3e8;
  --brand-100:#ffe6d1;

  --accent:#1e293b;

  --radius-sm:.5rem;
  --radius-md:.75rem;
  --radius-lg:1rem;

  --shadow-1:0 1px 2px rgba(15,23,42,.06);
  --shadow-2:0 10px 24px rgba(15,23,42,.14);

  --header-h:60px;
  --composer-h:64px;
  --nav-h:60px;
  --safe-bottom:env(safe-area-inset-bottom,0px);
}

/* -------- Base / Reset -------- */
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:'Inter',system-ui,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
}
.hidden{display:none!important}
[hidden]{display:none!important}
button{font:inherit;cursor:pointer;background:none;border:none}
button:focus-visible,
[role="menuitem"]:focus-visible,
.summary-btn:focus-visible,
input:focus-visible,
select:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
  border-radius:8px;
}

/* =========================================================
   Root screens (solo una visible)
========================================================= */
.screen-root{display:none; min-height:100dvh;}  /* dvh moderno */
.screen-root.active{display:block}
.screen-root[hidden]{display:none!important}

/* =========================================================
   Layout dividido
========================================================= */
.split-shell{
  display:flex;
  height:calc(100dvh - var(--nav-h) - var(--safe-bottom));
  width:100%;
}

.split-shell .screen{
  flex:1;
  display:flex;
  flex-direction:column;
}
#conversations{
  max-width:360px;
  border-right:1px solid var(--border);
  overflow:hidden;
}
#chat{
  flex:2;
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

/* Responsive móvil */
@media (max-width:720px){
  .split-shell{
    flex-direction:column;
    height:calc(100dvh - var(--nav-h) - var(--safe-bottom));
  }

  /* Garantiza que al abrir chat se oculte la lista */
  #rootChat:has(#chatActive:not([hidden])) #chat{display:flex !important;}
  #rootChat:has(#chatActive:not([hidden])) #conversations{display:none !important;}

  #conversations,#chat{max-width:100%}

  /* por defecto lista visible, chat oculto */
  #chat{display:none}

  /* mostrar chat cuando #chatActive está visible */
  #rootChat:has(#chatActive:not([hidden])) #chat{display:flex}
  #rootChat:has(#chatActive:not(.hidden))   #chat{display:flex}
  #rootChat:has(#chatActive:not([hidden])) #conversations{display:none}
  #rootChat:has(#chatActive:not(.hidden))   #conversations{display:none}

  .hide-when-compact{display:none!important}
}

/* =========================================================
   Header común
========================================================= */
.app-header{
  position:sticky;top:0;z-index:10;
  display:flex;align-items:center;justify-content:space-between;
  height:var(--header-h);
  padding:0 .95rem;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.app-header .header-title,.app-header h2{
  font-size:1.05rem;font-weight:700;color:var(--accent);
}
.header-actions{display:flex;align-items:center;gap:.5rem}
.icon-btn{
  width:36px;height:36px;border-radius:999px;
  display:inline-flex;align-items:center;justify-content:center;
  color:var(--muted);
  transition:background .15s,color .15s,box-shadow .15s,transform .06s;
}
.icon-btn:hover{background:#edf1f6;color:var(--accent)}
.icon-btn:active{transform:scale(.98)}
.cpap-header-logo{height:22px;width:auto;display:block;margin-right:.35rem;opacity:.95}

/* =========================================================
   Menús contextuales (dropdowns)
========================================================= */
.context-menu{
  position:fixed;
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:var(--shadow-2);
  display:flex;
  flex-direction:column;
  min-width:200px;
  padding:.35rem 0;
  z-index:1000;
  opacity:0;
  transform:translateY(-6px) scale(.98);
  transition:opacity .15s ease, transform .15s ease;
}
.context-menu:not(.hidden){
  opacity:1;
  transform:translateY(0) scale(1);
}
.menu-item{
  display:flex;align-items:center;gap:.55rem;
  padding:.62rem 1rem;
  font-size:.93rem;color:var(--text);
  white-space:nowrap;text-align:left;
  background:transparent;
}
.menu-item i{width:18px;text-align:center;color:var(--muted)}
.menu-item:hover{background:var(--brand-50);color:var(--brand-600)}
.menu-item:hover i{color:var(--brand-600)}
.menu-item.danger{color:#e11d48}
.menu-item.danger:hover{background:#fee2e2;color:#b91c1c}
.menu-sep{height:1px;background:var(--border);margin:.25rem 0}

/* =========================================================
   Toasts & Banner
========================================================= */
.toasts{position:fixed;top:1rem;right:1rem;display:flex;flex-direction:column;gap:.5rem;z-index:50}
.toast{
  background:#111827;color:#fff;
  padding:.55rem .85rem;border-radius:.6rem;
  font-size:.85rem;box-shadow:var(--shadow-2);
  opacity:0;transform:translateY(-8px);transition:.18s
}
.toast.visible{opacity:1;transform:translateY(0)}
.toast.info{background:var(--brand)}
.toast.error{background:#e11d48}

/* Banner de red */
.banner{
  position:fixed;left:0;right:0;top:0;
  display:flex;align-items:center;gap:.6rem;
  padding:.55rem .9rem;
  background:#111827;color:#fff;
  z-index:60;
  box-shadow:var(--shadow-2);
}
.banner.hidden,[hidden].banner{display:none!important}

/* =========================================================
   Lista de conversaciones
========================================================= */
.conversation-toolbar{
  background:var(--surface);
  border-bottom:1px solid var(--border);
  padding:.6rem .95rem;
}
.searchbar{
  display:flex;align-items:center;gap:.55rem;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:999px;
  padding:.45rem .85rem;
}
.searchbar input{
  flex:1;border:none;outline:none;background:transparent;
  color:var(--text);font-size:.95rem;
}
.searchbar input::placeholder{color:#9aa6b2}
.searchbar i{color:var(--muted-2)}
.searchbar .icon-btn{width:32px;height:32px}

.filters-collapsible{background:var(--surface);border-bottom:1px solid var(--border)}
.filters-collapsible>summary{
  list-style:none;cursor:pointer;padding:.65rem .95rem;
  color:var(--muted);font-weight:600;
}
.filters-collapsible[open]>summary{color:var(--text)}
.filters-panel{padding:.35rem .95rem .85rem}
.segments{display:flex;flex-wrap:wrap;gap:.5rem;margin:.2rem 0 .6rem}
.segment{
  background:#fff;color:var(--accent);
  border:1px solid var(--border);border-radius:999px;
  padding:.35rem .75rem;font-size:.83rem;cursor:pointer;
}
.segment:hover{border-color:#d8dbe2}
.segment.active{background:var(--brand);color:#fff;border-color:var(--brand)}

.conversation-list{background:var(--surface);overflow:auto;flex:1}
.conversation-item{
  display:flex;gap:.9rem;align-items:flex-start;
  padding:.95rem .95rem;
  border-bottom:1px solid #eef1f5;
  background:var(--surface);
  transition:background .15s,box-shadow .15s;
  cursor:pointer;
}
.conversation-item:hover{background:#fafbff}
.conversation-item .avatar{
  flex:0 0 40px;height:40px;display:flex;align-items:center;justify-content:center;
  font-size:2rem;color:#c1c9d6;
}
.conversation-info{flex:1;min-width:0}
.conversation-info .row{display:flex;justify-content:space-between;gap:.5rem}
.conversation-info .title{
  font-weight:700;font-size:.98rem;color:var(--accent);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.conversation-info .time{font-size:.78rem;color:#9aa6b2}
.conversation-info .snippet{
  margin-top:.2rem;font-size:.9rem;color:var(--muted);
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.meta{display:flex;gap:.35rem;align-items:center;margin-top:.42rem;flex-wrap:wrap}

.badge-unread{
  background:var(--brand);color:#fff;font-weight:800;
  border-radius:999px;padding:.05rem .5rem;font-size:.72rem;
}
.pin-icon{color:#f59e0b}
.archive-icon{color:#94a3b8}

.list-footer{background:var(--surface);border-top:1px solid var(--border);display:flex;justify-content:center;padding:.7rem}
.btn-secondary{
  background:#fff;color:var(--accent);
  border:1px solid var(--border);border-radius:.65rem;
  padding:.5rem .9rem;cursor:pointer;
}
.btn-secondary:hover{background:#fafafa;border-color:#d8dbe2}
.btn-primary{
  background:var(--brand);color:#fff;
  border:0;border-radius:.6rem;padding:.55rem 1rem;
  font-weight:700;cursor:pointer;
}
.btn-primary:hover{background:var(--brand-600)}
.btn-compact{padding:.25rem .55rem;border-radius:.5rem;font-size:.85rem}
.empty-state{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:.7rem;padding:2.5rem 1rem;color:var(--muted);
}
.empty-state i{font-size:2rem;color:#c1c9d6}

/* Checkbox selección */
.conversation-item .select-checkbox{
  margin-left:auto;
  align-self:center;
  width:18px;height:18px;
  cursor:pointer;
  accent-color:var(--brand);
  flex:0 0 auto;
}
.conversation-item .select-checkbox:focus-visible{
  outline:2px solid var(--brand);
  outline-offset:2px;
  border-radius:4px;
}

/* =========================================================
   Chat + marca de agua
========================================================= */
.chat-header-left{display:flex;align-items:center;gap:.6rem}
.back-btn{color:var(--muted);font-size:1.2rem}
.back-btn:hover{color:var(--accent)}
.chat-meta{display:flex;align-items:center;gap:.6rem}
.chat-meta img.avatar-img{width:34px;height:34px;border-radius:50%}
.name-role h2{font-size:1rem;font-weight:700;color:var(--accent)}
.chat-status{font-size:.78rem;color:#1aa36a}

#chatActive{
  display:flex;
  flex-direction:column;
  flex:1 1 auto;
  min-height:0;
}
#chatActive.hidden, #chatActive[hidden]{ display:none !important; }

/* Ocultar CTA cuando hay chat activo */
#chatEmpty.hidden, #chatEmpty[hidden]{display:none !important;}
#chat:has(#chatActive:not(.hidden)) #chatEmpty,
#chat:has(#chatActive:not([hidden])) #chatEmpty{display:none !important;}

.chat-box{
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: .6rem;
  overflow: auto;
  position: relative;
  padding: 1rem .9rem calc(var(--composer-h) + 16px);
  scroll-padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--composer-h) + 24px);
}

.chat-watermark{
  position:absolute; inset:0;
  display:block;
  background:url("CPPA_LOGO_BLACK.png") center/220px no-repeat;
  opacity:.15;
  pointer-events:none;
}

.message{max-width:860px;width:fit-content}
.message[data-sender="alma"]{align-self:flex-start}
.message[data-sender="user"]{align-self:flex-end}

.bubble{
  position:relative;background:#fff;
  border:1px solid var(--border);
  padding:.7rem 1rem;border-radius:999px;
  line-height:1.5;font-size:.96rem;
  box-shadow:var(--shadow-1);
}
.message[data-sender="alma"] .bubble{
  background:linear-gradient(180deg,#fff7f0,#ffffff);
  border-color:#ffd9b8;padding-left:1.1rem;
}
.message[data-sender="alma"] .bubble::before{
  content:"";position:absolute;left:.5rem;top:50%;
  transform:translateY(-50%);
  width:4px;height:65%;border-radius:4px;background:var(--brand);
}
.message[data-sender="user"] .bubble{background:#eef2f7;border-color:#e1e6ef}

.row.meta{
  display:flex;justify-content:flex-end;gap:.45rem;
  font-size:.72rem;color:#8893a3;margin-top:.25rem;
}
.thinking-indicator{font-size:.85rem;color:var(--muted);padding:.25rem .35rem}

/* Inline prompt */
.inline-prompt{
  display:inline-flex;gap:.4rem;align-items:center;margin-left:.6rem;
  background:#fff;border:1px dashed var(--border);border-radius:999px;
  padding:.18rem .35rem;font-size:.82rem
}
.inline-prompt span{color:var(--muted)}

/* el contenedor ya resta la nav; mantenlo así */
#chatActive{
  display:grid;
  grid-template-rows:auto 1fr auto;
  min-height:calc(100dvh - var(--nav-h) - var(--safe-bottom));
}

/* ── Composer: contenedor y posicionamiento ───────────────── */
.composer{
  position: static;
  margin: .5rem .9rem 0;
  z-index: auto;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .12rem;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.9));
  -webkit-backdrop-filter: saturate(1.2) blur(2px);
  backdrop-filter: saturate(1.2) blur(2px);
  border-radius: 14px;
}

/* La nav mantiene un z por debajo del composer */
.bottom-nav{ z-index: 30; }

.composer-field{
  flex:1;display:flex;align-items:center;gap:.6rem;
  background:#fff;border:1px solid var(--border);
  border-radius:999px;padding:.55rem .9rem;box-shadow:var(--shadow-2);
}
.composer-field input{flex:1;border:0;outline:none;background:transparent;font-size:.96rem}
.composer-field input::placeholder{color:#9aa6b2}
.send-status{color:var(--muted);font-size:.82rem}

/* Estados de micrófono sin romper estilos actuales */
#micBtn[aria-pressed="true"],
#micBtn.recording{
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-50);
}

/* Botones laterales del composer */
.composer-btn{ flex:0 0 44px; height:44px; }
.composer-send{ height:44px; padding:0 1rem; margin-left:.1rem; }

/* Botón enviar coherente con la altura */
.composer-send{
  height: 44px;
  padding: 0 1rem;
  margin-left: .1rem;
}

.composer-send:hover{background:var(--brand-600)}
.composer-send:disabled{opacity:.55;cursor:not-allowed;box-shadow:none}

/* Snackbar Undo */
.undo-bar{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--composer-h) + 24px);
  display: flex;
  align-items: center;
  gap: .6rem;
  background: #111827;
  color: #fff;
  border-radius: .75rem;
  padding: .5rem .8rem;
  box-shadow: var(--shadow-2);
  z-index: 25;
  font-size: .9rem;
}
.undo-bar .btn-secondary{
  background:#fff;border-color:transparent;color:var(--accent);
  padding:.28rem .6rem;border-radius:.5rem;
}
.undo-bar .countdown{opacity:.8;font-variant-numeric:tabular-nums;}

/* =========================================================
   Bottom nav
========================================================= */
.bottom-nav{
  position:fixed;left:0;right:0;bottom:0;
  height:calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom:var(--safe-bottom);
  background:var(--surface);
  border-top:3px solid var(--brand);
  display:flex;justify-content:space-around;align-items:center;
}
.bottom-nav{ z-index:30; }
.nav-item{
  flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:.18rem;color:var(--muted);font-size:.8rem;
}
.nav-item i{font-size:1.2rem}
.nav-item.active,
.bottom-nav .nav-item[aria-current="page"]{
  color:var(--brand-600);font-weight:700
}
.nav-item.active i,
.bottom-nav .nav-item[aria-current="page"] i{color:var(--brand-600)}

/* =========================================================
   Modales (base)
========================================================= */
.modal{
  position:fixed; inset:0; z-index:200;
  background:
    radial-gradient(1200px 600px at 70% 10%, rgba(245,130,32,.08), transparent),
    rgba(15,23,42,.38);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display:flex; align-items:center; justify-content:center;
}
.modal.hidden, .modal[hidden]{display:none!important}

.modal-content{
  position:relative;
  width:min(640px,92vw);
  max-height:calc(100vh - 12vh);
  overflow:auto;
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 30px 60px rgba(15,23,42,.25);
  padding:1.25rem 1.25rem 1rem;
  display:flex; flex-direction:column; gap:1rem;
}
.modal:not(.hidden) .modal-content{ animation:modalPop .18s ease-out }
@keyframes modalPop{
  from{ transform:translateY(6px) scale(.98); opacity:0 }
  to{   transform:translateY(0)   scale(1);   opacity:1 }
}
.modal-content::before{
  content:"";
  position:sticky; top:0; left:0; right:0;
  display:block; height:4px;
  background:linear-gradient(90deg,var(--brand),var(--brand-600));
  border-top-left-radius:16px; border-top-right-radius:16px;
  margin:-1.25rem -1.25rem 0;
}

.modal-close{
  position:absolute; top:.75rem; right:.75rem;
  width:36px; height:36px; border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  color:var(--muted);
}
.modal-close:hover{ background:#f1f5f9; color:var(--accent) }

.modal-body{font-size:.95rem; color:var(--text); line-height:1.5}

/* Campos de formulario */
.modal-content label{
  font-size:.85rem; font-weight:700; color:var(--accent);
  margin:.2rem 0 .25rem;
}
.modal-content input[type="text"],
.modal-content textarea{
  width:100%;
  border:1px solid var(--border);
  background:#fff;
  border-radius:.65rem;
  padding:.6rem .75rem;
  font-size:.95rem; color:var(--text);
  transition:border-color .15s, box-shadow .15s;
  resize:vertical;
}
.modal-content textarea{ min-height:92px }
.modal-content input::placeholder,
.modal-content textarea::placeholder{ color:#9aa6b2 }
.modal-content input:focus,
.modal-content textarea:focus{
  border-color:#ffcfac;
  box-shadow:0 0 0 3px var(--brand-50);
  outline:0;
}

.modal-actions{
  position:sticky; bottom:0; left:0; right:0;
  display:flex; justify-content:flex-end; gap:.6rem;
  padding:.75rem .25rem 0;
  margin-top:.35rem;
  background:linear-gradient(to top,#fff 70%,rgba(255,255,255,0));
  border-top:1px solid var(--border);
}
.modal-actions .btn-primary{ box-shadow:0 6px 16px rgba(245,130,32,.25) }

/* =========================================================
   Modales de My Space (tamaños / títulos con icono)
========================================================= */
#addWordModal .modal-content,
#editVocabModal .modal-content{ width:min(520px,92vw) }
#editSuggestionModal .modal-content,
#editCorrectionModal .modal-content{ width:min(640px,92vw) }

#addWordModal h2,
#editVocabModal h2,
#editSuggestionModal h2,
#editCorrectionModal h2{
  display:flex; align-items:center; gap:.5rem;
  font-size:1.05rem; font-weight:800; color:var(--accent);
  margin:.25rem 0;
}
#addWordModal h2::before,
#editVocabModal h2::before,
#editSuggestionModal h2::before,
#editCorrectionModal h2::before{
  content:"";
  display:inline-grid; place-items:center;
  width:28px; height:28px; border-radius:999px;
  background:var(--brand-50); color:var(--brand-600);
  font-family:"Font Awesome 6 Free"; font-weight:900; font-size:.9rem;
}
#addWordModal h2::before{ content:"\f067"; }        /* plus */
#editCorrectionModal h2::before{ content:"\f304"; }  /* pen */
#editSuggestionModal h2::before{ content:"\f0eb"; }  /* lightbulb */
#editVocabModal h2::before{ content:"\f02d"; }       /* book */

.suggestion-edit-list{ display:flex; flex-direction:column; gap:.5rem; margin:.4rem 0 .2rem }
.suggestion-edit-item{
  display:flex; align-items:center; gap:.4rem;
  background:#fff; border:1px dashed var(--border);
  border-radius:.55rem; padding:.4rem;
}
.suggestion-edit-item .sugg-input{
  flex:1; border:0; outline:0; font-size:.95rem; padding:.4rem .5rem;
}
.suggestion-edit-item .remove-sugg{
  border:1px solid var(--border); background:#fff; border-radius:.5rem;
  width:36px; height:36px;
}
.suggestion-edit-item .remove-sugg:hover{ border-color:#d8dbe2 }

/* Corrections modal: tarjetas misma altura en desktop */
@media (min-width:720px){
  #correctionModal .corr-card{ height:100% }
}

/* =========================================================
   Splash Screen
========================================================= */
.splash{
  position:fixed;inset:0;z-index:1000;
  background:#fff;display:flex;align-items:center;justify-content:center;
}
.splash-card{
  width:min(520px,88vw);
  display:flex;flex-direction:column;align-items:center;gap:14px;text-align:center
}
.splash-logo{width:min(320px,72vw)}
.splash-progress{
  width:100%;height:8px;
  background:#f3f4f6;border:1px solid var(--border);
  border-radius:999px;overflow:hidden;
  box-shadow:inset 0 1px 2px rgba(15,23,42,.06);
}
.splash-progress-bar{
  height:100%;
  background:linear-gradient(90deg,var(--brand),var(--brand-600));
  width:0%;transition:width .3s ease;
}
.splash-percent{font-weight:700;font-variant-numeric:tabular-nums;letter-spacing:.2px}
.splash-hint{font-size:.92rem;color:var(--muted);min-height:1.2em}
.splash-brand-strip{position:absolute;left:0;right:0;bottom:0;height:8px;background:var(--brand)}
.splash.is-hidden{opacity:0;pointer-events:none;transition:opacity .45s}

/* =========================================================
   CPPA Badge opcional
========================================================= */
.cpap-badge{
  position:fixed;right:16px;
  bottom:calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index:30;background:#fff;border:1px solid var(--border);
  border-radius:var(--radius-md);padding:6px 10px;box-shadow:var(--shadow-1);
  opacity:.85;transition:opacity .2s;
}
.cpap-badge:hover{opacity:1}
.cpap-badge img{display:block;height:20px;width:auto}

/* =========================================================
   Voice-only mode (opcional)
========================================================= */
.voice-only .composer-field,
.voice-only #sendBtn,
.voice-only #repeatBtn{display:none !important;}
.voice-only .composer{
  left:auto; right:16px;
  bottom:calc(var(--nav-h) + var(--safe-bottom) + 12px);
  width:auto; box-shadow:none;
}
.voice-only #micBtn{
  width:56px; height:56px;
  border-radius:999px;
  box-shadow:var(--shadow-2);
}

/* ===== Corrections modal – layout ===== */
.corr-grid{
  display:grid;
  gap:12px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px){
  .corr-grid{ grid-template-columns: 1fr 1fr; }
}
.corr-card{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .9rem;
  box-shadow: var(--shadow-1);
}
.corr-title{
  font-size: .95rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: .45rem;
}
.corr-text{
  font-size: .98rem;
  color: var(--text);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: .6rem;
  padding: .55rem .7rem;
}
.corr-fixed{
  border-color: #ffd9b8;
  background: linear-gradient(180deg, #fff7f0, #ffffff);
}
.corr-tip{ margin-top: .5rem; font-size: .9rem; color: var(--muted); }
.corr-actions{ display:flex; gap:.5rem; margin-top:.65rem; }
.corr-suggestions{
  list-style:none; padding:0; margin:0;
  display:flex; flex-direction:column; gap:.4rem;
}
.corr-suggestions li{
  display:flex; align-items:center; justify-content:space-between; gap:.6rem;
  background:#fff; border:1px solid var(--border);
  border-radius:.55rem; padding:.45rem .6rem; font-size:.95rem;
}
.corr-suggestions .save-sugg{
  border:1px solid var(--border); background:#fff; border-radius:.5rem;
  padding:.35rem .55rem; font-weight:700; cursor:pointer;
}
.corr-suggestions .save-sugg:hover{ border-color:#d8dbe2 }
.corr-suggestions .sugg-text{ flex:1; }
.corr-suggestions .save-sugg i{ margin-right:.35rem; }
.corr-suggestions .save-sugg:active{ transform:scale(.98); }

/* =========================
   Chat vacío (CTA inicial)
========================= */
#chat #chatEmpty{
  flex:1 1 auto;
  min-height:0;
  display:grid;
  place-items:center;
  padding:1.25rem;
  background:var(--bg);
  position:relative;
}
.chat-empty-card{
  width:min(520px,92vw);
  background:var(--surface);
  border:1px dashed var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-1);
  text-align:center;
  padding:2rem 1.5rem;
}
.chat-empty-logo{
  width:72px; height:72px;
  object-fit:contain;
  border-radius:16px;
  opacity:.9;
  margin-bottom:.75rem;
}
.chat-empty-card h3{
  font-size:1.15rem;
  font-weight:800;
  color:var(--accent);
  margin:.25rem 0 .35rem;
}
.chat-empty-card p{
  color:var(--muted);
  font-size:.95rem;
  margin:0 0 1rem 0;
}
.btn-cta{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  padding:.75rem 1.1rem;
  border-radius:.75rem;
  font-size:1rem;
  box-shadow:var(--shadow-2);
}
.btn-cta i{ margin-right:.1rem; }
.btn-cta:hover{ transform:translateY(-1px); }
.btn-cta:active{ transform:translateY(0); }

@media (min-width:721px){
  #chat #chatEmpty{ padding:1.75rem; }
}

/* =========================================================
   ──────── My Space (Corrections / Suggestions / Vocab) ────────
========================================================= */
.myspace-search{
  position:sticky;
  top:var(--header-h);
  z-index:9;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.myspace-search .searchbar{
  background:#fff;
  border-radius:12px;
  border:1px solid var(--border);
  box-shadow:var(--shadow-1);
}
.myspace-search .filters-panel{
  display:flex;flex-direction:column;gap:.6rem;
  padding:.6rem .95rem .8rem;
}
.myspace-search .segments .segment{
  transition:transform .08s ease,border-color .15s ease,background .15s ease;
}
.myspace-search .segments .segment:hover{transform:translateY(-1px)}

.myspace-tabs{
  position:sticky;
  top:calc(var(--header-h) + 62px);
  z-index:8;
  display:flex; gap:.5rem; padding:.5rem .95rem; background:var(--surface);
  border-bottom:1px solid var(--border);
}
.myspace-tabs .tab{
  position:relative;
  background:#fff;border:1px solid var(--border);color:var(--accent);
  border-radius:999px;padding:.4rem .9rem;font-size:.85rem;font-weight:600;
  transition:color .15s ease, border-color .15s ease, background .15s ease, transform .08s ease;
}
.myspace-tabs .tab:hover{border-color:#d8dbe2; transform:translateY(-1px)}
.myspace-tabs .tab.active{
  background:var(--brand);border-color:var(--brand);color:#fff;
}
.myspace-tabs .tab.active::after{
  content:""; position:absolute; left:12px; right:12px; bottom:-9px;
  height:3px; border-radius:2px;
  background:linear-gradient(90deg,var(--brand),var(--brand-600));
}

.tab-content{
  display:none;
  padding:1rem .95rem 5.5rem;
  gap:1rem;
  background:var(--bg);
  min-height:calc(100vh - var(--header-h) - var(--nav-h) - 160px);
  grid-template-columns:repeat(auto-fill,minmax(300px,1fr));
}
.tab-content.active{display:grid}
.tab-content[hidden]{display:none!important}

/* Mostrar panel de la pestaña activa (sin JS extra) */
#myspace:has(.myspace-tabs .tab.active[data-tab="corrections"]) #corrections{display:grid !important;}
#myspace:has(.myspace-tabs .tab.active[data-tab="suggestions"]) #suggestions{display:grid !important;}
#myspace:has(.myspace-tabs .tab.active[data-tab="vocabulary"])  #vocabulary{display:grid !important;}

#myspace:has(.myspace-tabs .tab.active[data-tab="corrections"]) #suggestions,
#myspace:has(.myspace-tabs .tab.active[data-tab="corrections"]) #vocabulary{display:none !important;}
#myspace:has(.myspace-tabs .tab.active[data-tab="suggestions"]) #corrections,
#myspace:has(.myspace-tabs .tab.active[data-tab="suggestions"]) #vocabulary{display:none !important;}
#myspace:has(.myspace-tabs .tab.active[data-tab="vocabulary"]) #corrections,
#myspace:has(.myspace-tabs .tab.active[data-tab="vocabulary"]) #suggestions{display:none !important;}

/* Cards My Space */
.ms-card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow-1);
  display:flex;flex-direction:column;overflow:hidden;
  transition:transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.ms-card:hover{
  transform:translateY(-2px);
  box-shadow:0 10px 28px rgba(15,23,42,.12);
  border-color:#dfe3ea;
}
.ms-card-head{
  display:flex;align-items:center;justify-content:space-between;
  gap:.6rem;padding:.65rem .85rem;border-bottom:1px solid var(--border);
  background:linear-gradient(180deg,#f9fafb,#fff);
}
.ms-card-head .chip{
  background:var(--brand-50);border:1px solid var(--brand-100);
  color:#7a3d00;border-radius:999px;padding:.18rem .55rem;font-size:.74rem;font-weight:800;
}
.ms-card-head .time{font-size:.78rem;color:var(--muted-2)}

.ms-card-body{
  padding:.85rem .95rem;
  display:flex;flex-direction:column;gap:.5rem
}
.ms-field{line-height:1.45}
.ms-field strong{color:var(--accent)}
.ms-field.strong{font-weight:800}
.ms-field.brand strong{color:var(--brand-600)}
.ms-tip{font-size:.9rem;color:var(--muted)}

.ms-card-actions{
  display:flex;gap:.5rem;justify-content:flex-end;align-items:center;
  padding:.6rem .75rem;border-top:1px solid var(--border);background:#fff;
}
.ms-card-actions .btn-secondary{
  background:#fff;border:1px solid var(--border);color:var(--accent);
  border-radius:.55rem;padding:.35rem .6rem;font-size:.86rem;
  transition:box-shadow .15s ease,border-color .15s ease,transform .08s ease;
}
.ms-card-actions .btn-secondary:hover{ border-color:#d8dbe2; box-shadow:var(--shadow-1); }
.ms-card-actions .btn-secondary:active{transform:translateY(1px)}

/* Corrections */
.correction-card .ms-corrected{color:#0b3b1a}
.correction-card .ms-field.brand .ms-corrected{
  background:linear-gradient(180deg,#fff7f0,#ffffff);
  border:1px solid #ffd9b8;border-radius:.6rem;padding:.35rem .5rem;display:inline-block
}

/* Suggestions */
.suggestion-card .ms-suggestions{
  list-style:none;display:flex;flex-direction:column;gap:.45rem;margin:.1rem 0 0;padding:0;
}
.suggestion-card .ms-suggestions li{
  background:#fff;border:1px solid var(--border);border-radius:.55rem;
  padding:.5rem .6rem;font-size:.95rem;color:var(--text);
  display:flex;gap:.6rem;align-items:flex-start;
}
.suggestion-card .ms-suggestions li::before{
  content:"\f058";
  font-family:"Font Awesome 6 Free"; font-weight:900;
  opacity:.55; margin-top:.1rem;
}

/* Vocabulary */
.vocab-card .vocab-word{font-size:1.05rem;font-weight:800;color:var(--accent)}
.vocab-card .vocab-note{font-size:.92rem;color:var(--muted)}
.vocab-card .ms-meta{display:flex;align-items:center;justify-content:space-between;margin-top:.35rem}
.vocab-card .tts{min-width:38px}

/* FAB Add Word */
.fab-add-word{
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  width: 52px;
  height: 52px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-2);
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  z-index: 95; /* por encima de la bottom-nav */
}
.fab-add-word i{ pointer-events: none; font-size: 1.1rem; }
.fab-add-word:hover{ background: var(--brand-600); transform: translateY(-1px); }
.fab-add-word:active{ transform: translateY(0); }
.fab-add-word:focus-visible{
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
@media (min-width:721px){
  .fab-add-word{ bottom: 20px; }
}

/* Tooltips simples */
.ms-tooltip{
  position: absolute;
  background: #111827;
  color: #fff;
  font-size: .78rem;
  padding: .3rem .45rem;
  border-radius: .45rem;
  box-shadow: var(--shadow-2);
  transform: translate(-50%,-100%);
  white-space: nowrap;
  pointer-events: none;
  z-index: 95;
}

/* Footers/paginación centrados */
#msCorrectionsFooter, #msSuggestionsFooter, #msVocabFooter{
  background: transparent;
  border: 0;
  padding: 0 0 1rem;
  display: flex;
  justify-content: center;
}
#msCorrectionsFooter .btn-secondary,
#msSuggestionsFooter .btn-secondary,
#msVocabFooter .btn-secondary{
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

/* Estados vacíos */
#myspace .empty-state{
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: 1rem;
}

/* =========================================================
   PROFILE (Speaking-first)
========================================================= */
#profile{ background: var(--surface); }
.profile-head-left{display:flex;align-items:center;gap:.6rem}
.profile-avatar{width:34px;height:34px;border-radius:50%;object-fit:cover;opacity:.95}
.profile-identity .profile-sub{font-size:.85rem;color:var(--muted)}

.profile-wrap{
  min-height: calc(100vh - var(--header-h) - var(--nav-h));
  display:flex; flex-direction:column; gap:1rem;
  padding:.9rem  .9rem 1rem;
}

/* HERO */
.profile-hero{
  background:linear-gradient(180deg,#fff7f0,#ffffff);
  border:1px solid #ffd9b8;border-radius:var(--radius-lg);
  box-shadow:var(--shadow-1);display:flex;justify-content:space-between;gap:1rem;
  padding:1rem 1.1rem;
}
.profile-hero .hero-copy h2{
  font-size:1.25rem; font-weight:800; color:var(--accent); margin-bottom:.2rem;
}
.profile-hero .subcopy{color:var(--muted); font-size:.95rem;}
.profile-hero .chips{display:flex;gap:.4rem;flex-wrap:wrap;margin-top:.4rem}
.profile-hero .chip{
  background:var(--brand-50);border:1px solid var(--brand-100);color:#7a3d00;
  border-radius:999px;padding:.18rem .5rem;font-size:.78rem;font-weight:800
}
.profile-hero .btn-cta{ padding:.8rem 1.1rem; }

/* WEEK */
.profile-week{
  background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-1);padding:1rem;
}
.profile-week h3{margin-bottom:.6rem;color:var(--accent)}
.week-grid{display:grid;grid-template-columns:160px 1fr;gap:1rem;align-items:center}
@media (max-width:720px){.week-grid{grid-template-columns:1fr}}
.week-ring{display:grid;place-items:center;gap:.25rem}
.ring-figure{width:120px;height:120px;border-radius:50%;background:conic-gradient(var(--brand) 0%, #e9edf5 0% 100%)}
.ring-center{position:relative;margin-top:-80px;font-size:1.1rem;font-weight:800;color:var(--accent)}
.ring-caption{font-size:.85rem;color:var(--muted);margin-top:28px}
.week-bars{display:flex;gap:.35rem;align-items:flex-end;height:72px;background:var(--surface-2);border:1px solid var(--border);border-radius:.6rem;padding:.5rem}
.week-bars .bar{flex:1;background:var(--brand);border-radius:.4rem;min-height:6px;opacity:.85}
.last-session{margin-top:.55rem;color:var(--muted);font-size:.9rem}

/* FOCUS */
.profile-focus h3,
.profile-coach h3,
.profile-actions h3,
.profile-settings h3{ font-size:1rem; color:var(--accent); margin-bottom:.5rem; }

.focus-grid{ display:grid; grid-template-columns:1fr; gap:.8rem; }
@media (min-width:720px){ .focus-grid{ grid-template-columns:repeat(3,minmax(0,1fr)); } }
.focus-card{
  background:#fff; border:1px solid var(--border); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-1); padding:.85rem;
}
.focus-card header{display:flex;justify-content:space-between;align-items:center}
.focus-card h4{ font-size:.98rem; font-weight:800; color:var(--accent); }
.focus-card .hint{ color:var(--muted); font-size:.95rem; margin:.25rem 0 .6rem; }
.focus-card .state{font-size:.82rem;color:var(--muted)}

/* COACH */
.profile-coach .coach-grid{display:grid;grid-template-columns:2fr 1fr 1fr;gap:.75rem}
@media (max-width:1080px){.profile-coach .coach-grid{grid-template-columns:1fr}}
.coach-card{background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);box-shadow:var(--shadow-1);padding:.85rem}
.coach-card h4{font-size:.98rem;color:var(--accent);margin-bottom:.35rem}
.coach-card p{color:var(--text)}
.coach-card .before,.coach-card .after{font-size:.92rem}
.coach-card .after{
  background:var(--brand-50);
  border:1px solid var(--brand-100);
  border-radius:.5rem;padding:.25rem .45rem;display:inline-block;margin-top:.25rem
}

/* QUICK actions */
.profile-actions{display:flex;flex-wrap:wrap;gap:.5rem}
.profile-actions .btn-secondary{box-shadow:var(--shadow-1)}

/* SETTINGS */
.profile-settings{
  background:#fff; border:1px solid var(--border); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-1); padding:1rem;
}
.settings-grid{
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.6rem;
}
@media (max-width:960px){.settings-grid{grid-template-columns:1fr}}
.settings-grid .inline{ display:flex; flex-direction:column; gap:.35rem; }
.settings-grid input[type="number"], .settings-grid select{
  border:1px solid var(--border); border-radius:.55rem; padding:.5rem .6rem;
}

/* ===== Coach Opener ===== */
.coach-opener{display:flex;flex-direction:column;gap:.55rem}
.opener-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.15rem}
.opener-head .pill{
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:999px;
  padding:.18rem .6rem;
  font-size:.78rem;font-weight:700;color:var(--accent)
}
.coach-opener p{font-size:1rem;line-height:1.5;color:var(--text)}
.coach-opener .opener-cta{display:flex;gap:.5rem}

/* ===== PATCH: que la bottom-nav no tape el perfil ===== */
#profile .profile-wrap{
  /* deja espacio de scroll equivalente a la altura de la bottom-nav */
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px);
}
.screen-root.active{
  padding-bottom: 0;
}

/* Solo ocultar Exam cuando el body tenga .no-exam */
body.no-exam .nav-item[data-target="exam"],
body.no-exam #exam,
body.no-exam [data-screen="exam"],
body.no-exam #view-exam { display: none !important; }
/* Override temporal para volver a mostrar Exam */
.nav-item[data-target="exam"],
#exam,
[data-screen="exam"],
#view-exam { display: revert !important; }

/* ============ AUTH ============ */
body.auth-required .bottom-nav {
  pointer-events: none;
  opacity: .6;
}
.auth-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  max-width: 720px;
  margin: 1rem auto;
  padding: 1rem 1.1rem 1.25rem;
}
.auth-tabs {
  display: flex;
  gap: .5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
  margin-bottom: .9rem;
}
.auth-tabs .tab {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 999px;
  padding: .4rem .9rem;
  font-size: .9rem;
  font-weight: 700;
}
.auth-tabs .tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.auth-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: .55rem;
}
.auth-panel label {
  font-weight: 700;
  color: var(--accent);
  margin-top: .3rem;
}
.auth-panel input[type="email"],
.auth-panel input[type="password"] {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: .6rem;
  padding: .6rem .7rem;
  font-size: .95rem;
}
.auth-panel .muted,
.auth-wrap .muted {
  color: var(--muted);
  font-size: .9rem;
}

input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.inline-prompt{
  position: relative;
  z-index: 2;              /* por si la barra decorativa de Alma tapa */
  visibility: visible;     /* evita estados heredados */
  opacity: 1;
  white-space: nowrap;     /* que no parta “Got a tip?” en móvil */
}

.message .bubble{
  overflow: visible;       /* por si algún reset lo dejó en hidden */
}

.message[data-sender="alma"] .bubble::before{
  z-index: 1;              /* por detrás del prompt */
}

