@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("./fonts/IBMPlexSansArabic-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("./fonts/IBMPlexSansArabic-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Arabic";
  src: url("./fonts/IBMPlexSansArabic-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Kawkab Mono";
  src: url("./fonts/KawkabMono-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Kawkab Mono";
  src: url("./fonts/KawkabMono-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
}

[data-theme] {
  --zd-ui-tab-strip: color-mix(
    in srgb,
    var(--zd-surface) 55%,
    var(--zd-border)
  );
  --zd-ui-hover: color-mix(
    in srgb,
    var(--zd-surface) 66%,
    var(--zd-border)
  );
  --zd-ui-active: color-mix(
    in srgb,
    var(--zd-surface) 89%,
    var(--zd-clay)
  );
  --zd-ui-placeholder: color-mix(
    in srgb,
    var(--zd-border) 48%,
    var(--zd-muted)
  );
  --zd-ui-gutter: color-mix(
    in srgb,
    var(--zd-border) 70%,
    var(--zd-muted)
  );
  --zd-ui-olive-tint: color-mix(
    in srgb,
    var(--zd-olive) 16%,
    transparent
  );
  /* The border colour itself. It used to be pulled 28% toward --zd-muted,
   * which is a *text* colour, so the rails were heavier than any other
   * hairline on the page — structural furniture drawn darker than the panel
   * edges beside it. */
  --zd-ui-indent-guide: var(--zd-border);
  --zd-ui-indent-guide-active: color-mix(
    in srgb,
    var(--zd-clay) 76%,
    var(--zd-ui-indent-guide)
  );
  /*
   * A scrim has one job — put the page a step back — and it can only do that
   * by darkening. These are the one pair of colours here that must not follow
   * the theme, so the day ink is written out rather than read from --zd-ink:
   * that token is #2A241E by day and #EFE7D9 by night, so a scrim mixed from
   * it inverted, and night got a 34% cream veil that left the workspace
   * lighter than the chrome around it. The night values below are black,
   * which is the only direction left on a page this dark.
   */
  --zd-ui-scrim: color-mix(in srgb, #2A241E 34%, transparent);
  --zd-ui-scrim-strong: color-mix(in srgb, #2A241E 45%, transparent);
  /*
   * A shadow is the same problem as a scrim and was missed when the scrims
   * were fixed: mixed from --zd-ink it followed the theme, and night's ink is
   * near-white, so every raised surface wore a pale halo instead of a shadow.
   * Also fixed, and black by night for the same reason the scrims are.
   */
  --zd-ui-shadow: #2A241E;
}

:root[data-theme="night"] {
  --zd-ui-scrim: color-mix(in srgb, #000000 55%, transparent);
  --zd-ui-scrim-strong: color-mix(in srgb, #000000 66%, transparent);
  --zd-ui-shadow: #000000;
}

:root[data-theme="night"],
.terminal-pane[data-theme="night"],
.session-pane[data-theme="night"] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-width: 0;
  overflow: hidden;
  background: var(--zd-bg);
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  margin: 0;
  font: inherit;
}

button,
select {
  cursor: default;
}

button,
select,
input {
  color: inherit;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--zd-clay);
  outline-offset: 2px;
}

a {
  color: var(--zd-clay);
  text-decoration: none;
}

a:hover {
  color: var(--zd-clay-deep);
}

::placeholder {
  color: var(--zd-ui-placeholder);
  opacity: 1;
}

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

.playground {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--zd-bg);
  color: var(--zd-ink);
}

.topbar {
  z-index: 2;
  height: 54px;
  min-height: 54px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--zd-border);
  background: var(--zd-surface);
}

.brand {
  min-width: max-content;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--zd-ink);
}

.brand-mark {
  width: 26px;
  height: 24px;
  flex: none;
  object-fit: contain;
}

.brand-marks {
  display: flex;
  align-items: center;
}

.brand-mark-night {
  display: none;
}

:root[data-theme="night"] .brand-mark-day {
  display: none;
}

:root[data-theme="night"] .brand-mark-night {
  display: block;
}

.topbar-spacer {
  min-width: 4px;
  flex: 1;
}

.topbar-actions {
  min-width: max-content;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.control:hover {
  border-color: var(--zd-muted);
  background: var(--zd-ui-hover);
}

.control svg {
  width: 13px;
  height: 13px;
  flex: none;
}

/*
 * Lit while the drawer is open and plain otherwise. This was the button's
 * unconditional style, so it sat clay-tinted next to four neutral controls and
 * announced a drawer that was closed; the `active` class the script toggled
 * had no rule anywhere and changed nothing. `aria-expanded` already carries
 * the state — same as `.new-file` above.
 */
.examples-toggle[aria-expanded="true"] {
  border-color: color-mix(
    in srgb,
    var(--zd-border) 60%,
    var(--zd-clay)
  );
  background: var(--zd-ui-active);
  color: var(--zd-clay);
}

/*
 * The version control is one of the topbar's buttons, not a form widget
 * dressed as one. It carries `.control` for its border, radius, height and
 * text weight, and the <select> inside it is stripped to nothing so the
 * wrapper is what a reader sees — otherwise the two disagree about padding and
 * the control renders a box inside a box.
 *
 * The chevron is ours for the same reason `appearance: none` is: macOS draws a
 * native select's indicator itself, at its own inset, ignoring inline-end
 * padding — a single chevron in Chrome and a double arrow in Safari, neither
 * of them matching this UI or reachable by our spacing. Drawing it here makes
 * the gap a number in this stylesheet rather than a platform's opinion.
 */
.version-control {
  position: relative;
  gap: 0;
  padding-inline: 12px 28px;
  cursor: default;
}

.version-control:focus-within {
  outline: 2px solid var(--zd-clay);
  outline-offset: 2px;
}

.version-control::after {
  content: "";
  position: absolute;
  inset-inline-end: 12px;
  /* Anchored rather than left at its static position, which would depend on
   * the wrapper remaining an inline-flex box. */
  top: 50%;
  width: 6px;
  height: 6px;
  margin-block-start: -5px;
  border-right: 1.5px solid var(--zd-muted);
  border-bottom: 1.5px solid var(--zd-muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.version-control select {
  /* Safari needed the prefix until 16.4, and without it the native indicator
   * survives — which is the whole defect. */
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
}

.theme-toggle {
  padding-inline: 10px;
}

.theme-toggle .moon-icon {
  display: none;
}

:root[data-theme="night"] .theme-toggle .sun-icon {
  display: none;
}

:root[data-theme="night"] .theme-toggle .moon-icon {
  display: block;
}

/* Icon-only, so it is sized like the other square controls rather than by a
 * text label that no longer exists. */
.github-link {
  padding-inline: 10px;
  color: var(--zd-muted);
}

.github-link:hover {
  color: var(--zd-clay);
}

.text-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--zd-clay);
  font-size: inherit;
  white-space: nowrap;
}

.text-link:hover {
  color: var(--zd-clay-deep);
}

.workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  overflow: hidden;
}

/*
 * The drawer sits over the workspace, so the workspace goes back a step while
 * it is open: without this the drawer read as a column flush against the
 * editor rather than as something laid over it. Clicking the dimmed area
 * closes the drawer, which is the whole point of having one.
 */
.drawer-backdrop {
  position: absolute;
  z-index: 7;
  inset: 0;
  background: var(--zd-ui-scrim);
  transition: opacity 0.25s ease;
}

.drawer-backdrop[hidden] {
  /* Same trick as the drawer: the UA `display: none` cannot be faded, and
   * `visibility` waits for the fade to finish before leaving the tab order. */
  display: block;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

/*
 * Over the workspace at every width, never beside it. Held in the flow the
 * drawer took a fixed 300px off the editor for as long as it was open, and at
 * 1100px and below that left too little to write in — so it already had to
 * become an overlay there, and the page had two drawers to reason about with a
 * breakpoint deciding which one a reader got. It is somewhere you go and come
 * back from; a reader who opens it to copy an example does not want the file
 * they are copying into to reflow underneath them.
 *
 * Closing slides it out rather than resizing it: animating width would reflow
 * every example row on each frame.
 */
.examples-drawer {
  position: absolute;
  z-index: 8;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(300px, 100%);
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--zd-border);
  background: var(--zd-surface);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--zd-ui-shadow) 18%,
    transparent);
  transition: transform 0.25s ease, opacity 0.18s ease,
    background-color 0.25s ease, color 0.25s ease,
    border-color 0.25s ease;
}

