* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
}

body { display: flex; flex-direction: column; }

header {
  padding: 18px 24px 14px;
  border-bottom: 1px solid #0f3460;
  position: relative;
}
header h1 { font-size: 22px; color: #e94560; font-weight: 700; }
header .subtitle { font-size: 13px; color: #888; margin-top: 2px; }
header .back {
  position: absolute; top: 18px; right: 24px;
  color: #888; text-decoration: none; font-size: 13px;
}
header .back:hover { color: #e94560; }

main {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

/* ─── Sidebar ────────────────────────────── */
#sidebar {
  background: #141428;
  border-right: 1px solid #0f3460;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #0f3460;
}
.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  color: #888;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tabs button:hover { color: #ccc; }
.tabs button.active { color: #e94560; border-bottom-color: #e94560; }

#lessonList {
  list-style: none;
  flex: 1;
  padding: 8px 0;
}
#lessonList li {
  padding: 10px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 14px;
  color: #c0c0c0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .1s;
}
#lessonList li:hover { background: #1b1b38; }
#lessonList li.active {
  background: #1b1b38;
  border-left-color: #e94560;
  color: #fff;
}
#lessonList li .check {
  color: #4ade80;
  font-size: 13px;
  margin-left: auto;
}
#lessonList li .check:empty::before { content: "○"; color: #444; }

#resetProgress {
  margin: 12px 18px 18px;
  background: transparent;
  border: 1px solid #333;
  color: #888;
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}
#resetProgress:hover { border-color: #e94560; color: #e94560; }

/* ─── Workspace ─────────────────────────── */
#workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#lessonHeader {
  padding: 16px 24px;
  border-bottom: 1px solid #0f3460;
  max-height: 40vh;
  overflow-y: auto;
}
#lessonHeader h2 {
  color: #fff;
  font-size: 18px;
  margin-bottom: 8px;
}
#lessonDesc {
  font-size: 14px;
  color: #bbb;
  line-height: 1.6;
}
#lessonDesc p { margin: 8px 0; }
#lessonDesc h2, #lessonDesc h3, #lessonDesc h4 {
  color: #fff;
  margin: 14px 0 6px;
  font-size: 15px;
}
#lessonDesc h4 { font-size: 14px; color: #ddd; }
#lessonDesc ul { margin: 6px 0 8px 20px; }
#lessonDesc li { margin: 2px 0; }
#lessonDesc code {
  background: #0f3460;
  color: #ffd97a;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 13px;
}
#lessonDesc strong { color: #fff; }
#lessonDesc .md-code {
  background: #0b0b1a;
  border: 1px solid #0f3460;
  border-radius: 5px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
}
#lessonDesc .md-code code {
  background: transparent;
  color: #d8d8d8;
  padding: 0;
  font-size: 12.5px;
  line-height: 1.45;
}

/* Lesson list sections */
#lessonList li.section-head {
  color: #888;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 18px 4px;
  cursor: default;
  border-left: none;
  font-weight: 700;
}
#lessonList li.section-head:hover { background: transparent; }

#editorWrap {
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid #0f3460;
  display: flex;
}
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 14px;
}

#controls {
  padding: 10px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #0f3460;
  background: #141428;
}
.hidden { display: none !important; }

/* Progress box */
#progressBox {
  padding: 10px 18px 8px;
  border-bottom: 1px solid #0f3460;
  background: #11112a;
}
.progressLabel {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.progressLabel #progressText {
  color: #e94560;
  font-weight: 700;
}
.progressBar {
  height: 5px;
  background: #0b0b1a;
  border-radius: 3px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  background: linear-gradient(90deg, #e94560, #ff8a9b);
  width: 0%;
  transition: width 0.3s ease;
}

/* Lesson list playground marker */
#lessonList li.playground-item {
  font-style: italic;
  color: #9aa3ff;
}

/* Hints box */
#hintsBox {
  margin-top: 12px;
  padding: 10px 14px;
  background: #0f1530;
  border-left: 3px solid #ffd97a;
  border-radius: 4px;
}
.linkBtn {
  background: none;
  border: none;
  color: #ffd97a;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-align: left;
}
.linkBtn:hover { color: #ffe89a; text-decoration: underline; }
#hintsList {
  margin: 8px 0 4px 22px;
  padding: 0;
  color: #ccc;
  font-size: 13px;
  line-height: 1.5;
}
#hintsList li { margin: 4px 0; }
#hintsList code {
  background: #0f3460;
  color: #ffd97a;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}

/* Keyboard hint inside buttons */
.kbd {
  display: inline-block;
  font-size: 10px;
  background: rgba(0,0,0,0.25);
  color: #ffd0d8;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
}

/* Output diff colours */
#output .diff-add { color: #4ade80; }
#output .diff-del { color: #ff6b7a; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 10px;
  max-width: 460px;
  padding: 24px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-box h3 {
  color: #e94560;
  font-size: 17px;
  margin-bottom: 10px;
}
.modal-box p {
  color: #bbb;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

button.primary {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
}
button.primary:hover { background: #ff5573; }
button.primary:disabled { background: #555; cursor: not-allowed; }
button.secondary {
  background: transparent;
  border: 1px solid #444;
  color: #aaa;
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 5px;
  cursor: pointer;
}
button.secondary:hover { border-color: #e94560; color: #e94560; }
#status { font-size: 13px; color: #888; }
#status.ok { color: #4ade80; }
#status.fail { color: #ff6b7a; }

#outputWrap {
  background: #0e0e1c;
  min-height: 22vh;
  max-height: 35vh;
  display: flex;
  flex-direction: column;
}
.outHead {
  padding: 8px 16px;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #0f3460;
}
#meta { color: #555; text-transform: none; letter-spacing: 0; }
#output {
  padding: 12px 16px;
  flex: 1;
  overflow: auto;
  font-family: 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  color: #d0d0d0;
  white-space: pre-wrap;
  word-break: break-word;
}
#output .err { color: #ff6b7a; }
#output .ok  { color: #4ade80; }
#output .info { color: #6bb6ff; }

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
  #sidebar { max-height: 40vh; border-right: none; border-bottom: 1px solid #0f3460; }
}
