/* python.algoprep.com/tester: the look of the AlgoPrep sites (paper, ink and the terracotta accent; Heebo for headings,
   Assistant for text) with the programmer's accent of python.algoprep.com: JetBrains Mono for numbers, labels and
   code, and code always on a dark editor surface. This page is a tool, so it is laid out as a workbench: an app bar,
   homework and question tabs, the code on one side and the test cases on the other.
   Bootstrap is still loaded for its tabs, modals and collapse; its colours are pointed at our tokens below.
   Fonts are own copies in assets/fonts (Open Font License). Light and dark are set on <html data-theme> by theme.js. */
@font-face { font-family: 'Assistant'; font-style: normal; font-weight: 400 800; font-display: swap; src: url("assets/fonts/assistant-hebrew.woff2") format('woff2'); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: 'Assistant'; font-style: normal; font-weight: 400 800; font-display: swap; src: url("assets/fonts/assistant-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Heebo'; font-style: normal; font-weight: 400 700; font-display: swap; src: url("assets/fonts/heebo-hebrew.woff2") format('woff2'); unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: 'Heebo'; font-style: normal; font-weight: 400 700; font-display: swap; src: url("assets/fonts/heebo-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 700; font-display: swap; src: url("assets/fonts/jetbrains-mono-latin.woff2") format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --paper: #faf9f5;
  --paper-deep: #f1ece3;
  --card: #fffcf7;
  --ink: #302b27;
  --muted: #70665c;
  --accent: #a94d31;
  --accent-soft: #f4e5db;
  --on-accent: #fffaf5;
  --line: #ded5c8;
  --ok: #3f7d4e;
  --ok-soft: #e3efe2;
  --bad: #b4233a;
  --bad-soft: #f8e4e5;
  --warn: #9a6a10;
  --warn-soft: #f6ecd4;
  --shadow: 0 1px 2px rgba(48, 43, 39, .04), 0 8px 24px -8px rgba(48, 43, 39, .12);
  --header-bg: rgba(250, 249, 245, .82);

  /* the editor surface: dark in both themes */
  --code-bg: #2a2522;
  --code-bar: #221e1b;
  --code-line: #3d3530;
  --code-ink: #ece4d9;
  --code-muted: #9a8d80;
  --code-accent: #ec9a78;

  --serif: 'Heebo', 'Assistant', system-ui, sans-serif;
  --sans: 'Assistant', 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --radius: 16px;
  --radius-sm: 10px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --bar-h: 60px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --paper: #262320;
  --paper-deep: #302b27;
  --card: #2d2824;
  --ink: #f3ece2;
  --muted: #c2b5a7;
  --accent: #e59c7e;
  --accent-soft: #493129;
  --on-accent: #2a1c15;
  --line: #50453c;
  --ok: #8fc39a;
  --ok-soft: #2c3a2e;
  --bad: #f08a98;
  --bad-soft: #47292e;
  --warn: #e8c57e;
  --warn-soft: #41361f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 10px 30px -10px rgba(0, 0, 0, .5);
  --header-bg: rgba(38, 35, 32, .82);
  --code-bg: #1c1917;
  --code-bar: #171413;
  --code-line: #3a322c;
}

/* Bootstrap's own parts (modals, close buttons, spinners) take our colours. */
:root, :root[data-bs-theme] {
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-body-font-family: var(--sans);
  --bs-border-color: var(--line);
  --bs-border-color-translucent: var(--line);
  --bs-secondary-color: var(--muted);
  --bs-code-color: var(--accent);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 169, 77, 49;
  --bs-link-hover-color: var(--accent);
  --bs-emphasis-color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
code, pre, kbd, textarea, .mono {
  font-family: var(--mono);
  font-variant-ligatures: none !important; /* == must look like two characters */
}
code { font-size: .88em; color: var(--accent); direction: ltr; unicode-bidi: isolate; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--ink); }

/* ─── App bar ─────────────────────────────────────────────────────────────── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.appbar-in {
  max-width: 1440px;
  height: var(--bar-h);
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 32px);
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-accent);
  font: 700 14px/1 var(--mono);
  letter-spacing: -.04em;
  direction: ltr;
}
.brand-text { display: grid; min-width: 0; line-height: 1.2; }
.brand-text strong {
  font: 500 16.5px/1.25 var(--serif);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text small {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The AlgoPrep brand (accounts.algoprep.com/account.js) sits at the top right: before the tool's name in Hebrew,
   at the end of the bar in English. */
[dir='ltr'] .appbar-in > [data-algoprep-brand] { order: 99; }
.appbar-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; flex: none; }

