:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-soft: #1f232c;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa2af;
  --accent: #f2a444;
  --accent-strong: #ffb75e;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

.error {
  color: var(--danger);
  margin: 0;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- Login */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(242, 164, 68, 0.16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(88, 128, 255, 0.12), transparent 50%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 32px 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 1.6rem;
}

.login-card p {
  margin: 0;
}

.login-card label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.brand-mark {
  font-size: 2rem;
}

input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary {
  margin-top: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1206;
  font-weight: 650;
}

.primary:hover {
  background: var(--accent-strong);
}

/* ---------------------------------------------------------------- Layout */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  white-space: nowrap;
}

.brand span {
  display: inline;
}

.search-wrap {
  flex: 1;
  min-width: 0;
}

.search-wrap input {
  max-width: 520px;
  margin: 0 auto;
  display: block;
}

.icon-button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  white-space: nowrap;
}

.icon-button:hover {
  border-color: var(--accent);
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  padding: 16px 12px 32px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100dvh - 62px);
  position: sticky;
  top: 62px;
}

.sidebar h2 {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.block-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.block-button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 0.92rem;
}

.block-button:hover {
  background: var(--bg-elevated);
}

.block-button[aria-current="true"] {
  background: rgba(242, 164, 68, 0.14);
  color: var(--accent-strong);
  font-weight: 600;
}

.block-button .count {
  color: var(--muted);
  font-size: 0.78rem;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 20px 64px;
}

/* ---------------------------------------------------------------- Lista */

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.4rem;
}

.page-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.continue-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(242, 164, 68, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(242, 164, 68, 0.14), rgba(242, 164, 68, 0.03));
  color: var(--text);
  text-decoration: none;
}

.continue-card:hover {
  border-color: var(--accent);
}

.continue-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
}

.continue-card .title {
  font-weight: 600;
}

.lesson-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.lesson-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: left;
}

.lesson-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.lesson-card.is-watched {
  border-color: rgba(91, 200, 138, 0.35);
}

.lesson-number {
  flex: 0 0 auto;
  min-width: 26px;
  padding-top: 1px;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.lesson-body {
  min-width: 0;
  flex: 1;
}

.lesson-title {
  font-weight: 550;
  overflow-wrap: anywhere;
}

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge.video {
  color: #9cc4ff;
  border-color: rgba(120, 165, 255, 0.35);
}

.badge.audio {
  color: #c3a6ff;
  border-color: rgba(170, 140, 255, 0.35);
}

.badge.document {
  color: #ffd48a;
  border-color: rgba(255, 200, 120, 0.35);
}

.badge.watched {
  color: #7fe0a8;
  border-color: rgba(91, 200, 138, 0.4);
}

.badge.empty {
  color: #8a919d;
}

.progress-track {
  display: block;
  width: 100%;
  height: 3px;
  margin-top: 9px;
  border: none;
  border-radius: 999px;
  appearance: none;
  background: var(--bg-soft);
  overflow: hidden;
}

.progress-track::-webkit-progress-bar {
  background: var(--bg-soft);
  border-radius: 999px;
}

.progress-track::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.progress-track::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.media-wrap {
  margin-top: 16px;
}

.nav-footer {
  justify-content: space-between;
  margin-top: 28px;
}

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------------------------------------------------------------- Detalle */

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.back-button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
}

.detail-title {
  margin: 0 0 6px;
  font-size: 1.35rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.player {
  width: 100%;
  max-height: 72dvh;
  border-radius: var(--radius);
  background: #000;
  border: 1px solid var(--border);
}

.audio-player {
  width: 100%;
  margin-top: 4px;
}

.section-title {
  margin: 26px 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}

.file-link:hover {
  border-color: var(--accent);
}

.file-link .size {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.description {
  max-width: 78ch;
  color: #cfd4dc;
  overflow-wrap: anywhere;
}

.description img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.description a {
  color: var(--accent-strong);
}

.notice {
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--bg-elevated);
}

.poster {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

/* ---------------------------------------------------------------- Móvil */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.55);
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    top: 62px;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(320px, 86vw);
    max-height: none;
    padding-bottom: 48px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 16px 14px 64px;
  }

  .lesson-list {
    grid-template-columns: 1fr;
  }

  .search-wrap input {
    padding: 9px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 520px) {
  .topbar {
    gap: 8px;
    padding: 10px 12px;
  }

  .brand span {
    display: none;
  }

  .icon-button {
    padding: 8px 10px;
  }
}

@media (min-width: 1200px) {
  .main {
    padding: 28px 36px 72px;
  }
}
