/* ==================== TOKENS DE DISEÑO ====================
   Todos los colores salen de aquí. sql-lab.css y study-tools.css usan estas mismas variables,
   así que cambiar un color aquí lo cambia en toda la web. */
:root {
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, Monaco, monospace;
  --page-width: 1240px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090e1a;
  --bg-elev: #0e1524;
  --bg-card: #121a2b;
  --bg-hover: #1a2439;
  --border: #212c44;
  --border-strong: #31405f;
  --text: #e9eef7;
  --text-muted: #8e9bb3;
  --primary: #4c7df6;
  --primary-hover: #3a69e0;
  --primary-soft: rgba(76, 125, 246, 0.15);
  --accent: #8b5cf6;
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.15);
  --danger: #f05252;
  --danger-soft: rgba(240, 82, 82, 0.15);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 48px rgba(0, 0, 0, 0.42);
  --glow-a: rgba(76, 125, 246, 0.13);
  --glow-b: rgba(139, 92, 246, 0.1);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f1f4fa;
  --border: #e1e7f0;
  --border-strong: #c9d3e2;
  --text: #101828;
  --text-muted: #56637a;
  --primary: #2f62e3;
  --primary-hover: #234fc4;
  --primary-soft: rgba(47, 98, 227, 0.09);
  --accent: #7c3aed;
  --success: #058a63;
  --success-soft: rgba(5, 138, 99, 0.11);
  --danger: #d92d20;
  --danger-soft: rgba(217, 45, 32, 0.09);
  --warning: #b9660a;
  --warning-soft: rgba(217, 119, 6, 0.13);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 18px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.06), 0 18px 44px rgba(16, 24, 40, 0.13);
  --glow-a: rgba(47, 98, 227, 0.09);
  --glow-b: rgba(124, 58, 237, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 480px at 12% -8%, var(--glow-a), transparent 65%),
    radial-gradient(760px 420px at 96% 0%, var(--glow-b), transparent 62%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

/* ==================== AUTH SCREEN ==================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: radial-gradient(circle at top, var(--primary-soft), transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.25rem;
}

.brand-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.65rem;
}

.auth-brand h1 {
  font-size: 1.55rem;
  margin-bottom: 0.35rem;
}

.bank-pill {
  text-align: center;
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.auth-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.15s;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.38rem;
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

/* ==================== BUTTONS & ALERTS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.05rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.83rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 0.8rem 1.35rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* ==================== TOPBAR & BREADCRUMBS ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
}

.brand-logo {
  font-size: 1.55rem;
}

.brand-title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.15;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.breadcrumb-bar {
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.breadcrumb-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0.45rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.crumb-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.crumb-link:hover {
  background: var(--primary-soft);
}

.crumb-current {
  font-weight: 700;
  color: var(--text);
  padding: 0.15rem 0.35rem;
}

.crumb-sep {
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 0.85rem;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: 0.15s;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-pill {
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 1rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.32rem 0.75rem 0.32rem 0.38rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

/* ==================== MAIN CONTAINER & CARDS ==================== */
.main-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 3.5rem;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ==================== LEVEL 1: SUBJECTS PORTAL ==================== */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.15rem;
}

.subject-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  box-shadow: var(--shadow);
}

.subject-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.subject-card.subject-ready {
  border-color: rgba(59, 130, 246, 0.5);
}

.subject-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.subject-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--primary-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  flex-shrink: 0;
}

.status-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill.pill-active {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.pill-empty {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ==================== LEVEL 2: EXAM BLOCKS CARDS ==================== */
.exam-blocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 480px) {
  .subjects-grid,
  .exam-blocks-grid {
    grid-template-columns: 1fr;
  }
}

.exam-block-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.exam-block-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.included-topics-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 0.9rem;
  border-radius: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}

.included-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ==================== KPI & STUDY GRIDS ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem;
}

.kpi-card.kpi-danger {
  border-color: rgba(239, 68, 68, 0.45);
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.83rem;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.55rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.fill-success {
  background: var(--success);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.75rem;
}

.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  transition: transform 0.15s, border-color 0.15s;
}