.drawer-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.example-count {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  white-space: nowrap;
}

.example-count {
  padding: 1px 8px;
  background: var(--zd-ui-active);
  color: var(--zd-clay);
  font-size: 10.5px;
}

.drawer-header-spacer {
  flex: 1;
}

.drawer-close,
.new-file {
  border: 0;
  background: transparent;
  color: var(--zd-muted);
}

.drawer-close {
  padding: 2px 4px;
  font-size: 15px;
  line-height: 1;
}

.drawer-close:hover,
.new-file:hover {
  color: var(--zd-clay);
}

/*
 * While its menu is open the + button showed nothing: hover feedback vanished
 * the moment the pointer moved down into the menu, so the control that opened
 * it looked untouched. `aria-expanded` already tracks the state — this gives
 * it a face.
 */
.new-file[aria-expanded="true"] {
  border-radius: 6px;
  /* Not `--zd-ui-active`: that token is a 89% surface mix, which reads against
   * a surface-coloured pane but disappears against the tab strip this button
   * sits on. Measured at 0.944,0.919,0.864 closed against 0.955,0.907,0.864
   * open — a difference no reader would see. */
  background: color-mix(in srgb, var(--zd-clay) 16%, var(--zd-surface));
  color: var(--zd-clay);
}

.drawer-search {
  flex: none;
  padding: 0 16px 12px;
}

.drawer-search input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  outline: none;
  background: var(--zd-bg);
  color: var(--zd-ink);
  font-size: 12px;
}

.drawer-search input:focus {
  border-color: var(--zd-clay);
}

.example-list {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 10px 10px;
  scrollbar-color: var(--zd-border) transparent;
  scrollbar-width: thin;
}

.example-list[hidden] {
  display: none;
}

.examples-drawer[hidden] {
  /* Overrides the user-agent `[hidden] { display: none }` so the closed state
   * is animatable. `visibility` still takes it out of the tab order, and its
   * transition is delayed to the end of the slide so it does not vanish
   * mid-animation.
   *
   * The document is RTL, so inset-inline-start is the right edge and a
   * positive translateX carries the drawer off it. */
  display: flex;
  opacity: 0;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease, opacity 0.18s ease,
    visibility 0s linear 0.25s;
}

.example-row {
  width: 100%;
  display: block;
  flex: none;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--zd-radius);
  background: transparent;
  color: var(--zd-ink);
  text-align: right;
}

.example-row[hidden] {
  display: none;
}

.example-row:disabled {
  opacity: 0.55;
}

.example-row:hover {
  background: var(--zd-ui-hover);
  color: var(--zd-ink);
}

.example-row.active {
  order: -1;
  background: var(--zd-ui-active);
  color: var(--zd-clay);
}

.example-name {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.45;
}

.example-description {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: var(--zd-muted);
  font-size: 10.5px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.example-row.active .example-name {
  color: var(--zd-clay);
  font-weight: 700;
}

.example-row.active .example-description {
  color: var(--zd-clay);
  opacity: 0.75;
}

.drawer-footer {
  min-height: 39px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--zd-border);
  font-size: 11px;
  white-space: nowrap;
}

.editor-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1.15 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--zd-border);
  background: var(--zd-surface);
}

.file-tabs-bar {
  min-height: 40px;
  flex: none;
  display: flex;
  align-items: flex-end;
  border-bottom: 1px solid var(--zd-border);
  background: var(--zd-ui-tab-strip);
}

.file-tabs {
  min-width: 0;
  min-height: 39px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 12px 0;
  scrollbar-width: none;
}

.file-tabs::-webkit-scrollbar {
  display: none;
}

.file-tab {
  flex: none;
  min-width: 0;
  max-width: 260px;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 5px 0 3px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--zd-radius) var(--zd-radius) 0 0;
  margin-bottom: -1px;
  background: transparent;
  color: var(--zd-muted);
  white-space: nowrap;
}

/*
 * Inactive tabs carried no border and no background, so a row of them read as
 * one run of text with no boundary between adjacent names. They take a fainter
 * version of the active tab's own border and surface — enough to read as
 * separate cards, not enough to compete with the active one for attention.
 */
.file-tab:not(.active) {
  border-color: color-mix(in srgb, var(--zd-border) 60%, transparent);
  background: color-mix(in srgb, var(--zd-surface) 40%, transparent);
}