.engine {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font: 500 12px/1.3 var(--mono);
  white-space: nowrap;
}
.engine i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); animation: blink 1.1s ease-in-out infinite; }
.engine[data-state='ready'] i { background: var(--ok); animation: none; }
.engine[data-state='error'] { color: var(--bad); border-color: var(--bad); }
.engine[data-state='error'] i { background: var(--bad); animation: none; }
@keyframes blink { 50% { opacity: .3; } }

.contact { display: flex; align-items: center; gap: 4px; }
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 9px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.contact a:hover { background: var(--paper-deep); color: var(--ink); }
.contact a .bi { font-size: 16px; }
.contact .phone span { font: 500 12.5px/1 var(--mono); direction: ltr; }
.contact .tutoring {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  padding: 0 12px;
  border-radius: 999px;
  margin-inline-end: 4px;
}
.contact .tutoring:hover { border-color: var(--accent); background: var(--accent-soft); }
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--ok);
  animation: ping 2s var(--ease-out) infinite;
}
@keyframes ping { to { transform: scale(2.8); opacity: 0; } }

.tool-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: 600 13.5px/1 var(--sans);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tool-btn:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ─── Page ────────────────────────────────────────────────────────────────── */
.shell {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px clamp(16px, 3vw, 32px) 36px;
  flex: 1;
}

/* How to use */
.howto {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 18px;
}
.howto-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px; padding-inline: 6px 8px; }
.howto-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  text-align: start;
  cursor: pointer;
}
.howto-toggle:hover { background: var(--paper-deep); }
.tutorial-chevron { font-size: 13px; color: var(--muted); transition: transform .25s var(--ease-out); }
.howto-toggle[aria-expanded='false'] .tutorial-chevron { transform: rotate(-90deg); }
[dir='rtl'] .howto-toggle[aria-expanded='false'] .tutorial-chevron { transform: rotate(90deg); }
.howto-file {
  font: 600 11px/1 var(--mono);
  letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 7px;
  border-radius: 6px;
}
.howto-title { font: 500 16px/1.3 var(--serif); }
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 28px;
  padding: 6px 18px 16px;
  border-top: 1px solid var(--line);
  margin-top: 0;
}
.step { display: flex; gap: 12px; padding: 12px 0 4px; }
.step-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--paper-deep);
  color: var(--accent);
  font: 600 12px/1 var(--mono);
}
.step-n.icon { font-size: 15px; }
.step h3 { font: 600 15px/1.35 var(--sans); margin-bottom: 2px; }
.step p { font-size: 14px; line-height: 1.5; color: var(--muted); }
.step p strong, .step p b { color: var(--ink); font-weight: 600; }
.step .ok { color: var(--ok); font-weight: 600; white-space: nowrap; }
.step .bad { color: var(--bad); font-weight: 600; white-space: nowrap; }
.link-btn {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font: 600 14px/1.3 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .15s var(--ease-out);
}
.ui-btn:hover { border-color: var(--accent); }
.ui-btn:active { transform: translateY(1px); }
.ui-btn:disabled { opacity: .75; cursor: progress; }
.ui-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ui-btn.primary:hover { filter: brightness(1.07); }
.ui-btn.quiet { border-color: transparent; background: none; color: var(--muted); }
.ui-btn.quiet:hover { background: var(--paper-deep); color: var(--ink); border-color: transparent; }
.ui-btn.danger { border-color: transparent; background: none; color: var(--muted); }
.ui-btn.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.ui-btn.sm { padding: 5px 9px; font-size: 13px; border-radius: 8px; gap: 6px; }
.ui-btn.run { padding: 10px 18px; font-size: 15px; }
.ui-btn.run .bi { font-size: 17px; margin-inline: -3px -1px; }
.ui-btn.run .spinner-border { display: none; }
.ui-btn.run.is-running .bi { display: none; }
.ui-btn.run.is-running .spinner-border { display: inline-block; }
.run-q {
  font: 600 12px/1 var(--mono);
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .18);
}
:root[data-theme='dark'] .run-q { background: rgba(0, 0, 0, .14); }
.spinner-border-sm { --bs-spinner-width: .9rem; --bs-spinner-height: .9rem; --bs-spinner-border-width: .15em; }

