/* ============================================================
   Платформа курса — дизайн-система в духе «Дворецкого»:
   две темы, тёплый латунный акцент, редакционная типографика.
   ============================================================ */

:root {
  /* Светлая тема — база по умолчанию */
  --bg: #FAF7F2;
  --bg-2: #F3EEE5;
  --surface: #FFFFFF;
  --surface-2: #FBF8F3;
  --text: #1B1713;
  --text-2: #595046;
  --text-3: #635A50;
  --brass: #B0803A;
  --brass-ink: #8A6229;
  --brass-soft: rgba(176, 128, 58, .12);
  --line: rgba(27, 23, 19, .11);
  --line-strong: rgba(27, 23, 19, .20);
  --shadow-1: 0 1px 2px rgba(27, 23, 19, .04), 0 2px 8px rgba(27, 23, 19, .05);
  --shadow-2: 0 2px 6px rgba(27, 23, 19, .05), 0 12px 32px rgba(27, 23, 19, .09);

  --radius: 12px;
  --radius-sm: 8px;
  --space-1: 6px;
  --space-2: 12px;
  --space-3: 20px;
  --space-4: 32px;
  --transition: 200ms;
  --easing: cubic-bezier(.4, 0, .2, 1);
  --container: 760px;
}

:root[data-theme="dark"] {
  --bg: #141110;
  --bg-2: #221D18;
  --surface: #201B18;
  --surface-2: #251F1B;
  --text: #F2EDE5;
  --text-2: #B8AEA1;
  --text-3: #A99E90;
  --brass: #D8A85C;
  --brass-ink: #E5BD78;
  --brass-soft: rgba(216, 168, 92, .14);
  --line: rgba(242, 237, 229, .13);
  --line-strong: rgba(242, 237, 229, .24);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px rgba(0, 0, 0, .24);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .34), 0 12px 32px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition) var(--easing), color var(--transition) var(--easing);
}

.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 16px 64px;
}

h1, h2, h3 {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 .4em;
  letter-spacing: -0.01em;
  color: var(--text);
}

h1 { font-size: clamp(24px, 5vw, 30px); }

h2 {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--brass-ink);
  margin-bottom: var(--space-2);
}

/* ---- Брендшапка ---- */
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.brand-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg { width: 17px; height: 17px; color: var(--brass); }

.brand-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .005em;
  color: var(--text);
}

.brand-name .muted-part {
  color: var(--text-3);
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

/* ---- Переключатель темы (ползунок) ---- */
.theme-switch {
  display: inline-flex;
  align-items: center;
  width: 56px;
  height: 30px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  transition: border-color var(--transition) var(--easing);
}

.theme-switch:hover { border-color: var(--brass); }

.theme-switch-track {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 0 7px;
}

.theme-switch-icon { width: 14px; height: 14px; position: relative; z-index: 1; color: inherit; }

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 2px 6px rgba(17, 13, 8, .3);
  transition: transform var(--transition) var(--easing);
}

.theme-switch--floating {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

:root[data-theme="dark"] .theme-switch-thumb { transform: translateX(26px); }

/* ---- Карточка входа ---- */
.wrap.narrow {
  max-width: 380px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-3);
  box-shadow: var(--shadow-2);
  text-align: center;
}

.login-card h1 { font-size: 22px; }
.login-card .muted { margin: var(--space-1) 0 var(--space-3); }

/* ---- Плеер ---- */
.player-box {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}

video { width: 100%; display: block; }

.watermark {
  position: absolute;
  top: 12px;
  left: 12px;
  color: rgba(255, 255, 255, .35);
  font-size: 12px;
  pointer-events: none;
  text-shadow: 0 0 2px #000;
}

.lesson-text {
  margin-top: var(--space-3);
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-line;
}

.materials-box {
  margin-top: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.materials-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.material-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid color-mix(in srgb, var(--brass) 27%, var(--line));
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  background: linear-gradient(105deg, color-mix(in srgb, var(--brass) 9%, var(--surface-2)), var(--surface-2) 48%);
  text-decoration: none;
}

