:root {
  --ink: #17201f;
  --muted: #65706e;
  --paper: #fbfbf7;
  --panel: #ffffff;
  --line: #dbe3df;
  --teal: #176b62;
  --teal-dark: #0f413d;
  --blue: #285e8e;
  --gold: #b98726;
  --coral: #b95b47;
  --sidebar: #14201f;
  --sidebar-soft: #1c2d2b;
  --shadow: 0 18px 55px rgba(27, 39, 37, .12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.55 "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  color: #edf5f2;
  background: var(--sidebar);
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  color: #f6dca4;
  background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.04)), var(--sidebar-soft);
  font-weight: 800;
}

.brand strong { display: block; font-size: 18px; line-height: 1.15; }
.brand small { color: #aebeba; }

.main-nav {
  display: grid;
  gap: 8px;
}

.main-nav a,
.logout-form .button {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px;
  color: #edf5f2;
  background: transparent;
  text-decoration: none;
}

.main-nav a:hover { background: var(--sidebar-soft); border-color: rgba(246,220,164,.42); }
.logout-form { margin-top: auto; }

.dev-badge {
  padding: 9px 10px;
  border: 1px solid rgba(246,220,164,.36);
  border-radius: 8px;
  color: #f6dca4;
  background: rgba(246,220,164,.08);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.auth-screen {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.auth-card,
.narrow-page,
.document-page,
.admin-page,
.lesson-page,
.reader-shell {
  max-width: 1080px;
  margin: 0 auto;
}

.auth-card {
  width: min(720px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.narrow-page {
  width: min(760px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; line-height: 1.12; letter-spacing: 0; }
h1 { font-size: clamp(2rem, 4.4vw, 4rem); max-width: 980px; }
h2 { font-size: clamp(1.45rem, 2vw, 2.1rem); }
h3 { font-size: 1.08rem; }
p { margin: 10px 0 0; }
.lead { color: var(--muted); font-size: 1.1rem; max-width: 72ch; }

.button,
.small-button,
.icon-control {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.button.secondary { background: var(--blue); }
.button.neutral { color: #102326; background: #dfe9ee; }
.button.ghost {
  color: var(--teal-dark);
  border: 1px solid var(--line);
  background: #fff;
}

.small-button {
  min-height: 32px;
  padding: 6px 10px;
  background: var(--blue);
  font-size: 13px;
}

.small-button.muted { color: var(--ink); background: #edf1ef; }
.icon-control { width: 42px; padding: 0; border: 1px solid var(--line); color: var(--teal-dark); background: #fff; }
.icon-control.active { color: #fff; border-color: var(--gold); background: var(--blue); }
.icon-control.link { text-decoration: none; }

.notice {
  max-width: 1080px;
  margin: 0 auto 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

.notice.success { border-color: rgba(23,107,98,.35); background: #eef8f6; }
.notice.error { border-color: rgba(185,91,71,.35); background: #fff1ee; }

.mock-panel,
.soft-box,
.progress-card,
.panel-form,
.course-head,
.lesson-head {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mock-panel {
  display: grid;
  gap: 3px;
  margin: 22px 0 14px;
  padding: 14px;
  background: #f4f7f5;
}

.mock-panel span,
.section-title span,
.material-row small,
.lesson-card p,
.soft-box p,
.progress-card span,
.reader-note,
.player-note {
  color: var(--muted);
}

.mock-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 18px;
  color: var(--muted);
  font-weight: 800;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.password-login {
  display: grid;
  gap: 12px;
}

.google-login-box {
  display: grid;
  gap: 12px;
}

.auth-help {
  margin: 0;
  color: var(--muted);
  font-size: .96rem;
}

.course-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 22px;
  align-items: stretch;
  padding: 28px;
  margin-bottom: 22px;
}

.progress-card {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  box-shadow: none;
  background: #f7faf8;
}

.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.progress-card strong {
  color: var(--teal-dark);
  font-size: 3rem;
  line-height: 1;
}

.progress-line,
.sticky-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ece8;
}

.progress-line i,
.sticky-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.sticky-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -28px -28px 22px;
  border-radius: 0;
}

.section { margin-top: 26px; }
.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 12px;
}

.lesson-card {
  min-height: 258px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(27,39,37,.08);
  text-decoration: none;
}

.lesson-card:hover { border-color: rgba(23,107,98,.45); transform: translateY(-1px); }
.lesson-card.done { background: #f3faf7; }
.lesson-card b { margin-top: auto; color: var(--teal-dark); }
.mini-label { color: var(--coral); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.soft-box {
  padding: 18px;
  box-shadow: none;
  background: #fffdf8;
}

.material-list {
  display: grid;
  gap: 9px;
}

.material-list.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.material-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 2px 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
}

.material-row span {
  grid-row: span 2;
  width: 58px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--teal-dark);
  background: #eaf4f1;
  font-size: 11px;
  font-weight: 900;
}

.lesson-head {
  padding: 24px;
  margin-bottom: 16px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 14px;
  color: var(--teal-dark);
  font-weight: 800;
  text-decoration: none;
}

.secure-player {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1110;
  box-shadow: var(--shadow);
}

.player-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0c1110;
}

.player-mount,
.player-mount iframe {
  position: absolute;
  inset: 0;
}

.player-frame iframe,
.secure-player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.player-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #dce8e3;
}

.player-status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  max-width: min(560px, calc(100% - 28px));
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(12, 17, 16, 0.84);
  color: #f8fbfa;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.secure-player.is-loading .player-status,
.player-status.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.player-screen-play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(58px, 8vw, 84px);
  height: clamp(58px, 8vw, 84px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding-left: 5px;
  background: rgba(248, 251, 250, 0.92);
  color: var(--teal-dark);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  font-size: clamp(22px, 4vw, 34px);
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.player-screen-play:hover {
  background: #fff;
  transform: translate(-50%, -50%) scale(1.04);
}

.secure-player.is-loading .player-screen-play {
  opacity: 0.62;
  cursor: wait;
}

.secure-player.is-playing .player-screen-play {
  opacity: 0;
  pointer-events: none;
}

.secure-player.mobile-native-video .player-screen-play {
  opacity: 0;
  pointer-events: none;
}

.secure-player.mobile-native-video iframe {
  pointer-events: auto;
}

.player-controls {
  display: grid;
  grid-template-columns: 42px 42px 42px 54px minmax(120px, 1fr) 54px 112px 42px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  color: #f8fbfa;
  background: #111b1a;
}

.player-controls input { width: 100%; accent-color: var(--gold); }
.player-controls button:disabled,
.player-controls input:disabled {
  opacity: 0.48;
  cursor: wait;
}
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: #d4dfdc; text-align: center; }
.player-note {
  margin: 0;
  padding: 0 14px 14px;
  color: #dce8e3;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pager { display: flex; flex-wrap: wrap; gap: 8px; }

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.pdf-stage {
  position: relative;
  height: min(78vh, 900px);
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #e9efec;
}

.pdf-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.watermark {
  position: absolute;
  inset: auto 18px 18px auto;
  z-index: 2;
  padding: 7px 10px;
  border-radius: 8px;
  color: rgba(20,32,31,.58);
  background: rgba(255,255,255,.68);
  pointer-events: none;
  font-size: 12px;
}

.document-page {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.document-content {
  margin-top: 22px;
  max-width: 860px;
}

.print-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.document-content h2,
.document-content h3,
.document-content h4 { margin-top: 24px; }
.document-content table,
table {
  width: 100%;
  border-collapse: collapse;
}

.document-content td,
th,
td {
  padding: 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.document-content code { padding: 2px 5px; border-radius: 5px; background: #f1f4f2; }

.profile-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.panel-form {
  display: grid;
  gap: 12px;
  padding: 18px;
  box-shadow: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }

.filter-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px 110px;
  gap: 10px;
  margin: 16px 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

th { color: var(--muted); background: #f4f7f5; font-size: 13px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.table-actions form { margin: 0; }

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

pre {
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101817;
  color: #e7f2ef;
}

@media (max-width: 1180px) {
  .lesson-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .site-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
  }
  .main { padding: 18px; }
  .sticky-progress { margin: -18px -18px 18px; }
  .course-head,
  .profile-grid,
  .admin-grid,
  .material-list.compact { grid-template-columns: 1fr; }
  .player-controls {
    grid-template-columns: 42px 42px 42px 52px minmax(90px, 1fr) 52px 42px;
  }
  .volume { display: none; }
  .filter-form { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main { padding: 14px; }
  .auth-card,
  .narrow-page,
  .course-head,
  .lesson-head,
  .document-page { padding: 18px; }
  .lesson-grid { grid-template-columns: 1fr; }
  .section-title,
  .reader-toolbar,
  .lesson-actions { align-items: stretch; flex-direction: column; }
  .mock-actions,
  .pager { flex-direction: column; }
  .button { width: 100%; }
  .material-row { grid-template-columns: 1fr; }
  .material-row span { grid-row: auto; }
  .pdf-stage { min-height: 520px; }
}

@media print {
  .sidebar,
  .back-link,
  .print-actions,
  .notice {
    display: none !important;
  }

  .site-shell,
  .main {
    display: block;
    padding: 0;
  }

  .document-page {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