.file-tab:not(.active):hover {
  border-color: var(--zd-border);
  background: color-mix(in srgb, var(--zd-surface) 75%, transparent);
  color: var(--zd-ink);
}

.file-tab.active {
  border-color: var(--zd-border);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-weight: 700;
}

.tab-select,
.tab-close {
  border: 0;
  background: transparent;
  color: inherit;
}

.tab-select {
  min-width: 0;
  max-width: 190px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  padding: 7px 7px 7px 5px;
  font-family: var(--zd-font-code);
  font-size: 11.5px;
  font-weight: inherit;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  unicode-bidi: isolate;
  white-space: nowrap;
}

.tab-close {
  width: 24px;
  height: 24px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 5px;
  color: var(--zd-muted);
  font-size: 12px;
  line-height: 1;
}

.tab-close:hover {
  background: var(--zd-ui-hover);
  color: var(--zd-clay);
}

/*
 * The input fills whatever width the tab already had — see `beginRename`,
 * which pins that width before swapping the label out. A fixed width here
 * resized the tab the moment renaming began, shoving every tab beside it.
 *
 * It carries no box of its own: its own margin, padding and border grew the
 * tab from 31.7px to 37px, so the tab rose above the ones beside it, and its
 * rounded frame sat inside the tab's frame and read as a double border. The
 * text is selected on entry and the caret blinks in it; the tab's own border
 * turning clay is the rest of the affordance.
 */
.tab-name-input {
  min-width: 0;
  flex: 1;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
}

.file-tab.renaming {
  border-color: var(--zd-clay);
}

.new-file {
  flex: none;
  margin: 0 6px 5px;
  padding: 4px 8px;
  background: var(--zd-ui-tab-strip);
  font-size: 14px;
  line-height: 1.5;
}

.new-tab-control {
  position: relative;
  flex: none;
  display: flex;
  align-items: flex-end;
}

/*
 * Anchored to the + button rather than to the tab strip. It used to sit at a
 * fixed inline-start offset, which in RTL is the right edge — while the button
 * sits after the tabs, at the far left. The menu opened across the bar from
 * the control that opened it.
 *
 * `inset-inline-end: 0` lines the menu's outer edge up with the button's and
 * lets it open inward, away from the viewport edge the button is nearest.
 */
.new-tab-menu {
  position: absolute;
  z-index: 5;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  width: 238px;
  max-width: calc(100vw - 24px);
  padding: 5px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--zd-ui-shadow) 16%,
    transparent);
  color: var(--zd-ink);
}

.new-tab-menu[hidden] {
  display: none;
}

.new-tab-menu button {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: right;
}

.new-tab-menu button:hover,
.new-tab-menu button:focus-visible {
  background: var(--zd-ui-hover);
}

.new-tab-menu strong {
  color: var(--zd-ink);
  font-size: 12.5px;
  font-weight: 700;
}

.new-tab-menu span {
  color: var(--zd-muted);
  font-size: 10.5px;
  line-height: 1.55;
}

.file-tab[data-tab-type="session"] {
  border-color: color-mix(in srgb, var(--zd-clay) 38%, transparent);
}

.file-tab[data-tab-type="session"].active {
  border-color: var(--zd-clay);
}

.session-temporary-badge,
[data-session-temporary-badge] {
  flex: none;
  padding: 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--zd-gold) 14%, transparent);
  color: var(--zd-gold);
  font-family: var(--zd-font-ui);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
}

.workspace-notice {
  flex: none;
  margin: 0;
  padding: 7px 12px;
  border-bottom: 1px solid var(--zd-border);
  background: var(--zd-ui-active);
  color: var(--zd-ink);
  font-size: 11.5px;
  line-height: 1.7;
}

.workspace-notice[data-kind="error"] {
  background: color-mix(in srgb, var(--zd-error) 10%, var(--zd-surface));
  color: var(--zd-error);
}

.workspace-notice[data-kind="success"] {
  background: var(--zd-ui-olive-tint);
  color: var(--zd-olive);
}

.code-area {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--zd-surface);
  color: var(--zd-syn-name);
  font-family: var(--zd-font-code);
  font-size: 13.5px;
  line-height: 2.2;
  direction: rtl;
}

#editor > .cm-editor {
  min-width: 0;
  min-height: 0;
  height: 100%;
  flex: 1;
  background: var(--zd-surface);
  color: var(--zd-syn-name);
  direction: rtl;
  font-family: var(--zd-font-code);
  font-size: 13.5px;
}

/*
 * A text editor announces focus with its caret; no desktop editor rings the
 * whole surface. This also overrides CodeMirror's own `1px dotted #212121`,
 * which is why the rule stays rather than being deleted — removing it would
 * expose the library default instead of nothing.
 */
#editor > .cm-editor.cm-focused {
  outline: none;
}

#editor .cm-scroller {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  direction: rtl;
  font-family: var(--zd-font-code);
  line-height: 2.2;
  scrollbar-color: var(--zd-border) transparent;
  scrollbar-width: thin;
}

/*
 * The trailing gap belongs to the line, not to the content box. As padding on
 * .cm-content it sat outside every .cm-line, so the active-line highlight
 * stopped 14px short of the line's end and left a strip of plain background
 * behind it. Padding on .cm-line is inside the line's own background, so the
 * highlight now runs edge to edge while the text keeps the same inset.
 */
#editor .cm-content {
  min-width: max-content;
  /* No inset above line 1: it read as a band of empty editor hanging under
   * the tab strip. The one below stays — it is scroll room at the end of a
   * file, not decoration. The CodeMirror theme in editor.ts sets the same
   * padding and has to agree; this rule is the one that wins. */
  padding: 0 0 16px;
  caret-color: var(--zd-ink);
  direction: rtl;
  text-align: start;
}

#editor .cm-line {
  padding: 0 10px 0 24px;
}

/*
 * VS Code-style guides expose every indentation level. The cursor's enclosing
 * block overlays its neutral guide with softened clay, while syntax, active-line
 * and diagnostic backgrounds, and lint underlines keep their own channels.
 */
#editor .cm-line[data-block-extent],
#editor .cm-line[data-indent-guide-depth] {
  position: relative;
}

#editor .cm-line[data-indent-guide-depth]::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset-block: 0;
  inset-inline-start: 10px;
  width: 1px;
  background: var(--zd-ui-indent-guide);
  box-shadow: var(--zd-indent-guide-shadows);
  pointer-events: none;
}