.material-card:hover { border-color: var(--brass); }
.material-card-lead { display: grid; gap: 3px; min-width: 0; }
.material-kind, .material-preview-context { color: var(--brass-ink); font-size: 10px; font-weight: 800; letter-spacing: .09em; line-height: 1.25; text-transform: uppercase; }
.material-card-title { overflow: hidden; font-size: 15px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.material-card-context { overflow: hidden; color: var(--text-2); font-size: 11px; font-weight: 500; letter-spacing: 0; text-overflow: ellipsis; text-transform: none; white-space: nowrap; }
.material-actions { display: inline-flex; gap: 10px; flex-shrink: 0; }
.material-action { margin: 0; padding: 0; border: 0; background: transparent; color: var(--brass-ink); font: inherit; font-size: 12px; font-weight: 700; text-decoration: none; box-shadow: none; }
.material-action:hover { background: transparent; color: var(--text); box-shadow: none; }

.material-preview { width: min(960px, calc(100vw - 28px)); height: min(760px, calc(100vh - 28px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow-2); }
.material-preview::backdrop { background: rgba(15, 12, 10, .6); backdrop-filter: blur(3px); }
.material-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 10px 16px; color: #f8f3e8; border-bottom: 1px solid #8d7140; background: linear-gradient(105deg, #101116, #242016 55%, #15130f); }
.material-preview-heading { display: grid; gap: 2px; min-width: 0; }
.material-preview-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-preview-context { color: #ddbd70; }
.material-preview-head .preview-close { color: #f8f3e8; border: 1px solid rgba(221, 189, 112, .55); background: transparent; }
.material-preview-head .preview-close:hover { color: #17140f; background: #ddbd70; }
.preview-close { width: 32px; height: 32px; margin: 0; padding: 0; border-radius: 50%; font-size: 22px; font-weight: 400; line-height: 1; }
.material-preview iframe { display: block; width: 100%; height: calc(100% - 110px); border: 0; background: #fff; }
.material-preview iframe.hidden, .pdf-preview.hidden { display: none; }
.material-preview-text { box-sizing: border-box; width: 100%; height: calc(100% - 110px); margin: 0; padding: 24px; overflow: auto; color: #1d1b19; background: #fff; font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.material-preview-text.hidden { display: none; }
.material-preview-actions { display: flex; align-items: center; gap: 18px; height: 56px; padding: 0 16px; border-top: 1px solid var(--line); }
.material-preview-actions a { color: var(--brass-ink); font-size: 13px; font-weight: 700; text-decoration: none; }
.pdf-preview { display: flex; align-items: flex-start; justify-content: center; width: 100%; height: calc(100% - 110px); overflow: auto; padding: 20px; background: #4b4b4b; }
.pdf-preview canvas { max-width: none; height: auto; box-shadow: 0 8px 28px rgba(0, 0, 0, .42); }
.pdf-page-control { width: 30px; height: 30px; min-width: 30px; margin: 0; padding: 0; border-radius: 50%; font-size: 16px; }
.pdf-page-control:disabled { opacity: .35; cursor: default; }
.pdf-page-counter { min-width: 42px; color: var(--text-2); font-size: 12px; text-align: center; }
.preview-divider { width: 1px; min-width: 1px; height: 24px; margin: 0 2px; padding: 0; border: 0; border-radius: 0; background: var(--line); }

.feedback-box {
  margin-top: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.lesson-navigation { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.lesson-navigation a { color: var(--brass-ink); font-size: 13px; font-weight: 700; text-decoration: none; }
.lesson-navigation .lesson-nav-next { margin-left: auto; }
.lesson-navigation .lesson-nav-back { color: var(--text-2); font-weight: 500; }
.lesson-navigation a:hover { color: var(--text); }

.rating {
  font-size: 28px;
  letter-spacing: 6px;
  cursor: pointer;
  margin-bottom: var(--space-2);
}

.rating span { color: var(--line-strong); transition: color .15s ease; }
.rating span.active { color: var(--brass); }

textarea {
  width: 100%;
  min-height: 80px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

textarea:focus, input:focus {
  outline: none;
  border-color: var(--brass);
}

/* ---- Кнопки: тёмный/светлый инверт + латунь при наведении ---- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--space-2);
  background: var(--text);
  color: var(--bg);
  border: none;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  text-align: center;
  text-decoration: none;
  transition: background var(--transition) var(--easing), transform .1s ease, box-shadow var(--transition) var(--easing);
}

button:hover, .btn:hover {
  background: var(--brass-ink);
  color: #fff;
  box-shadow: var(--shadow-1);
}

button:active, .btn:active { transform: translateY(1px); }

.btn { display: block; }

#feedback-status {
  margin-top: var(--space-1);
  color: var(--brass-ink);
  font-size: 13px;
}

.muted { color: var(--text-2); font-size: 14px; }
.hidden { display: none; }

/* ---- Кабинет ученика ---- */
.student-overview {
  margin: 0 0 24px;
  padding: 8px 0 22px;
  border-bottom: 1px solid var(--line);
}

.section-kicker {
  margin: 0 0 9px;
  color: var(--brass-ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.overview-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.overview-heading h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); }
.overview-heading p { max-width: 480px; margin: 0; color: var(--text-2); line-height: 1.55; font-size: 14px; }

.overview-stats { display: flex; gap: 18px; flex-shrink: 0; }
.overview-stats span { color: var(--text-3); font-size: 11px; line-height: 1.3; text-align: right; }
.overview-stats strong { display: block; color: var(--brass-ink); font-family: 'Playfair Display', Georgia, serif; font-size: 24px; line-height: 1; }

.course-shelf { margin: 0 0 var(--space-4); }

.support-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin: 28px 0 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.support-icon { color: var(--brass-ink); font-size: 19px; }
.support-card strong { display: block; font-size: 14px; }
.support-card p { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }
.support-card a { color: var(--brass-ink); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.support-card a:hover { color: var(--text); }

.course-hero {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  overflow: hidden;
  color: #F8F5EF;
  text-align: left;
  background: #090C12;
  border: 1px solid rgba(176, 128, 58, .46);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(17, 13, 8, .18);
}

.course-hero:hover { background: #090C12; box-shadow: 0 21px 50px rgba(17, 13, 8, .26); }

.course-hero img {
  width: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  display: block;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: var(--space-2);
}

.course-hero-footer {
  display: flex;
  justify-content: center;
  padding: 16px 18px;
  border-top: 1px solid rgba(216, 168, 92, .26);
}

.course-hero-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid rgba(216, 168, 92, .5);
  color: #F8F5EF;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.course-hero-action span { color: #D8A85C; font-size: 18px; vertical-align: -1px; }

/* ---- Списки курсов / уроков ---- */
.list {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 15px;
  transition: border-color var(--transition) var(--easing), transform .1s ease, box-shadow var(--transition) var(--easing);
}

.list-item:hover {
  border-color: var(--brass);
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

/* ---- Дорожная карта модулей ---- */
.module-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.module-block--locked { opacity: .68; background: var(--surface-2); }
.module-block--feedback_required { border-color: var(--brass); box-shadow: var(--shadow-1); }
.module-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.module-header h3 { margin: 0; font-size: 19px; }
.module-status { margin: 3px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.45; }
.module-block--locked .module-status { color: var(--text-3); }
.module-open-btn { margin-bottom: 0; }
.module-lessons { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.intro-lesson-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 16px;
  padding: 18px;
  color: #F8F5EF;
  text-decoration: none;
  background: #201C16;
  border: 1px solid #4D3A20;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.intro-lesson-card:hover { color: #F8F5EF; border-color: var(--brass); }
.intro-lesson-label { grid-column: 1 / -1; color: #D8A85C; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.intro-lesson-title { font-size: 18px; font-weight: 700; }
.intro-lesson-action { align-self: end; color: #D8A85C; font-size: 14px; font-weight: 700; }

.checkpoint-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.checkpoint-box > p:first-child { margin: 0 0 12px; color: var(--text-2); line-height: 1.55; }
.checkpoint-box select {
  width: 100%; padding: 11px 12px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit;
}
.checkpoint-box textarea { margin-top: 8px; }
.checkpoint-box button { width: 100%; }
.checkpoint-status { color: var(--brass-ink); font-size: 13px; }

#lessons-section {
  margin-top: var(--space-4);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}

.lessons-meta { margin: -8px 0 var(--space-2); color: var(--text-2); font-size: 13px; }

#empty-state {
  margin-top: var(--space-3);
  text-align: center;
  padding: var(--space-4) 0;
}

.back-link {
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  display: inline-block;
  margin-bottom: 12px;
  transition: color var(--transition) var(--easing);
}

.back-link:hover { color: var(--brass-ink); }

/* ---- Адаптив ---- */
@media (max-width: 480px) {
  .wrap { padding: 0 12px 48px; }
  .login-card { padding: var(--space-3) var(--space-2); }
  .course-hero-footer { padding: 12px 14px 14px; }
  .course-hero-action { font-size: 12px; }
  .course-grid { grid-template-columns: 1fr; }
  .overview-heading { align-items: flex-start; flex-direction: column; gap: 16px; }
  .overview-stats { width: 100%; justify-content: flex-start; }
  .overview-stats span { text-align: left; }
  .support-card { grid-template-columns: auto minmax(0, 1fr); }
  .support-card a { grid-column: 2; justify-self: start; margin-top: 2px; }
  .material-card { align-items: flex-start; flex-direction: column; gap: 10px; padding: 13px; }
  .material-card-title, .material-card-context { white-space: normal; }
  .material-actions { width: 100%; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); }
  .material-preview-context { max-width: calc(100vw - 130px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