.quick-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.quick-card h3 {
  font-size: 1.02rem;
  margin-bottom: 0.25rem;
}

.quick-card p {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.75rem;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.topic-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.ud-tag {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}

.topic-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stat-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.stat-chip.chip-fail {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
  font-weight: 600;
}

.topic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.resume-banner {
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 14px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ==================== QUIZ BUILDER ==================== */
.builder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.2rem;
}

.radio-cards {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.radio-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.count-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.count-pill {
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.count-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ==================== QUIZ RUNNER ==================== */
.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 920px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.meta-tag {
  font-size: 0.77rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.meta-tag.tag-warn {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: transparent;
}

.question-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  line-height: 1.45;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.95rem 1.05rem;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.97rem;
  line-height: 1.45;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--bg-hover);
}

.option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.option-btn.selected .option-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.option-btn.correct {
  border-color: var(--success) !important;
  background: var(--success-soft) !important;
}
.option-btn.correct .option-letter {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
}

.option-btn.wrong {
  border-color: var(--danger) !important;
  background: var(--danger-soft) !important;
}
.option-btn.wrong .option-letter {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}

.explanation-box {
  margin-top: 1.2rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border-left: 4px solid var(--primary);
  background: var(--bg);
}

.explanation-box.exp-correct {
  border-left-color: var(--success);
}
.explanation-box.exp-wrong {
  border-left-color: var(--danger);
}

.quiz-footer {
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.qnav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.qnav-cell {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  position: relative;
}

.qnav-cell.current {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.qnav-cell.answered {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.qnav-cell.right {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.qnav-cell.wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.qnav-cell.flagged::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.shortcut-hint {
  margin-top: 0.9rem;
  font-size: 0.77rem;
  color: var(--text-muted);
}

/* ==================== RESULTS & FAILURE CARDS ==================== */
.score-hero {
  text-align: center;
  padding: 1.6rem 1rem;
  margin-bottom: 1.4rem;
}

.score-big {
  font-size: 3.1rem;
  font-weight: 900;
  line-height: 1.05;
}

.score-pass {
  color: var(--success);
}
.score-fail {
  color: var(--danger);
}

.failure-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.failure-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
}

.ans-compare {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.92rem;
}

.ans-wrong-line {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}

.ans-right-line {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
}

/* ==================== NOTES READER ==================== */
.notes-body {
  line-height: 1.7;
  font-size: 0.98rem;
}
.notes-body h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.notes-body h2 {
  font-size: 1.22rem;
  margin: 1.4rem 0 0.6rem;
  color: var(--primary);
}
.notes-body h3 {
  font-size: 1.05rem;
  margin: 1.1rem 0 0.45rem;
}
.notes-body ul, .notes-body ol {
  padding-left: 1.4rem;
  margin-bottom: 0.85rem;
}
.notes-body li {
  margin-bottom: 0.35rem;
}
.notes-body p {
  margin-bottom: 0.75rem;
}
.notes-body code {
  padding: 0.14rem 0.4rem;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: Consolas, Monaco, monospace;
  font-size: 0.88em;
}

/* ==================== TABLES ==================== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 340px;
}

.toast.toast-success {
  border-left-color: var(--success);
}
.toast.toast-error {
  border-left-color: var(--danger);
}


/* ==================== LINUX TERMINAL SIMULATOR & LIVE TUTOR ==================== */
.linux-lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  gap: 1.15rem;
  align-items: start;
}

@media (max-width: 980px) {
  .linux-lab-grid {
    grid-template-columns: 1fr;
  }
}

.linux-window {
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.linux-window-bar {
  background: #111827;
  border-bottom: 1px solid #1e293b;
  padding: 0.6rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.linux-dots {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.linux-dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #22c55e; }

.linux-window-title {
  font-family: Consolas, 'JetBrains Mono', Monaco, monospace;
  font-size: 0.82rem;
  color: #cbd5e1;
  font-weight: 600;
}

.linux-body-wrap {
  position: relative;
  padding: 0.95rem 1.05rem;
  min-height: 470px;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: Consolas, 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.linux-term-output {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.35rem;
  margin-bottom: 0.65rem;
}

.term-banner {
  color: #93c5fd;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.48;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px dashed #1e293b;
}

.term-info-line {
  color: #fcd34d;
  font-size: 0.85rem;
  margin: 0.35rem 0;
  white-space: pre-wrap;
}

.term-block {
  margin-bottom: 0.6rem;
}

.term-cmdline {
  line-height: 1.45;
  word-break: break-all;
}

.term-user {
  color: #4ade80;
  font-weight: 700;
}

.term-user.term-root {
  color: #f87171;
}

.term-path {
  color: #60a5fa;
  font-weight: 700;
}

.term-sym {
  color: #cbd5e1;
  margin-left: 1px;
}

.term-cmd-typed {
  color: #f8fafc;
}

.term-stdout {
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  margin: 0.2rem 0 0;
  line-height: 1.42;
}

.term-stderr {
  color: #fca5a5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  margin: 0.2rem 0 0;
  line-height: 1.42;
}

.linux-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid #1e293b;
  padding-top: 0.6rem;
}

.linux-prompt-label {
  white-space: nowrap;
  flex-shrink: 0;
}

.linux-cmd-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  color: #f8fafc !important;
  font-family: Consolas, 'JetBrains Mono', 'Courier New', monospace !important;
  font-size: 0.92rem !important;
  padding: 0.2rem 0 !important;
}

.linux-cmd-input::placeholder {
  color: #64748b;
}

.linux-live-hint-bar {
  background: #0f172a;
  border-top: 1px solid #1e293b;
  padding: 0.55rem 0.95rem;
  font-size: 0.82rem;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.term-mini-chip {
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #93c5fd;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.78rem;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s;
}

[data-theme="light"] .linux-side-panel .term-mini-chip {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.1);
}

.term-mini-chip:hover {
  background: rgba(59, 130, 246, 0.32);
}

/* Nano Overlay Editor */
.nano-modal-host {
  position: absolute;
  inset: 0;
  background: #0b1120;
  z-index: 15;
  display: flex;
  flex-direction: column;
}

.nano-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0.65rem;
}

.nano-header {
  background: #e2e8f0;
  color: #0f172a;
  padding: 0.32rem 0.7rem;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

.nano-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  background: #020617 !important;
  color: #f8fafc !important;
  border: 1px solid #334155 !important;
  border-radius: 8px;
  padding: 0.75rem;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.88rem;
  line-height: 1.48;
}

.nano-footer {
  margin-top: 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Side Assistant Panel */
.linux-side-panel {
  padding: 1rem;
}

.term-side-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  background: var(--bg);
  padding: 0.28rem;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.term-tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.48rem 0.35rem;
  border-radius: 7px;
  cursor: pointer;
}

.term-tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tutor-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.tutor-breakdown-list {
  margin: 0.7rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.84rem;
  line-height: 1.48;
}

.tutor-breakdown-list li {
  margin-bottom: 0.35rem;
}

.tutor-exam-box {
  margin-top: 0.85rem;
  padding: 0.65rem 0.8rem;
  border-radius: 9px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  font-size: 0.83rem;
  line-height: 1.45;
}

.quick-cmd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.lab-steps-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.lab-step-item {
  padding: 0.7rem 0.8rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.85rem;
  line-height: 1.42;
}

.lab-step-item.step-done {
  border-color: rgba(34, 197, 94, 0.55);
  background: var(--success-soft);
}

.lab-hint-box {
  margin: 0.55rem 0 0;
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  background: #0f172a;
  color: #93c5fd;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.79rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.cheat-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 0.25rem;
}


/* ============================================================================
   REDISEÑO 2026-11 · Capa visual
   Todo lo de abajo afina el aspecto de los componentes de arriba (mismas clases).
   Para cambiar colores: tokens del principio del fichero.
   ============================================================================ */

/* ---------- Base ---------- */
h1, h2, h3, h4 {
  letter-spacing: -0.015em;
  line-height: 1.25;
}

button, input, select, textarea {
  font-family: inherit;
}

::selection {
  background: var(--primary);
  color: #fff;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.grad-text {
  background: linear-gradient(100deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.view-section:not(.hidden) {
  animation: view-in 0.22s ease-out;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Formularios ---------- */
input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* La línea de comandos de la terminal y los editores de código no llevan anillo de foco: son "pantalla". */
.linux-cmd-input:focus,
.linux-cmd-input:focus-visible,
.nano-textarea:focus,
.nano-textarea:focus-visible,
.sqll textarea:focus,
.sqll textarea:focus-visible {
  box-shadow: none;
  outline: none;
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
  margin-top: 0.18rem;
  flex-shrink: 0;
}

.form-group label {
  color: var(--text);
  font-size: 0.84rem;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- Botones ---------- */
.btn {
  border-radius: var(--radius-sm);
  letter-spacing: 0.005em;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 62%, var(--accent)));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 4px 14px color-mix(in srgb, var(--primary) 32%, transparent);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), color-mix(in srgb, var(--primary-hover) 62%, var(--accent)));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset, 0 6px 20px color-mix(in srgb, var(--primary) 42%, transparent);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-success {
  box-shadow: 0 4px 14px color-mix(in srgb, var(--success) 28%, transparent);
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-sm {
  border-radius: 8px;
}

.alert {
  border-radius: var(--radius-sm);
}

.alert-error {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

/* ---------- Pantalla de acceso ---------- */
.auth-screen {
  background: none;
  padding: 2rem 1.25rem;
}

.auth-layout {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px);
  gap: 3.5rem;
  align-items: center;
}

.auth-pitch h1 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 800;
  line-height: 1.12;
  margin: 0.4rem 0 0.9rem;
}

.auth-pitch > p {
  font-size: 1.02rem;
  max-width: 46ch;
}

.auth-features {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.2rem;
  margin: 1.8rem 0 1.5rem;
}

.auth-features li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.auth-features strong {
  display: block;
  font-size: 0.92rem;
}

.auth-features small {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  display: block;
}

.feature-ico {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.auth-pitch .bank-pill {
  display: inline-block;
  margin: 0;
  text-align: left;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
}

.auth-card {
  max-width: none;
  border-radius: 20px;
  padding: 2rem 1.9rem;
  box-shadow: var(--shadow-lg);
}

.auth-brand .brand-logo {
  width: 52px;
  height: 52px;
  font-size: 1.6rem;
  margin: 0 auto 0.7rem;
}

.auth-brand h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.auth-brand p {
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

.auth-tabs {
  border-radius: var(--radius-sm);
}

.auth-tab {
  border-radius: 7px;
  font-size: 0.88rem;
}

.auth-tab:not(.active):hover {
  color: var(--text);
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

@media (max-width: 860px) {
  .auth-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
    max-width: 460px;
  }
  .auth-pitch {
    text-align: center;
  }
  .auth-pitch > p {
    margin: 0 auto;
  }
  .auth-features {
    display: none;
  }
  .auth-pitch .bank-pill {
    margin-top: 1.1rem;
  }
}

/* ---------- Cabecera ---------- */
.topbar {
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}

.topbar-inner {
  max-width: var(--page-width);
  padding: 0.6rem 1.25rem;
  flex-wrap: nowrap;
  gap: 1rem;
}

.brand-row {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  min-width: 0;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent);
}

.brand-sub {
  max-width: 30ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.22rem;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-right: auto;
}

.tool-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.8rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.87rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.tool-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tool-link.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--border);
}

.icon-btn {
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background-color 0.15s;
}

.icon-btn:hover,
.user-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.user-chip {
  transition: border-color 0.15s, background-color 0.15s;
  max-width: 200px;
}

.user-chip.active {
  border-color: var(--primary);
}

.user-chip > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  flex-shrink: 0;
}

/* Pestañas del examen: fila propia debajo de la cabecera */
.main-nav {
  flex-wrap: nowrap;
  gap: 0.15rem;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--border);
  padding: 0 max(1.25rem, calc((100% - var(--page-width)) / 2 + 1.25rem));
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  position: relative;
  white-space: nowrap;
  border-radius: 0;
  padding: 0.7rem 0.85rem;
  font-size: 0.88rem;
}

.nav-btn:hover {
  background: transparent;
}

.nav-btn::after {
  content: "";
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background-color 0.15s;
}

.nav-btn:hover::after {
  background: var(--border-strong);
}

.nav-btn.active {
  background: transparent;
  color: var(--text);
}

.nav-btn.active::after {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.breadcrumb-bar {
  background: transparent;
  border-top: none;
}

.breadcrumb-inner {
  max-width: var(--page-width);
  padding: 0.9rem 1.25rem 0;
  font-size: 0.82rem;
  gap: 0.3rem;
}

.crumb-link {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.crumb-link:hover {
  color: var(--primary);
}

.crumb-current {
  font-weight: 600;
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .brand-text {
    display: none;
  }
  .tool-label {
    display: none;
  }
  .tool-link {
    padding: 0.45rem 0.7rem;
    font-size: 1.05rem;
  }
  #user-chip-name {
    display: none;
  }
  .user-chip {
    padding: 0.3rem;
  }
}

/* ---------- Contenedor, títulos y tarjetas ---------- */
.main-container {
  max-width: var(--page-width);
  padding: 1.4rem 1.25rem 4rem;
}

.section-header {
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.55rem;
  margin: 0.15rem 0 0.2rem;
}

.section-header p {
  max-width: 78ch;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.08rem;
  font-weight: 700;
  margin: 2rem 0 0.9rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 0.9rem;
}

.section-title-row .section-title {
  margin: 0;
}

.section-subtitle {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 1.6rem 0 0.7rem;
}

.card,
.kpi-card,
.quick-card,
.topic-card,
.failure-card,
.subject-card,
.exam-block-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.exam-block-card {
  border-width: 1px;
}

/* ---------- Portada: saludo + anillo de progreso ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.6rem 1.75rem;
  margin-bottom: 1.1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    radial-gradient(520px 220px at 0% 0%, var(--glow-a), transparent 70%),
    radial-gradient(420px 220px at 100% 100%, var(--glow-b), transparent 70%),
    var(--bg-card);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.35rem;
}

.hero h2 {
  font-size: clamp(1.45rem, 3vw, 1.95rem);
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.hero p {
  max-width: 60ch;
}

.hero-ring {
  --pct: 0;
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(var(--success) calc(var(--pct) * 1%), var(--border) 0);
  display: grid;
  place-items: center;
}

.hero-ring-inner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.hero-ring-inner strong {
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hero-ring-inner span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

@media (max-width: 600px) {
  .hero {
    padding: 1.25rem;
  }
  .hero-ring {
    width: 84px;
    height: 84px;
  }
  .hero-ring-inner {
    width: 66px;
    height: 66px;
  }
  .hero-ring-inner strong {
    font-size: 1.1rem;
  }
  .hero-ring-inner span {
    display: none;
  }
}

/* ---------- KPIs ---------- */
.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
}

.kpi-card {
  padding: 1.05rem 1.15rem;
}

.kpi-label {
  font-size: 0.74rem;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin: 0.3rem 0 0.2rem;
}

.kpi-of {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-sub {
  font-size: 0.8rem;
}

.kpi-card.kpi-danger {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: linear-gradient(180deg, var(--danger-soft), transparent 70%), var(--bg-card);
}

.kpi-card.kpi-ok {
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

.progress-track {
  height: 7px;
  background: color-mix(in srgb, var(--border) 75%, transparent);
}

.progress-fill {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.5s ease;
}

.progress-fill.fill-success {
  background: linear-gradient(90deg, var(--success), color-mix(in srgb, var(--success) 60%, var(--primary)));
}

/* ---------- Portada: laboratorios ---------- */
.lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.9rem;
}

.lab-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "ico body" "btn btn";
  gap: 0.9rem 1rem;
  align-items: start;
  padding: 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.lab-card:hover {
  transform: translateY(-2px);
}

.lab-terminal {
  background: linear-gradient(135deg, var(--primary-soft), transparent 55%), var(--bg-card);
}

.lab-terminal:hover {
  border-color: var(--primary);
}

.lab-sql {
  background: linear-gradient(135deg, var(--success-soft), transparent 55%), var(--bg-card);
}

.lab-sql:hover {
  border-color: var(--success);
}

.lab-card-ico {
  grid-area: ico;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 1.45rem;
}

.lab-card-body {
  grid-area: body;
  min-width: 0;
}

.lab-card-body h3 {
  font-size: 1.03rem;
  margin-bottom: 0.25rem;
}

.lab-card-body p {
  font-size: 0.86rem;
}

.lab-card .btn {
  grid-area: btn;
  justify-self: start;
}

@media (max-width: 480px) {
  .lab-grid {
    grid-template-columns: 1fr;
  }
  .lab-card .btn {
    justify-self: stretch;
  }
}

/* ---------- Portada: asignaturas ---------- */
.subjects-grid {
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
}

.subject-card {
  padding: 1.2rem;
  gap: 0.85rem;
  justify-content: flex-start;
}

.subject-card.subject-ready {
  border-color: var(--border);
}

.subject-card:hover,
.subject-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
}

.subject-card-top {
  align-items: center;
}

.subject-card-title {
  flex: 1;
  min-width: 0;
}

.subject-card-title h3 {
  font-size: 1.02rem;
  line-height: 1.25;
}

.subject-card-title .ud-tag {
  margin-bottom: 0.2rem;
}

.subject-icon-box {
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--accent) 14%, transparent));
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
}

