:root {
  --orange: #fd4a10;
  --orange-dark: #d83a06;
  --ink: #151515;
  --muted: #6e6e6e;
  --line: #e9e9e9;
  --paper: #ffffff;
  --soft: #f7f7f5;
  --green: #1e9d68;
  --red: #df3f35;
  --editor: #111310;
  --editor-2: #191b18;
  --editor-line: #2a2d28;
  --shadow: 0 18px 55px rgba(25, 25, 25, .08);
  font-family: Alexandria, "Trebuchet MS", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(20,20,20,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,20,20,.035) 1px, transparent 1px);
  background-size: 62px 62px;
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 88px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 30px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 16px; text-decoration: none; color: var(--ink); width: fit-content; }
.brand img { width: 105px; height: auto; display: block; }
.brand-divider { width: 1px; height: 35px; background: #dadada; }
.product-name { font-size: 15px; letter-spacing: .12em; font-weight: 600; white-space: nowrap; }
.product-name b { color: var(--orange); }

.topbar-center { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(30,157,104,.1); }

.course-progress { justify-self: end; min-width: 170px; }
.course-progress > span { display: block; text-align: right; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.progress-track { height: 5px; border-radius: 20px; background: #ededed; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--orange); transition: width .35s ease; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 88px); }
.task-rail { border-right: 1px solid var(--line); background: rgba(255,255,255,.92); padding: 28px 18px; position: sticky; top: 88px; height: calc(100vh - 88px); display: flex; flex-direction: column; }
.rail-heading { padding: 0 10px 22px; }
.eyebrow { display: block; color: var(--orange); font-size: 10px; line-height: 1.3; font-weight: 800; letter-spacing: .15em; }
.rail-heading h1 { font-size: 21px; letter-spacing: -.04em; margin: 7px 0 6px; }
.rail-heading p { color: var(--muted); font-size: 12px; margin: 0; }

.task-list { display: grid; gap: 8px; }
.task-link { width: 100%; display: grid; grid-template-columns: 34px minmax(0,1fr) 20px; gap: 8px; align-items: center; border: 1px solid transparent; border-radius: 14px; background: transparent; text-align: left; padding: 11px 10px; color: #5f5f5f; transition: .2s ease; }
.task-link:hover { background: #f7f7f7; color: var(--ink); }
.task-link.active { background: var(--ink); color: #fff; box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.task-link .num { font-size: 11px; font-weight: 800; color: #9d9d9d; }
.task-link.active .num { color: #ff8b66; }
.task-link .label { font-size: 12px; font-weight: 700; line-height: 1.3; }
.task-link .state { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #cfcfcf; display: grid; place-items: center; font-size: 10px; }
.task-link.done .state { border-color: var(--green); background: var(--green); color: white; }
.task-link.active .state { border-color: #666; }

.shortcut-note { margin-top: auto; padding: 16px 10px 4px; color: #a0a0a0; font-size: 11px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.shortcut-note kbd { min-width: 25px; padding: 4px 6px; border: 1px solid #dedede; border-radius: 6px; background: #fafafa; color: #555; text-align: center; box-shadow: 0 2px 0 #ddd; }
.shortcut-note small { width: 100%; margin-top: 5px; }

.workspace { min-width: 0; display: grid; grid-template-columns: minmax(360px, .85fr) minmax(520px, 1.35fr); gap: 18px; padding: 18px; }
.problem-pane, .code-pane { min-width: 0; }
.problem-pane { background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.problem-scroll { height: calc(100vh - 125px); overflow: auto; padding: 38px 38px 50px; }
.problem-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.task-number { color: var(--orange); font-weight: 800; font-size: 14px; }
.level-pill { border: 1px solid #ddd; border-radius: 999px; font-size: 10px; font-weight: 700; padding: 5px 10px; background: var(--soft); }
.problem-pane h2 { margin: 0; font-size: clamp(28px, 3vw, 44px); line-height: 1.08; letter-spacing: -.055em; }
.task-lead { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 18px 0 32px; }
.section-block { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 24px; }
.section-block h3 { margin: 0 0 15px; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
.step-list { margin: 0; padding-left: 22px; display: grid; gap: 11px; color: #444; font-size: 13px; line-height: 1.65; }
.step-list li::marker { color: var(--orange); font-weight: 800; }
.requirement-list { display: flex; flex-wrap: wrap; gap: 8px; }
.requirement-chip { border: 1px solid #dfdfdf; background: #fafafa; padding: 8px 11px; border-radius: 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.example-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.example-grid > div { background: #f5f5f3; border: 1px solid #e7e7e4; border-radius: 12px; padding: 12px; min-width: 0; }
.example-grid span { color: #909090; display: block; text-transform: uppercase; font-size: 9px; font-weight: 800; letter-spacing: .09em; margin-bottom: 8px; }
.example-grid code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; color: #222; font-size: 12px; line-height: 1.5; }
.security-note { margin-top: 28px; padding: 14px; border-radius: 13px; display: flex; gap: 10px; align-items: flex-start; background: #f1faf6; color: #34725a; font-size: 11px; line-height: 1.5; }
.security-note p { margin: 0; }
.security-icon { width: 19px; height: 19px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--green); font-size: 10px; }

.code-pane { display: grid; grid-template-rows: minmax(390px, 1.05fr) minmax(230px, .75fr); gap: 14px; height: calc(100vh - 125px); }
.editor-card, .results-card { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.editor-card { display: grid; grid-template-rows: 56px minmax(0,1fr) 30px; background: var(--editor); border: 1px solid #252824; }
.editor-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 0 13px 0 18px; color: #ddd; border-bottom: 1px solid var(--editor-line); background: #171916; }
.file-tab { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 700; }
.bash-mark { color: var(--orange); margin-right: 7px; }
.editor-actions { display: flex; gap: 8px; }
.ghost-button, .run-button { border: 0; border-radius: 999px; height: 34px; padding: 0 15px; font-size: 11px; font-weight: 800; }
.ghost-button { background: #292c27; color: #b8bcb4; }
.ghost-button:hover { color: #fff; background: #333730; }
.run-button { display: flex; align-items: center; gap: 7px; color: #fff; background: var(--orange); min-width: 112px; justify-content: center; box-shadow: 0 7px 18px rgba(253,74,16,.22); }
.run-button:hover { background: #ff5a24; transform: translateY(-1px); }
.run-button:disabled { opacity: .65; cursor: wait; transform: none; }
.play { font-size: 9px; }
.editor-wrap { min-height: 0; position: relative; display: grid; grid-template-columns: 53px minmax(0, 1fr); }
.line-numbers { margin: 0; padding: 19px 14px 40px 0; text-align: right; color: #5e625b; background: #151714; border-right: 1px solid #262925; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; user-select: none; overflow: hidden; }
#codeEditor { width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 19px 22px 40px; background: var(--editor); color: #edf1e9; caret-color: var(--orange); font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; white-space: pre; overflow: auto; }
#codeEditor::selection { background: rgba(253,74,16,.32); }
.editor-status { display: flex; justify-content: flex-end; gap: 18px; align-items: center; padding: 0 16px; border-top: 1px solid var(--editor-line); background: #171916; color: #6f746a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

.results-card { background: rgba(255,255,255,.97); border: 1px solid var(--line); overflow: auto; }
.results-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 22px 24px 18px; position: sticky; top: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); z-index: 2; border-bottom: 1px solid var(--line); }
.results-head h3 { margin: 5px 0 4px; font-size: 16px; letter-spacing: -.02em; }
.results-head p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; max-width: 560px; }
.score-ring { --ring-color: #bcbcbc; width: 68px; height: 68px; border-radius: 50%; flex: 0 0 auto; display: grid; place-content: center; grid-auto-flow: column; align-items: baseline; color: var(--ink); background: radial-gradient(circle 26px at center, #fff 97%, transparent 100%), conic-gradient(var(--ring-color) calc(var(--score) * 1%), #ececea 0); }
.score-ring strong { font-size: 19px; }
.score-ring span { font-size: 9px; font-weight: 800; }
.results-card.success .score-ring { --ring-color: var(--green); }
.results-card.partial .score-ring { --ring-color: var(--orange); }
.results-card.failure .score-ring { --ring-color: var(--red); }
.result-list { display: grid; padding: 8px 24px 22px; }
.result-row { display: grid; grid-template-columns: 24px minmax(0,1fr); gap: 11px; padding: 12px 0; border-bottom: 1px solid #efefed; }
.result-row:last-child { border-bottom: 0; }
.result-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 900; }
.result-row.pass .result-icon { background: #e9f8f1; color: var(--green); }
.result-row.fail .result-icon { background: #fff0ee; color: var(--red); }
.result-row strong { display: block; font-size: 11px; margin: 2px 0 4px; }
.result-row p { margin: 0; color: #737373; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.result-row.fail p { color: #9c3731; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 360px; padding: 13px 17px; border-radius: 12px; color: white; background: #222; font-size: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.2); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

@media (max-width: 1050px) {
  .topbar { grid-template-columns: 1fr 1fr; }
  .topbar-center { display: none; }
  .app-shell { grid-template-columns: 215px minmax(0,1fr); }
  .workspace { grid-template-columns: 1fr; }
  .problem-scroll { height: auto; max-height: none; }
  .code-pane { height: auto; grid-template-rows: 520px minmax(260px, auto); }
  .task-rail { height: calc(100vh - 88px); }
}

@media (max-width: 720px) {
  .topbar { height: 70px; padding: 0 15px; gap: 12px; }
  .brand img { width: 76px; }
  .brand-divider, .product-name { display: none; }
  .course-progress { min-width: 125px; }
  .app-shell { display: block; }
  .task-rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 15px; }
  .rail-heading, .shortcut-note { display: none; }
  .task-list { display: flex; overflow-x: auto; gap: 7px; padding-bottom: 3px; }
  .task-link { min-width: 66px; width: auto; display: flex; justify-content: center; padding: 9px 12px; }
  .task-link .label { display: none; }
  .workspace { padding: 10px; gap: 10px; }
  .problem-pane, .editor-card, .results-card { border-radius: 16px; }
  .problem-scroll { padding: 26px 21px 35px; }
  .problem-pane h2 { font-size: 31px; }
  .example-grid { grid-template-columns: 1fr; }
  .code-pane { grid-template-rows: 480px minmax(280px, auto); }
  .ghost-button { display: none; }
  .results-head { padding: 18px; }
  .result-list { padding: 7px 18px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
