:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #171a1d;
  --panel-2: #1d2024;
  --panel-3: #23272c;
  --border: #2d3238;
  --muted: #8f979f;
  --text: #eef1f4;
  --text-soft: #c8ced5;
  --accent: #f1f3f5;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; }
body { min-height: 100vh; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.boot, .login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}

.login-card {
  width: min(430px, 100%); background: linear-gradient(180deg, #1a1d20, #151719);
  border: 1px solid var(--border); border-radius: 20px; padding: 34px; box-shadow: var(--shadow);
}
.login-brand { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.login-card h1 { margin: 12px 0 8px; font-size: 30px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 12px; margin-top: 26px; }

input, textarea {
  width: 100%; background: #101214; color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: #59616b; box-shadow: 0 0 0 3px rgba(120,130,140,.12); }
textarea { resize: vertical; min-height: 130px; }

.btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel-3); border-radius: 11px;
  padding: 10px 14px; cursor: pointer; font-weight: 600; transition: transform .12s, background .12s, border-color .12s;
}
.btn:hover { background: #2a3036; border-color: #424a53; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #eceff2; color: #121416; border-color: #eceff2; }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffb0b0; }
.btn.small { padding: 7px 10px; font-size: 12px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 66px; display: flex; align-items: center; gap: 18px; padding: 0 22px;
  border-bottom: 1px solid var(--border); background: rgba(17,19,21,.94); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tab-btn { border: 0; background: transparent; color: var(--muted); padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.tab-btn.active { background: var(--panel-2); color: var(--text); }
.topbar-spacer { flex: 1; }
.role-pill { color: var(--muted); font-size: 12px; border: 1px solid var(--border); padding: 6px 9px; border-radius: 999px; }

.course-layout {
  min-height: calc(100vh - 66px); display: grid; grid-template-columns: minmax(0, 1fr) 390px;
}
.stage { padding: 22px; min-width: 0; }
.player-card {
  background: #090a0b; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
.player-frame { aspect-ratio: 16 / 9; width: 100%; background: #070809; display: grid; place-items: center; }
.player-frame iframe, .player-frame video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.empty-player { color: var(--muted); text-align: center; padding: 30px; line-height: 1.6; }
.lesson-meta { padding: 22px 4px 0; }
.kicker { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; }
.lesson-meta h1 { margin: 8px 0 8px; font-size: clamp(24px, 3vw, 38px); }
.lesson-meta p { margin: 0; color: var(--muted); line-height: 1.6; }

.curriculum {
  border-left: 1px solid var(--border); background: var(--panel); min-height: calc(100vh - 66px);
  position: sticky; top: 66px; height: calc(100vh - 66px); overflow: auto;
}
.curriculum-head { padding: 22px; border-bottom: 1px solid var(--border); }
.curriculum-head h2 { font-size: 17px; margin: 0 0 5px; }
.curriculum-head span { color: var(--muted); font-size: 12px; }
.module { border-bottom: 1px solid var(--border); }
.module-toggle {
  width: 100%; background: transparent; border: 0; display: grid; grid-template-columns: 1fr auto; gap: 12px;
  text-align: left; padding: 17px 20px; cursor: pointer;
}
.module-toggle:hover { background: rgba(255,255,255,.025); }
.module-title { font-weight: 650; font-size: 14px; }
.module-count { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chevron { color: var(--muted); transition: transform .15s; }
.module.open .chevron { transform: rotate(90deg); }
.lesson-list { display: none; padding: 0 10px 10px; }
.module.open .lesson-list { display: grid; gap: 4px; }
.lesson-item {
  border: 0; background: transparent; width: 100%; display: grid; grid-template-columns: 78px minmax(0,1fr); gap: 11px;
  align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; text-align: left;
}
.lesson-item:hover, .lesson-item.active { background: var(--panel-3); }
.thumb { width: 78px; aspect-ratio: 16/9; border-radius: 7px; object-fit: cover; background: #0e1012; border: 1px solid #30353a; }
.thumb.placeholder { display: grid; place-items: center; color: #59616b; font-size: 10px; }
.lesson-number { color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.lesson-title { font-size: 12px; line-height: 1.35; color: var(--text-soft); }

.editor { padding: 24px; max-width: 1320px; width: 100%; margin: 0 auto; }
.editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 24px; }
.editor-head h1 { margin: 0 0 7px; }
.editor-head p { margin: 0; color: var(--muted); }
.editor-grid { display: grid; grid-template-columns: 380px minmax(0,1fr); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.card h2 { font-size: 15px; margin: 0 0 14px; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 7px; }
.field label { color: var(--text-soft); font-size: 12px; font-weight: 600; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.5; }
.file-row { display: grid; gap: 8px; }
.file-input { background: #101214; border: 1px dashed #3a4148; border-radius: 12px; padding: 12px; }
.import-actions, .toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

.module-editor { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; margin-bottom: 12px; }
.module-editor-head { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 8px; padding: 10px; align-items: center; background: var(--panel-2); }
.module-editor-head input { padding: 9px 10px; }
.module-index { color: var(--muted); text-align: center; font-size: 12px; }
.lesson-editor { display: grid; grid-template-columns: 58px minmax(150px, .8fr) minmax(220px, 1.4fr) 34px; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: center; }
.lesson-editor input { padding: 9px 10px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; background: transparent; border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--panel-3); }
.editor-empty { padding: 35px; color: var(--muted); text-align: center; }
.status { min-height: 20px; color: var(--muted); font-size: 12px; }
.status.ok { color: #9bd5a5; }
.status.err { color: #ff9c9c; }

@media (max-width: 980px) {
  .course-layout { grid-template-columns: 1fr; }
  .curriculum { position: static; height: auto; min-height: auto; border-left: 0; border-top: 1px solid var(--border); }
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 660px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand { display: none; }
  .stage { padding: 12px; }
  .lesson-editor { grid-template-columns: 48px 1fr 34px; }
  .lesson-editor .link-cell { grid-column: 1 / -1; }
  .editor { padding: 14px; }
  .editor-head { flex-direction: column; }
}
