:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #183153;
  background: #f4f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.page-width {
  width: min(92%, 56rem);
  margin-inline: auto;
}

.site-header {
  padding: 1rem 0;
  background: #173f6b;
}

.header-content,
.account-nav,
.section-heading,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.account-nav {
  color: #ffffff;
}

.header-link {
  color: #ffffff;
  font-weight: 700;
}

.account-nav form {
  margin: 0;
}

.brand {
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.card {
  margin-block: clamp(2rem, 8vw, 5rem);
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid #d8e1eb;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 0.75rem 2rem rgb(24 49 83 / 8%);
}

.card-narrow {
  max-width: 38rem;
  margin-inline: auto;
}

.card-compact {
  margin-block: 1.5rem;
}

.eyebrow {
  margin: 0;
  color: #356b9f;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0.35rem 0 1rem;
  font-size: clamp(2rem, 7vw, 3.5rem);
}

h2,
h3 {
  line-height: 1.25;
}

p {
  max-width: 42rem;
  line-height: 1.65;
}

.button {
  display: inline-block;
  padding: 0.75rem 1rem;
  border: 2px solid #173f6b;
  border-radius: 0.5rem;
  color: #ffffff;
  background: #173f6b;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  background: #0f2c4b;
}

.button-secondary {
  border-color: #ffffff;
  color: #ffffff;
  background: transparent;
}

.button-outline {
  color: #173f6b;
  background: #ffffff;
}

.button-outline:hover,
.button-outline:focus-visible {
  color: #ffffff;
}

.button-danger {
  border-color: #9f1d1d;
  background: #9f1d1d;
}

.button-danger:hover,
.button-danger:focus-visible {
  background: #791616;
}

.button-small {
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
}

.stacked-form {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.form-field {
  display: grid;
  gap: 0.45rem;
}

.form-field label {
  font-weight: 700;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #8395a7;
  border-radius: 0.4rem;
  color: inherit;
  background: #ffffff;
  font: inherit;
}

.form-field input:focus,
.form-field select:focus {
  border-color: #173f6b;
  outline: 3px solid rgb(23 63 107 / 20%);
}

.form-field-checkbox {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.form-field-checkbox input {
  width: auto;
}

.checkbox-list {
  padding: 1rem;
  border: 1px solid #c8d5e3;
  border-radius: 0.5rem;
}

.checkbox-list legend {
  padding-inline: 0.4rem;
  font-weight: 700;
}

.checkbox-list ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.65rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.form-errors,
.errorlist {
  margin: 0;
  color: #9f1d1d;
}

.help-text {
  margin: 0;
  color: #53657a;
  font-size: 0.9rem;
}

.messages {
  margin-top: 1.5rem;
}

.message {
  padding: 0.8rem 1rem;
  border-left: 0.3rem solid #16834d;
  background: #e9f7ef;
}

.code-sample {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  color: #152638;
  background: #eef3f8;
  white-space: pre-wrap;
  word-break: break-word;
}

.page-intro {
  margin-top: clamp(2rem, 7vw, 4rem);
}

.module-list {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 4rem;
}

.module-card {
  margin-block: 0;
}

.module-number {
  margin: 0;
  color: #356b9f;
  font-size: 0.9rem;
  font-weight: 700;
}

.module-heading h2 {
  margin: 0.3rem 0 0.6rem;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
}

.challenge-list {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  margin: 1.5rem 0 0;
  list-style: none;
}

.challenge-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #c8d5e3;
  border-radius: 0.65rem;
  color: inherit;
  text-decoration: none;
}

.challenge-link:hover,
.challenge-link:focus-visible {
  border-color: #173f6b;
  outline: 3px solid rgb(23 63 107 / 15%);
  background: #f7faff;
}

.challenge-main,
.challenge-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.challenge-main {
  align-items: flex-start;
  flex-direction: column;
}

.challenge-main span,
.challenge-meta {
  color: #53657a;
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  color: #244d73;
  background: #e5f0fa;
  font-size: 0.85rem;
  font-weight: 700;
}

.breadcrumb {
  display: flex;
  gap: 0.6rem;
  margin-top: 2rem;
  color: #53657a;
}

.breadcrumb a {
  color: #173f6b;
}

.challenge-detail {
  margin-top: 1rem;
}

.challenge-detail section {
  padding-top: 1.25rem;
  margin-top: 1.75rem;
  border-top: 1px solid #d8e1eb;
}

.challenge-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}

.example-case {
  padding: 1rem;
  border: 1px solid #d8e1eb;
  border-radius: 0.65rem;
  background: #f8fafc;
}

.example-case h3 {
  margin-top: 0;
}

.example-case dl,
.example-case dd {
  margin: 0;
}

.example-case dl {
  display: grid;
  gap: 1rem;
}

.example-case dt {
  font-weight: 700;
}

.example-case pre {
  overflow-x: auto;
  padding: 0.75rem;
  margin: 0.4rem 0 0;
  border-radius: 0.4rem;
  background: #eaf0f6;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint-panel {
  padding: 1rem;
  margin-top: 1.75rem;
  border-left: 0.3rem solid #d49711;
  background: #fff8e6;
}

.hint-panel summary {
  font-weight: 700;
  cursor: pointer;
}

.editor-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.code-editor-fallback {
  width: 100%;
  min-height: 24rem;
  padding: 1rem;
  border: 1px solid #8395a7;
  border-radius: 0.5rem;
  color: #152638;
  background: #ffffff;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  tab-size: 4;
}

.code-editor-fallback:focus {
  border-color: #173f6b;
  outline: 3px solid rgb(23 63 107 / 20%);
}

.CodeMirror {
  height: 24rem;
  border: 1px solid #8395a7;
  border-radius: 0.5rem;
  color: #152638;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
}

.CodeMirror-focused {
  border-color: #173f6b;
  outline: 3px solid rgb(23 63 107 / 20%);
}

.editor-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.draft-status {
  margin: 0;
  color: #53657a;
  font-size: 0.9rem;
}

.stdin-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #8395a7;
  border-radius: 0.5rem;
  color: #152638;
  background: #ffffff;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.stdin-input:focus {
  border-color: #173f6b;
  outline: 3px solid rgb(23 63 107 / 20%);
}