#editor .cm-line[data-block-extent]::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset-block: 0;
  inset-inline-start: var(--zd-block-guide-offset);
  width: 0;
  border-inline-start: 1px solid var(--zd-ui-indent-guide-active);
  pointer-events: none;
}

#editor .cm-line[data-block-extent="header"]::before {
  inset-block-start: 100%;
}

/*
 * `unicode-bidi: plaintext` takes each line's base direction from its first
 * strong character, which is what lets a line of Latin render left-to-right
 * inside an RTL editor. An empty line has no strong character, and the
 * fallback is left-to-right — so the caret sat at the far left of a blank line
 * in an Arabic file, jumping to the right as soon as a letter was typed.
 *
 * CodeMirror renders an empty line as a lone <br>, so `:empty` does not match
 * it. Isolating just that case lets the line's own `direction: rtl` decide,
 * and leaves every non-empty line on plaintext.
 */
#editor .cm-line:has(> br:only-child) {
  unicode-bidi: isolate;
}

#editor .cm-gutters {
  border: 0;
  background: var(--zd-surface);
  color: var(--zd-ui-gutter);
  direction: ltr;
  font-size: 11px;
  user-select: none;
}

#editor .cm-gutter {
  direction: ltr;
}

#editor .cm-lineNumbers .cm-gutterElement {
  min-width: 42px;
  padding: 0 14px 0 12px;
  direction: ltr;
  text-align: right;
}

/*
 * `align-items: center` in the editor theme centres the number's line box in
 * its row, which is not the same as centring the digits in it. Kawkab Mono
 * keeps 14px above the baseline and 7px below at this size, while a digit inks
 * 8px above it and nothing below — so a number sat 1.09px above the middle of
 * a row whose height comes from the larger code font.
 *
 * Block padding on a centred flex box moves its content by half, so 2.3px
 * buys the 1.15px; the row keeps the fixed height CodeMirror writes inline, so
 * nothing resizes. Not on the first child: that is CodeMirror's zero-height
 * width spacer, and padding gives it a height — which pushed every number
 * 2.3px down, off the line it belongs to. Measured against the line: 1.09px
 * high before, 0.05px low after, with each row still starting where its line
 * starts.
 */
#editor .cm-lineNumbers .cm-gutterElement:not(:first-child) {
  padding-block-start: 2.3px;
}

#editor .cm-activeLine {
  background: color-mix(in srgb, var(--zd-clay) 7%, transparent);
}

#editor .cm-activeLineGutter {
  background: color-mix(in srgb, var(--zd-clay) 10%, transparent);
  color: var(--zd-muted);
}

#editor .cm-selectionBackground,
#editor .cm-content ::selection {
  background: color-mix(in srgb, var(--zd-clay) 24%, transparent);
}

#editor .cm-cursor,
#editor .cm-dropCursor {
  border-left-color: var(--zd-ink);
}

#editor .cm-specialChar,
#editor .cm-nonmatchingBracket {
  color: var(--zd-error);
}

#editor .cm-matchingBracket {
  background: color-mix(in srgb, var(--zd-olive) 24%, transparent);
}

#editor .cm-nonmatchingBracket {
  background: color-mix(in srgb, var(--zd-error) 18%, transparent);
}

#editor .cm-selectionMatch,
#editor .cm-searchMatch {
  background: color-mix(in srgb, var(--zd-gold) 24%, transparent);
}

#editor .cm-searchMatch-selected {
  background: color-mix(in srgb, var(--zd-clay) 30%, transparent);
}

#editor .cm-panels {
  border-color: var(--zd-border);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
}

#editor .cm-panel.cm-search {
  border-color: var(--zd-border);
  direction: rtl;
}

#editor .cm-textfield,
#editor .cm-button {
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-bg);
  background-image: none;
  color: var(--zd-ink);
  font: inherit;
}

#editor .cm-button:active {
  background: var(--zd-ui-hover);
  background-image: none;
}

#editor .cm-placeholder,
#editor .cm-foldPlaceholder {
  border-color: var(--zd-border);
  background: var(--zd-ui-hover);
  color: var(--zd-muted);
}

#editor .cm-line.educational-line,
#editor .cm-line[data-educational-panel-line] {
  padding: 2px 10px;
  margin-block: 0;
  background: var(--zd-syn-edu-bg);
  color: var(--zd-syn-edu);
  border-radius: 0;
  line-height: calc(2.2em - 4px);
}

#editor .cm-line.educational-line-start,
#editor .cm-line[data-educational-block-start] {
  border-start-start-radius: var(--zd-radius);
  border-start-end-radius: var(--zd-radius);
}

#editor .cm-line.educational-line-end,
#editor .cm-line[data-educational-block-end] {
  border-end-start-radius: var(--zd-radius);
  border-end-end-radius: var(--zd-radius);
}

#editor .cm-line.educational-line.cm-activeLine,
#editor .cm-line[data-educational-panel-line].cm-activeLine {
  background: color-mix(
    in srgb,
    var(--zd-clay) 7%,
    var(--zd-syn-edu-bg)
  );
}

.word,
[data-highlight-kind="word"] {
  color: var(--zd-syn-name);
  font-weight: 400;
}

.word.vocabulary,
[data-highlight-kind="word"][data-vocabulary] {
  color: var(--zd-syn-kw);
  font-weight: 700;
}

.literal,
[data-highlight-kind="literal"] {
  color: var(--zd-syn-lit);
}

.number,
[data-highlight-kind="number"] {
  color: var(--zd-syn-num);
}

.string,
[data-highlight-kind="string"] {
  color: var(--zd-syn-str);
}

.comment,
[data-highlight-kind="comment"] {
  color: var(--zd-syn-comment);
}

.educational-prefix,
.educational-prose,
[data-highlight-kind="educational-prefix"],
[data-highlight-kind="educational-prose"] {
  color: var(--zd-syn-edu);
}

.educational-prefix,
[data-highlight-kind="educational-prefix"] {
  font-weight: 700;
}

.delimiter,
.operator,
.punctuation,
[data-highlight-kind="delimiter"],
[data-highlight-kind="operator"],
[data-highlight-kind="punctuation"] {
  color: var(--zd-syn-punct);
}

.diagnostic-span,
#editor .cm-line [data-diagnostic],
[data-diagnostic="span"],
#editor .cm-lintRange.cm-lintRange-error {
  background-image: none;
  padding-bottom: 0;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--zd-error);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  text-decoration-skip-ink: none;
}

