:root {
  color-scheme: light;
  --bg: #f7f3ef;
  --surface: #fffaf6;
  --line: #ded4c9;
  --text: #29231f;
  --muted: #746a61;
  --accent: #c95f4b;
  --accent-strong: #a94536;
  --green: #2f7d66;
  --green-soft: #e2f2ec;
  --warning: #986a12;
  --warning-soft: #fff4d8;
  --danger: #a63838;
  --danger-soft: #fae6e6;
  --shadow: 0 12px 30px rgba(73, 52, 36, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

button.secondary {
  background: #e9ddd2;
  color: var(--text);
}

button.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
}

button:disabled {
  opacity: 0.55;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(247, 243, 239, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

h2 {
  font-size: 19px;
  margin-bottom: 12px;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #eadfd5;
  border-radius: 8px;
}

.mode-tabs a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 7px;
}

.mode-tabs a.active {
  background: white;
  color: var(--text);
  box-shadow: 0 3px 10px rgba(80, 55, 35, 0.08);
}

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.section {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-grid .wide,
.toolbar .wide {
  grid-column: 1 / -1;
}

.profile-line,
.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eee3d8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.pill.good {
  background: var(--green-soft);
  color: var(--green);
}

.pill.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.pill.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.course,
.module,
.lesson-row,
.user-row {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.course:first-child,
.module:first-child,
.lesson-row:first-child,
.user-row:first-child {
  border-top: 0;
}

.hint-line {
  margin: 0 0 6px;
  padding: 8px 12px;
  background: var(--green-soft);
  border-radius: 8px;
  font-size: 13px;
}

.module-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.module-head:hover {
  background: #efe5da;
}

.lesson-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.lesson-title {
  margin: 0;
  font-weight: 800;
}

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

.empty {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.viewer {
  display: grid;
  gap: 12px;
}

.video-wrap {
  display: grid;
  gap: 8px;
}

.video-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.video-tabs .video-tab {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
}

.video-sources-list {
  display: grid;
  gap: 6px;
  margin-bottom: 4px;
}

.video-source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 8px;
  background: #111;
}

.video-expand {
  justify-self: start;
}

.video-wrap.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.video-wrap.fullscreen .video-frame {
  flex: 1;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.video-wrap.fullscreen .video-expand {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1001;
}

.text-block {
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
}

.admin-layout {
  display: grid;
  gap: 14px;
}

.content-admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 100px;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.admin-subtabs a {
  flex: 1;
  text-align: center;
}

.tree {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.tree-branch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #efe5da;
  cursor: pointer;
  user-select: none;
}

.tree-branch:hover {
  background: #e8dccf;
}

.tree-caret {
  width: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.tree-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
}

.tree-children {
  display: grid;
  gap: 6px;
  margin: 4px 0 10px 16px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.tree-children .lesson-admin-row {
  border-top: 0;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tree-add {
  padding-top: 2px;
}

.tree-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}

.tree-add-form input {
  flex: 1 1 160px;
  width: auto;
}

.tree-add-form button {
  min-height: 36px;
}

.block-editor {
  display: grid;
  gap: 10px;
}

.editor-caption {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.block-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

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

.block-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.block-actions button,
.block-add button {
  min-height: 32px;
  padding: 0 10px;
}

.block-add {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.editor-panel {
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  margin-bottom: 14px;
}

.checkbox-line {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  width: auto;
}

.lesson-admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.lesson-admin-main {
  flex: 1 1 200px;
  min-width: 0;
}

.lesson-day {
  flex: 0 0 110px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.danger-btn {
  color: var(--danger);
  border-color: var(--danger);
}

.freeze-days {
  width: 64px;
}

.trash-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-tabs a {
    flex: 1;
    text-align: center;
  }

  .two-col,
  .form-grid,
  .content-admin-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 14px;
  }
}