.button-run {
  border-color: #16834d;
  background: #16834d;
}

.button-run:hover,
.button-run:focus-visible {
  background: #10683d;
}

.button-submit {
  border-color: #6d3eb3;
  background: #6d3eb3;
}

.button-submit:hover,
.button-submit:focus-visible {
  background: #532d8d;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.run-panel {
  padding: 1rem;
  margin-top: 1.25rem;
  border: 1px solid #b8c7d8;
  border-radius: 0.65rem;
  background: #f8fafc;
}

.run-panel h3,
.run-panel h4 {
  margin-top: 0;
}

.run-panel h4 {
  margin-bottom: 0.4rem;
}

.run-status {
  font-weight: 700;
}

.submission-panel {
  border-color: #bca7dd;
  background: #fbf9ff;
}

.progress-card {
  padding: 1rem;
  margin-top: 1.25rem;
  border: 1px solid #b8c7d8;
  border-radius: 0.65rem;
  background: #f8fafc;
}

.badge-success {
  color: #0d5f36;
  background: #dff5e8;
}

.badge-warning {
  color: #704d00;
  background: #fff0c2;
}

.badge-assigned {
  color: #56308e;
  background: #eee6fa;
}

.assignment-note {
  color: #56308e !important;
  font-weight: 700;
}

.assignment-panel {
  padding: 1rem;
  margin-top: 1.25rem;
  border-left: 0.3rem solid #6d3eb3;
  background: #f5f0fc;
}

.assignment-panel ul {
  margin-bottom: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
}

.summary-grid > div {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid #d8e1eb;
  border-radius: 0.65rem;
  background: #f8fafc;
}

.summary-grid strong {
  color: #173f6b;
  font-size: 1.5rem;
}

.summary-grid span {
  color: #53657a;
}

.dashboard-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-block: 1.5rem;
}

.assignment-preview {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  list-style: none;
}

.assignment-preview li {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem 1rem;
  border-left: 0.25rem solid #6d3eb3;
  background: #f5f0fc;
}

.assignment-preview span {
  color: #53657a;
  font-size: 0.9rem;
}

.console-output {
  max-height: 20rem;
  overflow: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  color: #eaf3fb;
  background: #142435;
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.console-error {
  color: #ffd9d9;
  background: #351b20;
}

.execution-unavailable {
  margin-top: 1rem;
}

.error-explanation {
  padding: 0.75rem;
  border-left: 0.2rem solid #b83232;
  border-radius: 0.25rem;
  color: #8b2020;
  background: #fff1f1;
  font-size: 0.875rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.error-details summary {
  width: fit-content;
  padding-block: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.error-details summary:focus-visible {
  outline: 3px solid #356b9f;
  outline-offset: 2px;
}

.run-result section {
  margin-top: 1.5rem;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid #d8e1eb;
  text-align: left;
}

th {
  background: #eef3f8;
}

.empty-state {
  padding: 1rem;
  border-radius: 0.5rem;
  background: #eef3f8;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.status-list {
  display: grid;
  gap: 1rem;
  margin: 2rem 0 0;
}

.status-list div {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) 2fr;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e3e9f0;
}

.status-list dt {
  font-weight: 700;
}

.status-list dd {
  margin: 0;
}

.status-dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: #16834d;
}

@media (max-width: 32rem) {
  .header-content,
  .section-heading,
  .button-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-nav {
    align-items: center;
    flex-direction: row;
  }

  .status-list div {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .challenge-link,
  .challenge-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
/* Interactive console: keep the existing workspace and its independent scroll. */
.challenge-page .interactive-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #e0e7ee;
  font-size: 0.8rem;
}
.challenge-page .interactive-mode select { width: auto; max-width: 100%; padding: 0.35rem; }
.challenge-page .workspace-console-body.interactive-console-body { display: flex; flex-direction: column; }
.challenge-page .interactive-console-body .workspace-console-results { width: 100%; box-sizing: border-box; }
.challenge-page .interactive-status-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.challenge-page .interactive-status-row .run-status { margin: 0; }
.challenge-page .interactive-transcript {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 0.85rem/1.6 Consolas, monospace;
  color: #24415d;
  background: #f1f5f9;
  border-radius: 0.5rem;
  padding: 0.65rem;
  margin-block: 0.5rem;
  min-height: 2.5rem;
  max-height: 12rem;
  overflow: auto;
}
.challenge-page .interactive-echo { color: #175a44; border-left: 3px solid #72b89b; padding-left: 0.5rem; margin-block: 0.25rem; }
.challenge-page .interactive-echo-label { font: 0.75rem system-ui, sans-serif; color: #436050; }
.challenge-page .interactive-answer-row { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.challenge-page .interactive-answer-row input { flex: 1; min-width: 0; padding: 0.5rem; }
.challenge-page [data-interactive-answer-form] label { font-size: 0.85rem; font-weight: 600; }
.challenge-page .interactive-transcript:focus-visible { outline: 3px solid #356b9f; }