#editor .cm-tooltip-lint {
  margin: 0;
  padding: 0;
  border-color: var(--zd-border);
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-ui);
  text-align: start;
}

#editor .cm-diagnostic {
  padding: 5px 8px;
  border: 0;
  border-inline-start: 3px solid var(--zd-error);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
}

/*
 * Completion is learner-facing Arabic UI, not code: Kawkab Mono's fixed
 * Arabic cells break joining, and CodeMirror's LTR icon/label row puts its
 * stock keyword icon on top of the first letters. The source disables that
 * redundant icon; these rules make the remaining list a sibling of the lint
 * tooltip in both themes.
 */
#editor .cm-tooltip.cm-tooltip-autocomplete {
  overflow: hidden;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-ui);
  text-align: start;
}

#editor .cm-tooltip-autocomplete > ul {
  min-width: 180px;
  max-width: min(360px, calc(100vw - 24px));
  max-height: min(240px, 45vh);
  padding: 4px;
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-ui);
  scrollbar-color: var(--zd-border) transparent;
  scrollbar-width: thin;
  text-align: start;
}

#editor .cm-tooltip-autocomplete > ul > li {
  min-height: 30px;
  display: flex;
  align-items: center;
  padding: 4px 9px;
  border-inline-start: 3px solid transparent;
  border-radius: calc(var(--zd-radius) - 3px);
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-ui);
  line-height: 1.45;
  text-align: start;
}

#editor .cm-tooltip-autocomplete > ul > li[aria-selected] {
  border-inline-start-color: var(--zd-clay);
  background: var(--zd-ui-active);
  color: var(--zd-ink);
}

/*
 * With the type icon off, the heading is what separates the learner's own
 * names from Zaid's vocabulary. It is a label rather than a choice, so it
 * reads quieter than the options beneath it and takes the list's indent
 * without the option padding that would make it look selectable.
 */
#editor .cm-tooltip-autocomplete > ul > completion-section {
  display: list-item;
  padding: 7px 9px 3px;
  border: 0;
  border-bottom: 1px solid var(--zd-border);
  margin-bottom: 3px;
  background: var(--zd-surface);
  color: var(--zd-muted);
  direction: rtl;
  font-family: var(--zd-font-ui);
  font-size: 0.82em;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.4;
  opacity: 1;
  text-align: start;
}

#editor .cm-tooltip-autocomplete > ul > completion-section ~ completion-section {
  margin-top: 5px;
}

#editor .cm-completionLabel,
#editor .cm-completionMatchedText {
  font-family: var(--zd-font-ui);
}

#editor .cm-completionMatchedText {
  color: var(--zd-clay);
  font-weight: 700;
  text-decoration: none;
}

#editor .cm-lintPoint-error::after {
  border-bottom-color: var(--zd-error);
}

#editor .cm-line.diagnostic-line,
#editor .cm-line[data-diagnostic],
#editor .cm-line[data-diagnostic="line"] {
  background: color-mix(in srgb, var(--zd-error) 12%, transparent);
}

.editor-toolbar {
  min-height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--zd-border);
  background: var(--zd-surface);
}

.toolbar-button,
.run-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.toolbar-button:hover {
  background: var(--zd-ui-hover);
}

.run-button {
  gap: 8px;
  padding-inline: 14px;
  border-color: var(--zd-clay);
  background: var(--zd-clay);
  color: var(--zd-surface);
  font-size: 13px;
  font-weight: 700;
}

.run-button:hover {
  border-color: var(--zd-clay-deep);
  background: var(--zd-clay-deep);
}

.run-button .stop-icon {
  display: none;
}

.run-button[data-execution-state="running"] {
  border-color: var(--zd-madder);
  background: var(--zd-madder);
}

.run-button[data-execution-state="running"]:hover {
  border-color: var(--zd-error);
  background: var(--zd-error);
}

.run-button[data-execution-state="running"] .run-icon {
  display: none;
}

.run-button[data-execution-state="running"] .stop-icon {
  display: block;
}

.run-button svg {
  width: 11px;
  height: 11px;
  flex: none;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--zd-border);
  border-radius: 4px;
  background: var(--zd-ui-hover);
  color: inherit;
  font-family: var(--zd-font-code);
  font-size: 9.5px;
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
}

.run-button kbd {
  border-color: color-mix(in srgb, var(--zd-surface) 28%, transparent);
  background: color-mix(in srgb, var(--zd-surface) 22%, transparent);
}

/* Running is the one thing this bar is for, so it keeps the inline start on
 * its own and the two quieter actions sit at the far end. */
.editor-toolbar-spacer {
  min-width: 8px;
  flex: 1;
}

.toolbar-button:disabled,
.clear-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.session-pane {
  min-width: 0;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--zd-bg);
  color: var(--zd-ink);
}

.session-pane[hidden],
.code-area[hidden],
.editor-toolbar[hidden],
.terminal-pane[hidden],
.control[hidden],
.statusbar[hidden] {
  display: none;
}

.session-temporary-note {
  min-height: 34px;
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 7px 16px;
  border-bottom: 1px solid var(--zd-border);
  background: color-mix(in srgb, var(--zd-gold) 10%, var(--zd-surface));
  color: var(--zd-muted);
  font-family: var(--zd-font-ui);
  font-size: 11px;
  line-height: 1.7;
}

.session-temporary-note strong {
  flex: none;
  color: var(--zd-gold);
  font-weight: 700;
}

.session-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 18px 20px;
  scrollbar-color: var(--zd-border) transparent;
  scrollbar-width: thin;
}

.session-transcript {
  min-height: 100%;
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-code);
  font-size: 13.5px;
  line-height: 2.05;
  overflow-wrap: anywhere;
  text-align: start;
  unicode-bidi: plaintext;
  white-space: pre-wrap;
}

.session-source-line,
.session-output,
.session-failure,
.session-read-line,
.session-reset-marker,
.session-transcript [data-session-source],
.session-transcript [data-session-output],
.session-transcript [data-session-failure],
.session-transcript [data-session-read],
.session-transcript [data-session-reset] {
  margin: 0;
  white-space: pre-wrap;
}

.session-source-line,
.session-transcript [data-session-source] {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: var(--zd-ink);
}

.session-line-prompt,
.session-transcript [data-session-line-prompt] {
  flex: none;
  color: var(--zd-clay);
  font-weight: 700;
  user-select: none;
}

.session-result-marker,
.session-transcript [data-session-result-marker] {
  color: var(--zd-repl-marker);
  font-weight: 700;
}

