:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5f6b7a;
  --line: #dce3ec;
  --accent: #315efb;
  --accent-soft: #eaf0ff;
  --good: #16794b;
  --warn: #a15c00;
  --bad: #b42318;
  --code: #111827;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
  padding: 1.5rem 2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .25rem; }
.eyebrow { margin-bottom: .25rem; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.subtitle, #lessonObjective { color: var(--muted); margin-bottom: 0; }

.progress-wrap { min-width: 260px; }
.progress-track { height: 9px; background: #e7ebf1; border-radius: 999px; overflow: hidden; margin-top: .5rem; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 112px); }
.sidebar { padding: 1.5rem; border-right: 1px solid var(--line); background: #f9fbfd; }
.sidebar h2 { font-size: 1rem; }
#lessonNav { display: grid; gap: .5rem; margin-bottom: 1rem; }
.lesson-button {
  width: 100%; text-align: left; padding: .75rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); cursor: pointer; color: var(--text);
}
.lesson-button.active { border-color: var(--accent); background: var(--accent-soft); }
.lesson-button.complete::after { content: " ✓"; color: var(--good); font-weight: 800; }

.content { padding: 1.5rem; max-width: 1050px; width: 100%; margin: 0 auto; }
.lesson-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.tag { display: inline-block; padding: .3rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; font-weight: 800; margin-bottom: .6rem; }
.status-badge { padding: .45rem .7rem; border-radius: 999px; background: #fff4df; color: var(--warn); font-weight: 700; font-size: .85rem; }
.status-badge.complete { background: #e8f7ef; color: var(--good); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; margin-bottom: 1rem; box-shadow: 0 4px 14px rgba(16, 24, 40, .04); }
.mission-card { border-left: 5px solid var(--accent); }
.transfer-card { border-left: 5px solid #7a5af8; }
.diagnostic-card { border-left: 5px solid #0e9384; }

.ipo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 1rem; }
.ipo-grid div { padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: #fafcff; }
.ipo-grid strong { display: block; margin-bottom: .3rem; }
.ipo-grid span { color: var(--muted); }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: .8rem; }
.choice { border: 1px solid var(--line); padding: .75rem; border-radius: 10px; background: var(--panel); cursor: pointer; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }

label { display: block; font-weight: 700; margin: .7rem 0 .4rem; }
textarea, input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .75rem; font: inherit; color: var(--text); background: #fff;
}
textarea:focus, input:focus, select:focus { outline: 3px solid rgba(49, 94, 251, .15); border-color: var(--accent); }

.code-block, .console, .code-editor {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.code-block, .console { background: var(--code); color: #f8fafc; border-radius: 10px; padding: 1rem; overflow-x: auto; }
.code-editor { min-height: 260px; background: #0b1220; color: #e5edf7; line-height: 1.5; tab-size: 4; }
.console { min-height: 90px; white-space: pre-wrap; }

.primary-button, .secondary-button {
  border: 0; border-radius: 9px; padding: .72rem 1rem; font-weight: 800; cursor: pointer; margin-top: .75rem;
}
.primary-button { background: var(--accent); color: white; }
.secondary-button { background: #e9edf3; color: var(--text); }
.button-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.editor-toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: .6rem; margin-bottom: .75rem; }
.editor-toolbar label { margin: 0 0 .5rem; }
.editor-toolbar .secondary-button { margin-top: 0; }

.feedback { min-height: 1.4rem; margin: .7rem 0 0; font-weight: 700; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.warn { color: var(--warn); }

.profile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.profile-item { padding: .75rem; border-radius: 10px; background: #f6f8fb; border: 1px solid var(--line); }
.profile-item strong { display: block; margin-bottom: .2rem; }

@media (max-width: 800px) {
  .app-header { position: static; align-items: start; flex-direction: column; }
  .progress-wrap { width: 100%; min-width: 0; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  #lessonNav { grid-template-columns: repeat(2, 1fr); }
  .ipo-grid, .choice-grid, .profile-grid { grid-template-columns: 1fr; }
  .editor-toolbar { grid-template-columns: 1fr; align-items: stretch; }
}
