/* The course site's two typefaces, served from here: Assistant for text, Heebo for headings (both under the Open Font License). */
@font-face { font-family: 'Assistant'; font-style: normal; font-weight: 400 800; font-display: swap; src: url("vendor/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("vendor/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("vendor/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("vendor/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; }
:root {
  color-scheme: light;
  /* Colours of the course site (site/assets/style.css): paper, ink and the terracotta accent. */
  --ink: #302b27;
  --muted: #70665c;
  --paper: #fffcf7;
  --line: #ded5c8;
  --green: #a94d31;
  --light: #f1ece3;
  --orange: #a94d31;
  --bg: #faf9f5;
  --shadow: 0 0.5rem 2rem #302b2708;
  --sans: 'Assistant', Arial, "Noto Sans Hebrew", sans-serif;
  --serif: 'Heebo', Arial, "Noto Sans Hebrew", sans-serif; /* the site's heading face */
  font-family: var(--sans);
  /* The app's one size knob: every size below is in rem, so the whole app scales with this. Phones keep 16px; a
     tablet is drawn at 90% and a laptop or desktop at 80% (the owner's choice, 2026-11-25: 100% looked too big). */
  font-size: 16px;
  --chat-w: 1000px; /* the conversation, the composer and the cards above them, at most (the screen's px, not scaled) */
}
@media (min-width: 600px) { :root { font-size: 14.4px; } }
@media (min-width: 900px) { :root { font-size: 12.8px; } }
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  height: var(--app-h, 100dvh); /* --app-h: the height above the on-screen keyboard (app.js) */
  overflow: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 0.5625rem;
  background: var(--green);
  color: white;
  padding: 0.625rem 1.0625rem;
  transition:
    background 0.15s,
    box-shadow 0.15s;
}
button:hover {
  filter: brightness(0.96);
}
button:disabled {
  opacity: 0.48;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 0.1875rem solid #c69b54;
  outline-offset: 0.125rem;
}
a {
  color: var(--green);
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--paper);
  color: var(--ink);
  padding: 0.625rem;
}
textarea {
  resize: vertical;
  min-height: 5.5rem;
  max-height: 15rem;
  unicode-bidi: plaintext;
  line-height: 1.6;
}
input::placeholder,
textarea::placeholder {
  color: #8b8982;
}
.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  padding: 0.5rem 0.75rem;
}
/* The settings button lives in the top bar (.top-actions) with the other header buttons. */
.workspace {
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-columns: minmax(0, 62fr) minmax(20rem, 38fr);
  min-height: 0;
  overflow: hidden;
}
.tutor-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
  padding-top: 4.25rem;
}
.eyebrow {
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  color: #70665c;
  margin-bottom: 0.5rem;
}
.catalog-filters h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.filter-row label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}
.filter-row input,
.filter-row select {
  min-width: 5.5rem;
}
.result-card {
  width: 100%;
  text-align: right;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0.75rem 0.875rem;
  margin-bottom: 0.4375rem;
  display: block;
}
.result-card:hover {
  border-color: #b9aca0;
  background: #f4f2ec;
}
.result-card strong {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin: 0.375rem 0;
  line-height: 1.5;
}
.card-meta {
  font-size: 0.6875rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.card-meta b {
  color: var(--green);
  font-weight: 500;
}
.learning-area {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1.875rem;
  scroll-behavior: smooth;
}
.welcome {
  max-width: 42.5rem;
  margin: 0 auto 1.75rem;
  text-align: center;
}
.welcome-prompt {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 1rem 0 0;
}
.stem {
  white-space: pre-wrap;
  font-size: 0.8125rem;
  line-height: 1.9;
  max-height: 11.875rem;
  overflow: auto;
  padding: 0 0 0.875rem;
}
.question-actions {
  display: flex;
  gap: 0.4375rem;
  flex-wrap: wrap;
  margin-top: 0.375rem;
}
.question-actions button {
  font-size: 0.6875rem;
  padding: 0.3125rem 0.5rem;
  background: #f4f2ec;
  border: 1px solid var(--line);
  color: var(--green);
}
.question-actions button:first-child {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: var(--chat-w);
  margin: auto;
}
.message {
  display: flex;
  gap: 0.6875rem;
  align-items: flex-start;
}
.avatar {
  flex: 0 0 1.75rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  background: #f0e6df;
  color: var(--green);
  font:
    1rem Georgia,
    serif;
  border-radius: 0.5rem;
}
.message.system {
  padding: 0.5rem 0;
  border-block: 1px solid var(--line);
}
.message.system .avatar {
  display: none;
}
.message.system .content {
  font-size: 0.75rem;
  color: var(--muted);
}
.catalog-text {
  font-size: 0.75rem;
  margin-block: 0.375rem;
}
.catalog-text summary {
  cursor: pointer;
}
.part-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3125rem;
}
.message.user .avatar {
  background: #eeece6;
  color: #6b6760;
  font: 0.75rem Arial;
}
.message-body {
  min-width: 0;
  flex: 1;
  font-size: 1rem;
  line-height: 1.85;
}
.message.user .content {
  background: #eeece6;
  padding: 0.625rem 0.875rem;
  border-radius: 0.625rem;
  white-space: pre-wrap;
  unicode-bidi: plaintext;
}
.message-label {
  font-size: 0.625rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.content p {
  margin: 0.25rem 0 0.75rem;
}
.content pre,
.content code {
  direction: ltr;
  unicode-bidi: isolate;
  background: #eeece6;
  border-radius: 0.3125rem;
}
.content pre {
  padding: 0.75rem;
  overflow: auto;
}
.content table {
  border-collapse: collapse;
}
.content td,
.content th {
  padding: 0.375rem;
  border: 1px solid var(--line);
}
.content blockquote {
  border-right: 0.1875rem solid #cc9c88;
  margin: 0.625rem 0;
  padding-right: 0.75rem;
  color: var(--muted);
}
.content img {
  max-width: 100%;
}
.content .katex,
.composer-input .katex {
  direction: ltr;
  unicode-bidi: isolate;
}
.katex-display {
  overflow: auto hidden;
  padding: 0.3125rem 0;
  direction: ltr;
  unicode-bidi: isolate;
}
.source-chip {
  background: #f0eee8;
  color: #706a61;
  border: 1px solid #dedad1;
  border-radius: 1.25rem;
  font-size: 0.625rem;
  padding: 0.1875rem 0.5625rem;
}
.usage {
  font-size: 0.625rem;
  color: var(--muted);
  margin-top: 0.5rem;
  line-height: 1.6;
  direction: rtl;
}
.notice {
  color: #9b613b;
  font-size: 0.75rem;
}
.composer-area {
  background: #faf9f5;
  padding: 0.75rem 1.875rem 1.25rem;
  width: min(calc(var(--chat-w) + 3.75rem), 100%); /* the composer as wide as the messages (its padding outside) */
  margin-inline: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.composer {
  background: var(--paper);
  border: 1px solid #d9d5cd;
  border-radius: 1.375rem;
  box-shadow: 0 0.1875rem 0.3125rem #302c2410, 0 0.75rem 2.1875rem #302c2405;
  padding: 1rem;
  order: 1;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer textarea {
  width: 100%;
  border: 0;
  padding: 0.375rem 0.25rem;
  background: transparent;
  outline-offset: 0;
  display: block;
  min-height: 4.25rem;
  height: 4.25rem;
  max-height: 11.25rem;
  resize: none;
  font-size: 1rem;
}
.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}
.composer-tools > div {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.math-button {
  font-size: 0.6875rem;
  border: 0;
  padding: 0.3125rem;
}
.math-button span {
  font:
    italic 1rem Georgia,
    serif;
}
.composer-tools #send {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font: 1.5rem Arial, sans-serif;
  border-radius: 0.625rem;
  display: grid;
  place-items: center;
}
.session-panel {
  display: grid;
  gap: 0.625rem;
  margin-bottom: 0.25rem;
}
.session-panel-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.8125rem;
}
.session-label {
  color: var(--muted);
  font-size: 0.75rem;
}
.session-panel #reset-session {
  justify-self: start;
  font-size: 0.75rem;
  padding: 0.4375rem 0.6875rem;
}
.key-notice {
  font-size: 0.6875rem;
  line-height: 1.7;
  background: #f3eddf;
  border: 1px solid #e8dfc8;
  border-radius: 0.4375rem;
  padding: 0.5rem 0.6875rem;
  margin-bottom: 0.5rem;
  color: #8c7551;
}
.image-pane {
  background: #eeece6;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.25rem 0.75rem 0.75rem;
  position: relative;
}
.page-chrome {
  position: absolute;
  top: 0.875rem;
  inset-inline-start: 0.875rem;
  z-index: 2;
  display: flex;
  gap: 0.375rem;
  align-items: center;
  pointer-events: none;
}
.page-chrome > * {
  pointer-events: auto;
}
.page-open {
  display: grid;
  place-items: center;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 62.4375rem;
  background: #fffffff2;
  border: 1px solid #d5dbc8;
  color: var(--green);
  text-decoration: none;
  font-size: 0.875rem;
  box-shadow: 0 0.125rem 0.625rem #26302014;
}
.page-open:hover {
  background: #fff;
}
.page-stage {
  flex: 1;
  overflow: auto;
  text-align: center;
  min-height: 0;
  border: 1px solid #dcd8cf;
  border-radius: 0.5rem;
  background: #e8e5de;
}
.page-stage img {
  width: 100%;
  height: auto;
  display: block;
  background: white;
  box-shadow: 0 0.125rem 1.25rem #2630200a;
}
.page-empty {
  height: 100%;
  min-height: 17.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #70665c;
}
.page-empty > span {
  font-size: 3.125rem;
  font-weight: 100;
  color: #aaa298;
}
.page-empty p {
  font-size: 0.875rem;
  margin: 0.875rem 0 0.5rem;
}
.page-empty small {
  font-size: 0.6875rem;
}
.settings-dialog {
  border: 1px solid var(--line);
  border-radius: 0.9375rem;
  background: var(--paper);
  color: var(--ink);
  padding: 1.5625rem;
  box-shadow: 0 1.5625rem 6.25rem #18331d30;
  width: min(30rem, calc(100% - 1.75rem));
  max-height: 90dvh;
}
dialog::backdrop {
  background: #302b273b;
  backdrop-filter: blur(0.125rem);
}
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
.dialog-heading h2 {
  font-size: 1.3125rem;
  font-weight: 500;
  margin: 0;
}
.dialog-heading .quiet {
  border: 0;
}
.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.75rem;
}
.settings-fields label {
  display: flex;
  flex-direction: column;
  gap: 0.4375rem;
}
.settings-fields select {
  width: 100%;
}
.settings-fields label[for="reasoning"] {
  flex-direction: row;
  justify-content: space-between;
  margin-top: 0.625rem;
}
.settings-fields input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}
.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--muted);
  margin-top: -0.5rem;
}
.mapping {
  font-family: monospace;
  font-size: 0.6875rem;
  line-height: 1.6;
  background: #f0eee8;
  border-radius: 0.4375rem;
  padding: 0.625rem;
}
.price-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-top: 0.5rem;
}
.price-grid > div {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem;
  color: var(--muted);
}
.price-grid strong {
  font-size: 1.4375rem;
  font-weight: 500;
  color: var(--green);
  display: block;
  margin-top: 0.4375rem;
}
.muted {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.7;
  margin: 0.375rem 0;
}
.settings-fields small {
  color: #70665c;
  line-height: 1.7;
}
.settings-help {
  font-size: 0.75rem;
  line-height: 1.8;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.875rem;
  margin-bottom: 0;
}
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.25rem;
  background: #302b27;
  color: white;
  border-radius: 0.5625rem;
  z-index: 100;
  font-size: 0.8125rem;
  max-width: 90vw;
  box-shadow: var(--shadow);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1000px) {
  .learning-area {
    padding: 0.875rem 1.25rem;
  }
  .composer-area {
    padding: 0.625rem 1.25rem;
  }
  .question-actions {
    gap: 0.3125rem;
  }
}
@media (max-width: 740px) {
  .learning-area {
    padding: 1rem;
  }
  .welcome {
    margin: 0.5rem auto 0.75rem;
  }
  .page-empty {
    min-height: 7.5rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}


.settings-divider {
  border: 0;
  border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
  margin: 1rem 0;
}

.byok-block h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.byok-note {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  line-height: 1.45;
}

.byok-block label {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}

.byok-block input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  border-radius: 0.55rem;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  background: color-mix(in srgb, Canvas 92%, CanvasText 8%);
  color: inherit;
  font: inherit;
}

.byok-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.35rem;
}

.byok-actions #byok-status {
  font-size: 0.85rem;
}

/* The start screen stays focused on the conversation. The exam opens on selection. */
/* The mark is the letter σ in the formulas' own italic (KaTeX's face, which the page already has). A small
   letter fills less of its line than the asterisk it replaced, so it is set larger on a shorter line: the mark
   looks the same size and takes the same room (58, 48 and 36 pixels high). */