.session-failure,
.session-transcript [data-session-failure] {
  margin-block: 6px;
  padding: 8px 11px;
  border-inline-start: 3px solid var(--zd-error);
  border-radius: var(--zd-radius);
  background: color-mix(in srgb, var(--zd-error) 8%, var(--zd-bg));
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
  line-height: 1.8;
}

.session-failure strong,
.session-transcript [data-session-failure] strong {
  color: var(--zd-error);
}

.session-failure-location {
  margin-inline-start: 9px;
  color: var(--zd-muted);
  font-family: var(--zd-font-code);
  font-size: 11px;
}

.session-failure p {
  margin: 4px 0 0;
}

.session-failure-trace {
  margin: 7px 0 0;
  padding-inline-start: 22px;
  color: var(--zd-muted);
  font-family: var(--zd-font-code);
  font-size: 11px;
}

.session-read-line,
.session-transcript [data-session-read] {
  color: var(--zd-clay);
}

.session-reset-marker,
.session-transcript [data-session-reset] {
  margin-block: 8px;
  color: var(--zd-gold);
  font-family: var(--zd-font-ui);
  font-size: 11.5px;
}

.session-ended {
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--zd-gold) 50%, var(--zd-border));
  border-radius: var(--zd-radius);
  background: color-mix(in srgb, var(--zd-gold) 10%, var(--zd-bg));
  color: var(--zd-gold);
  font-family: var(--zd-font-ui);
  font-size: 12px;
  line-height: 1.8;
}

.session-ended[hidden] {
  display: none;
}

.session-toolbar {
  min-height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--zd-border);
  background: var(--zd-surface);
}

.session-input-line {
  min-width: 120px;
  min-height: 36px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline-start: 11px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-bg);
}

.session-input-line:focus-within {
  border-color: var(--zd-clay);
}

.session-prompt {
  flex: none;
  color: var(--zd-clay);
  direction: rtl;
  font-family: var(--zd-font-code);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.session-prompt[data-session-state="open"],
.session-prompt[data-session-state="awaiting-commit"] {
  color: var(--zd-gold);
}

.session-input {
  min-width: 0;
}

#session-input {
  min-width: 0;
  min-height: 34px;
  flex: 1;
  padding: 6px 0 6px 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--zd-ink);
  font-family: var(--zd-font-code);
  font-size: 12.5px;
}

.session-submit,
.session-stop,
.session-restart {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.session-submit {
  border-color: var(--zd-clay);
  background: var(--zd-clay);
  color: var(--zd-surface);
}

.session-submit:hover {
  border-color: var(--zd-clay-deep);
  background: var(--zd-clay-deep);
}

.session-submit kbd {
  border-color: color-mix(in srgb, var(--zd-surface) 28%, transparent);
  background: color-mix(in srgb, var(--zd-surface) 22%, transparent);
}

.session-stop {
  border-color: var(--zd-madder);
  background: var(--zd-madder);
  color: var(--zd-surface);
}

.session-stop:hover {
  border-color: var(--zd-error);
  background: var(--zd-error);
}

.session-restart {
  border-color: var(--zd-clay);
  color: var(--zd-clay);
}

.session-restart:hover {
  background: var(--zd-ui-hover);
}

.session-submit:disabled,
.session-stop:disabled,
#session-input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.session-submit[hidden],
.session-stop[hidden],
.session-restart[hidden] {
  display: none;
}

.session-inline-input,
.session-transcript [data-session-inline-input] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: 6px;
  white-space: normal;
}

.session-inline-input input,
.session-transcript [data-session-inline-input] input {
  min-width: 10rem;
  max-width: min(22rem, 48vw);
  padding: 5px 8px;
  border: 1px solid var(--zd-clay);
  border-radius: var(--zd-radius);
  outline: none;
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-code);
}

.session-inline-input button,
.session-transcript [data-session-inline-input] button {
  padding: 5px 9px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
  font-size: 11px;
}

.session-inline-input button:hover,
.session-transcript [data-session-inline-input] button:hover {
  border-color: var(--zd-clay);
}

.terminal-pane {
  min-width: 0;
  min-height: 0;
  flex: 0.85 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--zd-bg);
  color: var(--zd-ink);
}

.terminal-tabs {
  height: 40px;
  min-height: 40px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 10px;
  border-bottom: 1px solid var(--zd-border);
  background: var(--zd-surface);
  scrollbar-width: none;
}

.terminal-tabs::-webkit-scrollbar {
  display: none;
}

.terminal-title {
  flex: none;
  padding: 10px 12px;
  color: var(--zd-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.terminal-tabs-spacer {
  min-width: 8px;
  flex: 1;
}

/*
 * The block padding is deliberately lopsided. CSS centres the line box, not
 * the letters in it, and «مسح» has no ascender and no mark above, so under
 * symmetric padding it sat low in a line box holding IBM Plex Sans Arabic's
 * full 12px ascent — and lower still than «المخرجات» beside it, whose ا and ل
 * reach the top of that box.
 *
 * The target is where the eye puts the word, which is not the middle of its
 * ink box: «ح» ends in a deep bowl, so a box-centred «مسح» hangs its body
 * above the middle and leaves a visible gap underneath. Aiming instead at the
 * coverage-weighted centroid, where that bowl counts for its area rather than
 * for its reach, measured at 8× off the rendered pixels:
 *
 *   4px / 4px      centroid 2.20px low
 *   3px / 5px      centroid 1.22px low
 *   2.5px / 5.5px  centroid 0.23px low   <- here
 *   1.5px / 6.5px  centroid 0.75px high  (ink box centred, and visibly high)
 */
.clear-button {
  flex: none;
  padding: 2.5px 11px 5.5px;
  border: 1px solid var(--zd-border);
  border-radius: 7px;
  background: transparent;
  color: var(--zd-muted);
  font-size: 11px;
  line-height: 1.4;
}

.clear-button:hover {
  border-color: var(--zd-muted);
  color: var(--zd-ink);
}

.terminal-output {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  font-family: var(--zd-font-code);
  font-size: 13px;
  line-height: 2.1;
  scrollbar-color: var(--zd-border) transparent;
  scrollbar-width: thin;
}

/*
 * An empty dark rectangle says nothing about what it is for. Arabic prose, so
 * the UI font rather than the code font this pane sets for its output.
 *
 * Which of the two states holds is decided here rather than from script,
 * because every path that writes into this pane would otherwise have to
 * remember to take the placeholder away. Three signals mean something is in
 * the pane: the run heading, the diagnostic card — `افحص` reports without
 * starting a run, so the heading alone is not enough — and the retained-output
 * counter the output element already keeps for its own truncation cap.
 */
.output-placeholder {
  margin: 0;
  color: var(--zd-ui-placeholder);
  font-family: var(--zd-font-ui);
  font-size: 12.5px;
  line-height: 1.7;
}

.terminal-output:has(#run-heading:not([hidden]), #editor-diagnostic:not([hidden]), #run-output:not([data-retained-code-units="0"])) .output-placeholder {
  display: none;
}

.run-heading {
  margin: 0 0 4px;
  color: var(--zd-muted);
  font-size: 11px;
}

.output-lines {
  display: block;
  color: var(--zd-ink);
  direction: rtl;
  font-family: inherit;
  font-style: normal;
  overflow-wrap: anywhere;
  text-align: start;
  unicode-bidi: plaintext;
  white-space: pre-wrap;
}

.run-completion {
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--zd-olive);
}

.run-completion[data-status="failed"] {
  color: var(--zd-error);
}

.run-completion[data-status="cancelled"] {
  color: var(--zd-gold);
}

.output-truncation {
  position: sticky;
  z-index: 1;
  top: 0;
  margin: 0 0 10px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--zd-gold) 55%, var(--zd-border));
  border-radius: var(--zd-radius);
  background: color-mix(in srgb, var(--zd-gold) 12%, var(--zd-bg));
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
  font-size: 11.5px;
  line-height: 1.7;
}