/* ─── Tabs: homework (folders) and questions ──────────────────────────────── */
.hw-tabs, .q-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.q-tabs { gap: 6px; margin-top: 12px; }
.tabchip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted);
  transition: border-color .15s, background .15s, color .15s;
}
.tabchip:hover { border-color: var(--accent); color: var(--ink); }
.tabchip .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: 600 13.5px/1.3 var(--mono);
  cursor: pointer;
  transition: none;
}
.tabchip .nav-link .bi { font-size: 15px; }
.tabchip:has(.nav-link.active) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.tabchip:has(.nav-link.active) .nav-link { padding-inline-end: 6px; }
.chip-tool {
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: inherit;
  font-size: 12px;
  opacity: .7;
  cursor: pointer;
}
.chip-tool:hover { opacity: 1; background: rgba(169, 77, 49, .14); }
.chip-tool.chip-close:hover { background: var(--bad-soft); color: var(--bad); }
.tabchip:has(.nav-link.active) .chip-tool { display: inline-grid; }
.tabchip .chip-tool:last-child { margin-inline-end: 5px; }
.tabchip.editing .nav-link { padding-inline-end: 0; }
.chip-input {
  min-width: 2ch;
  padding: 0 1px;
  margin-inline-end: 6px;
  border: 0;
  border-bottom: 2px solid var(--accent);
  border-radius: 0;
  background: none;
  color: inherit;
  font: 600 13.5px/1.3 var(--mono);
  outline: 0;
  direction: ltr;
}
/* questions: smaller, rounder */
.q-tabs .tabchip { border-radius: 999px; }
.q-tabs .tabchip .nav-link { padding: 5px 13px; font-size: 13px; }
.q-tabs .tabchip:has(.nav-link.active) .nav-link { padding-inline-end: 4px; }
.q-tabs .chip-tool { width: 23px; height: 23px; border-radius: 50%; font-size: 11px; }
.q-tabs .chip-input { font-size: 13px; }

.chip-add {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.chip-add.sm { width: 31px; height: 31px; border-radius: 50%; font-size: 13px; }
.chip-add:hover { border-color: var(--accent); border-style: solid; background: var(--accent-soft); color: var(--accent); }

/* ─── Workbench ───────────────────────────────────────────────────────────── */
.workspace { display: grid; gap: 18px; margin-top: 14px; align-items: start; }
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 11px 12px 11px 16px;
  padding-inline: 16px 12px;
  min-height: 56px;
}
.panel-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-title h2 { font: 500 17px/1.3 var(--serif); letter-spacing: -.01em; }
.tag {
  font: 500 11.5px/1 var(--mono);
  color: var(--muted);
  background: var(--paper-deep);
  padding: 5px 7px;
  border-radius: 6px;
  white-space: nowrap;
  direction: ltr;
}
.panel-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--paper-deep); }
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font: 600 13px/1.3 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(48, 43, 39, .14); }
:root[data-theme='dark'] .seg button.active { background: var(--line); }