.welcome-mark { color: #c37356; font-family: KaTeX_Math, "Times New Roman", serif; font-style: italic; font-size: 4.8125rem; line-height: 0.75; margin-bottom: 1.375rem; }
.welcome h1 {
  font-family: var(--serif);
  font-size: clamp(2.125rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: -0.025rem;
  line-height: 1.2;
  margin: 0;
}
.workspace:not(.page-expanded) { grid-template-columns: minmax(0, 1fr); }
.tutor-pane:has(#welcome:not([hidden])) { justify-content: center; padding-bottom: 8dvh; }
.tutor-pane:has(#welcome:not([hidden])) .learning-area { flex: 0 0 auto; padding-bottom: 0; }
.tutor-pane:has(#welcome:not([hidden])) .messages:empty { display: none; }
.key-notice { order: 4; background: transparent; border: 0; text-align: center; color: var(--muted); margin: 0.75rem 0 0; padding: 0; }
.composer:focus-within { border-color: #b7afa1; box-shadow: 0 0.1875rem 0.3125rem #302c2410, 0 0 0 0.125rem #b7afa115; }
.composer textarea:focus-visible { outline: none; }
.composer-tools > div { gap: 0.5rem; min-width: 0; flex: 1; margin-inline-end: 0.75rem; }
.math-button { border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.375rem 0.5625rem; color: #68645e; white-space: nowrap; }
.model-button { display: flex; align-items: center; gap: 0.5rem; border: 0; color: #68645e; font-size: 0.75rem; padding: 0.375rem 0.5rem; min-width: 0; }
.model-button bdi { min-width: 0; max-width: 11.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message.user { margin-inline-start: 2.125rem; }
.message.user .avatar, .message.user .message-label { display: none; }
.message.user .content { padding: 0.875rem 1.125rem; border-radius: 1rem; }
.message:not(.user) .avatar { background: transparent; color: var(--green); font-size: 1.5rem; }
.message.system { padding: 0.875rem; border: 1px solid var(--line); border-radius: 0.75rem; background: #f2f0ea; }
.source-chip { color: #706a61; }
.settings-dialog { box-shadow: 0 1.5625rem 6.25rem #302c2429; }
dialog::backdrop { background: #302c243b; }
@media (max-width: 740px) {
  .tutor-pane { padding-top: 3.75rem; }
  .tutor-pane:has(#welcome:not([hidden])) { padding-bottom: 8dvh; }
  .welcome { margin-bottom: 1rem; }
  .welcome-mark { font-size: 4rem; margin-bottom: 1.125rem; }
  .welcome-prompt { font-size: 0.875rem; }
  .composer-area { padding: 0.75rem 1rem 1rem; }
  .composer { padding: 0.75rem; border-radius: 1.125rem; }
  .composer-tools > div { gap: 0.25rem; }
  .model-button bdi { max-width: 7.5rem; }
  .message-body { font-size: 0.9375rem; }
}
@media (max-height: 620px) {
  .tutor-pane:has(#welcome:not([hidden])) { justify-content: flex-start; padding-bottom: 0; overflow: auto; }
  .tutor-pane:has(#welcome:not([hidden])) .learning-area { overflow: visible; padding-top: 1rem; }
  .welcome-mark { font-size: 3rem; margin-bottom: 0.75rem; }
  .welcome h1 { font-size: 2rem; }
}

.panel-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0 0 0.1875rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--paper);
  color: var(--muted);
  font: 1.75rem Arial, sans-serif;
  box-shadow: 0 0.125rem 0.375rem #302c2408;
}
.panel-toggle:hover, .quiet:hover { background: #eeece6; filter: none; }
.page-chrome:has(.page-open[hidden]) { display: none; }
@media (max-width: 740px) {
  .panel-toggle { top: 0.75rem; left: 0.75rem; }
}

.reply-waiting {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0 0.375rem 0.75rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.waiting-dots { display: flex; align-items: center; gap: 0.25rem; }
.waiting-dots i {
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 50%;
  background: var(--green);
  animation: waiting-pulse 1.2s ease-in-out infinite;
}
.waiting-dots i:nth-child(2) { animation-delay: 0.15s; }
.waiting-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes waiting-pulse {
  0%, 70%, 100% { opacity: 0.3; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-0.1875rem); }
}
@media (prefers-reduced-motion: reduce) {
  .waiting-dots i { animation: none; opacity: 0.7; }
}

/* MathPaster formula editor overlay (vendor/mathpaster). */
.mp-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.mp-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.mp-overlay iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color-scheme: normal;
}
.mp-exit {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9375rem;
  cursor: pointer;
  box-shadow: 0 0.25rem 1.125rem #0003;
  z-index: 2;
}

/* Scope pickers (subject, material) sit in the composer toolbar like the other quiet controls. */
.composer-tools > div { flex-wrap: wrap; }
.scope-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 0.75rem;
  color: #68645e;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2368645e' stroke-width='1.5'%3E%3Cpath d='m1 1 4 4 4-4'/%3E%3C/svg%3E") no-repeat left 0.5rem center;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.375rem 0.5625rem 0.375rem 1.5rem;
  cursor: pointer;
  width: auto;
  max-width: 8.125rem;
}
.scope-select:hover { background-color: #eeece6; }
.scope-select:focus-visible { outline: 0.125rem solid #b7afa180; outline-offset: 1px; }
/* Live preview of $...$ typed in the message box. */
.message.user .content { white-space: pre-wrap; }

/* ── Polish ─────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: #d2cdc3 transparent; }
::-webkit-scrollbar { width: 0.5rem; height: 0.5rem; }
::-webkit-scrollbar-thumb { background: #d2cdc3; border-radius: 0.5rem; border: 0.125rem solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b7afa1; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* One calm focus ring everywhere (replaces the double ring). */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 0.125rem solid #a94d31;
  outline-offset: 0.125rem;
  box-shadow: none;
}

button { transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, opacity 0.15s; }
button:not(:disabled):active { transform: scale(0.97); }
.composer-tools #send { background: var(--green); color: #fff; }
.composer-tools #send:not(:disabled):hover { background: #94422a; }
.composer-tools #send:disabled { opacity: 0.55; cursor: progress; }

/* Starter prompts on the empty screen. */
.starters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.375rem;
  max-width: 35rem;
  margin-inline: auto;
}
.starter {
  font-size: 0.8125rem;
  color: #68645e;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 62.4375rem;
  padding: 0.4375rem 0.875rem;
  cursor: pointer;
}
.starter:hover { background: #eeece6; border-color: #cfc9bd; color: var(--ink); }

/* Composer controls share one height. */
.composer-tools .math-button, .scope-select, .model-button { height: 2rem; }
.composer-tools .math-button { display: inline-flex; align-items: center; gap: 0.375rem; }
.model-button { border-radius: 0.5rem; }
.model-button:hover { background: #eeece6; }

/* Messages. */
.message { animation: message-in 0.22s ease-out both; }
@keyframes message-in { from { opacity: 0; transform: translateY(0.375rem); } to { opacity: 1; transform: none; } }
.message.user .content { width: fit-content; max-width: 100%; background: #efede7; }
.content ol, .content ul { margin: 0.375rem 0 0.75rem; padding-inline-start: 1.5em; }
.content li { margin: 0.1875rem 0; }
.content li > p { margin: 0; }
.content h1, .content h2, .content h3 { line-height: 1.4; margin: 1rem 0 0.375rem; }
.content h1 { font-size: 1.25em; } .content h2 { font-size: 1.15em; } .content h3 { font-size: 1.05em; }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 0.875rem 0; }
.usage { color: #9a968e; font-size: 0.6875rem; margin-top: 0.375rem; }
.notice:not(:empty) { color: #9a4a35; background: #fbeeea; border-radius: 0.5rem; padding: 0.375rem 0.625rem; margin-top: 0.5rem; font-size: 0.8125rem; }

/* Catalog note: quiet and compact. */
.message.system { padding: 0.625rem 0.875rem; gap: 0.625rem; }
.message.system .message-label { font-size: 0.6875rem; letter-spacing: 0.02em; }
.message.system .content { font-size: 0.8125rem; color: #5d5a54; }
.catalog-text summary { color: var(--green); list-style-position: inside; padding: 0.125rem 0; }
.catalog-text[open] summary { margin-bottom: 0.375rem; }
.catalog-text .stem { background: #fbfaf7; border: 1px solid var(--line); border-radius: 0.625rem; padding: 0.75rem 0.875rem; }

/* Settings dialog. */
.settings-dialog { border: 0; border-radius: 1.125rem; }
.settings-dialog select, .settings-dialog input { border-radius: 0.625rem; }

/* Phones: the toolbar scrolls sideways instead of wrapping into rows. */
@media (max-width: 740px) {
  .composer-tools { align-items: flex-end; }
  .composer-tools > div {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.125rem;
    scrollbar-width: none;
    margin-inline-end: 0.5rem;
  }
  .composer-tools > div::-webkit-scrollbar { display: none; }
  .composer-tools > div { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 1.375rem); mask-image: linear-gradient(to right, transparent 0, #000 1.375rem); }
  .composer-tools > div > * { flex: none; }
  .starters { margin-top: 1rem; }
  .starter { font-size: 0.7812rem; padding: 0.375rem 0.75rem; }
}
@media (prefers-reduced-motion: reduce) { .message { animation: none; } button { transition: none; } }

/* ── Dialogs and overlays ───────────────────────────────── */
.settings-dialog {
  padding: 0;
  width: min(32.5rem, calc(100% - 1.5rem));
  max-height: min(86dvh, 47.5rem);
  overflow: hidden;
  display: none;
  flex-direction: column;
  background: #faf9f6;
  border-radius: 1.25rem;
  box-shadow: 0 1.875rem 5.625rem #302c2440, 0 0.125rem 0.5rem #302c2410;
}
.settings-dialog[open] { display: flex; animation: dialog-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }
.settings-dialog[open]::backdrop { animation: fade-in 0.2s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(0.625rem) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 1.375rem 0.875rem;
  border-bottom: 1px solid var(--line);
  background: #faf9f6;
  flex: none;
}
.sd-head h2 { font-size: 1.25rem; font-weight: 500; margin: 0.125rem 0 0; }
.sd-close {
  width: 2.125rem; height: 2.125rem; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 0.625rem;
  background: transparent; color: var(--muted); font-size: 0.9375rem; cursor: pointer;
}
.sd-close:hover { background: #eeece6; color: var(--ink); }
.sd-body {
  overflow-y: auto;
  padding: 1rem 1.375rem 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}
.sd-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  padding: 1rem 1rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.sd-card h3 { margin: 0; font-size: 0.875rem; font-weight: 600; color: var(--ink); }
.sd-card .muted { margin: 0; }
.sd-field { display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.7812rem; color: #5d5a54; }
.sd-field select, .sd-field input[type="password"], .sd-field input[type="number"], .settings-dialog .filter-row input {
  width: 100%;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink);
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  padding: 0.5625rem 0.6875rem;
}
.sd-field select:hover, .sd-field input:hover { border-color: #cfc9bd; }
.sd-field select:focus, .sd-field input:focus { border-color: #a94d31; outline: none; box-shadow: 0 0 0 0.1875rem #a94d3126; }
.sd-row { display: flex; justify-content: space-between; align-items: baseline; }
.sd-row output { color: var(--green); font-weight: 600; }
.settings-dialog .filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.settings-dialog .slider-labels { margin-top: -0.25rem; font-size: 0.6875rem; }
.settings-dialog .mapping { margin: 0.125rem 0 0; font-size: 0.6875rem; color: #6b6760; background: #f4f2ec; border-radius: 0.5rem; }
.settings-dialog .price-grid { margin-top: 0; }
.settings-dialog .price-grid > div { border-radius: 0.625rem; padding: 0.625rem 0.75rem; font-size: 0.75rem; background: #fbfaf7; }
.settings-dialog .price-grid strong { font-size: 1.25rem; margin-top: 0.25rem; text-align: start; }
.sd-fine { color: #8d8a83; font-size: 0.7188rem; line-height: 1.7; }
.settings-dialog .session-panel-row { font-size: 0.8125rem; }
.settings-dialog .session-label { color: var(--muted); }
.settings-dialog #reset-session { align-self: flex-start; }
.settings-dialog .byok-actions { margin-top: 0.125rem; gap: 0.5rem; }
.sd-primary {
  background: var(--green); color: #fff; border: 0; border-radius: 0.625rem;
  padding: 0.5625rem 1rem; font: inherit; font-size: 0.8125rem; cursor: pointer;
}
.sd-primary:hover { background: #94422a; }
.settings-dialog .quiet { border: 1px solid var(--line); border-radius: 0.625rem; font-size: 0.8125rem; padding: 0.5rem 0.8125rem; }
.settings-dialog .byok-actions #byok-status { color: #4f7a4a; font-size: 0.75rem; }

/* Formula editor overlay: same dim and blur as the dialogs. */
.mp-overlay { background: #302c2400; transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.22s; }
.mp-overlay.open { background: #302c243b; backdrop-filter: blur(0.125rem); }
.mp-exit { transition: opacity 0.15s, background-color 0.15s; }
.mp-exit:hover { background: #eeece6; }

/* Toast. */
.toast {
  background: #302b27;
  border-radius: 0.75rem;
  box-shadow: 0 0.625rem 2.125rem #302c2438;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.6875rem 1.125rem;
  text-align: center;
}
.toast:not([hidden]) { animation: toast-in 0.22s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 0.625rem); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (max-width: 740px) {
  .settings-dialog { width: calc(100% - 1rem); max-height: 92dvh; border-radius: 1.125rem; }
  .sd-head { padding: 0.875rem 1rem 0.75rem; }
  .sd-body { padding: 0.75rem 0.875rem 1.125rem; }
}
@media (prefers-reduced-motion: reduce) {
  .settings-dialog[open], .settings-dialog[open]::backdrop, .toast:not([hidden]) { animation: none; }
}

.settings-dialog input[type="range"] { width: 100%; accent-color: #a94d31; padding: 0; margin: 0.125rem 0; }
/* Opening the dialog focuses its first control; do not paint a ring on the close button for that. */
.sd-close:focus:not(:focus-visible) { outline: none; }
.sd-close:focus-visible { outline: 0.125rem solid #a94d31; outline-offset: 1px; }
.settings-dialog:focus, .sd-body:focus { outline: none; }

/* ── Exam-pane toggle ───────────────────────────────────── */
.panel-toggle {
  padding: 0;
  font-size: 0;
  border-radius: 0.75rem;
  color: #6f6a62;
  background: #fffffff2;
  backdrop-filter: blur(0.375rem);
  box-shadow: 0 1px 0.125rem #302c240d, 0 0.25rem 0.875rem #302c2410;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.2s, color 0.2s, border-color 0.2s, background-color 0.2s;
}
.panel-toggle .chev {
  display: block;
  /* Points right when the pane is closed (open it), left when open (tuck it away). */
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.panel-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.panel-toggle:hover {
  color: var(--green);
  border-color: #dcb7a8;
  background: #fff;
  box-shadow: 0 0.125rem 0.25rem #a94d311a, 0 0.5rem 1.375rem #a94d3126;
  transform: translateY(-1px);
}
.panel-toggle:hover .chev { transform: translateX(0.125rem); }
.panel-toggle[aria-expanded="true"]:hover .chev { transform: rotate(180deg) translateX(0.125rem); }
.panel-toggle:active { transform: scale(0.93); transition-duration: 0.08s; }
.panel-toggle:focus-visible { outline: 0.125rem solid #a94d3199; outline-offset: 0.1875rem; }
/* The word in the toggle belongs to sheet mode (narrow or short screens). On a wide screen it is taken out, so
   the chevron is the button's only child and sits exactly in its middle. */
#page-toggle .toggle-text { display: none; }
/* Wide screens: the toggle rides on the pane's edge. Closed, it waits at the screen's corner; open, it sits just
   outside the pane's inner edge and travels there together with the pane (same curve and time as the grid). */
@media (min-width: 1001px) and (min-height: 521px) {
  #page-toggle {
    transition: left 0.5s cubic-bezier(0.22, 0.9, 0.3, 1), transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1),
      box-shadow 0.2s, color 0.2s, border-color 0.2s, background-color 0.2s;
  }
  #page-toggle[aria-expanded="true"] { left: calc(38% + 0.625rem); }
}
/* A soft ring pulses once when the pane opens by itself (a question just loaded). */
.panel-toggle.ping::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 0.75rem;
  border: 0.125rem solid #a94d31;
  animation: toggle-ping 0.9s ease-out;
  pointer-events: none;
}
@keyframes toggle-ping { from { opacity: 0.7; transform: scale(1); } to { opacity: 0; transform: scale(1.7); } }

/* Desktop: the exam pane slides open and shut instead of popping. */
@media (min-width: 1001px) {
  .workspace {
    grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
    transition: grid-template-columns 0.5s cubic-bezier(0.22, 0.9, 0.3, 1);
  }
  .workspace:not(.page-expanded) { grid-template-columns: minmax(0, 1fr) minmax(0, 0fr); }
  .image-pane {
    min-width: 0;
    overflow: hidden;
    transition: opacity 0.35s ease, visibility 0s linear 0s;
  }
  .image-pane[hidden] {
    display: flex !important;
    visibility: hidden;
    opacity: 0;
    padding-inline: 0;
    border-width: 0;
    transition: opacity 0.2s ease, visibility 0s linear 0.5s;
  }
}
@media (prefers-reduced-motion: reduce) {
  .panel-toggle, .panel-toggle .chev, .workspace, .image-pane { transition: none !important; }
  .panel-toggle.ping::after { animation: none; }
}

/* ── Custom dropdowns (composer pickers) ────────────────── */
.dd { position: relative; display: inline-flex; flex: none; }
.dd-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dd-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2rem;
  padding: 0 0.625rem 0 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  color: #68645e;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.dd-btn:hover { background: #f1efe9; border-color: #d3cdc1; }
.dd-btn[aria-expanded="true"] { background: #fbf1ed; border-color: #dcb7a8; color: var(--green); box-shadow: 0 0 0 0.1875rem #b8634218; }
.dd-btn:focus-visible { outline: 0.125rem solid #a94d3199; outline-offset: 0.125rem; }
.dd-chev { flex: none; transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
.dd-btn[aria-expanded="true"] .dd-chev { transform: rotate(180deg); }
.dd-list {
  position: fixed;
  z-index: 70;
  margin: 0;
  padding: 0.3125rem;
  list-style: none;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  box-shadow: 0 0.875rem 2.5rem #302c2426, 0 0.125rem 0.5rem #302c240d;
  font-size: 0.8125rem;
  outline: none;
  animation: dd-in-down 0.16s cubic-bezier(0.2, 0.8, 0.3, 1);
  transform-origin: top;
}
.dd-list[data-dir="up"] { animation-name: dd-in-up; transform-origin: bottom; }
.dd-list[hidden] { display: none; }
@keyframes dd-in-down { from { opacity: 0; transform: translateY(-0.375rem) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes dd-in-up { from { opacity: 0; transform: translateY(0.375rem) scale(0.97); } to { opacity: 1; transform: none; } }
.dd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5625rem;
  color: #4a4742;
  cursor: pointer;
  white-space: nowrap;
}
.dd-item.active { background: #f3f1eb; }
.dd-item[aria-selected="true"] { color: var(--green); font-weight: 600; }
.dd-item[aria-selected="true"]::after {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (prefers-reduced-motion: reduce) { .dd-list { animation: none; } .dd-chev { transition: none; } }

/* ── Chat history ───────────────────────────────────────── */
.top-actions { position: fixed; top: 1rem; right: 1rem; z-index: 5; display: flex; gap: 0.5rem; }
.top-actions .panel-toggle { position: static; }
.history-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: #302c2400; transition: background-color 0.3s;
}
.history-backdrop.open { background: #302c243b; backdrop-filter: blur(0.125rem); }
.history-drawer {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 41;
  width: min(21.25rem, 88vw);
  display: flex; flex-direction: column; gap: 0.625rem;
  padding: 1rem 0.875rem 0.75rem;
  background: #faf9f6;
  border-left: 1px solid var(--line);
  box-shadow: -1.25rem 0 3.75rem #302c2426;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.3, 1);
}
.history-drawer.open { transform: none; }
.history-head { display: flex; align-items: center; justify-content: space-between; padding: 0.125rem 0.25rem 0.125rem 0.125rem; }
.history-head h2 { margin: 0; font-size: 1.125rem; font-weight: 500; }
.history-new {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 0.875rem; border: 0; border-radius: 0.75rem;
  background: var(--green); color: #fff; font: inherit; font-size: 0.875rem; cursor: pointer;
}
.history-new:hover { background: #94422a; }
.history-search {
  display: flex; align-items: center; gap: 0.5rem; padding: 0 0.75rem; height: 2.375rem;
  border: 1px solid var(--line); border-radius: 0.75rem; background: #fff; color: var(--muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.history-search:focus-within { border-color: #a94d31; box-shadow: 0 0 0 0.1875rem #b8634226; }
.history-search input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 0.875rem; color: var(--ink);
  appearance: none; -webkit-appearance: none;
}
.history-search input::-webkit-search-cancel-button { display: none; }
.history-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -0.375rem; padding: 0 0.375rem 0.5rem; }
.history-group { margin: 0.875rem 0.5rem 0.375rem; font-size: 0.6875rem; font-weight: 600; color: #9a968e; letter-spacing: 0.02em; }
.history-empty { margin: 1.75rem 0.75rem; text-align: center; color: var(--muted); font-size: 0.8125rem; line-height: 1.8; }
.chat-row {
  position: relative; display: flex; align-items: center; gap: 0.125rem;
  border-radius: 0.6875rem; transition: background-color 0.15s;
}
.chat-row:hover, .chat-row:focus-within { background: #f0eee8; }
.chat-row.current { background: #f8ece7; }
.chat-row.current .chat-title { color: var(--green); font-weight: 600; }
.chat-main {
  flex: 1; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 0.625rem;
  padding: 0.5625rem 0.75rem; border: 0; background: transparent; font: inherit; font-size: 0.8438rem; text-align: start; cursor: pointer; color: var(--ink);
  border-radius: 0.6875rem;
}
.chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-when { flex: none; font-size: 0.6875rem; color: #a09b92; }
.chat-actions { display: none; flex: none; gap: 0.125rem; padding-inline-end: 0.25rem; }
.chat-row:hover .chat-actions, .chat-row:focus-within .chat-actions { display: flex; }
.chat-row:hover .chat-when, .chat-row:focus-within .chat-when { display: none; }
.chat-act {
  width: 1.75rem; height: 1.75rem; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 0.5rem; background: transparent; color: #8d8a83; cursor: pointer;
}
.chat-act:hover { background: #e4e0d7; color: var(--ink); }
.chat-act.danger:hover { background: #f7dfd8; color: #a3402a; }
.chat-rename {
  flex: 1; margin: 0.25rem 0.375rem; padding: 0.375rem 0.625rem; font: inherit; font-size: 0.8438rem;
  border: 1px solid #a94d31; border-radius: 0.5625rem; outline: none; box-shadow: 0 0 0 0.1875rem #b8634226; background: #fff;
}
.chat-row.confirming { flex-wrap: wrap; padding: 0.5rem 0.75rem; gap: 0.5rem; background: #fbeeea; }
.chat-confirm-text { flex: 1 1 100%; font-size: 0.8125rem; color: #7a3524; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-confirm { padding: 0.375rem 0.875rem; border-radius: 0.5625rem; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 0.7812rem; cursor: pointer; }
.chat-confirm.yes { background: #b3402a; border-color: #b3402a; color: #fff; }
.chat-confirm.yes:hover { background: #9a3623; }
.history-drawer :focus-visible { outline: 0.125rem solid #a94d3199; outline-offset: 1px; }
@media (max-width: 740px) {
  .top-actions { top: 0.75rem; right: 0.75rem; }
  .history-drawer { width: min(21.25rem, 92vw); }
}
@media (prefers-reduced-motion: reduce) { .history-drawer, .history-backdrop { transition: none; } }
.history-search input:focus-visible { outline: none; }
.chat-confirm { color: var(--ink); }
.chat-confirm.yes { color: #fff; }
.chat-confirm:hover { background: #f3f1eb; }
.chat-confirm.yes:hover { background: #9a3623; }

/* ── Exam page navigator ────────────────────────────────── */
.page-stage { outline: none; scroll-behavior: smooth; padding-bottom: 4rem; }
.page-stage:focus-visible { box-shadow: inset 0 0 0 0.125rem #a94d3166; }
.page-stage img { transition: opacity 0.2s ease; }
.page-stage img.turning { opacity: 0.35; }
/* A question image shorter than the pane sits in its middle; a taller one starts at the top and scrolls.
   The top padding keeps the corner buttons off the question. */
.page-stage { display: flex; flex-direction: column; padding-top: 3.25rem; }
.page-stage > img { margin-block: auto; flex: none; }
.page-stage > .page-empty { flex: 1; height: auto; }
.page-nav {
  position: absolute;
  inset-inline: 0;
  bottom: 1.375rem;
  margin-inline: auto;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.25rem;
  background: #fffffff0;
  backdrop-filter: blur(0.625rem);
  border: 1px solid var(--line);
  border-radius: 62.4375rem;
  box-shadow: 0 0.375rem 1.375rem #302c2420, 0 1px 0.1875rem #302c240d;
  animation: nav-in 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.page-nav[hidden] { display: none; }
@keyframes nav-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }
.pn-btn {
  width: 2.125rem; height: 2.125rem; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #5d5a54; cursor: pointer;
}
.pn-btn:hover:not(:disabled) { background: #f3ebe7; color: var(--green); }
.pn-btn:disabled { opacity: 0.3; cursor: default; }
.pn-pos { min-width: 6rem; text-align: center; font-size: 0.8125rem; color: #4a4742; font-variant-numeric: tabular-nums; padding: 0 0.375rem; user-select: none; }
.pn-sep { width: 1px; height: 1.125rem; background: var(--line); margin: 0 0.25rem; }
.pn-chip {
  border: 0; border-radius: 62.4375rem; padding: 0.375rem 0.75rem; margin-inline: 0.125rem;
  background: #f8ece7; color: var(--green); font: inherit; font-size: 0.75rem; cursor: pointer; white-space: nowrap;
}
.pn-chip:hover { background: #f3dcd2; }
.pn-chip[hidden], .pn-btn[hidden] { display: none; }
.page-log {
  position: absolute; bottom: calc(100% + 0.625rem); inset-inline-start: 0;
  margin: 0; padding: 0.3125rem; list-style: none; min-width: 15rem; max-height: 16.25rem; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 0.875rem;
  box-shadow: 0 0.875rem 2.5rem #302c2426; animation: dd-in-up 0.16s cubic-bezier(0.2, 0.8, 0.3, 1); transform-origin: bottom;
}
.page-log[hidden] { display: none; }
.pl-item {
  width: 100%; display: flex; justify-content: space-between; gap: 0.875rem; align-items: baseline;
  padding: 0.5rem 0.75rem; border: 0; border-radius: 0.5625rem; background: transparent; font: inherit; font-size: 0.8125rem;
  color: #4a4742; text-align: start; cursor: pointer; white-space: nowrap;
}
.pl-item:hover { background: #f3f1eb; }
.pl-item[aria-current="true"] { color: var(--green); font-weight: 600; }
.pl-page { color: #9a968e; font-size: 0.75rem; font-weight: 400; }
.pn-btn:focus-visible, .pn-chip:focus-visible, .pl-item:focus-visible { outline: 0.125rem solid #a94d3199; outline-offset: 1px; }
@media (max-width: 740px) {
  .page-nav { bottom: 0.875rem; }
  .pn-pos { min-width: 5.25rem; font-size: 0.75rem; }
  .pn-chip { padding: 0.375rem 0.625rem; }
}
@media (prefers-reduced-motion: reduce) { .page-nav, .page-log { animation: none; } .page-stage { scroll-behavior: auto; } .page-stage img { transition: none; } }

/* ── Collection view: every question of a type, in the side pane ── */
.collection { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid #dcd8cf; border-radius: 0.5rem; background: #e8e5de; overflow: hidden; animation: co-in 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }
.collection[hidden] { display: none; }
@keyframes co-in { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }
.image-pane.show-collection .page-stage,
.image-pane.show-collection .page-nav,
.image-pane.show-collection .page-chrome { display: none; }

/* ── Figure view: what the tutor drew (graphs, geometry), in the side pane ── */
.figure {
  --fg-surface: #ffffff; --fg-ink: #302b27; --fg-soft: #66635d; --fg-grid: #ebe8e1; --fg-axis: #55524c;
  --fg-accent: #94422a; --fg-s1: #2a78d6; --fg-s2: #d95926; --fg-s3: #12906a; --fg-s4: #b07a00; --fg-s5: #d55181;
  flex: 1; min-height: 0; display: flex; flex-direction: column; border: 1px solid #dcd8cf; border-radius: 0.5rem;
  background: var(--fg-surface); overflow: hidden; animation: co-in 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.figure[hidden] { display: none; }
.image-pane.show-figure .page-stage,
.image-pane.show-figure .page-nav,
.image-pane.show-figure .page-chrome { display: none; }
.fg-body { flex: 1; min-height: 0; overflow: auto; padding: 0.75rem 0.75rem 1.125rem; display: flex; flex-direction: column; justify-content: safe center; gap: 0.625rem; outline: none; }
.fg-body:focus-visible { box-shadow: inset 0 0 0 0.125rem var(--focus); }
.fg-canvas { position: relative; flex: none; min-width: 0; direction: ltr; }
.fg-svg { display: block; margin-inline: auto; max-width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.fg-grid { stroke: var(--fg-grid); stroke-width: 1; }
.fg-axis { stroke: var(--fg-axis); stroke-width: 1.2; }
.fg-arrow { fill: var(--fg-axis); }
.fg-tick, .fg-name, .fg-label { font-family: KaTeX_Main, "Times New Roman", "Noto Sans Hebrew", serif; fill: var(--fg-soft); font-size: 0.7812rem;
  paint-order: stroke; stroke: var(--fg-surface); stroke-width: 0.2188rem; stroke-linejoin: round; }
.fg-name { font-style: italic; font-size: 0.875rem; fill: var(--fg-axis); }
.fg-label { fill: var(--fg-ink); font-size: 0.9688rem; }
.fg-label.small { font-size: 0.8438rem; }
.fg-label.free { font-size: 0.875rem; }
.fg-curve { fill: none; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.fg-curve.dashed, .fg-shape.dashed { stroke-dasharray: 7 5; }
.fg-s1 { stroke: var(--fg-s1); } .fg-s2 { stroke: var(--fg-s2); } .fg-s3 { stroke: var(--fg-s3); }
.fg-s4 { stroke: var(--fg-s4); } .fg-s5 { stroke: var(--fg-s5); }
.fg-shape { fill: none; stroke: var(--fg-ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fg-shape.fill { fill: color-mix(in srgb, var(--fg-accent) 13%, transparent); }
.fg-area { fill: color-mix(in srgb, var(--fg-accent) 22%, transparent); stroke: none; }
.fg-head { fill: var(--fg-ink); }
.fg-angle { fill: none; stroke: var(--fg-accent); stroke-width: 1.5; }
.fg-point { fill: var(--fg-ink); stroke: var(--fg-surface); stroke-width: 2; }
.fg-hair { stroke: var(--fg-soft); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.7; }
.fg-probe { fill: var(--fg-surface); stroke: var(--fg-soft); stroke-width: 2; }
.fg-probe.fg-s1 { stroke: var(--fg-s1); } .fg-probe.fg-s2 { stroke: var(--fg-s2); } .fg-probe.fg-s3 { stroke: var(--fg-s3); }
.fg-probe.fg-s4 { stroke: var(--fg-s4); } .fg-probe.fg-s5 { stroke: var(--fg-s5); }
.fg-read { position: absolute; top: 0.125rem; right: 0.25rem; padding: 0.1875rem 0.5625rem; border-radius: 62.4375rem; background: var(--fg-surface);
  border: 1px solid var(--line); color: var(--fg-ink); font-size: 0.7812rem; font-variant-numeric: tabular-nums; direction: ltr; pointer-events: none; }
.fg-read[hidden] { display: none; }
.fg-legend { list-style: none; margin: 0; padding: 0 0.25rem; display: flex; flex-wrap: wrap; gap: 0.375rem 1.125rem; justify-content: center; direction: ltr; }
.fg-legend[hidden], .fg-note[hidden] { display: none; }
.fg-legend li { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--fg-ink); font-size: 0.875rem; }
.fg-legend svg { flex: none; }
.fg-legend .fg-curve { stroke-width: 2.6; }
.fg-legend code { font-size: 0.8125rem; }
.fg-note { margin: 0; text-align: center; color: var(--fg-soft); font-size: 0.8125rem; line-height: 1.5; }
/* The formula sheet in the figure's place: the printed page, and a loop around each formula the tutor named. */
/* Left to right, so that a pane narrower than the page scrolls sideways to all of it. */
.figure.is-sheet .fg-body { justify-content: flex-start; direction: ltr; }
.figure.is-sheet .fg-canvas { width: max-content; align-self: safe center; }
.fg-sheet { position: relative; flex: none; }
.fg-sheet img, .fg-marks { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fg-sheet img { user-select: none; -webkit-user-select: none; }
.fg-marks { overflow: visible; pointer-events: none; }
.fg-mark { fill: color-mix(in srgb, var(--fg-accent) 11%, transparent); stroke: var(--fg-accent); stroke-width: 2.4;
  vector-effect: non-scaling-stroke; stroke-linejoin: round; animation: fg-mark-in 0.9s ease-out 0.15s both; }
@keyframes fg-mark-in { from { opacity: 0; stroke-width: 7; } to { opacity: 1; stroke-width: 2.4; } }
@media (prefers-reduced-motion: reduce) { .fg-mark { animation: none; } }
@media (prefers-reduced-motion: reduce) { .figure { animation: none; } }
.co-head { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; padding: 0.625rem 0.75rem; padding-inline-end: 3.75rem; background: #fffffff2; border-bottom: 1px solid var(--line); flex: none; }
.co-titles { display: flex; flex-direction: column; min-width: 0; }
.co-titles strong { font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-titles small { color: var(--muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.co-actions { display: flex; gap: 0.375rem; flex: none; }
.co-btn { border: 1px solid var(--line); background: #fff; color: #4a4742; border-radius: 62.4375rem; padding: 0.375rem 0.75rem; font: inherit; font-size: 0.7812rem; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.co-btn:hover { background: #f8ece7; color: var(--green); border-color: #e7c9bd; }
.co-btn[hidden] { display: none; }
.co-list { flex: 1; min-height: 0; overflow: auto; padding: 0.75rem 0.75rem 4.375rem; display: flex; flex-direction: column; gap: 0.875rem; outline: none; scroll-behavior: smooth; }
.co-list:focus-visible { box-shadow: inset 0 0 0 0.125rem #a94d3166; }
.co-card { background: #fff; border-radius: 0.5rem; box-shadow: 0 0.125rem 0.875rem #2630200d; overflow: hidden; flex: none; }
.co-card-head { display: flex; align-items: center; gap: 0.625rem; padding: 0.5625rem 0.75rem; border-bottom: 1px solid #f0ede7; }
.co-num { width: 1.625rem; height: 1.625rem; flex: none; border-radius: 50%; background: #f8ece7; color: var(--green); display: grid; place-items: center; font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.co-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.co-info strong { font-size: 0.8438rem; }
.co-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.co-chip { font-size: 0.6875rem; line-height: 1; padding: 0.1875rem 0.4375rem; border-radius: 62.4375rem; background: #f0ede7; color: #5d5a54; }
.co-chip.accent { background: #f8ece7; color: var(--green); }
.co-open { flex: none; border: 0; border-radius: 62.4375rem; padding: 0.4375rem 0.75rem; background: var(--green); color: #fff; font: inherit; font-size: 0.7812rem; cursor: pointer; transition: filter 0.15s, transform 0.1s; }
.co-open:hover { filter: brightness(1.08); }
.co-open:active { transform: scale(0.97); }
.co-card img { display: block; width: 100%; height: auto; min-height: 10rem; background: #fafaf8; }
.co-more { align-self: center; border: 1px dashed #cfc9bd; background: #fffffff0; color: var(--green); border-radius: 62.4375rem; padding: 0.5625rem 1.125rem; font: inherit; font-size: 0.8125rem; cursor: pointer; }
.co-more:hover { background: #f8ece7; }
.co-note { margin: 0.25rem 0.5rem 0; text-align: center; font-size: 0.7812rem; color: var(--muted); }
.co-btn:focus-visible, .co-open:focus-visible, .co-more:focus-visible { outline: 0.125rem solid #a94d3199; outline-offset: 0.125rem; }
@media (max-width: 700px) { .co-card-head { flex-wrap: wrap; } .co-open { margin-inline-start: auto; } }
@media (prefers-reduced-motion: reduce) { .collection { animation: none; } .co-list { scroll-behavior: auto; } }
.co-section { margin: 0.5rem 0.25rem 0; font-size: 0.8125rem; font-weight: 600; color: var(--green); display: flex; align-items: center; gap: 0.5rem; }
.co-section::after { content: ""; flex: 1; height: 1px; background: #d9d3c7; }
.co-section:first-child { margin-top: 0; }

/* ── Chat history additions (owned by chats.js: second line, touch actions, export/import, reset confirm) ── */
.chat-main { align-items: center; }
.chat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.chat-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.7188rem; color: #8d8a83; }
.chat-sub.match { color: #7a5a4c; }
.history-tools { display: flex; gap: 0.25rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.history-tool {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.4375rem;
  padding: 0.5625rem 0.625rem; border: 0; border-radius: 0.625rem; background: transparent;
  font: inherit; font-size: 0.8125rem; color: var(--muted); cursor: pointer;
}
.history-tool::before {
  content: ""; width: 0.9375rem; height: 0.9375rem; flex: none; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.history-tool:first-child { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 11l5 5 5-5M5 20h14'/%3E%3C/svg%3E"); }
.history-tool:nth-child(2) { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V5M7 9l5-5 5 5M5 20h14'/%3E%3C/svg%3E"); }
.history-tool:hover { background: var(--light); color: var(--ink); }
.history-list { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.history-list::-webkit-scrollbar { width: 0.5rem; }
.history-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 0.5rem; }
.history-list::-webkit-scrollbar-button { display: none; }
@media (hover: none), (pointer: coarse) {
  /* No hover on touch screens: keep rename and delete visible, with finger-sized targets. */
  .chat-actions { display: flex; }
  .chat-row .chat-when { display: none; }
  .chat-act { width: max(44px, 2.75rem); height: max(44px, 2.75rem); }
  .history-tool { padding: 0.75rem 0.625rem; }
  .history-search input, .chat-rename { font-size: max(16px, 1rem); } /* 16px keeps iOS from zooming in on focus */
}
.reset-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.625rem; padding: 0.625rem 0.75rem; border-radius: 0.6875rem; background: color-mix(in srgb, var(--green) 14%, transparent); }
.reset-confirm .chat-confirm-text { white-space: normal; }

/* ══ Stream D: layout, page viewer, collection, a11y, dark mode, print ══════════════════════════════ */
:root {
  --green: #94422a; /* the accent, a touch darker: 5:1 on white, so it passes as text and under white text */
  --orange: #94422a;
  --muted: #66635d; /* secondary text, 5.6:1 on the page background */
  --bg: #faf9f5;
  --top-h: 4rem; /* room for the fixed top bar */
  --focus: #94422a;
}
body { background: var(--bg); }

/* Top bar: history, new chat and settings sit together (top right in RTL); the exam toggle top left. */
.top-actions .settings-btn { position: static; }

/* Focus rings: one solid ring, visible on every surface. */
.panel-toggle:focus-visible, .dd-btn:focus-visible, .pn-btn:focus-visible, .pn-chip:focus-visible, .pl-item:focus-visible,
.co-btn:focus-visible, .co-open:focus-visible, .co-more:focus-visible, .history-drawer :focus-visible, .sd-close:focus-visible,
.scope-select:focus-visible, .starter:focus-visible, .zm-btn:focus-visible, .co-remove:focus-visible, .co-link:focus-visible {
  outline: 0.125rem solid var(--focus);
  outline-offset: 0.125rem;
}
.page-stage:focus-visible, .co-list:focus-visible { box-shadow: inset 0 0 0 0.125rem var(--focus); }
.composer:focus-within { border-color: #9d958a; }

/* Readable small text (WCAG AA): nothing under 12px, secondary gray at >= 4.5:1. */
.eyebrow, .message-label, .source-chip, .slider-labels, .mapping, .card-meta, .page-empty small, .co-chip,
.history-group, .chat-when, .settings-dialog .slider-labels, .settings-dialog .mapping { font-size: 0.75rem; }
.usage { color: var(--muted); font-size: 0.75rem; }
.eyebrow, .settings-fields small, .page-empty, .history-group, .chat-when, .pl-page, .sd-fine, input::placeholder,
textarea::placeholder { color: var(--muted); }
.sd-fine { font-size: 0.75rem; }
.key-notice { font-size: 0.75rem; }
.math-button, .model-button, .scope-select, .dd-btn, .starter { color: #57544e; }

/* Wide display equations scroll sideways; a soft shadow at the edge says there is more. */
.content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.375rem 0.125rem;
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left center / 1.75rem 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right center / 1.75rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, #302c2430, transparent) left center / 0.75rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, #302c2430, transparent) right center / 0.75rem 100% no-repeat scroll;
}
/* Hebrew words inside math (a numerator like "דרך", a unit like קמ"ש) are taller than KaTeX's Latin metrics. */
.content .katex { line-height: 1.35; }
.content .katex .vlist-t2 > .vlist-r:first-child, .content .katex .vlist { overflow: visible; }

/* Page viewer: the page is clickable (opens the zoom view). */
#exam-page { cursor: zoom-in; }
.page-chrome { gap: 0.5rem; }
.page-zoom { padding: 0; border: 1px solid #d5dbc8; cursor: pointer; }
.page-zoom:hover { filter: none; background: #fff; }
.toggle-text { white-space: nowrap; }

/* Collection cards: clear label, every page, done and remove. */
.co-card-head { align-items: flex-start; }
.co-info strong { font-size: 0.875rem; line-height: 1.45; }
.co-subject { font-size: 0.7812rem; color: var(--muted); line-height: 1.4; }
.co-chip { line-height: 1.2; padding: 0.1875rem 0.5rem; color: #4f4c46; }
.co-card-actions { display: flex; align-items: center; gap: 0.375rem; flex: none; }
.co-done { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.7812rem; color: #4f4c46; cursor: pointer; padding: 0.375rem 0.5rem; border-radius: 62.4375rem; user-select: none; }
.co-done:hover { background: #f3f1eb; }
.co-done input { width: 1.0625rem; height: 1.0625rem; margin: 0; accent-color: var(--green); cursor: pointer; }
.co-remove { width: 2rem; height: 2rem; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.co-remove:hover { background: #f7dfd8; color: #9a3623; filter: none; }
.co-card img { cursor: zoom-in; }
.co-card img.co-cont { border-top: 0.125rem dashed #e3ddd2; }
.co-card.done .co-num { background: #e6efe3; color: #3f6b3a; }
.co-card.done .co-num::before { content: "✓"; }
.co-card.done .co-num { font-size: 0; }
.co-card.done .co-num::before { font-size: 0.875rem; }
.co-card.done img { opacity: 0.55; }
.co-card.done .co-info strong { color: var(--muted); }
.co-bar { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.4375rem 0.75rem; background: #fbf4ef; border-bottom: 1px solid #ecd9cf; font-size: 0.8125rem; color: #4f4c46; flex: none; }
.co-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 0.625rem; min-width: 0; }
.co-bar-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-link { flex: none; background: transparent; border: 0; padding: 0.25rem 0.375rem; color: var(--green); font: inherit; font-size: 0.8125rem; font-weight: 600; text-decoration: underline; text-underline-offset: 0.1875rem; }
.co-link:hover { filter: none; color: #8a4530; }
@media (max-width: 700px) {
  .co-card-head { flex-wrap: wrap; }
  .co-card-actions { width: 100%; justify-content: flex-end; }
  .co-open { margin-inline-start: 0; }
}

/* ── Zoom view (a page, large) ─────────────────────────── */
.zoom {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: #1d1c1af2; color: #f3f1ec;
  display: none; flex-direction: column; overflow: hidden;
}
.zoom[open] { display: flex; animation: fade-in 0.18s ease-out; }
.zoom::backdrop { background: transparent; }
html.zoom-open, html.zoom-open body { overflow: hidden; }
.zm-top {
  flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: max(0.625rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.5rem max(1rem, env(safe-area-inset-left));
}
.zm-title { font-size: 0.9375rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zm-hint { font-size: 0.7812rem; color: #c9c5bd; white-space: nowrap; }
.zm-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
.zm-stage:active { cursor: grabbing; }
.zm-img { position: absolute; top: 0; left: 0; transform-origin: 0 0; max-width: none; background: #fff; box-shadow: 0 0.625rem 2.5rem #0006; border-radius: 0.125rem; }
.zm-bar {
  flex: none; align-self: center; display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; justify-content: center;
  margin: 0.5rem 0.75rem max(0.75rem, env(safe-area-inset-bottom)); padding: 0.3125rem;
  background: #fffffff2; color: #302b27; border-radius: 62.4375rem; box-shadow: 0 0.5rem 1.875rem #0005;
}
.zm-btn {
  width: 2.75rem; height: 2.75rem; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: #4a4742; text-decoration: none; cursor: pointer;
}
.zm-btn:hover:not(:disabled) { background: #f3ebe7; color: var(--green); filter: none; }
.zm-btn:disabled { opacity: 0.3; cursor: default; }
.zm-btn[hidden], .zm-pos[hidden], .zm-sep[hidden] { display: none; }
.zm-fit { width: auto; min-width: 4rem; padding: 0 0.625rem; border-radius: 62.4375rem; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.zm-close { background: var(--green); color: #fff; }
.zm-close:hover:not(:disabled) { background: #8a4530; color: #fff; }
.zm-pos { min-width: 5.75rem; text-align: center; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.zm-sep { width: 1px; height: 1.375rem; background: #ddd8cf; margin: 0 0.25rem; }
@media (max-width: 560px) {
  .zm-hint, .zm-link, .zm-sep { display: none !important; }
  .zm-bar { flex-wrap: nowrap; gap: 0; margin-inline: 0.5rem; }
  .zm-pos { min-width: 0; padding: 0 0.25rem; font-size: 0.7812rem; white-space: nowrap; }
  .zm-fit { min-width: 3.25rem; padding: 0 0.375rem; }
}
@media (prefers-reduced-motion: reduce) { .zoom[open] { animation: none; } }

/* ── Sheet mode: phones, small tablets, short or zoomed-in windows ──────────────────────────────
   The conversation and the message box get the whole screen. The exam pane, when open, is a sheet that
   covers the conversation only: it sits between the top bar and the message box, which stays usable
   (its height comes from pageview.js as --composer-h). Nothing ever covers the message box. */
@media (max-width: 1000px), (max-height: 520px) {
  .workspace, .workspace:not(.page-expanded) { display: flex; flex-direction: column; height: var(--app-h, 100dvh); }
  .tutor-pane { flex: 1; min-height: 0; padding-top: var(--top-h); }
  .learning-area { min-height: 0; }
  .composer-area { padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }
  .image-pane {
    position: fixed; z-index: 4; top: 0; inset-inline: 0;
    bottom: calc(var(--composer-h, 0px) + var(--keyboard-h, 0px));
    max-height: none; min-height: 0;
    padding: var(--top-h) max(0.625rem, env(safe-area-inset-right)) 0.375rem max(0.625rem, env(safe-area-inset-left));
    border: 0; border-bottom: 1px solid var(--line);
    box-shadow: 0 0.375rem 1.125rem #302c2414;
    animation: sheet-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
  }
  .image-pane .page-stage { display: flex; flex: 1; min-height: 0; max-height: none; padding-bottom: 3.75rem; }
  .page-chrome { position: absolute; top: calc(var(--top-h) + 0.5rem); inset-inline-start: 1.125rem; margin: 0; }
  .page-nav { bottom: 0.875rem; }
  /* The exam toggle says what it does, and appears only once there is a page or a worksheet to open. */
  html:not(.has-exam) #page-toggle { display: none; }
  #page-toggle { width: auto; display: inline-flex; align-items: center; gap: 0.25rem; padding: 0 0.75rem 0 0.5rem; }
  #page-toggle .toggle-text { display: inline; font-size: 0.875rem; color: var(--ink); }
  #page-toggle[aria-expanded="true"] { background: var(--green); border-color: var(--green); color: #fff; }
  #page-toggle[aria-expanded="true"] .toggle-text { color: #fff; }
  #page-toggle:hover .chev, #page-toggle[aria-expanded="true"]:hover .chev { transform: none; }
  #page-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
  .co-head { padding-inline-end: 0.75rem; flex-wrap: wrap; }
  .co-actions { flex-wrap: wrap; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(-0.625rem); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .image-pane { animation: none !important; } }
@media (max-width: 740px) {
  :root { --top-h: 3.875rem; }
  .page-chrome { inset-inline-start: 0.875rem; }
  .composer textarea { min-height: 2.875rem; height: 2.875rem; padding: 0.375rem 0.25rem; }
  .pn-pos { min-width: 0; }
}
/* Short screens (landscape phone, on-screen keyboard up, 200% zoom): a slimmer top bar and message box. */
@media (max-height: 600px) and (max-width: 740px) { .pv-home .welcome-mark { display: none; } }
@media (max-height: 520px) {
  :root { --top-h: 3.25rem; }
  .top-actions, .panel-toggle { top: 0.5rem; }
  #page-toggle { top: 0.5rem; left: 0.75rem; }
  .top-actions { right: 0.75rem; }
  .composer-area { padding: 0.375rem 1rem max(0.5rem, env(safe-area-inset-bottom)); }
  .composer { padding: 0.5rem 0.75rem; border-radius: 1rem; }
  .composer textarea { min-height: 2.5rem; height: 2.5rem; padding: 0.25rem; --pad-top: 0.25rem; }
  .key-notice { margin-top: 0.375rem; }
  .reply-waiting { padding-bottom: 0.375rem; }
  .page-nav { bottom: 0.5rem; }
  .image-pane .page-stage { padding-bottom: 3.25rem; }
}

/* The on-screen keyboard is up (html.keyboard-up, app.js): the page is only as tall as what is visible above it,
   and the message box with what is being written gets the room. Safari on iPhone and iPad does not shorten the
   screen for the keyboard, so the short-screen rules above do not reach it: the ones that matter are repeated. */
html.keyboard-up { --top-h: 3.25rem; }
html.keyboard-up .top-actions, html.keyboard-up .panel-toggle { top: 0.5rem; }
html.keyboard-up #page-toggle { top: 0.5rem; left: 0.75rem; }
html.keyboard-up .top-actions { right: 0.75rem; }
html.keyboard-up .tutor-pane { padding-top: var(--top-h); }
html.keyboard-up .tutor-pane:has(#welcome:not([hidden])) { justify-content: flex-end; padding-bottom: 0; }
html.keyboard-up .tutor-pane:has(#welcome:not([hidden])) .learning-area { display: none; } /* back when it closes */
html.keyboard-up .composer-area { padding: 0.375rem 0.75rem 0.375rem; }
html.keyboard-up .composer { padding: 0.5rem 0.75rem; border-radius: 1rem; }
html.keyboard-up .composer-input { --min-h: 2.5rem; --pad-top: 0.25rem; }
html.keyboard-up .key-notice { margin-top: 0.375rem; }
html.keyboard-up .learning-area { padding-block: 0.25rem; }
html.keyboard-up .fx { gap: 0.375rem; padding-top: 0.375rem; }
html.keyboard-up .fx-keys { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; }
html.keyboard-up .fx-key { flex: none; }

/* Message box toolbar on narrow screens: one row that scrolls sideways, with a fade at the far edge as a cue. */
@media (max-width: 740px), (max-height: 520px) {
  .composer-tools > div {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
    padding-inline-end: 1.75rem; margin-inline-end: 0.5rem;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 2.25rem);
    mask-image: linear-gradient(to right, transparent 0, #000 2.25rem);
  }
  .composer-tools > div::-webkit-scrollbar { display: none; }
  .composer-tools > div > * { flex: none; }
  /* The formula button shows just ƒx here; its name stays for screen readers and in the tooltip. */
  .composer-tools .math-button { font-size: 0; gap: 0; padding: 0 0.625rem; }
  .composer-tools .math-button span { font-size: 1.0625rem; }
}

/* Touch screens: every control at least 44px. */
@media (pointer: coarse) {
  .panel-toggle { width: max(44px, 2.75rem); height: max(44px, 2.75rem); }
  .composer-tools #send { width: max(44px, 2.75rem); height: max(44px, 2.75rem); }
  .composer-tools .math-button, .scope-select, .model-button, .dd-btn { height: max(44px, 2.75rem); min-width: max(44px, 2.75rem); }
  .composer-tools > div { gap: 0.375rem; }
  .pn-btn, .sd-close, .chat-act, .co-remove, .page-open { width: max(44px, 2.75rem); height: max(44px, 2.75rem); }
  .pn-chip, .co-btn, .co-open, .co-more, .co-link, .starter { min-height: max(44px, 2.75rem); }
  .co-done { min-height: max(44px, 2.75rem); }
  .co-done input { width: 1.375rem; height: 1.375rem; }
  .dd-item, .pl-item { min-height: max(44px, 2.75rem); }
  .chat-main { min-height: max(44px, 2.75rem); }
  .zm-bar { gap: 0.125rem; }
}
/* Chat rename / delete: with no hover (touch), always shown. */
@media (hover: none) {
  .chat-actions { display: flex; }
  .chat-row .chat-when { display: none; }
}

/* ── Print the conversation (the worksheet has its own print view) ── */
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000; }
  .workspace { display: block !important; height: auto !important; overflow: visible !important; }
  .tutor-pane { display: block !important; padding: 0 !important; overflow: visible !important; }
  .learning-area { overflow: visible !important; height: auto !important; padding: 0 !important; }
  .messages { max-width: none; }
  .message { animation: none !important; break-inside: avoid-page; }
  .composer-area, .image-pane, .top-actions, .panel-toggle, .history-drawer, .history-backdrop, .toast,
  .welcome, .reply-waiting, .zoom, .mp-overlay, dialog, .message button { display: none !important; }
  .content .katex-display { background: none; overflow: visible; }
}

/* ── Dark mode ─────────────────────────────────────────── */
/* dark theme */
:root[data-theme='dark'] {

    color-scheme: dark;
    --ink: #f3ece2;
    --muted: #c2b5a7;
    --paper: #2d2824;
    --line: #50453c;
    --green: #e59c7e;
    --orange: #e59c7e;
    --light: #302b27;
    --bg: #262320;
    --focus: #e59c7e;
}
:where(:root[data-theme='dark']) body, :where(:root[data-theme='dark']) .composer-area { background: var(--bg); }
:where(:root[data-theme='dark']) button { color: #fff; }
:where(:root[data-theme='dark']) button { background-color: #a94d31; } /* class rules (quiet, chips, icons) still win */
:where(:root[data-theme='dark']) .composer-tools #send, :where(:root[data-theme='dark']) .sd-primary, :where(:root[data-theme='dark']) .history-new, :where(:root[data-theme='dark']) .co-open { background: #a94d31; color: #fff; }
:where(:root[data-theme='dark']) .composer-tools #send:not(:disabled):hover, :where(:root[data-theme='dark']) .sd-primary:hover, :where(:root[data-theme='dark']) .history-new:hover { background: #b85c3e; }
:where(:root[data-theme='dark']) .composer, :where(:root[data-theme='dark']) .settings-dialog, :where(:root[data-theme='dark']) .sd-head, :where(:root[data-theme='dark']) .history-drawer, :where(:root[data-theme='dark']) .dd-list, :where(:root[data-theme='dark']) .page-log, :where(:root[data-theme='dark']) .sd-card { background: var(--paper); border-color: var(--line); }
:where(:root[data-theme='dark']) .settings-dialog, :where(:root[data-theme='dark']) .sd-head, :where(:root[data-theme='dark']) .history-drawer { background: #2a2622; }
:where(:root[data-theme='dark']) .composer:focus-within { border-color: #6a655c; }
:where(:root[data-theme='dark']) .message.user .content { background: #2e2c28; }
:where(:root[data-theme='dark']) .message.system, :where(:root[data-theme='dark']) .catalog-text .stem, :where(:root[data-theme='dark']) .mapping, :where(:root[data-theme='dark']) .settings-dialog .mapping, :where(:root[data-theme='dark']) .settings-dialog .price-grid > div, :where(:root[data-theme='dark']) .sd-field select, :where(:root[data-theme='dark']) .sd-field input[type="password"], :where(:root[data-theme='dark']) .sd-field input[type="number"], :where(:root[data-theme='dark']) .settings-dialog .filter-row input, :where(:root[data-theme='dark']) .history-search { background: #302b27; border-color: var(--line); color: var(--ink); }
:where(:root[data-theme='dark']) .message.system .content, :where(:root[data-theme='dark']) .sd-field, :where(:root[data-theme='dark']) .co-chip, :where(:root[data-theme='dark']) .co-done, :where(:root[data-theme='dark']) .co-bar, :where(:root[data-theme='dark']) .dd-item, :where(:root[data-theme='dark']) .pl-item, :where(:root[data-theme='dark']) .pn-pos { color: #d3cfc7; }
:where(:root[data-theme='dark']) .content pre, :where(:root[data-theme='dark']) .content code { background: #2e2c28; }
:where(:root[data-theme='dark']) .math-button, :where(:root[data-theme='dark']) .model-button, :where(:root[data-theme='dark']) .scope-select, :where(:root[data-theme='dark']) .dd-btn, :where(:root[data-theme='dark']) .starter, :where(:root[data-theme='dark']) .chat-act, :where(:root[data-theme='dark']) .pn-btn, :where(:root[data-theme='dark']) .sd-close { color: #cfcac1; }
:where(:root[data-theme='dark']) .quiet:hover, :where(:root[data-theme='dark']) .model-button:hover, :where(:root[data-theme='dark']) .scope-select:hover, :where(:root[data-theme='dark']) .starter:hover, :where(:root[data-theme='dark']) .dd-btn:hover, :where(:root[data-theme='dark']) .dd-item.active, :where(:root[data-theme='dark']) .pl-item:hover, :where(:root[data-theme='dark']) .chat-row:hover, :where(:root[data-theme='dark']) .chat-row:focus-within, :where(:root[data-theme='dark']) .chat-act:hover, :where(:root[data-theme='dark']) .sd-close:hover, :where(:root[data-theme='dark']) .pn-btn:hover:not(:disabled), :where(:root[data-theme='dark']) .co-done:hover { background: #3a332d; color: var(--ink); }
:where(:root[data-theme='dark']) .dd-btn[aria-expanded="true"], :where(:root[data-theme='dark']) .chat-row.current, :where(:root[data-theme='dark']) .pn-chip, :where(:root[data-theme='dark']) .co-num, :where(:root[data-theme='dark']) .co-chip.accent { background: #493129; color: #eaa98c; border-color: #7a4a36; }
:where(:root[data-theme='dark']) .panel-toggle, :where(:root[data-theme='dark']) .page-open, :where(:root[data-theme='dark']) .page-nav, :where(:root[data-theme='dark']) .co-head, :where(:root[data-theme='dark']) .co-btn { background: #302b27f2; border-color: var(--line); color: #d3cfc7; }
:where(:root[data-theme='dark']) .panel-toggle:hover { background: #3a332d; border-color: #7a4a36; }
:where(:root[data-theme='dark']) .toast { background: #ebe8e2; color: #1c1b19; }
:where(:root[data-theme='dark']) .image-pane { background: #2a2622; }
:where(:root[data-theme='dark']) .page-stage, :where(:root[data-theme='dark']) .collection { background: #231f1c; border-color: var(--line); }
:where(:root[data-theme='dark']) .figure {

    --fg-surface: #231f1c; --fg-ink: #ebe8e2; --fg-soft: #b2ada4; --fg-grid: #2c2b27; --fg-axis: #bdb8ae;
    --fg-accent: #e59c7e; --fg-s1: #3987e5; --fg-s2: #d95926; --fg-s3: #199e70; --fg-s4: #c98500; --fg-s5: #d55181;
    border-color: var(--line);
}
/* The formula sheet is black line art on nothing: in the dark it turns to light ink on the pane's own surface. */
:where(:root[data-theme='dark']) .fg-sheet img { filter: invert(1) brightness(0.92); }
/* Exam pages stay paper-white (they are scans) but a little dimmer, so they do not glare at night. */
:where(:root[data-theme='dark']) .page-stage img, :where(:root[data-theme='dark']) .co-card img { filter: brightness(0.86) contrast(1.05); }
:where(:root[data-theme='dark']) .co-card { background: #2d2824; box-shadow: none; }
:where(:root[data-theme='dark']) .co-card-head { border-bottom-color: var(--line); }
:where(:root[data-theme='dark']) .co-chip { background: #3a332d; }
:where(:root[data-theme='dark']) .co-card.done .co-num { background: #26382a; color: #9fd09a; }
:where(:root[data-theme='dark']) .co-bar { background: #2f2622; border-color: #5a3a2e; }
:where(:root[data-theme='dark']) .co-link { color: #eaa98c; }
:where(:root[data-theme='dark']) .co-more { background: #2d2824; border-color: #55524b; }
:where(:root[data-theme='dark']) .co-section::after { background: var(--line); }
:where(:root[data-theme='dark']) .notice:not(:empty) { background: #3a2520; color: #f0b3a3; }
:where(:root[data-theme='dark']) .history-backdrop.open, :where(:root[data-theme='dark']) dialog::backdrop, :where(:root[data-theme='dark']) .mp-overlay.open { background: #0008; }
:where(:root[data-theme='dark']) .chat-confirm { background: #302b27; color: var(--ink); }
:where(:root[data-theme='dark']) .chat-row.confirming { background: #3a2520; }
:where(:root[data-theme='dark']) .chat-confirm-text { color: #f0b3a3; }
:where(:root[data-theme='dark']) ::-webkit-scrollbar-thumb { background: #4a4740; background-clip: content-box; }
:where(:root[data-theme='dark']) * { scrollbar-color: #4a4740 transparent; }
:where(:root[data-theme='dark']) .waiting-dots i { background: var(--green); }
:where(:root[data-theme='dark']) .zm-bar { background: #302b27f2; color: var(--ink); }
:where(:root[data-theme='dark']) .zm-btn { color: #d3cfc7; }
:where(:root[data-theme='dark']) .zm-btn:hover:not(:disabled) { background: #3a332d; color: #eaa98c; }
:where(:root[data-theme='dark']) .zm-close { background: #a94d31; color: #fff; }
:where(:root[data-theme='dark']) .zm-sep { background: var(--line); }
:where(:root[data-theme='dark']) .welcome-mark { color: #e59c7e; }
:where(:root[data-theme='dark']) .katex { color: var(--ink); }
@media (max-width: 1000px), (max-height: 520px) {
  :where(:root[data-theme='dark']) #page-toggle[aria-expanded="true"] { background: #a94d31; border-color: #a94d31; }
}
/* ══ end of Stream D ════════════════════════════════════════════════════════════════════════════ */

/* ══ Stream C: composer and messages (stop button, counter, message actions) ═══════════════════════ */
.composer-tools #send { user-select: none; -webkit-user-select: none; }
.composer-tools #send.stop { background: var(--ink); color: var(--paper); cursor: pointer; }
.composer-tools #send.stop:hover { background: #000; }
.char-count { margin: 0 0.375rem 0.25rem; font-size: 0.75rem; color: var(--muted); }
.char-count.over { color: #9a4a35; font-weight: 600; }
.message-actions { display: flex; gap: 0.375rem; margin-top: 0.375rem; }
.message-actions:empty { display: none; }
.msg-act {
  font: inherit; font-size: 0.75rem; line-height: 1.4; padding: 0.1875rem 0.625rem; border-radius: 62.4375rem;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer;
}
.msg-act:hover { color: var(--ink); border-color: #cfcac0; }
.msg-act:focus-visible { outline: 0.125rem solid #b7afa1; outline-offset: 1px; }
.msg-act.retry { color: var(--green); border-color: currentColor; font-weight: 600; }
.msg-act.retry:hover { background: #fbf1ed; color: var(--green); }
.message .content .math-inline, .message .content .ltr-run { unicode-bidi: isolate; }
.usage-toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.7812rem; color: var(--muted); margin: 0.5rem 0; cursor: pointer; }
/* dark theme */
:where(:root[data-theme='dark']) .composer-tools #send.stop { background: #e9e5dc; color: #1f1e1b; }
:where(:root[data-theme='dark']) .composer-tools #send.stop:hover { background: #fff; }
:where(:root[data-theme='dark']) .msg-act:hover { border-color: #5a564e; }
:where(:root[data-theme='dark']) .msg-act.retry:hover { background: #3a2520; }
:where(:root[data-theme='dark']) .char-count.over { color: #eaa98c; }
/* ══ end of Stream C ═══════════════════════════════════════════════════════════════════════════════ */

/* ══ Settings dialog: flat sections with dividers; owner options collapsed under "הגדרות מתקדמות" ══════════ */
.settings-dialog { width: min(30rem, calc(100% - 1.5rem)); }
.sd-head { padding: 1rem 1.375rem 0.875rem; }
.sd-head h2 { margin: 0; font-size: 1.125rem; font-weight: 600; }
.sd-body { padding: 0 1.375rem 0.875rem; gap: 0; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.sd-body::-webkit-scrollbar { width: 0.5rem; }
.sd-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 0.5rem; }
.sd-body::-webkit-scrollbar-button { display: none; }
.sd-sec { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.25rem 0; border-bottom: 1px solid var(--line); }
.sd-sec h3 { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--ink); }
.sd-hint { margin: 0; font-size: 0.8125rem; line-height: 1.65; color: var(--muted); }
.settings-dialog .sd-field { gap: 0.4375rem; font-size: 0.8438rem; color: var(--ink); }
.settings-dialog .sd-row { align-items: center; }
.settings-dialog .sd-row output {
  font-size: 0.7812rem; font-weight: 600; color: var(--green);
  background: color-mix(in srgb, var(--green) 13%, transparent); border-radius: 62.4375rem; padding: 0.1875rem 0.6875rem;
}
.settings-dialog input[type="range"] { accent-color: var(--green); margin: 0.25rem 0 0; }
.settings-dialog .slider-labels { margin-top: 0; font-size: 0.7812rem; color: var(--muted); }
.sd-advanced > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 1rem 0 0.75rem; font-size: 0.875rem; color: var(--muted); cursor: pointer; list-style: none; border-radius: 0.5rem;
}
.sd-advanced > summary::-webkit-details-marker { display: none; }
.sd-advanced > summary::after {
  content: ""; width: 0.4375rem; height: 0.4375rem; margin-inline-end: 0.25rem;
  border: solid currentColor; border-width: 0 0.1125rem 0.1125rem 0; transform: rotate(45deg); transition: transform 0.15s;
}
.sd-advanced[open] > summary::after { transform: rotate(-135deg); }
.sd-advanced > summary:hover { color: var(--ink); }
.sd-advanced > summary:focus-visible { outline: 0.125rem solid var(--green); outline-offset: 0.125rem; }
.sd-adv-body { display: flex; flex-direction: column; gap: 1.625rem; padding: 0.375rem 0 0.5rem; }
.sd-group { display: flex; flex-direction: column; gap: 0.6875rem; }
.sd-group h4 { margin: 0; font-size: 0.7812rem; font-weight: 600; color: var(--muted); }
.settings-dialog .mapping { margin: 0; padding: 0.5rem 0.6875rem; font-size: 0.75rem; background: var(--light); color: var(--muted); border-radius: 0.5rem; overflow-wrap: anywhere; }
.settings-dialog .price-grid { gap: 0.5rem; }
.settings-dialog .price-grid > div { border: 0; background: var(--light); padding: 0.625rem 0.75rem; font-size: 0.7812rem; }
.settings-dialog .price-grid strong { margin-top: 0.1875rem; font-size: 1rem; font-weight: 600; color: var(--ink); }
.settings-dialog .session-panel-row { font-size: 0.8438rem; }
.settings-dialog .usage-toggle { margin: 0.125rem 0; font-size: 0.8438rem; color: var(--ink); }
@media (max-width: 560px) { .sd-body { padding: 0 1rem 0.75rem; } .sd-head { padding: 0.875rem 1rem 0.75rem; } }
@media (prefers-reduced-motion: reduce) { .sd-advanced > summary::after { transition: none; } }
/* ══ end of settings dialog ═════════════════════════════════════════════════════════════════════════ */

/* ══ Formula panel inside the message box: field, symbol tabs, symbol keys ════════════════════════════ */
.fx { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.25rem; padding: 0.625rem 0 0.125rem; border-top: 1px solid var(--line); }
.fx[hidden] { display: none; }
.fx-field {
  display: flex; align-items: center; gap: 0.75rem; min-height: 2.875rem; padding: 0.25rem 0.875rem 0.25rem 0.3125rem;
  border: 1px solid var(--line); border-radius: 0.75rem; background: color-mix(in srgb, var(--ink) 3%, transparent);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fx-field:focus-within { border-color: color-mix(in srgb, var(--green) 60%, var(--line)); box-shadow: 0 0 0 0.1875rem color-mix(in srgb, var(--green) 14%, transparent); }
.fx-input {
  order: 1; flex: 1; min-width: 0; display: block; padding: 0.25rem 0; border: 0; outline: 0; background: transparent; color: var(--ink);
  font-size: 1.1875rem; --caret-color: var(--green); --selection-background-color: color-mix(in srgb, var(--green) 24%, transparent);
  --selection-color: var(--ink); --contains-highlight-background-color: transparent; --placeholder-color: var(--muted);
  --smart-fence-color: var(--ink);
}
.fx-input:focus, .fx-input:focus-within { outline: 0; }
.fx-input::part(virtual-keyboard-toggle), .fx-input::part(menu-toggle) { display: none; }
.fx-insert {
  order: 0; flex: none; height: 2.125rem; padding: 0 1rem; border: 0; border-radius: 0.5625rem; cursor: pointer;
  background: var(--green); color: #fff; font: inherit; font-size: 0.8438rem;
}
.fx-insert:hover { filter: brightness(1.07); }
.fx-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.fx-tabs { display: flex; gap: 0.125rem; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.fx-tabs::-webkit-scrollbar { display: none; }
.fx-tab {
  flex: none; padding: 0.3125rem 0.6875rem; border: 0; border-radius: 62.4375rem; background: transparent; cursor: pointer;
  font: inherit; font-size: 0.8125rem; color: var(--muted);
}
.fx-tab:hover { color: var(--ink); }
.fx-tab[aria-selected="true"] { background: var(--light); color: var(--ink); }
.fx-close {
  flex: none; width: 1.75rem; height: 1.75rem; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 0.8125rem; cursor: pointer;
}
.fx-close:hover { background: var(--light); color: var(--ink); }
.fx-keys { display: flex; flex-wrap: wrap; gap: 0.375rem; max-height: 5.125rem; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.fx-key {
  flex: none; min-width: 2.5rem; height: 2.375rem; padding: 0 0.5625rem; display: grid; place-items: center; direction: ltr;
  border: 1px solid var(--line); border-radius: 0.625rem; background: transparent; color: var(--ink); cursor: pointer;
  font-size: 0.9375rem; line-height: 1; transition: background-color 0.12s, border-color 0.12s, transform 0.08s;
}
.fx-key:hover { background: var(--light); border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.fx-key:active { transform: scale(0.95); }
.fx-key .katex { font-size: 1em; }
.fx-key .amsrm { opacity: 0.55; font-size: 0.82em; } /* the empty-slot squares */
.fx-key:has(.mfrac) .katex { font-size: 0.74em; } /* fractions and binomials are two lines tall */
.fx-tab:focus-visible, .fx-key:focus-visible, .fx-close:focus-visible, .fx-insert:focus-visible { outline: 0.125rem solid var(--green); outline-offset: 1px; }
.math-button[aria-expanded="true"] { background: var(--light); color: var(--ink); }
@media (hover: none), (pointer: coarse) {
  .fx-key { min-width: max(44px, 2.75rem); height: max(44px, 2.75rem); } .fx-keys { max-height: 5.875rem; } .fx-close { width: max(40px, 2.5rem); height: max(40px, 2.5rem); }
  .fx-insert { height: max(40px, 2.5rem); } .fx-tab { padding: 0.5625rem 0.75rem; }
}
@media (prefers-reduced-motion: reduce) { .fx-key, .fx-field { transition: none; } }
@media (hover: none) { .fx-key:hover { background: transparent; border-color: var(--line); } } /* no stuck hover after a tap */
/* dark theme */
:where(:root[data-theme='dark']) .fx-insert { background: #a94d31; }
@media print { .fx { display: none !important; } }
/* ══ end of formula panel ═════════════════════════════════════════════════════════════════════ */
.toast { cursor: pointer; } /* a click dismisses it */

/* ── Guide ──────────────────────────────────────────────── */
.guide-dialog { width: min(47.5rem, calc(100% - 1.5rem)); max-height: min(88dvh, 53.75rem); }
.guide-dialog .sd-body { padding: 1.125rem 1.375rem 1.375rem; gap: 0; }
.gd-lead { margin: 0 0 1rem; font-size: 0.9062rem; line-height: 1.7; color: var(--ink); }
.gd-sec { border-top: 1px solid var(--line); padding: 0.25rem 0 0.125rem; }
.gd-sec > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 0; cursor: pointer; list-style: none;
  font-size: 0.9375rem; font-weight: 600; color: var(--ink);
}
.gd-sec > summary::-webkit-details-marker { display: none; }
.gd-sec > summary::after {
  content: ""; width: 0.4375rem; height: 0.4375rem; flex: none; margin-inline-end: 0.25rem;
  border-right: 0.125rem solid var(--muted); border-bottom: 0.125rem solid var(--muted);
  transform: rotate(45deg); transition: transform 0.15s ease;
}
.gd-sec[open] > summary::after { transform: rotate(-135deg); }
.gd-sec > summary:focus-visible { outline: 0.125rem solid var(--green); outline-offset: 0.125rem; border-radius: 0.375rem; }
.gd-sec > :not(summary) { margin-bottom: 0.875rem; }
.gd-asks { margin: 0; display: grid; grid-template-columns: minmax(7.5rem, max-content) 1fr; gap: 0.625rem 1rem; align-items: start; }
.gd-asks dt { font-size: 0.8125rem; color: var(--muted); padding-top: 0.4375rem; }
.gd-asks dd { margin: 0; display: flex; flex-wrap: wrap; gap: 0.375rem 0.5rem; align-items: center; min-width: 0; }
.gd-asks .starter, .gd-tags .starter { text-align: start; }
.gd-note { font-size: 0.7812rem; color: var(--muted); flex-basis: 100%; }
.gd-list { margin: 0; padding-inline-start: 1.125rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.8438rem; line-height: 1.7; color: var(--ink); }
.gd-search { margin: 0 0 0.75rem; }
.gd-tags { display: flex; flex-direction: column; gap: 0.875rem; }
.gd-subject { display: flex; flex-direction: column; gap: 0.5rem; padding-bottom: 0.875rem; border-bottom: 1px dashed var(--line); }
.gd-subject:last-of-type { border-bottom: 0; padding-bottom: 0; }
.gd-subject h3 { margin: 0; }
.gd-subject h3 .starter { font-size: 0.875rem; font-weight: 600; color: var(--ink); border-color: #cfc9bd; }
.gd-row { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.gd-kind { font-size: 0.75rem; color: var(--muted); min-width: 3.875rem; }
.gd-tag { display: inline-flex; align-items: baseline; gap: 0.375rem; padding: 0.3125rem 0.6875rem; font-size: 0.7812rem; }
.gd-count { font-size: 0.6875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .gd-asks { grid-template-columns: 1fr; gap: 0.25rem; }
  .gd-asks dt { padding-top: 0.5rem; }
  .gd-kind { min-width: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .gd-sec > summary::after { transition: none; } }
@media print { .guide-dialog { display: none !important; } }

/* ── Scrollbars on the right ────────────────────────────── */
/* In a right-to-left page a scrolling box puts its scrollbar on the left. The chat, the dialogs and the chat list
   scroll as left-to-right boxes so the bar is on the right, and their content is turned back to right-to-left. */
.learning-area, .sd-body, .history-list { direction: ltr; }
.learning-area > *, .sd-body > *, .history-list > * { direction: rtl; }

/* ── The caret of the message box ───────────────────────── */
/* An empty box used to take its direction from its (missing) text, which put the caret on the left. While the
   placeholder shows, the box follows the page, so the caret waits on the right where Hebrew starts. */
.composer textarea:placeholder-shown { unicode-bidi: normal; }
/* The caret is the accent colour and breathes (a slow fade) instead of blinking on and off. */
@property --caret-a { syntax: "<number>"; inherits: false; initial-value: 1; }
input, textarea { caret-color: var(--green); }
.composer textarea { caret-animation: manual; animation: caret-breathe 1.3s ease-in-out infinite; }
@keyframes caret-breathe {
  0%, 100% { --caret-a: 1; caret-color: var(--green); }
  50% { --caret-a: 0.28; caret-color: color-mix(in srgb, var(--green) 35%, transparent); }
}
/* Empty and focused: instead of the browser's hairline, a tapered stroke with a soft glow stands where the first
   letter will go. It is drawn as the box's background, so nothing has to follow the caret; once there is text,
   the browser's own caret (same colour, same breathing) takes over. */
.composer textarea:focus:placeholder-shown {
  caret-color: transparent !important;
  background-image:
    linear-gradient(to bottom, transparent, rgb(from var(--green) r g b / var(--caret-a)) 24%,
      rgb(from var(--green) r g b / var(--caret-a)) 76%, transparent),
    radial-gradient(closest-side, rgb(from var(--green) r g b / calc(var(--caret-a) * 0.4)), transparent);
  background-repeat: no-repeat;
  background-size: 0.1562rem 1.625rem, 1.125rem 2.25rem;
  background-position: right 0 top calc(var(--pad-top, 0.375rem) - 0.0312rem), right -0.4844rem top calc(var(--pad-top, 0.375rem) - 0.3438rem);
}
@media (prefers-reduced-motion: reduce) {
  .composer textarea { animation: none; caret-animation: auto; }
}

/* ── Accounts (hosted app) ──────────────────────────────── */
/* Signing in is a dialog that opens when it is needed: on the first message, or from the button at the top. */
.signin-dialog {
  border: 1px solid var(--line); border-radius: 1.125rem; background: var(--paper); color: var(--ink);
  padding: 2.125rem 1.75rem 1.625rem; width: min(26.875rem, calc(100% - 1.75rem)); box-shadow: 0 1.5625rem 6.25rem #302c2429;
}
.signin-dialog .sd-close { position: absolute; top: 0.75rem; inset-inline-end: 0.75rem; }
.signin-dialog .welcome-mark { margin-bottom: 0; }
.signin-card { max-width: 26.25rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.875rem; }
.signin-card h2 { margin: 0; font-size: 1.5rem; font-weight: 500; letter-spacing: -0.025rem; color: var(--ink); }
.signin-card p { margin: 0; font-size: 0.9375rem; line-height: 1.7; color: var(--muted); }
.signin-card small { font-size: 0.7812rem; color: var(--muted); }
.signin-google {
  display: inline-flex; align-items: center; gap: 0.625rem; margin-top: 0.375rem; padding: 0.6875rem 1.375rem;
  border: 1px solid var(--line); border-radius: 62.4375rem; background: var(--paper); color: var(--ink);
  font-size: 0.9375rem; font-weight: 500; cursor: pointer; box-shadow: 0 0.125rem 0.625rem #302c2412;
}
.signin-google:hover { border-color: #cfc9bd; filter: none; }
.signin-google:disabled { opacity: 0.6; cursor: progress; }
.signin-status { min-height: 1.4em; font-size: 0.8438rem; }
/* The one button of the offer to buy (#videos-buy): the brand colour, white text; in the dark look the brand's
   deeper tone, so the white stays readable. */
.buy-go {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.875rem; margin-top: 0.375rem;
  padding: 0.75rem 1.875rem; border: 0; border-radius: 0.75rem; background: var(--green); color: #fff;
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
}
.buy-go:hover { filter: brightness(1.07); }
:where(:root[data-theme='dark']) .buy-go { background: #a94d31; }
/* The quieter second option under it (videos only): plain text with an underline, no box. */
.buy-alt {
  margin: -0.125rem 0 0; padding: 0.25rem 0.5rem; border: 0; background: none; color: var(--ink); font: inherit;
  font-size: 0.9375rem; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.25em;
  cursor: pointer;
}
.buy-alt:hover { text-decoration-color: currentColor; }
.buy-alt[hidden] { display: none; }
/* The account at the top: "כניסה עם Google" for a visitor, the account's picture for a student. It is the last
   button of the row (its left end); the site tree is the first, in the corner. */
.top-signin {
  display: inline-flex; align-items: center; gap: 0.5rem; height: 2.25rem; padding: 0 0.875rem; border: 1px solid var(--line);
  border-radius: 0.75rem; background: var(--paper); color: var(--ink); font: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; box-shadow: 0 1px 0.125rem #302c240d, 0 0.25rem 0.875rem #302c2410;
}
.top-signin:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); filter: none; }
.top-signin:disabled { opacity: 0.6; cursor: progress; }
.top-signin svg { flex: none; }
.ts-short { display: none; }
@media (max-width: 620px) {
  .top-signin { padding: 0 0.6875rem; }
  .ts-long { display: none; }
  .ts-short { display: inline; }
}
/* On a touch screen the row's buttons are 44px tall (.panel-toggle): the sign-in button keeps their height. */
@media (pointer: coarse) {
  .top-signin { height: max(44px, 2.75rem); padding: 0 0.8125rem; }
  .top-actions .avatar-btn .avatar { width: 1.875rem; height: 1.875rem; }
}
/* A narrow phone with the whole row showing (a visitor in the free tutor): keep it clear of the left edge. */
@media (max-width: 400px) {
  .top-actions { gap: 0.375rem; }
  .top-signin { padding: 0 0.625rem; gap: 0.375rem; }
}
@media (max-width: 340px) {
  .top-signin { width: 2.75rem; padding: 0; justify-content: center; }
  .top-signin .ts-short { display: none; }
}
.avatar {
  display: grid; place-items: center; width: 1.625rem; height: 1.625rem; border-radius: 50%; overflow: hidden; flex: none;
  background: color-mix(in srgb, var(--green) 18%, var(--paper)); color: var(--green);
  font: 600 0.8125rem/1 system-ui, sans-serif;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 4rem; height: 4rem; font-size: 1.625rem; }
.top-actions .avatar-btn { border-radius: 50%; }
.account-menu {
  position: fixed; z-index: 40; min-width: 14.375rem; max-width: calc(100vw - 1rem); padding: 0.375rem; display: flex;
  flex-direction: column; border: 1px solid var(--line); border-radius: 0.875rem; background: var(--paper);
  color: var(--ink); box-shadow: 0 0.875rem 2.75rem #302c2426;
}
.account-menu[hidden] { display: none; }
/* The site as a tree, under the top button. Branch lines come from each nested list's border and a short tick
   before each row; the last row's ::after hides the line below its tick. */
.nav-menu {
  position: fixed; z-index: 40; width: min(23.125rem, calc(100vw - 1rem)); max-height: calc(100dvh - 4.75rem); overflow-y: auto;
  padding: 0.5rem; border: 1px solid var(--line); border-radius: 0.875rem; background: var(--paper); color: var(--ink);
  box-shadow: 0 0.875rem 2.75rem #302c2426; overscroll-behavior: contain;
  --nt-line: color-mix(in srgb, var(--ink) 30%, var(--paper));
}
.nt, .nt ul { list-style: none; margin: 0; padding: 0; }
.nt ul { margin-inline-start: 1.0625rem; padding-inline-start: 0.75rem; border-inline-start: 0.0938rem solid var(--nt-line); }
.nt ul > li { position: relative; }
.nt ul > li::before { content: ""; position: absolute; inset-inline-start: -0.75rem; top: 1.125rem; width: 0.5625rem; border-top: 0.0938rem solid var(--nt-line); }
.nt ul > li:last-child::after { content: ""; position: absolute; inset-inline-start: -0.875rem; top: 1.2188rem; bottom: 0; width: 0.1875rem; background: var(--paper); }
.nt-row { display: flex; align-items: center; gap: 0.125rem; }
.nt-link {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.5rem; min-height: 2.25rem; padding: 0.4375rem 0.625rem; border-radius: 0.5625rem;
  color: var(--ink); text-decoration: none; font-size: 0.9062rem; line-height: 1.4;
}
.nt > li > .nt-row .nt-link, .nt > li > ul > li > .nt-row .nt-link { font-weight: 600; }
.nt ul ul ul .nt-link { font-size: 0.8438rem; }
.nt-label { flex: 1; min-width: 0; }
.nt-link.quiet .nt-label { color: var(--muted); }
.nt-num { flex: none; font-size: 0.75rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.nt-done { flex: none; color: var(--green); font-size: 0.8125rem; font-weight: 700; }
.nt-here { flex: none; align-self: center; padding: 1px 0.5rem; border-radius: 6.1875rem; font-size: 0.7188rem; font-weight: 600; background: var(--green); color: var(--paper); }
.nt-link:hover, .nt-link:focus-visible { background: color-mix(in srgb, var(--ink) 7%, transparent); outline: none; }
.nt-link[aria-current] { background: color-mix(in srgb, var(--green) 14%, transparent); font-weight: 600; }
.nt-link:focus-visible, .nt-toggle:focus-visible { outline: 0.125rem solid var(--focus); outline-offset: -0.125rem; }
.nt-toggle {
  flex: none; width: 2.125rem; height: 2.125rem; display: grid; place-items: center; border-radius: 0.5625rem; background: transparent;
  color: var(--muted); font-size: 1.25rem; line-height: 1;
}
.nt-toggle:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); filter: none; }
.nt-chev { display: block; transition: transform 0.15s; }
.nt-toggle[aria-expanded="true"] .nt-chev { transform: rotate(-90deg); }
@media (pointer: coarse) {
  .nt-link { min-height: max(42px, 2.625rem); padding-block: 0.5625rem; }
  .nt ul > li::before { top: 1.3125rem; }
  .nt ul > li:last-child::after { top: 1.4062rem; }
  .nt-toggle { width: max(42px, 2.625rem); height: max(42px, 2.625rem); }
}
.am-who { display: flex; flex-direction: column; gap: 0.125rem; padding: 0.5625rem 0.75rem 0.625rem; margin-bottom: 0.25rem; border-bottom: 1px solid var(--line); }
.am-who strong { font-size: 0.9062rem; font-weight: 600; overflow-wrap: anywhere; }
.am-who bdi { font-size: 0.7812rem; color: var(--muted); overflow-wrap: anywhere; align-self: flex-start; }
.account-menu a, .account-menu button {
  display: block; width: 100%; padding: 0.5625rem 0.75rem; border: 0; border-radius: 0.5625rem; background: none; color: var(--ink);
  font: inherit; font-size: 0.9062rem; text-align: start; text-decoration: none; cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover, .account-menu a:focus-visible, .account-menu button:focus-visible {
  background: color-mix(in srgb, var(--ink) 7%, transparent); filter: none; outline: none;
}
/* The personal area (#me, plans.js renderMe). */
.pv-me { display: flex; flex-direction: column; gap: 1rem; }
.pv-me[hidden] { display: none; }
.pv-me .pv-back { align-self: flex-start; margin-bottom: 0; }
.me-head { display: flex; align-items: center; gap: 1rem; margin: 0.25rem 0 0.375rem; }
.me-head h1 { font-size: 1.75rem; }
.me-head bdi { color: var(--muted); font-size: 0.9062rem; overflow-wrap: anywhere; }
.me-head > div { min-width: 0; }
.me-card { border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); padding: 1.125rem 1.25rem; display: flex; flex-direction: column; gap: 0.625rem; }
.me-card h2 { margin: 0; font-size: 1.0312rem; font-weight: 600; }
.me-card p { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.7; }
.me-plans { display: flex; flex-direction: column; gap: 0.625rem; }
.me-plan { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem 0.875rem; border: 1px solid var(--line); border-radius: 0.75rem; color: var(--ink); text-decoration: none; }
.me-plan:hover { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.me-plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.me-plan-head strong { font-size: 0.9375rem; font-weight: 600; }
.me-plan-goal, .me-plan-meta { color: var(--muted); font-size: 0.8125rem; }
.me-meter { height: 0.375rem; border-radius: 6.1875rem; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.me-meter span { display: block; height: 100%; border-radius: 6.1875rem; background: var(--green); }
.me-link { color: var(--green); font-size: 0.9062rem; text-decoration: none; align-self: flex-start; }
.me-link:hover { text-decoration: underline; }
.me-note { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.7; }
.me-signout { border: 1px solid var(--line); border-radius: 0.625rem; font-size: 0.875rem; padding: 0.5625rem 1rem; }
/* Online the tutor uses the service's own key, so the bring-your-own-key and model settings are not shown. */
.hosted .sd-advanced { display: none; }
/* Nor which model answers: the button beside the message box would only name it (settings open from the header). */
.hosted .model-button { display: none; }
/* One model online: nothing to choose, so the message box does not name it. */
.hosted #composer-model { display: none; }

/* ── Entry page and study plans (plans.js) ──────────────── */
.portal {
  position: fixed; inset: 0; z-index: 4; overflow-y: auto; background: var(--bg);
  padding: 4.75rem max(1.25rem, env(safe-area-inset-right, 0px)) 3.5rem max(1.25rem, env(safe-area-inset-left, 0px));
}
body.portal-open .workspace { visibility: hidden; }
body.portal-open #page-toggle, body.portal-open #history-open, body.portal-open #new-chat { display: none; }
/* A chapter of a study plan is not a chat of the free tutor: its list of chats and "new chat" do not belong here.
   The bar under the buttons leads back to the plan and to the chapter's lessons. */
body.in-plan #history-open, body.in-plan #new-chat { display: none; }
.pv { max-width: 53.75rem; margin: 0 auto; }
.pv[hidden] { display: none; }
.pv h1 {
  font-family: var(--serif); font-weight: 500; letter-spacing: -0.0187rem;
  font-size: clamp(1.75rem, 3.4vw, 2.5rem); line-height: 1.2; margin: 0; text-wrap: balance;
}
.pv-sub { color: var(--muted); font-size: 1rem; line-height: 1.7; margin: 0.75rem 0 0; max-width: 60ch; }
.pv-back { display: inline-flex; gap: 0.375rem; align-items: center; margin-bottom: 1.125rem; color: var(--muted); font-size: 0.875rem; text-decoration: none; border-radius: 0.5rem; padding: 0.25rem 0.375rem; margin-inline-start: -0.375rem; }
.pv-back:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.pv-home { min-height: calc(100dvh - 8.25rem); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.pv-home .welcome-mark { margin-bottom: 1.125rem; }
.pv-home .pv-sub { margin-inline: auto; }
.pv-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.125rem; margin-top: 2.125rem; width: 100%; text-align: start; }
.pv-card {
  display: flex; flex-direction: column; gap: 0.625rem; padding: 1.625rem 1.625rem 1.375rem; border: 1px solid var(--line); border-radius: 1.25rem;
  background: var(--paper); color: var(--ink); text-decoration: none; box-shadow: 0 0.125rem 0.625rem #302c240a;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.pv-card:hover { transform: translateY(-0.125rem); border-color: color-mix(in srgb, var(--green) 55%, var(--line)); box-shadow: 0 0.625rem 1.875rem #302c2416; }
.pv-card h2 { margin: 0.375rem 0 0; font-size: 1.375rem; font-weight: 600; letter-spacing: -0.0187rem; }
.pv-card p { margin: 0; color: var(--muted); font-size: 0.9375rem; line-height: 1.7; flex: 1; }
.pv-icon { width: 2.75rem; height: 2.75rem; color: var(--green); }
.pv-go { margin-top: 0.5rem; font-weight: 600; font-size: 0.9375rem; color: var(--green); }
.pv-card-plans { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); background: color-mix(in srgb, var(--green) 7%, var(--paper)); }
.pv-short { display: none; }
/* The plan page: a side panel (goal, progress, where to continue) beside a dense list of chapters. */
.pv-plan { max-width: 73.75rem; }
.pv-plan h1 { font-size: clamp(1.5rem, 2.4vw, 1.875rem); letter-spacing: -0.0312rem; }
.pv-plan .pv-back { margin-bottom: 0.625rem; }
.seg { display: inline-flex; padding: 0.1875rem; border: 1px solid var(--line); border-radius: 0.6875rem; background: var(--bg); gap: 0.125rem; }
.seg-btn { background: transparent; color: var(--muted); border: 0; border-radius: 0.5rem; padding: 0.375rem 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg-btn:hover { filter: none; color: var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--green); color: #fff; }
.pp-more { font-size: 0.8438rem; line-height: 1.75; color: var(--muted); }
.pp-more + .pp-more { border-top: 1px solid var(--line); }
.pp-more summary { cursor: pointer; color: var(--ink); padding: 0.625rem 0; border-radius: 0.375rem; }
.pp-more > div { padding-bottom: 0.75rem; }
.pp-more p { margin: 0 0 0.375rem; }
/* The overview chat ("תוכנית ומעקב"): not a chapter, so a compact card of its own under the details. */
.meter { height: 0.375rem; border-radius: 6.1875rem; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6.1875rem; background: var(--green); transition: width 0.4s; }

/* ── The plan page: the course's home (plans.js renderPlan) ──
   Where to continue first; the chapters as a short list; the chosen chapter opened beside it with its lessons and
   steps; the goal and the fine print in a quiet column. Nothing is a box inside a box: the resume card is the one
   filled surface, everything else is rows and hairlines. */
.pp-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.375rem 1.25rem; }
.pp-top h1 { order: 1; }
.pp-top .pv-back { order: 3; margin: 0; }
.pp-overall { order: 2; margin-inline-start: auto; display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.8438rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-overall[hidden], .pp-nav[hidden], .pp-main[hidden], .pp-side[hidden] { display: none; }
.pp-overall .meter { width: 10rem; }
.pp-layout { margin-top: 1.5rem; display: grid; gap: 1.75rem; align-items: start; }
.pp-nav, .pp-main, .pp-side { min-width: 0; }
.pp-main { display: grid; gap: 1.875rem; }
.ph-label { margin: 0 0 0.375rem; padding-inline: 0.625rem; font-size: 0.75rem; color: var(--muted); }

.ph-resume {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem;
  padding: 1.25rem 1.5rem; border-radius: 1rem; background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.ph-resume-text { display: grid; gap: 0.1875rem; min-width: 0; flex: 1 1 16rem; }
.ph-resume-where, .ph-resume-sub { color: var(--muted); font-size: 0.875rem; line-height: 1.5; }
.ph-resume-title { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.ph-resume-go {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.875rem; padding: 0.75rem 1.875rem;
  border-radius: 0.75rem; background: var(--green); color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; white-space: nowrap;
}
.ph-resume-go:hover { filter: brightness(1.07); }
:where(:root[data-theme='dark']) .ph-resume-go { background: #a94d31; }

.ph-chapters, .ph-lessons { list-style: none; margin: 0; padding: 0; display: grid; }
.ph-chapters { gap: 0.125rem; }
.ph-ch-row, .ph-ls-row, .ph-step {
  width: 100%; display: flex; align-items: center; gap: 0.75rem; text-align: start; background: transparent; color: var(--ink);
  border: 0; border-radius: 0.5rem; font-size: 0.9375rem; line-height: 1.4; font-weight: 400;
}
.ph-ch-row:hover, .ph-ls-row:hover, .ph-step:hover { filter: none; background: color-mix(in srgb, var(--ink) 5%, transparent); }
:where(:root[data-theme='dark']) .ph-ch-row, :where(:root[data-theme='dark']) .ph-ls-row, :where(:root[data-theme='dark']) .ph-step { background-color: transparent; color: var(--ink); }
:where(:root[data-theme='dark']) .ph-ch-row:hover, :where(:root[data-theme='dark']) .ph-ls-row:hover, :where(:root[data-theme='dark']) .ph-step:hover { background-color: color-mix(in srgb, var(--ink) 6%, transparent); }
.ph-ch-row { min-height: 2.75rem; padding: 0.4375rem 0.625rem; color: var(--muted); scroll-margin-top: 5.5rem; }
.ph-ch-title { flex: 1; min-width: 0; }
.ph-ch-meta { flex-shrink: 0; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ph-num {
  flex-shrink: 0; width: 1.625rem; height: 1.625rem; border-radius: 50%; display: grid; place-items: center;
  border: 0.0938rem solid color-mix(in srgb, var(--ink) 26%, transparent); font-size: 0.8125rem; font-variant-numeric: tabular-nums; font-weight: 500;
}
.ph-ch.now .ph-num { border-color: var(--green); color: var(--green); }
.ph-ch.done .ph-num { border-color: var(--green); background: var(--green); color: var(--bg); }
.ph-ch.here > .ph-ch-row { color: var(--ink); font-weight: 700; background: color-mix(in srgb, var(--green) 13%, transparent); }
:where(:root[data-theme='dark']) .ph-ch.here > .ph-ch-row { background-color: color-mix(in srgb, var(--green) 15%, transparent); }
.ph-overview {
  display: grid; gap: 1px; margin-top: 0.75rem; padding: 0.875rem 0.625rem 0.25rem; border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none; border-radius: 0 0 0.5rem 0.5rem;
}
.ph-overview strong { font-size: 0.9375rem; font-weight: 600; }
.ph-overview small { font-size: 0.8125rem; color: var(--muted); }
.ph-overview:hover strong { color: var(--green); }

.ph-detail { display: grid; gap: 1.25rem; min-width: 0; }
.ph-detail-head { display: grid; gap: 0.5rem; }
.ph-detail h2 { margin: 0; font-family: var(--serif); font-size: 1.5rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.0187rem; }
.ph-about { color: var(--ink); font-size: 0.9375rem; line-height: 1.7; max-width: 70ch; }
.ph-about p { margin: 0; }
.ph-facts { margin: 0; color: var(--muted); font-size: 0.875rem; }
.ph-lessons { gap: 0.25rem; }
.ph-ls { border-top: 1px solid var(--line); }
.ph-ls:last-child { border-bottom: 1px solid var(--line); }
.ph-ls-row { min-height: 3.25rem; padding: 0.625rem 0.5rem; font-size: 1.0625rem; font-weight: 600; border-radius: 0.5rem; }
.ph-ls-name { flex: 1; min-width: 0; }
.ph-ls-no { color: var(--muted); font-weight: 500; }
.ph-ls.open .ph-ls-no { color: var(--green); }
.ph-ls.off .ph-ls-title { color: var(--muted); }
.ph-ls-meta { flex-shrink: 0; font-size: 0.8125rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ph-ls-meta.ok { color: var(--green); }
.ph-ls-arrow { flex-shrink: 0; display: grid; color: var(--muted); }
.ph-ls-arrow svg { width: 0.875rem; height: 0.875rem; transition: transform 0.15s; }
.ph-ls.open .ph-ls-arrow svg { transform: rotate(180deg); }
.ph-steps { display: grid; gap: 0.0625rem; padding-bottom: 0.625rem; }
.ph-chapter-videos { padding-bottom: 0; }
.ph-step { min-height: 2.75rem; padding: 0.5rem; flex-wrap: wrap; row-gap: 0.125rem; }
.ph-step-name { flex: 1 1 auto; min-width: 0; }
.ph-step-meta { flex-shrink: 1; min-width: 0; font-size: 0.8125rem; color: var(--muted); }
.ph-step-go { flex-shrink: 0; font-size: 0.8125rem; font-weight: 600; color: var(--green); white-space: nowrap; }
.ph-step.done { color: var(--muted); }
.ph-step.off .ph-step-name { color: var(--muted); }
.ph-step.now { font-weight: 700; background: color-mix(in srgb, var(--ink) 6%, transparent); }
/* A video: its picture, large and centred in the column (▶ and the length in the bottom corner), played over this
   page; on the picture of the lesson to continue, the "המשך" button in the other bottom corner. */
.ph-video { position: relative; width: min(100%, 32rem); margin: 0.375rem auto 0.875rem; }
.ph-chapter-videos .ph-video { margin-block: 0; }
.ph-step.video { display: block; min-height: 0; padding: 0; border-radius: 0.875rem; transition: transform 0.15s, box-shadow 0.15s; }
.ph-step.video:hover { transform: translateY(-0.125rem); box-shadow: 0 0.5rem 1.5rem #0000002e; }
.ph-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: inherit; overflow: hidden; background: #1c1917; }
.ph-thumb.blank { display: grid; place-items: center; padding: 1rem 1.25rem 3rem; background: linear-gradient(135deg, #a94d31, #7d3621); }
.ph-thumb-title { font: 600 1.25rem/1.35 var(--serif); text-align: center; color: #fff; }
.ph-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.15s; }
.ph-step.video:hover .ph-thumb img { filter: brightness(1.08); }
.ph-step.video.done .ph-thumb img { filter: brightness(0.84) saturate(0.9); }
.ph-thumb-corner { position: absolute; bottom: 0.75rem; inset-inline-end: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.ph-thumb-play { display: grid; color: #a94d31; }
.ph-thumb-play svg { width: 3rem; height: 3rem; filter: drop-shadow(0 0.125rem 0.375rem #00000059); }
.ph-thumb-dur, .ph-thumb-tag {
  padding: 0.1875rem 0.5625rem; border-radius: 99rem; background: #000000b3; color: #fff;
  font-size: 0.875rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; direction: ltr;
}
.ph-thumb-tag { position: absolute; top: 0.75rem; inset-inline-start: 0.75rem; direction: rtl; font-size: 0.8125rem; }
.ph-thumb-tick {
  position: absolute; top: 0.75rem; inset-inline-end: 0.75rem; display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; background: #a94d31; color: #fff; font-weight: 700; font-size: 1.0625rem; box-shadow: 0 0.125rem 0.375rem #00000059;
}
.ph-video-go {
  position: absolute; bottom: 0.75rem; inset-inline-start: 0.75rem; min-height: 3rem; padding: 0.5rem 1.5rem; border-radius: 99rem;
  background: var(--green); color: #fff; font-weight: 700; font-size: 1.0625rem; white-space: nowrap; box-shadow: 0 0.25rem 0.875rem #00000059;
}
.ph-video-go:hover { filter: brightness(1.08); }
:where(:root[data-theme='dark']) .ph-video-go { background: #a94d31; }
.ph-mark {
  flex-shrink: 0; width: 1.375rem; height: 1.375rem; border-radius: 50%; display: grid; place-items: center;
  border: 0.0938rem solid color-mix(in srgb, var(--ink) 26%, transparent); color: var(--muted);
}
.ph-mark svg { width: 0.75rem; height: 0.75rem; }
.ph-mark.done { border-color: var(--green); background: var(--green); color: var(--bg); }
.ph-mark.now { border-color: var(--green); }
.ph-mark.now::after { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--green); }

.pp-side { display: grid; gap: 1.5rem; }
.ph-goal, .ph-exam { display: grid; gap: 0.625rem; justify-items: start; }
.ph-exam { gap: 0; justify-items: stretch; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.ph-side-title { font-size: 0.9375rem; font-weight: 700; }
.ph-exam .ph-side-title { margin-bottom: 0.375rem; }
.ph-side-note { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.6; }
.ph-exam .pp-more + .pp-more { border-top: 0; }
.ph-exam .pp-more summary { padding: 0.4375rem 0; }

@media (min-width: 1000px) {
  .pv-plan { max-width: 68rem; }
  /* Right-to-left: the chapters on the right, the chosen chapter in the middle; the quiet column goes under the
     chapters until the window has room for three columns. */
  .pp-layout { grid-template-columns: 19rem minmax(0, 1fr); column-gap: 2.5rem; }
  .pp-nav { grid-column: 1; grid-row: 1; }
  .pp-main { grid-column: 2; grid-row: 1 / span 2; }
  .pp-side { grid-column: 1; grid-row: 2; padding-top: 1.25rem; border-top: 1px solid var(--line); }
  .ph-ch-meta.time { display: none; }
}
@media (min-width: 1280px) {
  .pv-plan { max-width: 92rem; }
  .pp-layout { grid-template-columns: 19rem minmax(0, 1fr) 15rem; }
  .pp-main { grid-row: 1; }
  .pp-side { grid-column: 3; grid-row: 1; padding-top: 0; border-top: 0; position: sticky; top: 1.25rem; }
}
@media (max-width: 999px) {
  /* A narrow screen: where to continue, then the chapters (the chosen one opens in place), then the goal. */
  .pp-main { order: 1; }
  .pp-nav { order: 2; }
  .pp-side { order: 3; padding-top: 1.25rem; border-top: 1px solid var(--line); }
  .pp-overall { flex-basis: 100%; margin-inline-start: 0; }
  .pp-overall .meter { flex: 1; width: auto; }
  .ph-resume { padding: 1rem; }
  .ph-resume-go { flex: 1 1 100%; }
  .ph-detail { padding: 0.25rem 0.25rem 1rem; gap: 0.875rem; }
  .ph-detail h2 { display: none; }
  .ph-about { font-size: 0.875rem; color: var(--muted); }
  .ph-ls-row { font-size: 0.9375rem; }
  .ph-thumb-play svg { width: 2.75rem; height: 2.75rem; }
  .ph-video-go { min-height: 2.75rem; padding-inline: 1.25rem; font-size: 1rem; }
}

.plan-bar {
  position: relative; flex-shrink: 0; display: flex; align-items: center; gap: 0.75rem; width: min(calc(var(--chat-w) + 3.75rem), 100% - 2.5rem);
  margin: 0 auto 0.125rem; padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: 0.875rem; background: var(--paper);
}
.pb-back { color: var(--muted); text-decoration: none; font-size: 0.8438rem; white-space: nowrap; padding: 0.3125rem 0.5rem; border-radius: 0.5rem; }
.pb-back:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.pb-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pb-titles strong, .pb-titles small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-titles strong { font-size: 0.875rem; font-weight: 600; }
.pb-titles small { font-size: 0.75rem; color: var(--muted); }
.pb-titles small:empty { display: none; }
.pb-meter { width: 5.25rem; height: 0.375rem; border-radius: 6.1875rem; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; flex-shrink: 0; }
.pb-meter i { display: block; height: 100%; border-radius: 6.1875rem; background: var(--green); transition: width 0.4s; }
.pb-count { font-size: 0.7812rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pb-lessons-open {
  display: inline-flex; align-items: center; gap: 0.375rem; background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: 0.5625rem; padding: 0.375rem 0.625rem; font-size: 0.8125rem; white-space: nowrap;
}
.pb-lessons-open:hover { filter: none; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.pb-lessons-open[aria-expanded="true"] svg { transform: rotate(180deg); }
.plan-lessons {
  position: absolute; z-index: 6; top: calc(100% + 0.375rem); inset-inline: 0; max-height: min(60dvh, 28.75rem); overflow-y: auto;
  padding: 0.5rem; border: 1px solid var(--line); border-radius: 0.875rem; background: var(--paper); box-shadow: 0 0.875rem 2.75rem #302c2426;
}
.ls-title { padding: 0.5rem 0.625rem 0.25rem; font-size: 0.75rem; color: var(--muted); }
.ls-list { list-style: none; margin: 0; padding: 0; }
.ls-row { display: flex; align-items: center; gap: 0.25rem; border-radius: 0.625rem; }
.ls-row:hover, .ls-item.current > .ls-row { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.ls-main {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.625rem; text-align: start; background: transparent;
  color: var(--ink); border: 0; padding: 0.5625rem 0.5rem; border-radius: 0.625rem; font-size: 0.875rem;
}
.ls-main:hover { filter: none; }
.ls-name { flex: 1; min-width: 0; line-height: 1.5; }
.ls-item.current .ls-name { font-weight: 600; }
.ls-item.done .ls-name { color: var(--muted); }
.ls-arrow { align-self: center; display: grid; color: var(--muted); transition: transform 0.15s; }
.ls-main[aria-expanded="true"] .ls-arrow { transform: rotate(180deg); }
.ls-steps { list-style: none; margin: 0.125rem 0 0.375rem; padding: 0; padding-inline-start: 2.75rem; padding-inline-end: 0.625rem; }
.ls-step { display: flex; align-items: center; gap: 0.5625rem; padding: 0.25rem 0; font-size: 0.8125rem; color: var(--ink); }
.ls-step.done .ls-step-name, .ls-step.off .ls-step-name { color: var(--muted); }
.ls-mark {
  flex-shrink: 0; width: 0.9375rem; height: 0.9375rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.5625rem; line-height: 1;
  color: transparent; border: 0.0938rem solid color-mix(in srgb, var(--ink) 26%, transparent); user-select: none;
}
.ls-step.done .ls-mark { background: var(--green); border-color: var(--green); color: #fff; }
.ls-step.next .ls-mark { border-color: var(--green); }
.ls-step.next .ls-step-name { font-weight: 600; }
.ls-step.off .ls-mark { border-style: dashed; }
.ls-tag { font-size: 0.6875rem; padding: 1px 0.4375rem; border-radius: 6.1875rem; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.ls-tag.now { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.ls-jump {
  margin: 0 0 0.625rem; margin-inline-start: 2.75rem; padding: 0.3125rem 0.75rem; border-radius: 6.1875rem; font-size: 0.7812rem;
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.ls-jump:hover { filter: none; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.ls-meta { font-size: 0.75rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ls-check {
  flex-shrink: 0; width: 1.5rem; height: 1.5rem; margin-inline-start: 0.5rem; border-radius: 50%; font-size: 0.8125rem; line-height: 1;
  display: grid; place-items: center; user-select: none;
  background: transparent; color: transparent; border: 0.0938rem solid color-mix(in srgb, var(--ink) 28%, transparent);
}
.ls-item.done .ls-check { background: var(--green); border-color: var(--green); color: #fff; }
.in-plan .composer-tools .dd { display: none; }
.pv-card:focus-visible, .pv-track:focus-visible, .pv-back:focus-visible, .pb-back:focus-visible,
.seg-btn:focus-visible, .pb-lessons-open:focus-visible, .ls-main:focus-visible, .ls-jump:focus-visible,
.pp-more summary:focus-visible, .ph-ch-row:focus-visible, .ph-ls-row:focus-visible, .ph-step:focus-visible, .ph-video-go:focus-visible, .ph-resume-go:focus-visible, .ph-overview:focus-visible { outline: 0.125rem solid var(--focus); outline-offset: 0.125rem; }
@media (max-width: 740px) {
  .portal { padding-top: 4.25rem; padding-bottom: 2.5rem; }
  .pv-choices { grid-template-columns: minmax(0, 1fr); }
  /* The entry page on a phone fits the screen, with nothing to scroll: shorter texts, the icon beside the title,
     and the whole of it centred in the height the screen has. (A very short screen still scrolls.) */
  .portal.at-home { display: flex; flex-direction: column; padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px)); }
  .pv-home { flex: 1 0 auto; width: 100%; min-height: 0; }
  .pv-home .welcome-mark { margin-bottom: 0.5rem; }
  .pv-home .pv-sub { margin-top: 0.375rem; font-size: 0.9375rem; }
  .pv-long { display: none; }
  .pv-short { display: inline; }
  .pv-choices { margin-top: 1.25rem; gap: 0.75rem; }
  .pv-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.375rem 0.75rem; padding: 1rem 1.125rem; }
  .pv-card .pv-icon { width: 2.125rem; height: 2.125rem; }
  .pv-card h2 { margin: 0; font-size: 1.25rem; }
  .pv-card p, .pv-card .pv-go { grid-column: 1 / -1; }
  .pv-card p { font-size: 0.9062rem; line-height: 1.55; text-wrap: pretty; }
  .pv-card .pv-go { margin-top: 0.125rem; }
  .pv-track-row { grid-template-columns: minmax(0, 1fr); gap: 0.625rem; }
  .pv-track { min-height: 0; }
  .plan-bar { flex-wrap: wrap; row-gap: 0.375rem; width: calc(100% - 1.5rem); padding: 0.375rem 0.5rem; }
  .pb-titles { flex: 1 1 40%; }
  .pb-meter { order: 5; flex: 1 1 40%; width: auto; }
  .pb-count { order: 6; }
}
/* dark theme */
:where(:root[data-theme='dark']) .pv-card, :where(:root[data-theme='dark']) .pv-track { box-shadow: none; }
:where(:root[data-theme='dark']) .seg-btn, :where(:root[data-theme='dark']) .pb-lessons-open, :where(:root[data-theme='dark']) .ls-main { background-color: transparent; }
:where(:root[data-theme='dark']) .seg-btn { color: var(--muted); }
:where(:root[data-theme='dark']) .pb-lessons-open, :where(:root[data-theme='dark']) .ls-main { color: var(--ink); }
:where(:root[data-theme='dark']) .seg-btn[aria-pressed="true"] { background-color: #a94d31; color: #fff; }
:where(:root[data-theme='dark']) .ls-item.done .ls-check, :where(:root[data-theme='dark']) .ls-step.done .ls-mark { background-color: #a94d31; border-color: #a94d31; }
:where(:root[data-theme='dark']) .ls-jump { background-color: transparent; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .pv-card, .pv-track, .ph-ls-arrow svg, .ph-thumb img, .ls-arrow, .meter i, .pb-meter i { transition: none; } }


/* ══ Course plan additions (from the PDE app) ══════════════════════════════════════════════════════════════════════════ */
/* A link from the entry page back to the course site (the landing at /). */
.pv-site { margin-top: 1.375rem; color: var(--muted); font-size: 0.875rem; text-decoration: none; border-bottom: 1px solid var(--line); }
.pv-site:hover { color: var(--ink); border-color: var(--green); }
/* Short points instead of paragraphs (settings, guide lead, personal area). */
.sd-points, ul.gd-lead, ul.me-note { margin: 0; padding-inline-start: 1.125rem; }
ul.gd-lead { margin-bottom: 1rem; }
ul.gd-lead li + li, ul.me-note li + li { margin-top: 0.125rem; }
/* The topics that are not examined this year. */
.pp-out { margin: 0; padding: 0 0 0.75rem; padding-inline-start: 1.125rem; display: grid; gap: 0.1875rem; }
.pp-out p { margin: 0; }
/* Videos (plans.js paintVideos): a chapter's video is a row at the head of its lessons, a lesson's video the first of
   its steps. Above the conversation: the video's picture only, like a video sent in a chat (16:9, rounded, no frame
   or text): the lesson's about 320px wide on the start side, the chapter's about 200px beside it with "פרק"; ▶ and
   the length in the bottom corner, a ✓ once watched; each opens the player overlay (.video-overlay). */
a.ls-main { text-decoration: none; }
.ls-play { align-self: center; color: var(--green); font-size: 0.625rem; width: 0.75rem; text-align: center; }
.plan-video { max-width: var(--chat-w); margin: 0 auto 1.25rem; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-start; gap: 0.75rem; }
.vc-tile {
  flex: none; display: block; width: 25rem; max-width: 100%; padding: 0; border: 0; border-radius: 0.875rem;
  background: none; color: #fff; text-align: start; transition: transform 0.15s, box-shadow 0.15s;
}
.vc-tile.small { width: 15.625rem; }
.vc-tile:hover { filter: none; transform: translateY(-0.125rem); box-shadow: 0 0.5rem 1.5rem #0000002e; }
.vc-tile:not(:disabled):active { transform: scale(0.985); }
.vc-tile:focus-visible { outline: 0.1875rem solid var(--focus, #a94d31); outline-offset: 0.1875rem; }
.vc-pic {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: inherit; overflow: hidden;
  background: #1c1917;
}
.vc-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.15s; }
.vc-tile:hover .vc-pic img { filter: brightness(1.06); }
.vc-tile.done .vc-pic img { filter: brightness(0.84) saturate(0.9); }
.vc-tile.done:hover .vc-pic img { filter: brightness(0.94); }
.vc-blank { display: grid; place-items: center; padding: 0.75rem 1rem 2.75rem; background: linear-gradient(135deg, #a94d31, #7d3621); }
.vc-blank-title { font: 600 1.125rem/1.35 var(--serif); text-align: center; color: #fff; }
.small .vc-blank-title { font-size: 0.9375rem; }
/* The bottom corner (bottom-left in RTL): ▶ and the length, as a player shows them. */
.vc-corner {
  position: absolute; bottom: 0.5rem; inset-inline-end: 0.5rem; display: flex; align-items: center; gap: 0.375rem;
}
.vc-play { display: grid; color: #a94d31; }
.vc-play svg { width: 3rem; height: 3rem; filter: drop-shadow(0 0.125rem 0.375rem #00000059); transition: transform 0.15s; }
.small .vc-play svg { width: 2.625rem; height: 2.625rem; }
.vc-tile:hover .vc-play svg { transform: scale(1.08); }
.vc-dur, .vc-tag {
  padding: 0.1875rem 0.5rem; border-radius: 99rem; background: #000000b3; color: #fff;
  font: 600 0.9375rem/1.2 var(--sans, system-ui), system-ui, sans-serif; font-variant-numeric: tabular-nums; direction: ltr;
}
.vc-tag { position: absolute; top: 0.5rem; inset-inline-start: 0.5rem; direction: rtl; font-size: 0.875rem; }
.vc-tick {
  position: absolute; top: 0.5rem; inset-inline-end: 0.5rem; display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; background: #a94d31; color: #fff; font-weight: 700; font-size: 1.0625rem; box-shadow: 0 0.125rem 0.375rem #00000059;
}
@media (max-width: 599px) {
  .plan-video { flex-wrap: nowrap; gap: 4%; margin-bottom: 1rem; }
  .vc-tile { width: 70%; border-radius: 0.75rem; }
  .plan-video.two .vc-tile { width: 60%; }
  .plan-video.two .vc-tile.small { width: 36%; }
  .vc-corner { bottom: 0.375rem; inset-inline-end: 0.375rem; gap: 0.25rem; }
  .small .vc-corner { bottom: 0.25rem; inset-inline-end: 0.25rem; gap: 0.1875rem; }
  .vc-play svg { width: 2.25rem; height: 2.25rem; }
  .small .vc-play svg { width: 1.5rem; height: 1.5rem; }
  .vc-dur, .vc-tag { font-size: 0.8125rem; padding: 0.125rem 0.4375rem; }
  .small .vc-dur, .small .vc-tag { font-size: 0.6875rem; padding: 0.0625rem 0.3125rem; }
  .small .vc-tag { top: 0.25rem; inset-inline-start: 0.25rem; }
  .vc-tag { top: 0.375rem; inset-inline-start: 0.375rem; }
  .vc-tick { top: 0.375rem; inset-inline-end: 0.375rem; width: 1.75rem; height: 1.75rem; font-size: 0.9375rem; }
  .small .vc-tick { width: 1.5rem; height: 1.5rem; font-size: 0.8125rem; }
  .vc-blank-title { font-size: 0.9375rem; }
  .small .vc-blank-title { font-size: 0.75rem; }
}
@media print { .plan-video, .video-overlay { display: none !important; } }
/* The player overlay: the page dimmed, Vimeo's player centred at 16:9, as large as fits. Its sizes are the screen's
   (px), not the app's scale: the player is as big as the window allows. */
html.video-open .learning-area { overflow: hidden; }
.video-overlay {
  position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: transparent; color: #f5f1ea; overflow: hidden;
}
.video-overlay[open] { display: grid; place-items: center; }
.video-overlay::backdrop { background: #0d0b0ad9; backdrop-filter: blur(3px); }
:where(:root[data-theme='dark']) .video-overlay::backdrop { background: #000000e0; }
.vo-panel {
  --vo-w: min(1280px, calc(100vw - 64px), calc((100dvh - 150px) * 16 / 9));
  width: var(--vo-w); display: grid; gap: 12px;
}
.vo-head { display: flex; align-items: center; gap: 16px; }
.vo-titles { flex: 1; min-width: 0; display: grid; gap: 2px; }
.vo-title { font: 600 20px/1.35 var(--serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vo-meta { font-size: 14px; color: #c9c1b6; }
.vo-close {
  flex: none; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  background: #ffffff1f; color: #fff; border: 1px solid #ffffff33;
}
.vo-close:hover { filter: none; background: #ffffff33; }
.vo-close svg { width: 22px; height: 22px; }
.vo-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; box-shadow: 0 24px 80px #0008; }
.vo-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.vo-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-height: 40px; }
.vo-state { color: #e7b39c; font-size: 14px; }
.vo-mark { padding: 8px 16px; border-radius: 99px; font-size: 14px; background: #a94d31; color: #fff; border: 1px solid #a94d31; }
.vo-mark.quiet { background: transparent; color: #d9d2c7; border-color: #ffffff40; }
.vo-mark.quiet:hover { filter: none; color: #fff; border-color: #ffffff80; }
.vo-close:focus-visible, .vo-mark:focus-visible { outline: 3px solid #e7b39c; outline-offset: 2px; }
:where(:root[data-theme='dark']) .vo-close { background-color: #ffffff1f; color: #fff; }
:where(:root[data-theme='dark']) .vo-mark.quiet { background-color: transparent; color: #d9d2c7; }
@media (max-width: 599px), (max-height: 520px) {
  /* A phone: the whole screen; on its side, the player as tall as the screen allows. */
  .video-overlay::backdrop, :where(:root[data-theme='dark']) .video-overlay::backdrop { background: #0d0b0a; backdrop-filter: none; }
  .vo-panel { --vo-w: min(100vw, calc((100dvh - 120px) * 16 / 9)); gap: 8px; }
  .vo-head, .vo-foot { padding-inline: 12px; }
  .vo-frame { border-radius: 0; }
  .vo-title { font-size: 17px; }
}
@media (max-height: 520px) {
  .video-overlay[open] { place-items: center; }
  .vo-panel { --vo-w: min(100vw - 24px, calc((100dvh - 96px) * 16 / 9)); }
  .vo-frame { border-radius: 8px; }
}
@media (prefers-reduced-motion: reduce) { .vc-play svg { transition: none; } .vc-tile, .vc-pic img { transition: none; } .vc-tile:hover { transform: none; } }
/* Start a chapter's conversation over (the lessons menu in a chapter). */
.ls-clear { margin: 0.625rem 0.25rem 0.125rem; padding: 0.375rem 0.625rem; background: none; border: 1px solid var(--line); color: var(--muted); font-size: 0.8125rem; border-radius: 0.5625rem; }
.ls-clear:hover { color: var(--ink); border-color: var(--muted); }
/* A question with parts outside this year's material. */
.co-chip.out { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--muted); }
/* The open question as typed text, under its image. */
.page-text { margin: 0.625rem 0.75rem 1rem; border: 1px solid var(--line); border-radius: 0.75rem; background: var(--paper); color: var(--ink); font-size: 0.9062rem; line-height: 1.7; }
.page-text summary { cursor: pointer; padding: 0.5625rem 0.875rem; font-weight: 600; }
.page-text-body { padding: 0 0.875rem; }
.page-text-body p { margin: 0 0 0.5rem; }
.page-text small { display: block; padding: 0 0.875rem 0.625rem; color: var(--muted); font-size: 0.7812rem; }
.page-stage > .page-text { flex: none; text-align: start; }
.gd-out { margin-inline-start: 0.375rem; font-size: 0.6875rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 6.1875rem; padding: 0 0.375rem; }

/* Light or dark, in the settings: the same choice as the course site. */
.sd-theme { display: inline-flex; width: fit-content; align-self: flex-start; }

/* ── The message box as an editor (composer.js) ─────────── */
/* A formula between $ signs shows rendered inside the box; under the caret it is its LaTeX source. The sizes
   repeat the old text box: it starts 68px tall and grows with the text up to 180px, then scrolls. */
.composer-input { --pad-top: 0.375rem; --min-h: 4.25rem; width: 100%; font-size: 1rem; line-height: 1.6; cursor: text; }
.composer .composer-input .cm-editor { max-height: 11.25rem; background: transparent; }
.composer .composer-input .cm-editor.cm-focused { outline: none; }
.composer .composer-input .cm-scroller { font-family: inherit; line-height: inherit; overflow: auto; }
.composer .composer-input .cm-content {
  min-height: var(--min-h); padding: var(--pad-top) 0.25rem 0.375rem; color: var(--ink);
  caret-color: var(--green); caret-animation: manual; animation: caret-breathe 1.3s ease-in-out infinite;
}
.composer .composer-input .cm-line { padding: 0; }
.composer .composer-input .cm-placeholder { color: var(--muted); }
.composer-input .cm-math { display: inline-block; padding: 0 0.125rem; border-radius: 0.375rem; cursor: text; vertical-align: baseline; }
.composer-input .cm-math:hover { background: var(--light); }
.composer-input .cm-math-src {
  unicode-bidi: isolate; direction: ltr; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em; color: var(--green); background: var(--light); border-radius: 0.3125rem; padding: 1px 0.1875rem;
}
/* Empty and focused: the tapered stroke stands where the first letter will go (as it did in the old text box). */
.composer .composer-input.is-empty .cm-editor.cm-focused .cm-content {
  caret-color: transparent !important;
  background-image:
    linear-gradient(to bottom, transparent, rgb(from var(--green) r g b / var(--caret-a)) 24%,
      rgb(from var(--green) r g b / var(--caret-a)) 76%, transparent),
    radial-gradient(closest-side, rgb(from var(--green) r g b / calc(var(--caret-a) * 0.4)), transparent);
  background-repeat: no-repeat;
  background-size: 0.1562rem 1.625rem, 1.125rem 2.25rem;
  background-position: right 0 top calc(var(--pad-top) - 0.0312rem), right -0.4844rem top calc(var(--pad-top) - 0.3438rem);
}
@media (max-width: 740px) { .composer-input { --min-h: 2.875rem; } }
@media (max-height: 520px) { .composer-input { --min-h: 2.5rem; --pad-top: 0.25rem; } }
@media (prefers-reduced-motion: reduce) {
  .composer .composer-input .cm-content { animation: none; caret-animation: auto; }
}

/* Attached images (attach.js, a laptop only). Colours come from the theme's tokens, so both themes are covered. */
.attachments { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 0.125rem 0.625rem; }
.attachments[hidden] { display: none; }
.att {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--light);
  overflow: hidden;
}
.att img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att.sending img { opacity: 0.45; }
.att.sending::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.25rem;
  height: 1.25rem;
  border: 0.125rem solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: att-spin 0.8s linear infinite;
}
@keyframes att-spin { to { transform: rotate(360deg); } }
.att-x {
  position: absolute;
  top: 0.1875rem;
  inset-inline-end: 0.1875rem;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #1f1c19cc;
  color: #fff;
  font-size: 0.9375rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.att-x:hover { background: #1f1c19; }
.message-images { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.message-images a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--light);
  line-height: 0;
}
/* Sizes in fixed units, so the frame closes on the picture whatever its shape. */
.message-images img { display: block; max-width: min(16.25rem, 64vw); max-height: 13.75rem; width: auto; height: auto; }
.att-gone {
  border: 1px dashed var(--line);
  border-radius: 0.75rem;
  padding: 0.625rem 0.875rem;
  color: var(--muted);
  font-size: 0.8125rem;
}
.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
}
.drop-veil[hidden] { display: none; }
.drop-veil > div {
  border: 0.125rem dashed var(--green);
  border-radius: 1.25rem;
  padding: 2.125rem 2.75rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1875rem;
  text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .att.sending::after { animation: none; }
}

/* Phones: the top row keeps the everyday buttons (history, new chat, the account) and puts the site map, fullscreen,
   the guide and settings in the "עוד" menu (app.js), so the row fits a 320px screen beside the exam toggle.
   With an exam open the sign-in button and, on the narrowest screens, the toggle show only their icons. */
.top-actions .more-btn { display: none; }
.more-menu button { display: flex; align-items: center; gap: 0.625rem; min-height: 2.75rem; }
.more-menu svg { flex: none; color: var(--muted); }
@media (max-width: 740px) {
  .top-actions .more-btn { display: grid; }
  .top-actions #nav-open, .top-actions #fullscreen-toggle, .top-actions #guide-open, .top-actions #settings-open { display: none !important; }
  html.has-exam .top-signin { width: 2.75rem; padding: 0; justify-content: center; }
  html.has-exam .top-signin .ts-long, html.has-exam .top-signin .ts-short { display: none; }
}
@media (max-width: 440px) { html.has-exam .top-actions { gap: 0.25rem; } }
@media (max-width: 380px) {
  html.has-exam #page-toggle { width: 2.75rem; padding: 0; justify-content: center; }
  html.has-exam #page-toggle .toggle-text { display: none; }
}
/* The zoom bar on a narrow touch screen: two fingers zoom, so its + and − give their room to the page flip and the
   close button (on a 320px screen the full bar was 372px wide and close was off the edge). */
@media (max-width: 380px) and (pointer: coarse) {
  .zm-bar .zm-out, .zm-bar .zm-in { display: none; }
}
/* The message box toolbar on a phone: the filters wrap onto a second line rather than hide past the edge (on a 320px
   screen half of them were out of sight). With the on-screen keyboard up it stays one row that scrolls sideways. */
@media (max-width: 740px) {
  html:not(.keyboard-up) .composer-tools > div {
    flex-wrap: wrap; overflow: visible; row-gap: 0.375rem; padding-inline-end: 0; -webkit-mask-image: none; mask-image: none;
  }
  html:not(.keyboard-up) .composer-tools { align-items: flex-end; }
}
/* A small phone with the keyboard up (under 420px left): the top row steps aside while the student types, so the
   message box with the formula panel fits (on a 320x568 screen it was 20px taller than the room). */
html.keyboard-tight { --top-h: 0.375rem; }
html.keyboard-tight .top-actions, html.keyboard-tight #page-toggle { display: none !important; }
html.keyboard-tight .composer-area { padding: 0.25rem 0.5rem; }
html.keyboard-tight .composer { padding: 0.375rem 0.625rem; }
html.keyboard-tight .fx { gap: 0.25rem; padding-top: 0.25rem; margin-top: 0.125rem; }
/* The formula panel on a touch screen: its tabs scroll sideways (a fade at the far edge says so) and every control
   is 44px; the close mark is drawn in the text colour, not as a faint glyph. */
.fx-tabs { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 1.75rem); mask-image: linear-gradient(to right, transparent 0, #000 1.75rem); padding-inline-end: 1.25rem; }
.fx-close { color: var(--ink); font-size: 1.125rem; font-weight: 600; }
@media (hover: none), (pointer: coarse) {
  .fx-tab { min-height: max(44px, 2.75rem); }
  .fx-insert { height: max(44px, 2.75rem); }
  .fx-close { width: max(44px, 2.75rem); height: max(44px, 2.75rem); }
}
html.keyboard-tight .fx-field { min-height: 0; padding-block: 0.125rem; }
html.keyboard-tight .fx-insert { height: 2.25rem; }
html.keyboard-tight .composer:has(.fx:not([hidden])) .composer-input { --min-h: 1.875rem; --pad-top: 0.125rem; }
html.keyboard-tight .composer:has(.fx:not([hidden])) .composer-input .cm-editor { max-height: 2.125rem; }
/* The first screen on a phone: centred while it fits; taller (the formula panel open, the filters on two rows), it
   starts at the top and scrolls, so the message box is never pushed past the bottom edge. */
@media (max-width: 740px) {
  .tutor-pane:has(#welcome:not([hidden])) { justify-content: safe center; overflow-y: auto; }
}
html.keyboard-tight .learning-area { padding-block: 0; }
/* Touch screens: the plan's and the settings' small controls get a finger's room (44px), as the rest already do. */
@media (pointer: coarse) {
  .ls-step { padding: 0; }
  .ls-step button.ls-step-name { min-height: max(44px, 2.75rem); display: inline-flex; align-items: center; text-align: start; }
  .ls-jump, .pb-back, .pv-back, .pb-lessons-open, .seg-btn, .history-new { min-height: max(44px, 2.75rem); }
  .pb-back, .pv-back { display: inline-flex; align-items: center; }
  .sd-theme button, #settings input[type="number"] { min-height: max(44px, 2.75rem); }
}
/* Phones: the top row floats over the page; a band of the page colour behind it keeps scrolled text from showing
   between its buttons. */
@media (max-width: 740px) {
  body::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 5; pointer-events: none;
    height: calc(var(--top-h, 3.75rem) + 0.25rem); background: linear-gradient(var(--bg) 78%, transparent);
  }
  html.keyboard-tight body::before { display: none; }
}

/* Any step of a lesson opens from the lesson list (plans.js goTo). */
.ls-go { font: inherit; background: none; margin: 0; cursor: pointer; border: 0; padding: 0; color: inherit; text-align: start; min-width: 0; }
.ls-go:hover { text-decoration: underline; text-underline-offset: 0.1875rem; }
.ls-go:focus-visible { outline: 0.125rem solid var(--green); outline-offset: 0.125rem; border-radius: 0.25rem; }
.ls-hint { margin: 0.125rem 0.75rem 0.5rem; font-size: 0.75rem; color: var(--muted); }

/* Full screen (fullscreen.js): the button in the top row, highlighted for a few seconds on entering a chat page. */
.fs-toggle { position: relative !important; inset: auto !important; }
.fs-toggle .fs-off, .fs-toggle.on .fs-on { display: none; }
.fs-toggle.on .fs-off { display: block; }
.fs-toggle.attention { border-color: #e59c7e !important; color: #e59c7e !important; animation: fs-glow 1.4s ease-in-out infinite; }
.fs-toggle.attention::after { content: "מסך מלא"; position: absolute; top: calc(100% + 0.5rem); left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 0.25rem 0.625rem; border-radius: 0.5rem; background: #a94d31; color: #fff; font: 600 0.7812rem var(--sans); pointer-events: none; box-shadow: 0 0.375rem 1rem -0.375rem #302b2799; }
.fs-toggle.attention::before { content: ""; position: absolute; top: calc(100% + 0.1875rem); left: 50%; transform: translateX(-50%); border: 0.3125rem solid transparent; border-bottom-color: #a94d31; border-top: 0; pointer-events: none; }
@keyframes fs-glow { 0%, 100% { box-shadow: 0 0 0 0 #e59c7e66; } 50% { box-shadow: 0 0 0 0.375rem #e59c7e00, 0 0 0.875rem 0.125rem #e59c7e88; } }
@media (prefers-reduced-motion: reduce) { .fs-toggle.attention { animation: none; box-shadow: 0 0 0 0.1875rem #e59c7e66; } }
/* Every lesson is a chat of its own: its link at the end of its row (plans.js lessonList) */
.ls-open {
  flex-shrink: 0; display: inline-flex; align-items: center; min-height: 2rem; padding: 0.25rem 0.75rem; margin-inline-end: 0.25rem;
  border-radius: 6.1875rem; font-size: 0.8125rem; font-weight: 600; color: var(--green); text-decoration: none; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--green) 45%, var(--line));
}
.ls-open:hover { background: color-mix(in srgb, var(--green) 10%, transparent); }
.ls-item.done .ls-open { color: var(--muted); border-color: var(--line); font-weight: 500; }
/* A lesson's chat, finished: on to the next lesson (plans.js paintBar) */
.pb-next {
  display: inline-flex; align-items: center; min-height: 2rem; padding: 0.3125rem 0.75rem; border-radius: 0.5625rem; white-space: nowrap;
  font-size: 0.8125rem; font-weight: 600; text-decoration: none; color: #fff; background: var(--green);
}
.pb-next[hidden] { display: none; }
.pb-next:hover { filter: brightness(1.08); }
.ls-open:focus-visible, .pb-next:focus-visible { outline: 0.125rem solid var(--focus); outline-offset: 0.125rem; }
@media (pointer: coarse) { .ls-open, .pb-next { min-height: max(44px, 2.75rem); } }
@media (max-width: 740px) { .pb-next { order: 7; } }
:where(:root[data-theme='dark']) .pb-next { background-color: #a94d31; color: #fff; }
/* A phone: a lesson row with its own link still fits (the steps done and the time left go under the name, and the
   row shrinks instead of widening the chapter card past the screen). */
@media (max-width: 740px) {
  .plan-lessons .ls-main { flex-wrap: wrap; row-gap: 0; column-gap: 0.5rem; }
  .plan-lessons .ls-name { flex-basis: 100%; overflow-wrap: anywhere; }
  .ls-open { padding-inline: 0.625rem; }
}

/* ── The app's scale (2026-11-25) ──
   Every size above is in rem, so it follows :root's font-size (16px on a phone, 90% on a tablet, 80% from 900px up).
   Icons drawn with width/height attributes follow it too (class rules that size an icon still win), and so do the
   shared AlgoPrep account button and brand (accounts.algoprep.com, sized by --apa-size and rem). */
:where(svg[width="12"]) { width: 0.75rem; height: 0.75rem; }
:where(svg[width="14"]) { width: 0.875rem; height: 0.875rem; }
:where(svg[width="15"]) { width: 0.9375rem; height: 0.9375rem; }
:where(svg[width="16"]) { width: 1rem; height: 1rem; }
:where(svg[width="18"]) { width: 1.125rem; height: 1.125rem; }
:where(svg[width="19"]) { width: 1.1875rem; height: 1.1875rem; }
[data-algoprep-account], [data-algoprep-brand] { --apa-size: 2.5rem; }
@media (pointer: coarse) and (min-width: 600px) {
  /* A touch tablet, drawn at 90%: what is typed in stays 16px (smaller makes iOS zoom the page in). A phone is at
     full size already. */
  .composer-input, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea { font-size: max(16px, 1rem); }
}

/* ── The lesson page: the course outline and one step at a time (plans.js paintCourse) ─────────────────────────
   Beside every chat of the study plan, on the start side, the outline: on a wide screen a column of its own (the
   workspace moves aside for it), on a narrow one a drawer from "תוכן הקורס" in the top bar. In a lesson's chat the
   main column shows one step: its header (where it is, its name, a strip of the lesson's steps), then the video
   inline or the conversation, with one quiet line above the message box. Colours are the app's tokens, so both
   themes follow. The look is kept calm on purpose: one accent, no boxes inside boxes, numbers only where they say
   something (a video's length, progress once there is some). */
:root { --outline-w: 22.5rem; --ol-bg: color-mix(in srgb, var(--ink) 3%, var(--bg)); }
.outline { display: none; flex-direction: column; min-height: 0; background: var(--ol-bg); }
.outline-backdrop { display: none; }
.outline-open { display: none; }
body.portal-open .outline, body.portal-open .outline-open, body.portal-open .outline-backdrop { display: none !important; }
@media (min-width: 1001px) and (min-height: 521px) {
  body.has-outline .outline:not([hidden]) {
    display: flex; position: fixed; z-index: 2; top: 0; bottom: 0; inset-inline-start: 0; width: var(--outline-w);
    padding: 4.5rem 0 0; border-inline-end: 1px solid var(--line);
  }
  body.has-outline:not(.portal-open) .workspace { margin-inline-start: var(--outline-w); }
  /* The exam toggle rides on the pane's edge: the pane is 38% of what is left beside the outline. */
  body.has-outline #page-toggle[aria-expanded="true"] { left: calc((100% - var(--outline-w)) * 0.38 + 0.625rem); }
  /* The top bar is pinned to the screen's corner and would straddle the outline's edge (three buttons over the
     outline, two over the lesson). Here it is a header of two ends: the brand alone above the outline, and the
     buttons at the far end of the lesson's column, beside the exam toggle (which rides on the question pane's edge
     when that is open, so the buttons start past it). The brand's divider is the outline's own border now. The bar
     spans the row, so only its own things take clicks. */
  body.has-outline:not(.portal-open) .top-actions { left: 3.75rem; pointer-events: none; }
  body.has-outline:not(.portal-open) #page-toggle[aria-expanded="true"] ~ .top-actions { left: calc((100% - var(--outline-w)) * 0.38 + 3.375rem); }
  body.has-outline:not(.portal-open) .top-actions > * { pointer-events: auto; }
  body.has-outline:not(.portal-open) .top-actions > .course-name { margin-inline-end: auto; }
  body.has-outline:not(.portal-open) .top-actions .apb-sep { display: none; }
  /* The outline says which chapter and lesson: the header keeps "שיעור 1 › שלב 3 מתוך 12". */
  body.has-outline .sh-chapter, body.has-outline .sh-chapter-sep { display: none; }
}
.outline-open {
  align-items: center; gap: 0.5rem; height: 2.25rem; padding: 0 0.875rem; border-radius: 6.1875rem; font-size: 0.875rem; white-space: nowrap;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 0.125rem 0.375rem #302c2408;
}
.outline-open:hover { filter: none; background: color-mix(in srgb, var(--ink) 5%, var(--paper)); }
:where(:root[data-theme='dark']) .outline-open { background: var(--paper); color: var(--ink); }
@media (max-width: 1000px), (max-height: 520px) {
  body.has-outline .outline-open:not([hidden]) { display: inline-flex; }
  body.has-outline.outline-shown .outline:not([hidden]) {
    display: flex; position: fixed; z-index: 9; top: 0; bottom: 0; inset-inline-start: 0; width: min(24rem, 88vw);
    padding-top: max(0.75rem, env(safe-area-inset-top)); border-inline-end: 1px solid var(--line);
    box-shadow: 0 0 3rem #302c2433; animation: outline-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
  }
  .outline .ol-close { display: grid; }
  body.has-outline.outline-shown .outline-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 8; background: #302c243b; }
}
@keyframes outline-in { from { transform: translateX(1.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { body.has-outline.outline-shown .outline { animation: none !important; } .cp-meter i { transition: none; } }

/* The outline's head: its name, the way back to the plan, and the course's progress as one thin line. */
.ol-head { display: grid; gap: 0.75rem; padding: 0 1.25rem 1rem; border-bottom: 1px solid var(--line); }
.ol-head-row { display: flex; align-items: center; gap: 0.5rem; }
.ol-label { flex: 1; font-size: 1.0625rem; font-weight: 700; color: var(--ink); }
.ol-back { color: var(--muted); text-decoration: none; font-size: 0.8125rem; padding: 0.25rem 0.5rem; margin-inline-end: -0.5rem; border-radius: 0.5rem; white-space: nowrap; }
.ol-back:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.ol-close { display: none; place-items: center; width: max(44px, 2.75rem); height: max(44px, 2.75rem); margin-block: -0.5rem; padding: 0; background: transparent; color: var(--ink); border: 0; font-size: 1.125rem; }
.ol-close:hover { filter: none; background: color-mix(in srgb, var(--ink) 6%, transparent); }
:where(:root[data-theme='dark']) .ol-close { background-color: transparent; color: var(--ink); }
.ol-progress { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-meter { flex: 1; height: 0.25rem; border-radius: 6.1875rem; background: color-mix(in srgb, var(--ink) 11%, transparent); overflow: hidden; }
.cp-meter i { display: block; height: 100%; border-radius: 6.1875rem; background: var(--green); transition: width 0.4s; }
.cp-pct { color: var(--ink); font-weight: 600; }

/* The list. Its scrollbar shows only while the pointer is over the outline (two bars side by side with the
   conversation's would be the loudest thing on the page). */
.ol-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0.625rem 0.625rem 1rem; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.outline:hover .ol-scroll, .outline:focus-within .ol-scroll { scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
.ol-chapters, .ol-lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ol-ch-row, .ol-ls-row, .ol-step {
  width: 100%; display: flex; align-items: baseline; gap: 0.625rem; text-align: start; background: transparent; color: var(--ink);
  border: 0; border-radius: 0.5rem; padding: 0.5rem 0.625rem; font-size: 0.9375rem; line-height: 1.4; font-weight: 400;
}
.ol-ch-row:hover, .ol-ls-row:hover, .ol-step:hover { filter: none; background: color-mix(in srgb, var(--ink) 5%, transparent); }
:where(:root[data-theme='dark']) .ol-ch-row, :where(:root[data-theme='dark']) .ol-ls-row, :where(:root[data-theme='dark']) .ol-step { background-color: transparent; color: var(--ink); }
:where(:root[data-theme='dark']) .ol-ch-row:hover, :where(:root[data-theme='dark']) .ol-ls-row:hover, :where(:root[data-theme='dark']) .ol-step:hover { background-color: color-mix(in srgb, var(--ink) 6%, transparent); }
.outline :focus-visible { outline: 0.125rem solid var(--focus); outline-offset: -0.125rem; }

/* A chapter: its number in a column of its own, so the names line up. */
.ol-num { flex-shrink: 0; width: 1.125rem; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; }
.ol-ch-title { flex: 1; min-width: 0; }
.ol-ch-row { color: var(--muted); }
.ol-ch.current > .ol-ch-row, .ol-ch.open > .ol-ch-row { color: var(--ink); font-weight: 700; }
.ol-ch.open { padding-bottom: 0.625rem; }
.ol-ch.open + .ol-ch { border-top: 1px solid var(--line); padding-top: 0.375rem; margin-top: 0; }
.ol-ch:has(+ .ol-ch.open) { padding-bottom: 0.375rem; border-bottom: 1px solid var(--line); margin-bottom: 0.375rem; }
.ol-ch.optional:not(.open) .ol-ch-title { opacity: 0.75; }
.ol-ch-meta, .ol-ls-meta, .ol-min { flex-shrink: 0; font-size: 0.75rem; color: var(--muted); font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ol-ch-meta.ok, .ol-ls-meta.ok { color: var(--green); font-weight: 700; }
.ol-ch-meta:empty, .ol-ls-meta:empty { display: none; }

/* Its lessons, under the chapter's name: two columns down the whole outline, the numbers and the steps' marks in
   the first, every name in the second. */
.ol-ch-body { padding: 0; }
.ol-ls-row { font-size: 0.875rem; color: var(--muted); padding: 0.4375rem 0.625rem; padding-inline-start: 2.375rem; }
.ol-ls-name { flex: 1; min-width: 0; display: grid; gap: 0.0625rem; }
.ol-ls-no { font-size: 0.75rem; letter-spacing: 0.02em; color: var(--muted); font-weight: 400; }
.ol-ls-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.ol-ls.current > .ol-ls-row, .ol-ls.open > .ol-ls-row { color: var(--ink); font-weight: 600; }
.ol-ls.current > .ol-ls-row .ol-ls-no { color: var(--green); font-weight: 600; }
.ol-ls.off > .ol-ls-row { opacity: 0.8; }
.ol-ls-meta { align-self: center; }
.ol-chapter-videos { margin-bottom: 0.125rem; }

/* The open lesson's steps, on a rail: a ring for each, ✓ in a full one once done, a dot in the one on screen. */
.ol-steps { display: flex; flex-direction: column; padding: 0.125rem 0 0.375rem; }
.ol-step { position: relative; align-items: center; gap: 0.625rem; padding: 0.375rem 0.625rem; min-height: 2.125rem; font-size: 0.875rem; }
.ol-step::before {
  content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: calc(0.625rem + 0.5625rem - 0.0625rem); width: 0.125rem;
  background: color-mix(in srgb, var(--ink) 14%, transparent);
}
.ol-step:first-child::before { top: 50%; }
.ol-step:last-child::before { bottom: 50%; }
.ol-step:only-child::before { display: none; }
.ol-mark {
  position: relative; flex-shrink: 0; display: grid; place-items: center; width: 1.125rem; height: 1.125rem; border-radius: 50%;
  border: 0.125rem solid color-mix(in srgb, var(--muted) 60%, transparent); background: var(--ol-bg); color: var(--muted); line-height: 1;
}
.ol-mark svg { width: 0.625rem; height: 0.625rem; }
.ol-tick { font-size: 0.6875rem; font-weight: 700; }
.ol-tick:empty { display: none; }
.ol-step.done .ol-mark { background: var(--green); border-color: var(--green); color: var(--ol-bg); }
.ol-step.here .ol-mark { border-color: var(--green); color: var(--green); }
.ol-step.here.done .ol-mark { color: var(--ol-bg); }
.ol-step.here:not(.done):not(.video) .ol-mark::after { content: ""; width: 0.375rem; height: 0.375rem; border-radius: 50%; background: var(--green); }
.ol-step.here { background: color-mix(in srgb, var(--green) 13%, transparent); font-weight: 600; }
.ol-step.here:hover { background: color-mix(in srgb, var(--green) 17%, transparent); }
:where(:root[data-theme='dark']) .ol-step.here, :where(:root[data-theme='dark']) .ol-step.here:hover { background-color: color-mix(in srgb, var(--green) 15%, transparent); }
.ol-step.off { color: var(--muted); }
.ol-step-text { flex: 1; min-width: 0; display: grid; }
.ol-step-name, .ol-step-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-step-sub { font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.ol-tag { margin-inline-start: 0.375rem; font-size: 0.6875rem; padding: 1px 0.4375rem; border-radius: 6.1875rem; color: var(--muted); border: 1px solid var(--line); white-space: nowrap; font-weight: 400; }

/* "תוכנית ומעקב", apart from the chapters, at the bottom. */
.ol-overview {
  display: grid; gap: 0.0625rem; margin: 0; padding: 0.75rem 1.25rem max(0.75rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-size: 0.875rem;
}
.ol-overview strong { font-weight: 600; }
.ol-overview small { color: var(--muted); font-size: 0.75rem; }
.ol-overview:hover, .ol-overview.current { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.ol-overview.current strong { color: var(--green); }

/* The step's header, as wide as the conversation: where, the name with its chip beside it, the lesson's strip. */
.step-head { flex-shrink: 0; width: min(var(--chat-w), 100% - 3.75rem); margin: 0 auto; padding: 0 0 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.sh-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 1.5rem; }
.sh-where { margin: 0; font-size: 0.8125rem; color: var(--muted); min-width: 0; }
.sh-sep { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.sh-next-lesson {
  flex-shrink: 0; font-size: 0.8125rem; font-weight: 700; text-decoration: none; color: #fff; background: var(--green);
  padding: 0.375rem 0.875rem; border-radius: 6.1875rem; white-space: nowrap;
}
:where(:root[data-theme='dark']) .sh-next-lesson { background: #a94d31; }
.sh-bar { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }
.sh-bar .sh-strip { flex: 1; margin-top: 0; }
.sh-arrow {
  flex-shrink: 0; display: grid; place-items: center; width: 2.375rem; height: 2.375rem; border-radius: 0.625rem;
  font-size: 1.25rem; font-weight: 700; line-height: 1; text-decoration: none; color: #fff; background: var(--green);
  box-shadow: 0 0.125rem 0.5rem color-mix(in srgb, var(--green) 35%, transparent); transition: transform 0.15s, filter 0.15s;
}
:where(:root[data-theme='dark']) .sh-arrow { background: #a94d31; }
.sh-arrow:hover { filter: brightness(1.1); transform: scale(1.06); }
.sh-arrow:focus-visible { outline: 0.125rem solid var(--green); outline-offset: 0.125rem; }
.sh-arrow.off { opacity: 0.25; box-shadow: none; pointer-events: none; }
.sh-row { display: flex; align-items: center; justify-content: flex-start; gap: 0.375rem 0.75rem; flex-wrap: wrap; }
.sh-title { margin: 0; font-family: var(--serif); font-size: 1.625rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; min-width: 0; }
.sh-chip { flex-shrink: 0; font-size: 0.8125rem; color: var(--muted); background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 6.1875rem; padding: 0.1875rem 0.6875rem; white-space: nowrap; }
.sh-chip.done { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.sh-strip { display: flex; gap: 0.1875rem; margin-top: 0.625rem; }
.sh-strip span { flex: 1; height: 0.1875rem; border-radius: 0.125rem; background: color-mix(in srgb, var(--ink) 11%, transparent); }
/* Done is full, the step on screen is half-way there (a done step that is on screen stays full). */
.sh-strip span.here { background: color-mix(in srgb, var(--green) 50%, transparent); }
.sh-strip span.done { background: var(--green); }

/* A video step: the player itself. It is never taller than the window allows, so its buttons are on screen with it;
   the header narrows with it, and the two sit as one block. */
body.step-is-video #messages, body.step-is-video .composer-area, body.step-is-video #plan-video { display: none !important; }
body.step-is-video { --sv-w: max(22rem, (100dvh - 19.5rem) * 16 / 9); }
body.step-is-video .step-head { width: min(var(--chat-w), 100% - 3.75rem, var(--sv-w)); }
.step-video {
  width: min(var(--chat-w), 100%, var(--sv-w)); margin: 0 auto; padding-bottom: 1rem; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "stage stage" "actions next" "after after"; gap: 0.875rem 0.75rem; align-items: center;
}
.sv-stage { grid-area: stage; }
.sv-actions { grid-area: actions; }
.sv-next { grid-area: next; }
.sv-after { grid-area: after; }
.sv-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 0.875rem; overflow: hidden; background: #0f1215; }
.sv-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sv-cover { position: absolute; inset: 0; display: block; padding: 0; border: 0; border-radius: 0; background: #0f1215; color: #fff; }
.sv-cover:hover { filter: none; }
.sv-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sv-blank { display: grid; place-items: center; height: 100%; padding: 1.5rem; font-family: var(--serif); font-size: 1.75rem; font-weight: 600; }
.sv-corner { position: absolute; left: 1.25rem; bottom: 1.25rem; display: flex; align-items: center; gap: 0.625rem; }
.sv-play { display: grid; width: 3.75rem; height: 3.75rem; color: #a94d31; filter: drop-shadow(0 0.25rem 0.75rem #0006); transition: transform 0.15s; }
.sv-play svg { width: 100%; height: 100%; }
.sv-cover:hover .sv-play { transform: scale(1.06); }
.sv-dur { background: #000000a6; color: #fff; font-size: 0.875rem; padding: 0.125rem 0.5rem; border-radius: 0.375rem; font-variant-numeric: tabular-nums; }
.sv-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.sv-mark {
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6.1875rem; padding: 0.5rem 1rem; font-size: 0.9375rem;
}
.sv-mark:hover { filter: none; color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
:where(:root[data-theme='dark']) .sv-mark { background-color: transparent; color: var(--muted); }
:where(:root[data-theme='dark']) .sv-mark:hover { color: var(--ink); }
.sv-state { font-size: 0.875rem; color: var(--green); }
.sv-next {
  display: inline-flex; align-items: center; gap: 0.625rem; padding: 0.6875rem 1.25rem; border-radius: 0.75rem;
  background: var(--green); color: #fff; font-weight: 700; text-decoration: none; font-size: 1rem; transition: filter 0.15s;
}
.sv-next:hover { filter: brightness(1.07); }
:where(:root[data-theme='dark']) .sv-next { background: #a94d31; }
.sv-after { border-top: 1px solid var(--line); padding: 0.875rem 0.125rem 0; font-size: 0.875rem; line-height: 1.7; }
.sv-after-title { color: var(--muted); margin-bottom: 0.125rem; }
.sv-after-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; }
.sv-after-list li:not(:last-child)::after { content: "·"; margin-inline: 0.5rem; color: var(--muted); }
/* Beside the outline, the list of what follows would say it twice. */
@media (min-width: 1001px) and (min-height: 521px) { body.has-outline .sv-after { display: none; } }

/* A tutor step: one quiet line between the conversation and the message box (no box of its own). */
.step-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.25rem 0.75rem; flex-wrap: wrap; margin: 0; padding: 0 0.5rem 0.5rem;
  font-size: 0.8125rem; color: var(--muted);
}
.sb-next { color: var(--green); font-weight: 700; text-decoration: none; white-space: nowrap; border-radius: 0.375rem; }
/* In the place of "הבא" until the step is done: "הבנה", the tutor's estimate, filling a pill of the button's shape;
   at 100% the button itself takes its place. */
.sb-end { display: inline-flex; align-items: center; }
.sb-next[hidden] { display: none; }
.sb-meter {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: space-between; gap: 1.25rem;
  min-width: 11rem; min-height: 2.5rem; padding: 0.5rem 1rem; border-radius: 0.75rem; border: 1px solid var(--line);
  color: var(--ink); font-size: 0.875rem; font-variant-numeric: tabular-nums; cursor: default;
}
.sb-meter[hidden] { display: none; }
.sb-meter i { position: absolute; inset-block: 0; inset-inline-start: 0; background: color-mix(in srgb, var(--green) 26%, transparent); transition: width 0.6s; }
.sb-meter span, .sb-meter b { position: relative; }
.sb-meter span { color: var(--muted); }
.sb-meter b { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .sb-meter i { transition: none; } }
.sb-next:hover { text-decoration: underline; }
.sb-next[aria-disabled="true"] { color: var(--muted); font-weight: 400; opacity: 0.75; cursor: default; text-decoration: none; }
/* The step is done and its conversation ends here (each step has a chat of its own): "הבא" is the page's button. */
.step-bar.ready { align-items: center; padding-bottom: 0.625rem; color: var(--green); font-weight: 500; }
.step-bar.ready .sb-next {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.5rem; padding: 0.5rem 1.125rem; border-radius: 0.75rem;
  background: var(--green); color: #fff; white-space: normal;
}
.step-bar.ready .sb-next:hover { text-decoration: none; filter: brightness(1.07); }
:where(:root[data-theme='dark']) .step-bar.ready .sb-next { background: #a94d31; }
/* What the page sent to open a step's chat: not the student's words, so not shown. */
.message.user.kickoff { display: none; }

/* A move the student chose in the outline ("עוברים לשלב: זיהוי"): a line across the conversation, not a bubble. */
.message.user.jump { margin: 0.25rem 0; }
.message.user.jump .message-body { flex: 1; min-width: 0; }
.message.user.jump .content {
  display: flex; align-items: center; gap: 0.875rem; width: 100%; max-width: none; padding: 0; background: none; border-radius: 0;
  font-size: 0.8125rem; color: var(--muted); white-space: nowrap;
}
:where(:root[data-theme='dark']) .message.user.jump .content { background: none; }
.message.user.jump .content::before, .message.user.jump .content::after { content: ""; flex: 1; height: 1px; background: var(--line); }

@media (max-width: 1000px) {
  .step-head { width: min(var(--chat-w), 100% - 2.5rem); }
  body.step-is-video .step-head { width: min(var(--chat-w), 100% - 2.5rem, var(--sv-w)); }
}
@media (max-width: 740px) {
  body.step-is-video { --sv-w: 100vw; }
  .step-head, body.step-is-video .step-head { width: calc(100% - 2rem); padding-bottom: 0.625rem; }
  .sh-long { display: none; }
  .sh-title { font-size: 1.3125rem; line-height: 1.35; }
  .sh-chip { font-size: 0.75rem; padding: 0.125rem 0.625rem; }
  .step-video { width: 100%; min-height: 100%; grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "actions" "after" "next"; grid-template-rows: auto auto auto 1fr; gap: 0.875rem; padding-bottom: 0; }
  .sv-stage { border-radius: 0.75rem; }
  .sv-corner { left: 0.625rem; bottom: 0.625rem; }
  .sv-play { width: 2.75rem; height: 2.75rem; }
  .sv-dur { font-size: 0.75rem; }
  .sv-next {
    align-self: end; justify-content: center; padding: 0.9375rem; border-radius: 0.75rem;
    position: sticky; bottom: 0.75rem; box-shadow: 0 0 0 0.75rem var(--bg);
  }
  .step-bar { font-size: 0.75rem; padding: 0 0.25rem 0.375rem; }
}
@media (prefers-reduced-motion: reduce) { .sv-play, .sv-next { transition: none; } }

/* The course's name beside the AlgoPrep brand, as on the front page: the brand leads to algoprep.com, the name to this
   course's home. On a phone the bar has no room for it (the logo's panel lists this site's pages). */
.top-actions .course-name { display: inline-flex; align-items: center; gap: 0.4em; align-self: center; padding-inline: 0.15rem 0.5rem; color: var(--ink); font: 700 1.05rem var(--serif, var(--sans)); text-decoration: none; white-space: nowrap; }
.top-actions .course-name b { font: 600 0.9em var(--mono, ui-monospace, Menlo, Consolas, monospace); color: var(--orange); letter-spacing: -0.02em; }
.top-actions .course-name:hover { color: var(--orange); }
@media (max-width: 640px) { .top-actions .course-name { display: none; } }

/* The plan page and the entry page's card while the plan is still being written (plans.js renderComing, paintPortal). */
.pp-coming { display: grid; gap: 0.75rem; justify-items: start; max-width: 40rem; }
.pp-coming-head { margin: 0; font: 600 1.375rem var(--serif, var(--sans)); color: var(--ink); }
.pp-coming-text { margin: 0; color: var(--muted); line-height: 1.7; }
.pp-coming-go { font-weight: 600; color: var(--green); text-decoration: none; min-height: max(44px, 2.75rem); display: inline-flex; align-items: center; }
.pp-coming-go:hover { text-decoration: underline; }
.pv-card-plans.is-coming .pv-go { color: var(--muted); }