/*
 * Its own row, starting at the inline-start edge. As an inline-flex box it was
 * placed by inline layout inside pre-wrapped RTL output, which left it 215px
 * short of the edge on a line it had entirely to itself — measured against an
 * output box spanning 18–594 with the row at 18–378.
 *
 * A prompt keeps its own line above the field. `اقرأ("ما اسمك؟ ")` writes the
 * prompt without a newline, so an inline field used to follow it directly;
 * a field on the next line reads the same way a terminal does and does not
 * depend on where inline layout decides to put it.
 */
.run-input-request {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-block-start: 4px;
  white-space: normal;
}

.run-input-request input {
  min-width: 10rem;
  max-width: min(22rem, 48vw);
  padding: 5px 8px;
  border: 1px solid var(--zd-clay);
  border-radius: var(--zd-radius);
  outline: none;
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-code);
}

.run-input-request button {
  padding: 5px 9px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-surface);
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
  font-size: 11px;
}

.run-input-request button:hover {
  border-color: var(--zd-clay);
}

/*
 * Both inline read affordances — the one in a run and the one in a session —
 * offered two buttons of equal weight, and only one of them is what the
 * program is waiting for. أرسل is the answer; «لا مزيد من الإدخال» is the way
 * out of a loop reading until عدم (§18.4), which is the rarer thing to want
 * and no longer competes for the eye.
 */
button[data-submit-input] {
  border-color: var(--zd-clay);
  background: var(--zd-clay);
  color: var(--zd-surface);
  font-weight: 700;
}

button[data-submit-input]:hover {
  border-color: var(--zd-clay-deep);
  background: var(--zd-clay-deep);
}

button[data-end-input] {
  border-color: transparent;
  background: transparent;
  color: var(--zd-muted);
}

button[data-end-input]:hover {
  border-color: var(--zd-border);
  color: var(--zd-ink);
}

.diagnostic-card {
  max-width: 760px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid color-mix(
    in srgb,
    var(--zd-error) 55%,
    var(--zd-border)
  );
  border-inline-start-width: 3px;
  border-radius: var(--zd-radius);
  background: color-mix(in srgb, var(--zd-error) 8%, var(--zd-bg));
  color: var(--zd-ink);
  font-family: var(--zd-font-ui);
}

.diagnostic-card[hidden] {
  display: none;
}

/*
 * Once the text has changed, the card describes the last check or run and not
 * what is on screen — the highlight in the editor has already gone for the
 * same reason. It keeps its message at full contrast and gives up the error
 * tint, so it reads as a record rather than as a live complaint.
 */
.diagnostic-card[data-diagnostic-stale] {
  border-color: var(--zd-border);
  background: color-mix(in srgb, var(--zd-error) 3%, var(--zd-bg));
}

.diagnostic-card[data-diagnostic-stale] .diagnostic-category {
  color: var(--zd-muted);
}

.diagnostic-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  margin: 0;
}

.diagnostic-category {
  color: var(--zd-madder);
  font-weight: 700;
}

/*
 * "السطر ١" is Arabic prose, not code. In the monospace face every letter got
 * its own fixed cell, so the cursive joining broke and the word rendered as
 * "ا لسطر" — which reads as mangled text rather than as a location.
 */
/*
 * Two facts on one line, and both joins were too tight to see. Between them
 * sat 12px of flex gap, which the long tail of the final ل in «التشغيل»
 * crosses, so «خطأ وقت التشغيل السطر ١» read as one Arabic phrase; a middot
 * makes the boundary a mark rather than a distance.
 *
 * Inside the location, the space is 2.7px at this size — IBM Plex Sans Arabic
 * sets a quarter-em space — and «١» is a bare upright next to the small hook
 * of a final ر, so «السطر ١» read as «السطرا». The word spacing is widened
 * until the number is a separate token.
 */
.diagnostic-location {
  color: var(--zd-muted);
  font-size: 11.5px;
  word-spacing: 2.5px;
}

.diagnostic-category:not([hidden]) + .diagnostic-location::before {
  content: "·";
  margin-inline-end: 9px;
  /* Its own spacing, not the location's. */
  word-spacing: normal;
}

.diagnostic-source {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-inline-start: 2px solid var(--zd-border);
  background: var(--zd-surface);
  color: var(--zd-ink);
  direction: rtl;
  font-family: var(--zd-font-code);
  font-size: 12.5px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  white-space: pre-wrap;
}

.diagnostic-message {
  margin: 10px 0 0;
  color: var(--zd-ink);
  font-size: 13px;
  line-height: 1.8;
}

.diagnostic-call-trace {
  margin: 10px 0 0;
  padding-inline-start: 24px;
  color: var(--zd-muted);
  direction: rtl;
  font-family: var(--zd-font-code);
  font-size: 11.5px;
  line-height: 1.9;
}

