:root {
  --purple: #552791;
  --purple-dark: #35145d;
  --sidebar: #18181c;
  --panel: #17171a;
  --editor: #302f36;
  --editor-dark: #24232a;
  --border: #3b3942;
  --text: #eeeaf4;
  --muted: #b9b2c4;
  --yellow: #f5bd36;
  --green: #22d64f;
  --danger: #fb7185;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: 72px minmax(0, 1fr);
  color: var(--text);
  background: var(--panel);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }

.ed-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 86px 210px minmax(260px, 1fr) auto;
  align-items: center;
  height: 72px;
  background: linear-gradient(90deg, var(--purple), var(--purple) 72%, #452079);
  color: white;
  border-bottom: 1px solid #2c104f;
}
.ed-brand { padding-left: 30px; font-size: 34px; font-weight: 800; }
.monash-brand { display: flex; flex-direction: column; line-height: .88; font-size: 25px; }
.monash-brand span { font-size: 24px; }
.course-title { font-size: 27px; font-weight: 500; }
.ed-header-tools { display: flex; align-items: center; gap: 22px; padding-right: 22px; color: #eee8ff; font-size: 14px; }
.notify { display: grid; min-width: 28px; height: 22px; place-items: center; border-radius: 999px; background: #e11d48; font-size: 12px; font-weight: 800; }

.sidebar {
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.brand { min-height: 82px; display: flex; gap: 12px; align-items: center; padding: 18px; border-bottom: 1px solid #2a2930; }
.mark { width: 32px; color: #d8d2e3; font-size: 22px; }
h1, h2, h3, p { margin: 0; }
.brand h1 { font-size: 21px; color: #f3f0f7; }
.brand p { color: var(--muted); font-size: 12px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px; }
.stats div { border: 1px solid #34333a; border-radius: 8px; padding: 10px; background: #222127; }
.stats strong { display: block; font-size: 24px; }
.stats span { color: var(--muted); font-size: 12px; }
.progress-shell { height: 8px; margin: 0 12px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: #8ee6bd; transition: width .2s ease; }
.progress-text { margin: 8px 12px 0; color: #94a3b8; font-size: 12px; }
.side-actions, .mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 12px 0; }
.side-actions button, .mode-tab { border: 1px solid #34333a; border-radius: 8px; padding: 9px 10px; color: #e5e7eb; background: #222127; font-weight: 700; }
.mode-tab.active { color: #111827; background: var(--yellow); }
.question-search { margin: 12px; width: calc(100% - 24px); border: 1px solid #34333a; border-radius: 8px; outline: none; padding: 10px 12px; color: #e5e7eb; background: #222127; }
.question-search::placeholder { color: #94a3b8; }
.question-list { min-height: 0; overflow: auto; padding-bottom: 12px; }
.question-item { position: relative; width: 100%; border: 0; border-left: 6px solid transparent; padding: 14px 18px 14px 42px; text-align: left; color: #c9c4d4; background: transparent; transition: background .15s ease, border-color .15s ease; }
.question-item::before { content: "<>"; position: absolute; left: 17px; color: #facc15; font-weight: 900; }
.question-item.active { border-left-color: #8b5cf6; color: #fff; background: #38373d; }
.question-item:hover { background: #27262c; }
.question-item.done::after { content: ""; float: right; width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--green); }

.workspace { grid-row: 2; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.topbar { min-height: 64px; display: flex; justify-content: center; align-items: center; position: relative; background: var(--purple-dark); border-bottom: 1px solid #2e124f; }
.topbar p, .timer, #timerBtn { display: none; }
.topbar h2 { color: white; font-size: 26px; font-weight: 800; }
.content { flex: 1; min-height: 0; height: calc(100vh - 136px); background: var(--panel); }
.empty-instructions { display: none; }
.practice-view { --left-pane: 38%; height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(330px, var(--left-pane)) 8px minmax(520px, 1fr); gap: 0; }

.prompt { min-height: 0; overflow: auto; padding: 22px 28px; background: var(--panel); border-right: 1px solid var(--border); color: var(--text); }
.question-toolbar { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.question-toolbar span { color: var(--muted); font-weight: 800; text-align: center; }
.question-toolbar button, .ghost { border: 1px solid #3d3b44; border-radius: 8px; padding: 8px 12px; color: #ddd6e8; background: #25242a; font-weight: 700; }
#partTitle { margin-bottom: 12px; color: #ddd6e8; font-size: 22px; }
.question-markdown h2 { margin-bottom: 14px; color: #f7f4fb; font-size: clamp(30px, 3vw, 42px); font-weight: 400; }
.question-markdown h3 { margin: 24px 0 10px; color: #faf7ff; font-size: 24px; }
.question-markdown p, .question-markdown li { color: #ddd8e5; font-size: 19px; line-height: 1.48; }
.question-markdown ol, .question-markdown ul { padding-left: 24px; }
code { border-radius: 5px; padding: 2px 6px; color: #f1eef8; background: #55515d; }
.question-markdown pre, #answerBlock { margin-top: 10px; padding: 14px; border-radius: 8px; white-space: pre-wrap; color: #e7e2ef; background: #3b3942; overflow: auto; }
details { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
summary { cursor: pointer; font-weight: 800; color: #f3edf9; }

.split-handle { position: relative; z-index: 3; cursor: col-resize; background: #27262d; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.split-handle::before { content: ""; position: absolute; top: 50%; left: 50%; width: 3px; height: 54px; transform: translate(-50%, -50%); border-radius: 999px; background: #777281; box-shadow: -5px 0 0 #4d4a55, 5px 0 0 #4d4a55; }
body.is-resizing { cursor: col-resize; user-select: none; }

.editor-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--editor); }
.editor-head { min-height: 48px; display: flex; justify-content: space-between; align-items: center; padding: 0 14px; background: var(--editor-dark); border-bottom: 1px solid #46444d; }
.editor-title { display: flex; gap: 10px; align-items: center; min-width: 0; }
#fileName { color: #e7e2ee; font-weight: 800; }
#runtimeBadge { border: 1px solid #5b5865; border-radius: 999px; padding: 3px 8px; color: #cbd5e1; background: #35333c; font-size: 12px; }
.question-passed #runtimeBadge { border-color: rgba(134,239,172,.45); color: #86efac; background: #052e1a; }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.editor-actions button { border: 0; border-radius: 6px; padding: 8px 12px; color: white; background: #4f46e5; font-weight: 800; }
.editor-actions .dark { border: 1px solid #3d3b44; background: #25242a; }
#executeBtn { color: #111827; background: var(--yellow); }
#runBtn { background: #6d28d9; }
button.is-running::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -1px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.flow-steps { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: #45434d; }
.flow-steps span { padding: 9px 10px; color: #cfc9da; background: var(--editor-dark); font-size: 12px; font-weight: 800; text-align: center; }
.python-shell-label { padding: 8px 14px; color: var(--yellow); background: var(--editor-dark); border-bottom: 1px solid #46444d; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
#codeEditor { flex: 1 1 auto; min-height: 240px; width: 100%; resize: none; border: 0; outline: none; padding: 18px; color: #d8d4df; background: var(--editor); caret-color: var(--yellow); font: 17px/1.65 "SFMono-Regular", Consolas, monospace; tab-size: 4; }
#codeEditor:focus { box-shadow: inset 0 0 0 2px rgba(246,196,83,.25); }
.editor-status { display: flex; justify-content: space-between; gap: 12px; padding: 7px 14px; color: #cfc9da; background: var(--editor-dark); border-top: 1px solid #46444d; font-size: 12px; }
.terminal-head { height: 34px; display: flex; justify-content: space-between; align-items: center; padding: 0 14px; color: #cfc9da; background: var(--editor-dark); border-top: 1px solid #46444d; font-size: 13px; font-weight: 800; }
.terminal-clear { border: 1px solid #334155; border-radius: 6px; padding: 5px 9px; color: #cbd5e1; background: #111827; font-size: 12px; }
.result { min-height: 118px; max-height: 42vh; resize: vertical; overflow: auto; padding: 14px 16px; white-space: pre-wrap; color: #d8d4df; background: #17171a; font: 13px/1.5 "SFMono-Regular", Consolas, monospace; }
.result.idle { color: #a9a3b5; }
.result.ok { color: #b7f7ce; background: #0b2d1d; }
.result.fail { color: #fecdd3; background: #3c1117; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 340px; transform: translateY(18px); opacity: 0; pointer-events: none; border: 1px solid rgba(134,239,172,.4); border-radius: 8px; padding: 12px 14px; color: #dcfce7; background: #052e1a; box-shadow: 0 18px 45px rgba(0,0,0,.28); transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

body.focus-mode { grid-template-columns: 0 minmax(0,1fr); }
body.focus-mode .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; }

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0,1fr); overflow: auto; height: auto; }
  .ed-header { grid-template-columns: 70px 1fr; height: auto; min-height: 64px; }
  .monash-brand, .ed-header-tools { display: none; }
  .course-title { font-size: 18px; }
  .sidebar { grid-row: 2; max-height: 360px; }
  .workspace { grid-row: 3; }
  .content { height: auto; }
  .practice-view { grid-template-columns: 1fr; }
  .split-handle { display: none; }
  .flow-steps { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
