* { box-sizing: border-box; }

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

body {
  background: var(--canvas);
  color: var(--text-main);
  font-family: var(--font-arabic);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input { font: inherit; }

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.nav-brand {
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.workspace-wrapper {
  max-width: 1560px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  align-items: start;
}

.workspace-grid > .guide-pane,
.workspace-grid > .ide-pane {
  min-width: 0;
}

.guide-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
}

.guide-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.guide-lesson-title {
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.step-block {
  transition: background-color 180ms ease, box-shadow 180ms ease;
}

.step-block + .step-block {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.step-block[hidden],
.lesson-final-content[hidden] {
  display: none !important;
}

.step-content p,
.lesson-final-content p {
  margin: 0 0 14px;
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.step-content p:last-child,
.lesson-final-content p:last-child {
  margin-bottom: 0;
}

.lesson-list,
.step-content ol,
.step-content ul {
  margin: 0 0 16px;
  padding-inline-start: 24px;
}

.lesson-list li,
.step-content li {
  margin: 5px 0;
  padding-inline-start: 3px;
}

code:not(pre code) {
  display: inline-block;
  max-width: 100%;
  padding: 1.5px 7px;
  margin: 0 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-subtle);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  direction: ltr;
  unicode-bidi: isolate;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.cb-term {
  display: inline;
}

.cb-term-en,
.cb-en-phrase {
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--font-mono);
}

.cb-term-en {
  margin-inline-start: 0.18em;
}


.step-block.is-complete {
  opacity: 0.94;
}

.step-feedback {
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.step-feedback.is-success {
  border-color: color-mix(in srgb, var(--success-text) 34%, var(--border));
  color: var(--success-text);
}

.step-feedback.is-error {
  border-color: color-mix(in srgb, var(--error-text) 34%, var(--border));
  color: var(--error-text);
}

.lesson-final-content {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.ide-pane {
  min-width: 0;
  position: sticky;
  top: 76px;
}

.runtime-label {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.terminal-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--terminal-bg);
  border: 1px solid var(--border-code);
  border-radius: 8px;
  direction: ltr;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
  padding: 8px 14px;
  background: var(--terminal-header);
  border-bottom: 1px solid var(--border-code);
}

.terminal-title {
  color: var(--terminal-muted);
  font-family: var(--font-arabic);
  font-size: 13px;
  font-weight: 500;
}

.btn-clear-terminal {
  appearance: none;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border-code);
  border-radius: 4px;
  background: transparent;
  color: var(--terminal-soft);
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 12px;
  font-weight: 500;
}

.terminal-body {
  height: 260px;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--terminal-bg);
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  direction: ltr;
  text-align: left;
  cursor: text;
}

.terminal-history {
  min-height: 24px;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-prompt-line {
  display: flex;
  align-items: center;
  margin-top: 2px;
  direction: ltr;
  text-align: left;
}

.prompt-prefix {
  flex: 0 0 auto;
  margin-right: 8px;
  color: var(--terminal-success);
  user-select: none;
}

.shell-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--terminal-input);
  caret-color: var(--terminal-caret);
  font-family: var(--font-mono);
  font-size: 13px;
  direction: ltr;
  text-align: left;
}

.shell-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-shell-tool,
.btn-shell-enter {
  appearance: none;
  display: none;
  flex: 0 0 auto;
  min-height: 40px;
  margin-left: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border-code);
  border-radius: 6px;
  background: var(--terminal-header);
  color: var(--terminal-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.btn-shell-tool {
  min-width: 44px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
}

.btn-shell-tool svg {
  width: 14px;
  height: 14px;
}

.btn-shell-enter {
  min-width: 58px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.btn-clear-terminal:disabled,
.btn-shell-tool:disabled,
.btn-shell-enter:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.runtime-status {
  padding: 10px 14px;
  border-top: 1px solid var(--border-code);
  background: var(--terminal-footer);
  color: var(--terminal-soft);
  font-family: var(--font-arabic);
  font-size: 12px;
  direction: rtl;
}

@media (max-width: 1040px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .ide-pane {
    position: static;
  }
}

@media (max-width: 640px) {
  .top-nav { padding-inline: 12px; }

  .workspace-wrapper {
    padding: 12px 10px 32px;
  }

  .workspace-grid { gap: 12px; }

  .guide-pane {
    padding: 20px 16px;
  }

  .guide-breadcrumbs { font-size: 12px; }

  .guide-lesson-title {
    margin-bottom: 20px;
    font-size: 21px;
  }

  .terminal-header { padding-inline: 10px; }

  .btn-clear-terminal {
    min-height: 40px;
    padding-inline: 10px;
  }

  .btn-shell-tool,
  .btn-shell-enter {
    display: inline-flex;
  }

  .terminal-body {
    height: 230px;
    padding: 12px;
    font-size: 13px;
  }

  .shell-input {
    font-size: 16px;
    line-height: 40px;
  }
}

/* Python course session navigation */
.lesson-course-nav {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-lesson-nav {
  min-width: 118px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-arabic);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
}

.btn-lesson-nav:hover {
  background: var(--surface-subtle);
  border-color: var(--border-dark);
}

.btn-lesson-nav.is-disabled {
  color: var(--text-soft);
  background: var(--surface-subtle);
  cursor: default;
  opacity: 0.66;
}

@media (max-width: 640px) {
  .lesson-course-nav {
    gap: 8px;
  }

  .btn-lesson-nav {
    min-width: 0;
    flex: 1 1 0;
    min-height: 44px;
    padding-inline: 10px;
  }
}

/* Lesson SEO navigation links */
.guide-breadcrumbs a {
  color: inherit;
  text-decoration: none;
}

.guide-breadcrumbs a:hover,
.guide-breadcrumbs a:focus-visible {
  color: var(--text-main);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-breadcrumbs [aria-current="page"] {
  color: var(--text-main);
}

.lesson-course-nav.has-next-only {
  justify-content: flex-end;
}

.lesson-course-nav.has-previous-only {
  justify-content: flex-start;
}

/* Shared code editor card */
.editor-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  background: var(--terminal-bg);
  border: 1px solid var(--border-code);
  border-radius: 8px;
  direction: ltr;
}

.editor-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
  padding: 8px 14px;
  background: var(--terminal-header);
  border-bottom: 1px solid var(--border-code);
}

.editor-tabs {
  display: flex;
  align-items: center;
}

.editor-tab {
  padding: 4px 12px;
  border: 1px solid var(--border-code);
  border-radius: 4px;
  background: var(--terminal-bg);
  color: var(--terminal-soft);
  font-family: var(--font-mono);
  font-size: 12px;
}

.btn-reset-code {
  appearance: none;
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border-code);
  border-radius: 4px;
  background: transparent;
  color: var(--terminal-soft);
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 12px;
  font-weight: 500;
}

.btn-reset-code:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.editor-body {
  display: flex;
  min-height: 200px;
}

.line-numbers {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 12px 8px;
  background: var(--terminal-header);
  color: var(--terminal-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
  user-select: none;
}

.code-editor-container {
  position: relative;
  flex: 1;
  min-width: 0;
}

.code-highlight-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  overflow: hidden;
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
}

.code-highlight-layer code {
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-area {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 200px;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: transparent;
  caret-color: var(--terminal-caret);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-area::placeholder {
  color: var(--terminal-muted);
}

.code-area:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.editor-bottom-bar {
  display: flex;
  justify-content: flex-start;
  padding: 10px 14px;
  border-top: 1px solid var(--border-code);
  background: var(--terminal-header);
}

.btn-run {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 18px;
  border: 1px solid var(--border-code);
  border-radius: 6px;
  background: var(--terminal-footer);
  color: var(--terminal-text);
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 13px;
  font-weight: 600;
}

.btn-run:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Copy-to-editor affordance on source-backed code blocks */
.guide-code-toolbar {
  display: flex;
  justify-content: flex-start;
  direction: rtl;
}

.btn-copy-code {
  appearance: none;
  min-height: 28px;
  margin-bottom: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 11px;
  font-weight: 500;
}

.btn-copy-code:hover {
  color: var(--text-main);
  border-color: var(--border-dark);
}

.step-content pre,
.lesson-final-content pre {
  position: relative;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-code);
  border-radius: 6px;
  background: var(--terminal-bg);
  direction: ltr;
  overflow-x: auto;
}

.step-content pre code,
.lesson-final-content pre code {
  display: block;
  max-width: none;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--terminal-text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.terminal-prompt-line.is-input-mode .prompt-prefix {
  color: var(--terminal-caret);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

/* Source-backed hints */
.hint-box {
  margin-top: 14px;
}

.hint-list {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.hint-item {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.hint-item[hidden] {
  display: none !important;
}

.hint-toggle {
  appearance: none;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 12px;
  font-weight: 500;
}

.hint-toggle:hover {
  background: var(--surface-subtle);
}

.hint-toggle[hidden] {
  display: none !important;
}

/* Output prediction overlay */
.prediction-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.prediction-title {
  margin-bottom: 10px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
}

.prediction-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prediction-choice {
  appearance: none;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prediction-choice:hover:not(:disabled) {
  border-color: var(--border-dark);
  background: var(--surface-subtle);
}

.prediction-choice:disabled {
  cursor: default;
  opacity: 0.75;
}

.prediction-choice.is-correct {
  border-color: color-mix(in srgb, var(--success-text) 45%, var(--border));
  color: var(--success-text);
}

.prediction-choice.is-wrong {
  border-color: color-mix(in srgb, var(--error-text) 45%, var(--border));
  color: var(--error-text);
  opacity: 0.6;
}

.prediction-note {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.prediction-note[hidden] {
  display: none !important;
}

/* Skippable optional challenges */
.skip-challenge-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.skip-challenge-link:hover {
  color: var(--text-main);
}

.btn-lesson-nav[data-next-gated] {
  display: none;
}

.btn-lesson-nav[data-next-gated]:not([hidden]) {
  display: inline-flex;
}

@media (max-width: 640px) {
  .editor-top-bar,
  .editor-bottom-bar {
    padding-inline: 10px;
  }

  .editor-body {
    min-height: 170px;
  }

  .code-area,
  .code-highlight-layer {
    font-size: 14px;
  }

  .btn-reset-code {
    min-height: 40px;
  }

  .btn-run {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
  }
}

