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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--sp-2);
  line-height: 1.3;
  font-weight: 700;
}
h1 {
  font-size: var(--fs-xl);
}
h2 {
  font-size: var(--fs-lg);
}
h3 {
  font-size: var(--fs-md);
}

p {
  margin: 0 0 var(--sp-3);
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
}

/* Every math island is LTR and isolated from the surrounding Hebrew.
   Without this, a formula at the end of a Hebrew sentence jumps around. */
.math,
.katex,
[dir='ltr'] {
  direction: ltr;
  unicode-bidi: isolate;
}

.math {
  display: inline-block;
  white-space: nowrap;
}

.math-block {
  display: block;
  margin: var(--sp-3) 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding-block: 2px;
}

.katex {
  font-size: 1.05em;
}

.katex-error {
  color: var(--err);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

/* Latin or numeric tokens inside Hebrew prose. */
bdi {
  unicode-bidi: isolate;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