.subject-desc {
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.subject-progress {
  margin-top: auto;
}

.subject-progress-head,
.subject-progress-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
}

.subject-progress-head {
  font-weight: 600;
  color: var(--text-muted);
}

.subject-progress-head strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.subject-progress .progress-track {
  margin: 0.35rem 0;
}

.subject-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--primary);
}

.subject-cta span {
  transition: transform 0.15s;
}

.subject-card:hover .subject-cta span {
  transform: translateX(4px);
}

.subjects-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.6rem;
}

.subject-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.subject-mini:hover,
.subject-mini:focus-visible {
  background: var(--bg-card);
  border-color: var(--primary);
  border-style: solid;
}

.subject-mini .subject-icon-box {
  width: 38px;
  height: 38px;
  font-size: 1.15rem;
  border-radius: 10px;
  filter: grayscale(0.6);
  opacity: 0.85;
}

.subject-mini-text {
  flex: 1;
  min-width: 0;
}

.subject-mini-text h3 {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.subject-mini-text .ud-tag {
  margin-bottom: 0.1rem;
  font-size: 0.68rem;
  padding: 0.08rem 0.4rem;
}

.subject-mini .status-pill {
  font-size: 0.68rem;
}

/* ---------- Chips, etiquetas y pastillas ---------- */
.ud-tag {
  border-radius: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.stat-chip {
  border-radius: 7px;
  font-size: 0.79rem;
}

.count-pill {
  border-radius: 999px;
  padding: 0.42rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.count-pill:hover:not(.active) {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.status-pill.pill-active::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.resume-banner,
.study-banner {
  border-radius: var(--radius);
}

/* ---------- Bloques de examen, accesos rápidos y temas ---------- */
.exam-blocks-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
}

.exam-block-card:hover,
.quick-card:hover {
  box-shadow: var(--shadow-lg);
}

.topic-card {
  transition: border-color 0.15s;
}

.topic-card:hover {
  border-color: var(--border-strong);
}

.topic-card h3 {
  font-size: 1.02rem;
}

.included-topics-list {
  border-radius: var(--radius-md);
}

.included-topic-item + .included-topic-item {
  border-top: 1px dashed var(--border);
  padding-top: 0.4rem;
}

.radio-card {
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background-color 0.15s;
}

.radio-card:hover {
  border-color: var(--border-strong);
}

/* ---------- Test ---------- */
.quiz-layout > aside.card {
  position: sticky;
  top: 5.2rem;
}

.question-title {
  font-size: 1.22rem;
  line-height: 1.5;
}

.option-btn {
  border-width: 1.5px;
  border-radius: var(--radius-md);
  font-family: inherit;
}

.option-btn:hover:not(:disabled) {
  transform: translateX(2px);
}

.option-letter {
  border-radius: 8px;
  transition: background-color 0.14s, color 0.14s;
}

.explanation-box {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left-width: 4px;
}

.qnav-grid {
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
}

.qnav-cell {
  transition: transform 0.1s;
}

.qnav-cell:hover {
  transform: scale(1.06);
}

.score-hero {
  background:
    radial-gradient(480px 200px at 50% 0%, var(--glow-a), transparent 70%),
    var(--bg-card);
}

.score-big {
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Apuntes ---------- */
.notes-body {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem clamp(1.25rem, 4vw, 2.5rem);
}

.notes-body h2 {
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.notes-body code {
  font-family: var(--font-mono);
}

/* ---------- Tablas ---------- */
.card.table-wrap {
  padding: 0.4rem 0.6rem;
}

th {
  font-size: 0.72rem;
  white-space: nowrap;
}

td {
  font-variant-numeric: tabular-nums;
}

tbody tr {
  transition: background-color 0.12s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Avisos flotantes ---------- */
.toast {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
  .main-container {
    padding: 1rem 0.9rem 3rem;
  }
  .section-header h2 {
    font-size: 1.3rem;
  }
  .toast-container {
    left: 0.9rem;
    right: 0.9rem;
    bottom: 0.9rem;
  }
  .toast {
    max-width: none;
  }
}

/* Apuntes: bloques de código y consejos (ASO) */
.md-code { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 0.75rem 0.9rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.45; margin: 0.6rem 0 1rem; }
.md-code code { background: transparent; color: inherit; padding: 0; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.md-tip { border-left: 4px solid var(--warning); background: var(--warning-soft); border-radius: 0 10px 10px 0; padding: 0.5rem 0.8rem; margin: 0.6rem 0; }

/* =====================================================================
   MÓVIL 2026-11-24 · capa para pantallas pequeñas (≤ 640px)
   - Barra de secciones (Asignaturas / Terminal / SQL) abajo, estilo app
   - KPIs a 2 columnas, títulos más compactos, migas de pan en una línea
   - Campos a 16px (iOS no hace zoom al escribir) y zonas táctiles cómodas
   ===================================================================== */
@media (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* Cabecera: logo + nombre corto + tema + perfil.
     Sin backdrop-filter: si no, la barra inferior "fixed" quedaría anclada a la cabecera. */
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg-elev); }
  .topbar-inner { padding: 0.5rem 0.8rem; gap: 0.6rem; }
  .brand-text { display: block; min-width: 0; }
  .brand-text .brand-sub { display: none; }
  .brand-logo { width: 34px; height: 34px; font-size: 1.05rem; }

  /* Secciones principales → barra inferior fija */
  .tool-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    margin: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
    gap: 0.3rem;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.18);
  }
  .tool-link {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.35rem 0.2rem;
    min-height: 52px;
    font-size: 0.72rem;
    border-radius: 10px;
  }
  .tool-link .tool-ico { font-size: 1.25rem; line-height: 1; }
  .tool-link .tool-label { display: block; font-size: 0.7rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tool-link.active { color: var(--primary); }

  /* Pestañas del examen: deslizables con pista de que hay más */
  .main-nav {
    padding: 0 0.5rem;
    scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
  }
  .nav-btn { padding: 0.65rem 0.7rem; font-size: 0.85rem; scroll-snap-align: start; }

  /* Migas de pan: una sola línea deslizable */
  .breadcrumb-inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.7rem 0.9rem 0;
    white-space: nowrap;
  }
  .breadcrumb-inner::-webkit-scrollbar { display: none; }
  .crumb-link, .crumb-current { white-space: nowrap; font-size: 0.78rem; }
  .crumb-current { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; }

  /* Contenido */
  .main-container { padding: 0.9rem 0.8rem 2rem; }
  .section-header { margin-bottom: 1rem; }
  .section-header h2 { font-size: 1.2rem; line-height: 1.3; }
  .section-header p { font-size: 0.9rem; }
  .section-header > p:not(.expanded), .section-header > div > p:not(.expanded) {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
  }
  .section-title { font-size: 1.02rem; margin: 1.3rem 0 0.7rem; }
  h1 { font-size: 1.35rem; }
  .card { padding: 1rem; }

  /* KPIs a 2 columnas */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .kpi-card { padding: 0.75rem 0.8rem; }
  .kpi-label { font-size: 0.66rem; letter-spacing: 0.03em; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-card .muted, .kpi-sub { font-size: 0.74rem; }

  /* Botones y tarjetas de examen */
  .btn { min-height: 40px; }
  .btn-lg { padding: 0.75rem 1rem; font-size: 0.98rem; }
  .exam-blocks-grid { grid-template-columns: 1fr; }
  .exam-blocks-grid div:has(> .btn-lg) { display: flex; flex-direction: column; gap: 0.55rem; }
  .exam-blocks-grid div:has(> .btn-lg) > .btn { width: 100%; }
  .study-banner { flex-direction: column; align-items: stretch; gap: 0.7rem; }
  .study-banner .btn { width: 100%; }
  .quick-grid, .topics-grid, .subjects-grid { grid-template-columns: 1fr; }

  /* Apuntes: más ancho útil para leer */
  #notes-content .card, .notes-card { padding: 0.95rem 0.85rem; }
  .notes-body { font-size: 0.96rem; }
  .notes-body h1 { font-size: 1.3rem; }
  .notes-body h2 { font-size: 1.1rem; }
  .notes-body ul, .notes-body ol { padding-left: 1.1rem; }
  .md-code { font-size: 0.78rem; padding: 0.65rem 0.7rem; }

  /* Test */
  .option-btn { padding: 0.8rem 0.85rem; }

  /* Campos de texto a 16px: evita el zoom automático de iOS al escribir */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }

  /* Avisos por encima de la barra inferior */
  .toast-container { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tool-link .tool-label { font-size: 0.64rem; }
}

/* Terminal Linux: teclas virtuales para el móvil (Tab, flechas, Ctrl+C/D/L y símbolos) */
.linux-vkeys { display: none; }
@media (max-width: 900px), (pointer: coarse) {
  .linux-vkeys {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0.45rem 0.55rem;
    background: #0b1220;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
  }
  .linux-vkeys::-webkit-scrollbar { display: none; }
  .linux-vkeys button {
    flex: 0 0 auto;
    min-width: 42px;
    min-height: 38px;
    padding: 0 0.65rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: #111a2e;
    color: #e2e8f0;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.9rem;
    cursor: pointer;
    touch-action: manipulation;
  }
  .linux-vkeys button:active { background: #1e293b; }
}
@media (max-width: 640px) {
  .linux-bar-hint { display: none; }
  .linux-window-title { font-size: 0.74rem; }
  .linux-term-output { font-size: 0.8rem; }
  #view-terminal .section-header .btn-sm, #view-sqllab .section-header .btn-sm { min-height: 34px; padding: 0.35rem 0.65rem; font-size: 0.8rem; }
}

/* Zona segura (notch / barra de estado) cuando se abre como app instalada */
.topbar { padding-top: env(safe-area-inset-top); }

/* Apuntes: listas numeradas y viñetas dentro de un paso */
.notes-body ol { padding-left: 1.4rem; margin: 0.4rem 0 0.9rem; }
.notes-body ol > li { margin: 0.3rem 0; }
.notes-body ol > li::marker { font-weight: 700; color: var(--primary); }
.notes-body ol > li.md-sub { display: block; list-style: none; position: relative; margin-left: 1rem; font-size: 0.95em; }
.notes-body ol > li.md-sub::before { content: "•"; position: absolute; left: -0.9rem; color: var(--text-muted); }
