/* BioStudy Lab — capa de componentes y composición. Los tokens viven en variables.css. */
html { scroll-padding-top: 8rem; }
body { background: radial-gradient(ellipse at 85% 0, #ECEAFA66, transparent 42rem), var(--color-bg); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
main, section, article, aside, header, form, .field { min-width: 0; }
h1, h2, h3, h4 { overflow-wrap: anywhere; }
:where(.dash-head, .topic-page__header, .study-stage__head) > div { min-width: 0; max-width: 100%; }
button, .btn { touch-action: manipulation; }
input, select, textarea { max-width: 100%; }
select.input { text-overflow: ellipsis; }
a { text-underline-offset: .2em; }
::selection { background: #6256C92B; }
.skip-link { position: fixed; z-index: 1000; top: .75rem; left: 1rem; padding: .75rem 1rem; transform: translateY(-180%); border-radius: 10px; background: var(--color-night); color: #fff; }
.skip-link:focus { transform: translateY(0); }
.eyebrow { display: block; color: var(--color-teal-700); font-size: .72rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.btn { border-radius: 12px; min-height: 46px; transition: background .16s, box-shadow .16s, border-color .16s, transform .16s; }
.btn--primary { box-shadow: 0 4px 9px #6256C91C; }
.btn--primary:hover:not(:disabled) { box-shadow: 0 6px 15px #6256C930; transform: translateY(-1px); }
.input { border-color: var(--color-border); border-radius: 12px; background: #FCFCFE; }
.input:focus { background: #fff; }
.chip { min-height: 42px; background: #fff; border: 1px solid var(--color-border); }
.chip:hover:not([aria-pressed="true"]) { background: var(--color-violet-100); }
.config-banner { font-size: .85rem; }

/* Acceso: ilustración vectorial local y formulario de lectura tranquila. */
.auth-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); padding: 1rem; gap: 1rem; }
.auth-hero { min-height: calc(100dvh - 2rem); gap: 1.5rem; padding: clamp(2rem, 4vw, 4rem); border-radius: 28px; background-image: radial-gradient(ellipse at 70% 60%, #6256C93D, transparent 60%), linear-gradient(#ffffff03 1px, transparent 1px), linear-gradient(90deg, #ffffff03 1px, transparent 1px); background-size: auto, 32px 32px, 32px 32px; }
.auth-hero .brand { font-size: 1.25rem; }
.auth-hero .eyebrow { color: var(--color-teal-300); margin-bottom: 1rem; }
.auth-hero__body { margin-top: clamp(1rem, 3vh, 3rem); position: relative; z-index: 1; }
.auth-hero__body h1 { max-width: 14ch; font-size: clamp(2.25rem, 3.6vw, 3.65rem); letter-spacing: -.045em; line-height: 1.08; }
.auth-hero__body h1 em { font-style: normal; color: #7EDACE; }
.auth-hero__body p { max-width: 38ch; font-size: 1rem; line-height: 1.7; }
.auth-lab-art { width: min(100%, 520px); height: auto; align-self: center; margin: -1.5rem 0 -1rem; }
.auth-features { gap: .75rem; font-size: .85rem; color: #D5DAEB; }
.auth-features li { gap: .75rem; }
.auth-hero__foot { padding-top: 1rem; border-top: 1px solid #ffffff14; font-size: .75rem; }
.auth-panel { flex-direction: column; gap: 2rem; padding: clamp(1.25rem, 4vw, 4rem); }
.auth-panel__intro { width: min(100%, 420px); }
.auth-panel__intro .eyebrow { margin-bottom: .6rem; }
.auth-panel__intro p { color: var(--color-text-muted); font-size: .9rem; }
.auth-card { padding: 2rem; max-width: 480px; border: 1px solid #E5E8F1; border-radius: 24px; background: #fff; box-shadow: var(--shadow-md); }
.auth-form { gap: 1.3rem; }
.auth-form__head { margin-bottom: .3rem; }
.auth-form__head h2 { font-size: 1.7rem; letter-spacing: -.035em; }
.tabs { gap: 4px; margin-bottom: 1.7rem; border-radius: 12px; background: var(--color-bg); }
.tab { min-height: 44px; border-radius: 9px; }
.auth-panel__foot { max-width: 35ch; color: var(--color-text-muted); font-size: .76rem; text-align: center; }

/* Encabezado compacto con menú nativo accesible con teclado. */
.navbar { gap: 1rem; padding-inline: max(1rem, calc((100vw - 1280px) / 2)); min-height: 76px; box-shadow: none; }
.navbar > .brand { flex: none; font-size: 1.1rem; }
.navbar__stats { gap: .55rem; align-items: center; flex-wrap: wrap; }
.navbar .stat { padding: .45rem .7rem; font-size: .8rem; }
.navbar .btn { min-height: 40px; font-size: .8rem; }
.account-menu { margin-left: .5rem; position: relative; flex: none; }
.account-menu > summary { display: flex; align-items: center; gap: .65rem; min-height: 44px; padding: .4rem .8rem; border: 1px solid #ffffff24; border-radius: 12px; color: #E8EBF5; cursor: pointer; font-size: .85rem; list-style: none; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary::after { content: ''; width: 6px; height: 6px; margin: -.25rem 0 0 .25rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.account-menu[open] > summary { background: #ffffff12; }
.account-menu .navbar__user { position: absolute; right: 0; top: calc(100% + .8rem); display: grid; grid-template-columns: 1fr; min-width: 245px; max-width: calc(100vw - 2rem); gap: .7rem; padding: 1.1rem; border: 1px solid var(--color-border); border-radius: 16px; background: #fff; color: var(--color-night); box-shadow: var(--shadow-lg); }
.account-menu .user-name { display: block; }
.account-menu .navbar__user { max-height: calc(100dvh - 6rem); overflow-y: auto; overscroll-behavior: contain; }
.account-menu .user-profile-link { gap: .65rem; color: var(--color-night); padding-bottom: .75rem; border-bottom: 1px solid var(--color-border); }
.account-menu .avatar { color: #fff; }
.account-menu .role-badge { justify-self: start; background: var(--color-violet-100); color: var(--color-violet-600); }
.account-menu .btn--on-dark { color: var(--color-night); border-color: var(--color-border); background: var(--color-bg); }
.account-menu .btn--on-dark:hover { background: var(--color-violet-100); border-color: var(--color-violet); }
.workspace-nav { display: flex; gap: .4rem; padding: .6rem max(1rem, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--color-border); background: #FFFFFFD9; overflow-x: auto; scrollbar-width: none; }
.workspace-nav a { display: flex; gap: .55rem; align-items: center; flex: none; min-height: 42px; padding: .55rem 1rem; border-radius: 10px; text-decoration: none; font-size: .86rem; font-weight: 700; color: var(--color-text-muted); }
.workspace-nav a:hover { background: var(--color-bg); color: var(--color-night); }
.workspace-nav a[aria-current=page] { background: var(--color-violet-100); color: var(--color-violet-600); }
.workspace-nav svg { width: 18px; height: 18px; }

/* Inicio y tarjetas de modos. */
.dashboard { max-width: 1244px; padding-top: 2.2rem; }
.dashboard-welcome { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: center; gap: 1rem; padding: 2.25rem 2.5rem; margin-bottom: 1.4rem; overflow: hidden; border: 1px solid #E0DFEE; border-radius: 24px; background: linear-gradient(115deg, #FFFFFF, #ECEAFA70); }
.dashboard-welcome .dash-greeting { color: var(--color-teal-700); font-size: .85rem; font-weight: 700; }
.dashboard-welcome h1 { max-width: 18ch; margin-bottom: .8rem; font-size: clamp(1.85rem, 3.2vw, 2.8rem); letter-spacing: -.04em; line-height: 1.1; }
.dashboard-welcome__desc { max-width: 54ch; font-size: .94rem; line-height: 1.65; color: var(--color-text-muted); }
.dashboard-welcome__art { width: 100%; height: auto; padding: 0; border-radius: 22px; background: var(--color-night); }
.study-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 2.75rem; }
.study-mode { --mode: var(--color-violet); display: grid; grid-template-columns: 46px minmax(0, 1fr) 20px; gap: .9rem; align-items: center; padding: 1.3rem; border: 1px solid var(--color-border); border-radius: 18px; color: var(--color-night); text-decoration: none; background: #fff; box-shadow: var(--shadow-xs); transition: border-color .16s, transform .16s, box-shadow .16s; }
.study-mode:hover { border-color: var(--mode); box-shadow: var(--shadow-sm); transform: translateY(-3px); }
.study-mode__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--mode) 10%, white); color: var(--mode); }
.study-mode__icon svg { width: 24px; height: 24px; }
.study-mode strong { display: block; margin-bottom: .2rem; font-family: var(--font-display); font-size: 1.05rem; }
.study-mode small { color: var(--color-text-muted); font-size: .78rem; line-height: 1.4; }
.study-mode > svg { width: 18px; height: 18px; color: var(--color-text-muted); }
.study-mode--teal { --mode: var(--color-teal); }
.study-mode--amber { --mode: #9B7016; }
.dash-head h1, .dash-head h2 { font-size: var(--fs-2xl); letter-spacing: -.03em; }
.section-description { margin-top: .35rem; font-size: .9rem; color: var(--color-text-muted); }
#semester-filter { margin-bottom: 1.5rem; }
.semester-group + .semester-group { margin-top: 2rem; }
.semester-group__head { margin-bottom: 1rem; }
.subject-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 1.1rem; }
.subject-card { min-height: 245px; padding: 1.5rem; border-radius: 20px; gap: .8rem; box-shadow: var(--shadow-xs); transition: transform .18s, box-shadow .18s, border-color .18s; }
.subject-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, white); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.subject-card::before { inset: 0 1.5rem auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
.subject-card__glyph { width: 48px; height: 48px; border-radius: 14px; }
.subject-card__title { letter-spacing: -.02em; }
.subject-card__title, .topic-item__title, .study-sheet__title, .boss-card__prompt { overflow-wrap: anywhere; }
.subject-card__footer { border-top-style: solid; }
.subject-card__cta { min-height: 44px; }

/* Superficies comunes: lector, estudio, expediente y administración. */
.topic-page { max-width: 1244px; }
.topic-page__header, .study-stage__head { border-bottom: 0; margin-bottom: 1.6rem; }
.topic-page__header h1, .study-stage__head h1 { letter-spacing: -.035em; }
.breadcrumb { display: flex; flex-wrap: wrap; max-width: 100%; }
.breadcrumb > * { min-width: 0; overflow-wrap: anywhere; }
.topic-page__desc { overflow-wrap: anywhere; }
.topic-workspace { grid-template-columns: 280px minmax(0, 1fr); gap: 1.5rem; }
.topic-sidebar { border-radius: 18px; box-shadow: var(--shadow-xs); top: calc(var(--navbar-h) + 1.5rem); }
.topic-item { padding: .85rem; border-radius: 12px; }
.study-sheet, .admin-card, .quiz-card, .fc-card, .summary-card { border-radius: 20px; box-shadow: var(--shadow-sm); }
.study-sheet { border-color: #E2E5EE; }
.study-prose { line-height: 1.8; overflow-wrap: anywhere; }
.study-prose pre { max-width: 100%; }
.study-prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.study-prose th, .study-prose td { padding: .6rem; border: 1px solid var(--color-border); }
.study-sheet__slug { overflow-wrap: anywhere; }
.topic-actions__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.action-card { border-radius: 14px; }
.study-stage { width: min(100% - 2rem, 880px); padding-top: 2.2rem; }
.quiz-option { min-height: 56px; border-radius: 13px; }
.quiz-option:hover:not(:disabled) { box-shadow: var(--shadow-xs); }
.quiz-option__text, .quiz-card__prompt, .fc-face__text, .fc-face__answer, .fc-face__source, .review-item__prompt { overflow-wrap: anywhere; }
.fc-rate-btn { min-height: 60px; }
.deck-mode-bar { flex-wrap: wrap; border-radius: 14px; }
.profile-hero-card { border: 1px solid #DAD8EE; border-radius: 24px; padding: 2rem; background: linear-gradient(120deg, #fff, #ECEAFA); }
.profile-hero-card__avatar { border-radius: 22px; box-shadow: 0 8px 24px #6256C929; }
.profile-hero-card__name { letter-spacing: -.04em; }
.profile-hero-card__identity > div { min-width: 0; }
.profile-hero-card__meta, .profile-hero-card__name { overflow-wrap: anywhere; }
.profile-kpi-card { padding: 1.4rem; border-radius: 18px; box-shadow: var(--shadow-xs); }
.profile-kpi-card__value { letter-spacing: -.04em; }
.profile-kpi-card > * { min-width: 0; overflow-wrap: anywhere; }
.profile-hero-card .unit-pill { background: #6256C914; color: var(--color-violet-600); white-space: normal; }
.expediente-section { padding: 1.75rem; border-radius: 22px; background: #fff; box-shadow: var(--shadow-xs); }
.expediente-section__head { gap: 1.2rem; }
.expediente-section__head h2 { margin-top: .65rem; font-size: clamp(1.2rem, 2vw, 1.55rem); letter-spacing: -.025em; }
.expediente-section__head .unit-pill { background: var(--color-violet-100); color: var(--color-violet-600); white-space: normal; }
.expediente-hero { border-radius: 22px; padding: 2rem; background: var(--color-night); color: #fff; }
.expediente-hero h1 { letter-spacing: -.04em; color: #fff; }
.expediente-hero__desc { color: #C2CADF; }
.expediente-subject-card { background: #F9FAFD; border-radius: 16px; }
.expediente-subject-card__head > div { min-width: 0; max-width: 100%; }
.expediente-topic-row__name { min-width: 0; overflow-wrap: anywhere; }
.expediente-topic-row__top { min-width: 0; flex-wrap: wrap; }
.expediente-topics-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.expediente-review-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.expediente-review-card__prompt, .expediente-review-card__source { overflow-wrap: anywhere; }
.expediente-pct-badge--teal, .box-pill--3, .box-step--done, .box-status-tag--teal, .mastery-pct--teal, .action-card--teal .action-card__tag { color: var(--color-teal-700); }
.status-pill--published, .btn--status-publish, .quiz-feedback__badge:not(.quiz-feedback__badge--amber), .quiz-option.is-correct .quiz-option__letter { background-color: var(--color-teal-700); }
.quiz-feedback--wrong .quiz-feedback__badge { background-color: var(--color-danger); }
.profile-history-grid { gap: 1.5rem; }
.profile-feed-item { border-radius: 12px; }
.unit-pill, .status-pill, .box-pill { max-width: 100%; }
.admin-section { gap: 1.5rem; }
.admin-section__step { letter-spacing: .12em; }
.admin-form__row-2, .review-toolbar { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.review-columns { grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); }
.review-item, .admin-item { border-radius: 14px; }
.review-options__item { flex-wrap: wrap; overflow-wrap: anywhere; }
.review-options__correct-tag { white-space: normal; }
.admin-item__meta, .review-item__source, .verified-source__text, .profile-feed-item { overflow-wrap: anywhere; }
.modal-backdrop { overflow-y: auto; padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
.modal-card { max-height: calc(100dvh - 2rem); overflow-y: auto; overscroll-behavior: contain; border-radius: 22px; }
.state-panel { padding: clamp(1.5rem, 5vw, 3.5rem); border: 1px solid var(--color-border); border-radius: 20px; box-shadow: var(--shadow-xs); }
.state-panel p, .state-panel__detail, .alert { overflow-wrap: anywhere; }
.skeleton-card { border-radius: 20px; }

@media (min-width: 1600px) { .auth-layout { max-width: 1680px; margin-inline: auto; } }
@media (max-width: 1100px) {
  .navbar__stats { gap: .4rem; }
  .navbar .stat { font-size: .75rem; }
  .navbar > .brand { font-size: 1rem; }
  .dashboard-welcome { grid-template-columns: minmax(0, 1fr) 250px; }
  .study-mode { grid-template-columns: 40px minmax(0, 1fr); padding: 1rem; gap: .75rem; }
  .study-mode__icon { width: 40px; height: 40px; }
  .study-mode > svg { display: none; }
}
@media (max-width: 920px) {
  .topic-workspace, .admin-grid-two { grid-template-columns: 1fr; }
  .topic-actions__grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
  .auth-layout { padding: .75rem; gap: 0; grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 1.75rem; display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 1rem; border-radius: 22px; }
  .auth-hero > .brand { grid-column: 1 / -1; }
  .auth-hero__body { margin-top: .5rem; }
  .auth-hero__body h1 { max-width: 20ch; font-size: clamp(1.9rem, 4.4vw, 2.6rem); }
  .auth-hero__body p { display: block; font-size: .9rem; margin-top: .75rem; }
  .auth-hero .eyebrow { font-size: .62rem; margin-bottom: .6rem; }
  .auth-lab-art { margin: 0; }
  .auth-features, .auth-hero__foot { display: none; }
  .auth-panel { padding: 2rem 1rem; gap: 1.25rem; }
  .auth-panel__intro { display: none; }
  .auth-card { max-width: 520px; }
}
@media (max-width: 760px) {
  .navbar { flex-wrap: wrap; gap: .5rem; padding: calc(.65rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .65rem max(1rem, env(safe-area-inset-left)); }
  .navbar > .brand { font-size: 1.05rem; margin-right: auto; }
  .account-menu { margin-left: 0; }
  .account-menu > summary { min-height: 44px; padding: .45rem .65rem; font-size: .78rem; }
  .navbar__stats { order: 3; width: 100%; gap: .4rem; }
  .navbar__stats .stat { flex: 1; justify-content: center; }
  .navbar__stats .btn { flex: 1; }
  .navbar .stat { min-height: 40px; }
  .workspace-nav { gap: .15rem; padding: .45rem .75rem; }
  .workspace-nav a { flex: 1; justify-content: center; min-width: max-content; padding: .5rem .65rem; font-size: .76rem; }
  .workspace-nav svg { width: 16px; height: 16px; }
  .dashboard, .topic-page { padding: 1.25rem 1rem 3rem; }
  .dashboard-welcome { grid-template-columns: minmax(0, 1fr) 170px; padding: 1.5rem; border-radius: 20px; }
  .dashboard-welcome h1 { font-size: 1.85rem; }
  .dashboard-welcome__desc { font-size: .85rem; }
  .study-modes { gap: .65rem; margin-bottom: 2rem; }
  .study-mode { display: flex; flex-direction: column; align-items: flex-start; gap: .7rem; padding: 1rem; border-radius: 15px; }
  .study-mode strong { font-size: .92rem; }
  .study-mode small { font-size: .72rem; }
  .dash-head { gap: .8rem; margin-bottom: 1rem; }
  .profile-hero-card { padding: 1.4rem; }
  .profile-hero-card__identity { min-width: 0; }
  .expediente-section { padding: 1.2rem; }
  .expediente-hero { padding: 1.5rem; }
}
@media (max-width: 520px) {
  .auth-hero { grid-template-columns: 1fr; padding: 1.5rem; }
  .auth-hero__body h1 { font-size: 2rem; }
  .auth-hero__body p { max-width: 34ch; }
  .auth-lab-art { display: none; }
  .auth-card { padding: 1.5rem; border-radius: 20px; }
  .auth-panel { padding-inline: .25rem; }
  .dashboard-welcome { grid-template-columns: 1fr; padding: 1.5rem; }
  .dashboard-welcome__art { display: none; }
  .dashboard-welcome h1 { max-width: 19ch; font-size: 2rem; }
  .study-modes { grid-template-columns: 1fr; }
  .study-mode { display: grid; grid-template-columns: 42px minmax(0, 1fr) 18px; align-items: center; padding: 1rem; }
  .study-mode > svg { display: block; }
  .study-mode strong { font-size: 1rem; }
  .study-mode small { font-size: .78rem; }
  .workspace-nav a { gap: .35rem; font-size: .72rem; padding-inline: .4rem; }
  .topic-page__header h1 { font-size: 1.6rem; }
  .study-sheet { padding: 1.25rem; }
  .topic-actions__grid { grid-template-columns: 1fr; }
  .profile-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .profile-kpi-card { padding: 1rem; }
  .profile-kpi-card__value { font-size: 1.8rem; }
  .profile-hero-card__identity { flex-wrap: wrap; }
  .profile-hero-card__actions { width: 100%; }
  .profile-hero-card__actions .btn { width: 100%; }
  .profile-history-grid { grid-template-columns: 1fr; }
  .expediente-section { padding: 1rem; }
  .mastery-legend { font-size: .7rem; }
  .expediente-subject-card { padding: 1rem; }
  .expediente-subject-card__score { justify-items: start; }
  .status-actions .btn { min-height: 44px; }
  .modal-card { padding: 1.25rem; }
  .state-panel__actions, .modal-form__actions { width: 100%; }
  .state-panel__actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:hover, .subject-card:hover, .study-mode:hover, .action-card:hover { transform: none; }
}
@media (max-width: 359px) {
  .profile-kpi-grid { grid-template-columns: 1fr; }
}
@media (forced-colors: active) {
  .btn, .chip, .subject-card, .study-mode, .account-menu > summary { border: 1px solid ButtonText; }
  .workspace-nav a[aria-current=page] { outline: 2px solid Highlight; }
}