.statusbar {
  height: 30px;
  min-height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 14px;
  border-top: 1px solid var(--zd-border);
  background: var(--zd-surface);
  color: var(--zd-muted);
  font-size: 11px;
  white-space: nowrap;
  scrollbar-width: none;
}

.statusbar::-webkit-scrollbar {
  display: none;
}

/* The same readout as `.diagnostic-location` and the same reading: the
 * font's space is a quarter em and «١» is a bare upright, so «السطر ١، العمود
 * ١» ran each number into the word before it. */
.cursor-position {
  word-spacing: 2.5px;
}

@media (max-width: 700px) {
  .topbar {
    gap: 6px;
    padding-inline: 8px;
  }

  .brand {
    gap: 7px;
  }

  .version-control,
  .github-link,
  .examples-toggle span,
  .share-control span,
  .theme-toggle span {
    display: none;
  }

  .topbar-actions {
    min-width: 0;
    gap: 4px;
  }

  .topbar .control {
    padding-inline: 8px;
  }

  .workspace {
    flex-direction: column;
  }

  .editor-pane {
    width: 100%;
    flex: 1.15 1 0;
    border-left: 0;
  }

  .terminal-pane {
    width: 100%;
    flex: 0.85 1 0;
    border-top: 1px solid var(--zd-border);
  }

  .file-tabs {
    padding-inline: 8px;
  }

  .session-temporary-note {
    flex-wrap: wrap;
    gap: 1px 7px;
    padding-inline: 12px;
  }

  .session-scroll {
    padding: 14px 12px;
  }

  .session-toolbar {
    flex-wrap: wrap;
    padding: 8px;
  }

  .session-input-line {
    flex: 1 1 170px;
  }

  .session-submit,
  .session-stop,
  .session-restart {
    padding-inline: 9px;
  }
}

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

/*
 * Shown once on a phone-sized screen. The width matches the stacking
 * breakpoint rather than a device sniff: what makes the experience worse is
 * the editor and output stacking instead of sitting side by side, which is
 * exactly what that breakpoint governs.
 */
.modal-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--zd-ui-scrim-strong);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  max-width: 380px;
  padding: 20px;
  border: 1px solid var(--zd-border);
  border-radius: calc(var(--zd-radius) * 2);
  background: var(--zd-surface);
  color: var(--zd-ink);
  box-shadow: 0 18px 44px color-mix(in srgb, var(--zd-ui-shadow) 28%,
    transparent);
}

.modal-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  margin: 0 0 16px;
  color: var(--zd-muted);
  font-size: 13px;
  line-height: 1.7;
}

.modal-action {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--zd-clay);
  border-radius: var(--zd-radius);
  background: var(--zd-clay);
  color: var(--zd-surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}

.modal-action:hover {
  filter: brightness(1.06);
}

/*
 * Switching the theme rewrites one attribute on <html>, and every colour
 * derived from it changed in a single frame. These are the surfaces that carry
 * a theme colour. A universal selector would be simpler and wrong: it would
 * also animate hover and focus feedback, which has to feel immediate.
 *
 * Safe to apply unconditionally — data-theme ships in the markup, so the first
 * paint is already correct and there is no default to animate away from.
 */
.playground,
.topbar,
.control,
.version-control select,
.file-tabs-bar,
.file-tab,
.tab-name-input,
.editor-pane,
.terminal-pane,
.session-pane,
.statusbar,
.modal-card,
.cm-editor,
.cm-gutters {
  transition: background-color var(--zd-theme-fade) ease,
    color var(--zd-theme-fade) ease,
    border-color var(--zd-theme-fade) ease;
}

/*
 * The theme arrives in a circle growing out of the toggle rather than as a
 * cross-fade — see `sweepTheme`, which animates the clip path of the new root
 * snapshot.
 *
 * Two things have to be held down while it runs. The browser's own root
 * cross-fade would play underneath the circle and show through it. And the
 * colour transitions above would still be part-way when the new snapshot is
 * taken, so the circle would reveal a page frozen half-changed; the duration
 * is a variable for exactly this, so the list of surfaces is written once.
 */
:root {
  --zd-theme-fade: 0.25s;
}

:root.theme-sweep {
  --zd-theme-fade: 0s;
}

:root.theme-sweep::view-transition-old(root),
:root.theme-sweep::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

:root.theme-sweep::view-transition-old(root) {
  z-index: 0;
}

:root.theme-sweep::view-transition-new(root) {
  z-index: 1;
}

/* `sweepTheme` skips the circle under reduced motion; this covers a browser
 * that starts a root transition for any other reason. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

.modal-field {
  width: 100%;
  margin-block-end: 14px;
  padding: 9px 10px;
  border: 1px solid var(--zd-border);
  border-radius: var(--zd-radius);
  background: var(--zd-bg);
  color: var(--zd-ink);
  font-family: var(--zd-font-code);
  font-size: 11.5px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions .modal-action,
.share-option-actions .modal-action {
  flex: 1;
}

/*
 * The share card holds two ways out of the page rather than one, and four
 * buttons across a single row would leave each of them too narrow to read in
 * Arabic. Each way gets a titled block with its own actions, and only the
 * close button stays in the card's own action row.
 */
.share-card {
  width: 100%;
  max-width: 420px;
}

.share-option + .share-option {
  margin-block-start: 16px;
  padding-block-start: 16px;
  border-block-start: 1px solid var(--zd-border);
}

.share-option-title {
  margin: 0 0 10px;
  color: var(--zd-ink);
  font-size: 13px;
  font-weight: 700;
}

.share-option-note {
  margin: 0 0 10px;
  color: var(--zd-muted);
  font-size: 12px;
  line-height: 1.7;
}

.share-option-actions {
  display: flex;
  gap: 8px;
}

.share-option .modal-field {
  margin-block-end: 10px;
}

.share-option-status {
  margin: 10px 0 0;
  color: var(--zd-muted);
  font-size: 12px;
  line-height: 1.7;
}

.share-option-status[data-kind="error"] {
  color: var(--zd-error);
}

.modal-card .share-option:last-of-type {
  margin-block-end: 18px;
}

/* Clay is the colour of every other primary action on the page, and deleting a
 * file is not one of them. */
.modal-action-danger {
  border-color: var(--zd-error);
  background: var(--zd-error);
}

.modal-action-quiet {
  border-color: var(--zd-border);
  background: transparent;
  color: var(--zd-ink);
  font-weight: 500;
}

.modal-action-quiet:hover {
  background: var(--zd-ui-hover);
  filter: none;
}
