:root {
  --ink:    #1a1a1a;
  --muted:  #767676;
  --line:   #e2e2e2;
  --bg:     #ffffff;
  --panel:  #fafafa;
  --accent: #2f6fdb;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; color: var(--ink); text-decoration: none; }
nav { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
nav .who { color: var(--muted); }

a { color: var(--accent); }
a:hover { text-decoration: underline; }

main { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.narrow { max-width: 620px; }
.narrow.wide { max-width: 860px; }

h1 { font-size: 1.5rem; font-weight: 600; margin: 0 0 1rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 2rem 0 0.75rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.step-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.note {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px; padding: 0.6rem 0.85rem; font-size: 0.9rem;
}
.flash {
  background: var(--panel); border-inline-start: 3px solid var(--accent);
  padding: 0.6rem 0.85rem; font-size: 0.9rem; margin-bottom: 1.5rem;
}

/* two-column exercise view */
.layout { display: grid; grid-template-columns: 200px 1fr; gap: 3rem; align-items: start; }
aside h2 { margin-top: 0; font-size: 0.8rem; text-transform: uppercase;
           letter-spacing: 0.06em; color: var(--muted); }
.steps { margin: 0; padding-inline-start: 1.25rem; font-size: 0.9rem; }
.steps li { margin-bottom: 0.4rem; }
.steps .current { font-weight: 600; }
.steps .done a { color: var(--muted); text-decoration: none; }
.steps .done a:hover { color: var(--accent); }

.instructions { white-space: pre-wrap; }

pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.9rem 1rem; overflow-x: auto; font-size: 0.875rem; line-height: 1.5;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* screenshots */
.shots { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.shots figure { margin: 0; max-width: 100%; }
.shots img {
  /* Cap the height so a tall screenshot can't push the page down; the full
     image is one click away. */
  max-width: 100%; max-height: 55vh; display: block;
  border: 1px solid var(--line); border-radius: 4px; background: var(--panel);
}
.hint { font-size: 0.85rem; margin-top: -0.25rem; }
.shots figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }

/* forms */
form { margin-bottom: 1.5rem; }
label { display: block; font-size: 0.9rem; margin: 1rem 0 0.35rem; }
input[type=text], input[type=password], input:not([type]), textarea, input[type=file] {
  width: 100%; padding: 0.55rem 0.7rem; font-size: 0.95rem; font-family: inherit;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px;
}
textarea { resize: vertical; }
textarea, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
                  font-size: 0.875rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

button {
  margin-top: 1rem; padding: 0.55rem 1.1rem; font-size: 0.95rem; font-family: inherit;
  color: #fff; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 4px; cursor: pointer;
}
button:hover { filter: brightness(0.93); }
button.link {
  margin: 0; padding: 0.1rem 0.3rem; background: none; border: none;
  color: var(--accent); font-size: 0.875rem;
}
button.link.danger { color: var(--danger); }
button.link:disabled { color: #cfcfcf; cursor: default; }
button.link:hover:not(:disabled) { text-decoration: underline; filter: none; }
form.inline { display: inline; margin: 0; }
.finish { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 0.5rem;
          margin-bottom: 0; }
/* Sticks to the bottom of the window while the exercise is on screen, so the
   button is reachable however tall the screenshot is. */
.finish-bar {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 0.75rem 0 1rem;
}
.finish-bar button { margin-top: 0; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { text-align: start; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase;
     letter-spacing: 0.05em; color: var(--muted); }
.nowrap { white-space: nowrap; }
.grid .num { text-align: center; width: 2.2rem; }
.tick { color: var(--accent); }
.scroll { overflow-x: auto; }
.legend { font-size: 0.85rem; color: var(--muted); margin-top: 1.5rem; padding-inline-start: 1.25rem; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; }
  aside { order: 2; border-top: 1px solid var(--line); padding-top: 1rem; }
}


/* ---- direction handling -------------------------------------------------
   Python is written left to right even on a Hebrew page, so code keeps its
   own direction. Prose uses `plaintext`, which picks a direction per line
   from its first strong character -- so an English exercise title reads
   correctly inside the Hebrew interface, and vice versa. */
pre, code, .mono, textarea.mono, input[type=file] {
  direction: ltr;
  text-align: left;
}
.instructions, h1, .steps li, figcaption, .legend li, .who {
  unicode-bidi: plaintext;
}
nav .lang {
  padding-inline-start: 1rem;
  border-inline-start: 1px solid var(--line);
}

/* checkbox rows read as one line, not a stacked label */
label.check {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 1.25rem 0 0.25rem; cursor: pointer;
}
label.check input[type=checkbox] { width: auto; margin: 0; accent-color: var(--accent); }
label.check + .hint { margin-top: 0; }


/* the intro page between signing in and the first exercise */
.intro { padding-top: 2rem; }
.intro p { max-width: 46ch; }
a.button {
  display: inline-block; margin-top: 1rem;
  padding: 0.55rem 1.1rem; border-radius: 4px;
  color: #fff; background: var(--accent); border: 1px solid var(--accent);
  text-decoration: none; font-size: 0.95rem;
}
a.button:hover { filter: brightness(0.93); text-decoration: none; }

/* timelines */
.tag {
  display: inline-block; margin-inline-start: 0.5rem;
  padding: 0.05rem 0.4rem; border-radius: 3px;
  font-size: 0.72rem; letter-spacing: 0.03em;
  color: var(--accent); background: var(--panel); border: 1px solid var(--line);
}
.small { font-size: 0.78rem; margin-inline-start: 0.4rem; }
tr.elsewhere td { opacity: 0.72; }
.grid td.nowrap .link { margin-inline-end: 0.35rem; }

/* a student's written answer, in the teacher's submissions view */
.answer {
  margin: 0 0 1rem; padding: 0.7rem 0.9rem;
  border-inline-start: 3px solid var(--line); background: var(--panel);
  white-space: pre-wrap; unicode-bidi: plaintext;
}
.small-label { font-size: 0.78rem; text-transform: uppercase;
               letter-spacing: 0.05em; margin-bottom: 0.3rem; }

/* multiple-choice options */
.choices { list-style: none; margin: 0 0 1rem; padding: 0; }
.choices li { margin-bottom: 0.45rem; }
.choices label { display: flex; align-items: flex-start; gap: 0.6rem;
                 margin: 0; cursor: pointer; }
/* Each option decides its own direction from its first real letter. Without
   this, an option like  my_name = "Guido"  inherits the Hebrew page's RTL
   paragraph direction, and its trailing quote -- a neutral character -- is
   reordered to the far left, so it reads  "my_name = "Guido . */
.choices label > span { unicode-bidi: plaintext; text-align: start; }
.choices input { width: auto; margin: 0.3rem 0 0; accent-color: var(--accent); flex: none; }
.choices.picked { padding-inline-start: 1.1rem; list-style: disc; }
.choices.picked li { unicode-bidi: plaintext; }

/* a tick in the progress grid is also the "do this one again" control */
button.link.tick { color: var(--accent); font-size: 1rem; padding: 0 0.15rem; }
button.link.tick:hover { background: var(--panel); border-radius: 3px; }

/* the two class-move actions stack rather than crowd one line */
td > form.move-action { margin: 0; }
td > form + form { margin-top: 0.2rem; }

/* sorting questions */
.sortables { list-style: none; margin: 0 0 1rem; padding: 0; }
.sortables li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.8rem; flex-wrap: wrap;
  padding: 0.4rem 0; border-bottom: 1px solid var(--line);
}
.sortables .thing { unicode-bidi: plaintext; }
.sortables .groups { display: flex; flex-wrap: wrap; gap: 0.4rem; }
/* the radio itself stays in the page for keyboard and screen readers, but the
   label is what you see and press */
.groups input {
  position: absolute; opacity: 0; width: 1px; height: 1px;
  margin: 0; pointer-events: none;
}
.groups label {
  display: inline-block; margin: 0; padding: 0.3rem 0.8rem;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.9rem; line-height: 1.4; cursor: pointer;
  unicode-bidi: plaintext; user-select: none;
}
.groups label:hover { border-color: var(--accent); color: var(--accent); }
.groups input:checked + label {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.groups input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
select {
  padding: 0.4rem 0.5rem; font-size: 0.9rem; font-family: inherit;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 4px;
}
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* automatic path moves, on a student's page */
section.auto { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.auto-rules { list-style: none; margin: 0 0 1rem; padding: 0; }
.auto-rules li { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
                 padding: 0.35rem 0; }
.auto-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0; }
.auto-form select { width: auto; }
.auto-form button { margin-top: 0; }

/* students hidden from the progress page, tucked away at the bottom */
.hidden-students { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.hidden-students summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.hidden-students ul { list-style: none; margin: 0.8rem 0 0; padding: 0; }
.hidden-students li { display: flex; align-items: center; gap: 0.7rem; padding: 0.3rem 0; }
.small-note { font-size: 0.85rem; margin: 0.6rem 0 0; }

/* bulk hiding on the progress page */
.bulk-bar { margin: 0 0 1rem; }
.bulk-bar button { margin-top: 0; }
.grid th.pick, .grid td.pick { width: 1.6rem; padding-inline-end: 0; }
.grid td.pick input { width: auto; margin: 0; accent-color: var(--accent); }

/* course number on a student's page */
.course-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.course-form label { margin: 0; }
.course-form input { width: 5rem; }
.course-form button { margin-top: 0; }

/* a multiple-choice option shown as a code snippet */
code.opt-code {
  display: block; white-space: pre; direction: ltr; text-align: left; unicode-bidi: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.45rem 0.7rem; overflow-x: auto;
}
.choices label > span.has-code { flex: 1; min-width: 0; }
.choices.picked li code.opt-code { margin: 0.2rem 0; }
textarea.opt-code-input { min-height: 3.2rem; }

/* code options: one card per option, stacked, the whole card is the choice */
.choices li.code-choice { margin-bottom: 0.6rem; }
.choices label.code-card {
  display: block; position: relative; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); overflow: hidden;
}
.choices label.code-card input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.choices label.code-card code.opt-code {
  border: 0; border-radius: 0; background: transparent; margin: 0;
  padding: 0.7rem 2.4rem 0.7rem 0.9rem;
}
.choices label.code-card:hover { border-color: var(--accent); }
.choices label.code-card input:checked + code.opt-code {
  background: #eef3fc; box-shadow: inset 0 0 0 2px var(--accent);
}
.choices label.code-card input:checked + code.opt-code::after {
  content: "\2713"; position: absolute; top: 0.45rem; right: 0.7rem;
  color: var(--accent); font-weight: 600;
}
.choices label.code-card input:focus-visible + code.opt-code { outline: 2px solid var(--accent); outline-offset: -2px; }
textarea.opt-text { resize: vertical; min-height: 2.3rem; }

/* code cards side by side, equal height; more options wrap to a new row,
   and a narrow screen falls back to one column */
.choices.code-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem; align-items: stretch;
}
.choices.code-grid li { margin: 0; display: flex; }
.choices.code-grid li > label { flex: 1; }
.choices.code-grid label.code-card { display: flex; flex-direction: column; }
.choices.code-grid label.code-card code.opt-code { flex: 1; }

/* answer rules in the exercise editor */
.auto-form input.route-kw { width: auto; min-width: 12rem; unicode-bidi: plaintext; }
.route-words { unicode-bidi: plaintext; font-weight: 600; }

/* the continuous challenge: a code editor that keeps indentation visible */
textarea.challenge-editor {
  white-space: pre; overflow-x: auto; overflow-wrap: normal; tab-size: 4;
  font-size: 0.9rem; line-height: 1.6; min-height: 20rem;
}
.challenge .instructions { margin-bottom: 1rem; }
details.challenge-orig { margin-top: 1.5rem; }
details.challenge-orig summary, section.challenge-work summary {
  cursor: pointer; color: var(--muted); font-size: 0.9rem;
}
section.challenge-work { padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line); }

/* the landing photo, as the teacher sees it */
img.landing-thumb { display: block; width: 128px; height: 128px; border-radius: 50%;
                    object-fit: cover; margin: 0 0 0.6rem; border: 1px solid var(--line); }