/* the editor */
.code-panel { overflow: hidden; }
.code-editor-wrapper { background: var(--code-bg); color: var(--code-ink); border-top: 1px solid var(--line); }
.code-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  background: var(--code-bar);
  border-bottom: 1px solid var(--code-line);
}
.code-editor-dot { width: 10px; height: 10px; border-radius: 50%; opacity: .85; }
.code-editor-filename { margin-inline-start: 8px; font: 500 12.5px/1 var(--mono); color: var(--code-ink); }
.code-editor-lang { margin-inline-start: auto; font: 500 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--code-muted); }
.code-editor-body { display: flex; height: 340px; }
.code-editor-lines,
.code-editor-textarea {
  margin: 0;
  font: 400 13.5px/1.62 var(--mono);
  font-variant-ligatures: none !important;
  tab-size: 4;
}
.code-editor-lines {
  flex: none;
  min-width: 46px;
  padding: 14px 10px 60px 12px;
  overflow: hidden;
  text-align: right;
  white-space: pre;
  color: var(--code-muted);
  opacity: .75;
  border-right: 1px solid var(--code-line);
  user-select: none;
}
.code-editor-textarea {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--code-ink);
  caret-color: var(--code-accent);
  white-space: pre;
  overflow: auto;
  scrollbar-color: var(--code-line) transparent;
}
.code-editor-textarea::placeholder { color: var(--code-muted); opacity: .8; }
.code-editor-textarea::selection { background: rgba(236, 154, 120, .32); color: inherit; }

/* file slots */
.drop-area {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-area:hover { border-color: var(--accent); }
.drop-area.filled { border-style: solid; border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-soft); cursor: default; }
body.dragging-files .drop-area:not(.filled) { border-color: var(--accent); }
.drop-area.over, body.dragging-files .drop-area.over { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }
.drop-area > * { pointer-events: none; } /* a drop always lands on the area itself */
.drop-area > .slot-remove { pointer-events: auto; }
.slot { padding: 7px 8px 7px 10px; padding-inline: 10px 8px; min-height: 46px; }
.slot-empty { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--muted); }
.slot-empty > .bi { font-size: 17px; opacity: .8; }
.slot-label { display: grid; min-width: 0; font-size: 13px; line-height: 1.25; }
.slot-label code { font-size: 11.5px; color: var(--muted); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-file { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ok); }
.slot-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 12.5px/1.3 var(--mono);
  color: var(--ink);
  direction: ltr;
  unicode-bidi: isolate;
}
.slot-remove {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.slot-remove:hover { background: var(--bad-soft); color: var(--bad); }
.code-upload { padding: 0 12px 12px; }
.code-drop { justify-content: center; min-height: 320px; padding: 20px; }
.code-drop .slot-empty { flex-direction: column; gap: 10px; text-align: center; }
.code-drop .slot-empty > .bi { font-size: 40px; color: var(--accent); opacity: 1; }
.code-drop .slot-label { font-size: 15.5px; font-weight: 600; color: var(--ink); gap: 3px; }
.code-drop .slot-label small { font-size: 13.5px; font-weight: 400; color: var(--muted); }
.code-drop.filled { justify-content: space-between; min-height: 0; padding: 12px 12px 12px 16px; padding-inline: 16px 12px; }
.code-drop.filled .slot-name { font-size: 14px; }
.code-drop.filled .slot-file .bi { font-size: 18px; }

/* test cases */
.tests { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0 12px 12px; }
.test {
  --state: var(--line);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--state);
  min-width: 0;
  border-radius: 12px;
  background: var(--card);
  padding: 8px 10px 10px;
  transition: border-color .2s;
}
.test[data-state='running'] { --state: var(--accent); }
.test[data-state='pass'] { --state: var(--ok); }
.test[data-state='fail'] { --state: var(--bad); }
.test[data-state='error'] { --state: var(--warn); }
.test-head { display: flex; align-items: center; gap: 10px; min-height: 30px; margin-bottom: 6px; }
.test-name { flex: none; font-size: 14px; font-weight: 600; }
.test-name b { font: 600 13px/1 var(--mono); }
.test-status {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
}
.test[data-state='idle'] .test-status { font-size: 12.5px; opacity: .8; }
.test[data-state='running'] .test-status { color: var(--accent); }
.test[data-state='pass'] .test-status { color: var(--ok); font-weight: 600; }
.test[data-state='fail'] .test-status { color: var(--bad); font-weight: 600; }
.test[data-state='error'] .test-status { color: var(--warn); font-weight: 600; }
.test-status .status-msg {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 12.5px/1.4 var(--mono);
}
.test-status .time { flex: none; display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 4px; font: 400 11.5px/1 var(--mono); color: var(--muted); direction: ltr; }
.diff-btn { flex: none; display: none; }
.test[data-state='pass'] .diff-btn,
.test[data-state='fail'] .diff-btn,
.test[data-state='error'] .diff-btn { display: inline-flex; }
.test[data-state='fail'] .diff-btn,
.test[data-state='error'] .diff-btn { background: var(--paper-deep); color: var(--ink); }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.summary {
  font: 600 12.5px/1 var(--mono);
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--bad-soft);
  color: var(--bad);
  white-space: nowrap;
}
.summary[data-all='true'] { background: var(--ok-soft); color: var(--ok); }
.runbar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
  background: var(--card);
}

@media (min-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .code-panel { position: sticky; top: calc(var(--bar-h) + 14px); }
  .code-editor-body { height: clamp(320px, calc(100vh - 200px), 780px); }
}
@media (min-width: 720px) and (max-width: 1099.98px) {
  .tests { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ─── Modals ──────────────────────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  overflow: hidden;
}
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-header .btn-close { margin: 0; margin-inline-start: auto; }
.modal-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font: 500 18px/1.3 var(--serif); }
.modal-title > .bi { color: var(--accent); font-size: 17px; }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--line); justify-content: space-between; gap: 12px; }
.modal-footer small { color: var(--muted); font-size: 13px; }
.modal-backdrop { --bs-backdrop-bg: #1b1714; --bs-backdrop-opacity: .55; }

.video-modal .modal-body { padding: 0; background: #000; }
.video-modal video { display: block; width: 100%; max-height: 78vh; background: #000; }

/* the diff */
.diff-legend { display: none; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 12px; font-size: 13.5px; color: var(--muted); }
.modal-body:has(table.diff) .diff-legend { display: flex; }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg::before { content: ''; width: 14px; height: 14px; border-radius: 4px; background: var(--code-bg); box-shadow: inset 0 0 0 14px var(--hl); }
.lg.sub { --hl: rgba(240, 110, 125, .5); }
.lg.add { --hl: rgba(120, 190, 130, .5); }
.lg.chg { --hl: rgba(232, 197, 126, .5); }
.diff-table-wrapper { overflow: auto; border-radius: 12px; text-align: left; }
.diff-table-wrapper:has(table.diff) { background: var(--code-bg); border: 1px solid var(--code-line); }
table.diff {
  width: 100%;
  border-collapse: collapse;
  color: var(--code-ink);
  font: 400 13px/1.6 var(--mono);
  font-variant-ligatures: none !important;
}
table.diff .diff_next { display: none; } /* difflib's jump links: nothing to jump to here */
table.diff colgroup { display: none; }
table.diff thead th {
  position: sticky;
  top: 0;
  padding: 8px 12px;
  background: var(--code-bar);
  border-bottom: 1px solid var(--code-line);
  color: var(--code-muted);
  font: 500 11px/1.3 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  text-align: left;
}
table.diff td { padding: 1px 12px; vertical-align: top; white-space: pre; }
table.diff td.diff_header {
  width: 1%;
  padding: 1px 10px;
  text-align: right;
  color: var(--code-muted);
  opacity: .75;
  user-select: none;
  border-inline-start: 1px solid var(--code-line);
}
table.diff tr > td.diff_header:first-of-type, table.diff tr > td.diff_next + td.diff_header { border-inline-start-color: transparent; }
table.diff tr > td.diff_header ~ td.diff_header { border-inline-start-color: var(--code-line); }
table.diff tbody tr:first-child td { padding-top: 8px; }
table.diff tbody tr:last-child td { padding-bottom: 8px; }
table.diff td:not(.diff_header):not(.diff_next) { width: 49%; }
.diff_add { background: rgba(120, 190, 130, .3); border-radius: 3px; }
.diff_sub { background: rgba(240, 110, 125, .32); border-radius: 3px; }
.diff_chg { background: rgba(232, 197, 126, .32); border-radius: 3px; }

.diff-empty { display: grid; justify-items: center; gap: 6px; padding: 44px 16px; text-align: center; color: var(--muted); }
.diff-empty .bi { font-size: 34px; opacity: .6; }
.diff-empty h3 { font: 500 17px/1.3 var(--serif); color: var(--ink); }
.diff-empty p { font-size: 14.5px; }

.trace { border: 1px solid var(--code-line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.trace + .trace { margin-top: 12px; }
.trace::before {
  content: 'Traceback';
  display: block;
  padding: 8px 14px;
  background: var(--code-bar);
  border-bottom: 1px solid var(--code-line);
  color: #f0a39a;
  font: 500 11px/1.3 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.trace.out::before { content: 'Printed before the error'; color: var(--code-muted); }
.trace pre {
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  color: #f3b5ad;
  font: 400 13px/1.6 var(--mono);
  font-variant-ligatures: none !important;
  white-space: pre-wrap;
  word-break: break-word;
}
.trace.out pre { color: var(--code-ink); }

/* "How does bulk upload work?" */
.explainer .modal-body { font-size: 15px; }
.explainer .modal-body > p { margin-bottom: 14px; }
.explainer h3 { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font: 600 15.5px/1.3 var(--sans); }
.explainer h3 .bi { color: var(--accent); }
.explainer-lead {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--accent-soft);
}
.explainer-lead p { font-size: 14px; color: var(--muted); }
.explainer-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--card);
  color: var(--accent);
  font-size: 20px;
}
.explainer-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.explainer-cell { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.explainer-cell b { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-weight: 600; }
.explainer-cell b .mono { font-size: 11.5px; color: var(--accent); background: var(--accent-soft); padding: 4px 6px; border-radius: 6px; }
.explainer-cell small { display: block; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.small-note { font-size: 14px; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 12px; }
.explainer-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.explainer-table th, .explainer-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.explainer-table tbody tr:last-child > * { border-bottom: 0; }
.explainer-table thead th { background: var(--paper-deep); font: 500 11.5px/1.4 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.explainer-table thead th code { text-transform: none; }
.explainer-table tbody th { font-weight: 600; white-space: nowrap; }
.naming { padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; background: var(--paper-deep); font-size: 14px; line-height: 1.9; }
.naming code { color: var(--ink); font-size: 13px; }
.naming code b { color: var(--accent); font-weight: 700; }
.naming code i { color: var(--ok); font-style: normal; font-weight: 700; }
.naming code u { color: var(--warn); text-decoration: none; font-weight: 700; }

/* ─── Messages ────────────────────────────────────────────────────────────── */
.toasts {
  /* top centre: never on top of the Run button, which sits at the bottom */
  position: fixed;
  inset-block-start: calc(var(--bar-live, var(--bar-h)) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1090;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(460px, calc(100vw - 32px));
  pointer-events: none;
}
.toast-item {
  --tone: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 10px 11px 14px;
  padding-inline: 14px 10px;
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--tone);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow), 0 12px 32px -12px rgba(0, 0, 0, .3);
  font-size: 14.5px;
  line-height: 1.4;
  pointer-events: auto;
  animation: toast-in .3s var(--ease-out);
}
.toast-item.ok { --tone: var(--ok); }
.toast-item.warn { --tone: var(--warn); }
.toast-item.bad { --tone: var(--bad); }
.toast-item.info { --tone: var(--accent); }
.toast-item .toast-body { display: flex; align-items: flex-start; gap: 9px; padding: 0; min-width: 0; }
.toast-item .toast-body > .bi, .toast-item .toast-body > .spinner-border { flex: none; margin-top: 2px; color: var(--tone); }
.toast-x {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}
.toast-x:hover { background: var(--paper-deep); color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.drop-hint {
  position: fixed;
  inset-block-start: calc(var(--bar-live, var(--bar-h)) + 14px);
  left: 50%;
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--code-ink);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5);
  font-size: 14.5px;
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease-out);
}
.drop-hint .bi { color: var(--code-accent); font-size: 17px; }
body.dragging-files .drop-hint { opacity: 1; transform: translate(-50%, 0); }
body.dragging-files::after {
  content: '';
  position: fixed;
  inset: 8px;
  z-index: 1070;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  pointer-events: none;
  opacity: .55;
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 18px clamp(16px, 3vw, 32px) 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.app-footer p { max-width: 760px; margin-inline: auto; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-bottom: 8px; font: 500 12.5px/1.6 var(--mono); }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* Hebrew: JetBrains Mono has no Hebrew letters, so labels that are words use the text font. */
[lang='he'] .engine, [lang='he'] .footer-links { font-family: var(--sans); font-size: 13.5px; letter-spacing: 0; }

/* ─── Narrower screens ────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .contact .phone span, .contact a:not(.tutoring):not(.phone) { display: none; }
}
@media (max-width: 900px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact .tutoring { display: none; }
  .brand-text small { display: none; }
  /* The title, the status and the account button no longer fit on one row: stack them (title row, then tools row). */
  .appbar-in { height: auto; min-height: var(--bar-h); flex-wrap: wrap; gap: 6px 10px; padding-block: 8px; }
  [dir='ltr'] .appbar-in > [data-algoprep-brand] { order: 0; }
  .brand { flex: 1 1 0; min-width: 190px; }
  .brand-text strong { white-space: normal; overflow: visible; text-overflow: clip; }
  .appbar-tools { flex: 1 1 100%; margin-inline-start: 0; flex-wrap: wrap; row-gap: 4px; }
}
@media (max-width: 640px) {
  :root { --bar-h: 54px; }
  .appbar-in { gap: 10px; }
  .appbar-tools { gap: 6px; }
  .brand { gap: 9px; }
  .brand-mark { width: 32px; height: 32px; font-size: 13px; }
  .brand-text strong { font-size: 15px; }
  .contact a.phone { padding: 0 7px; }
  .tool-btn { width: 34px; height: 34px; }
  .shell { padding-top: 14px; }
  .steps { grid-template-columns: 1fr; padding-inline: 14px; }
  .howto-head .ui-btn span { display: none; }
  .panel-head { padding-inline: 12px 10px; }
  .panel-tools { width: 100%; justify-content: space-between; }
  .panel-tools > .ui-btn span { display: none; }
  .panel-tools > .ui-btn { padding: 8px 10px; font-size: 15px; }
  .code-editor-lines, .code-editor-textarea { font-size: 13px; }
  .tests { padding-inline: 8px; }
  .slot-label code { display: none; }
  .slot { min-height: 42px; }
  .runbar { padding-inline: 8px; }
  .ui-btn.run { flex: 1; }
  .explainer-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 14px; }
  .toasts { width: calc(100vw - 32px); max-width: none; align-items: stretch; }
}
@media (max-width: 400px) {
  .diff-btn span { display: none; }
  .ui-btn.danger span { display: none; }
}

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