:root {
  --bg: #f4f6f8;
  --bg-2: #eaeef2;
  --surface: #ffffff;
  --text: #0e161e;
  --muted: #55626e;
  --faint: #7b8794;
  --line: #d7dde3;
  --grid: rgba(14, 22, 30, 0.05);
  --accent: #b5650f;
  --accent-soft: rgba(181, 101, 15, 0.1);
  --shadow: 0 1px 2px rgba(14, 22, 30, 0.06), 0 12px 32px rgba(14, 22, 30, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1016;
    --bg-2: #0f161e;
    --surface: #121b24;
    --text: #edf1f5;
    --muted: #9eabb7;
    --faint: #7d8b98;
    --line: #223040;
    --grid: rgba(237, 241, 245, 0.045);
    --accent: #e9963c;
    --accent-soft: rgba(233, 150, 60, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

.mono {
  font-family: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.04em;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 720px) {
  .wrap { padding: 0 32px; }
}

/* ---------- Header ---------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  direction: ltr;
}

.brand svg { width: 28px; height: 28px; }

.lang {
  font-size: 0.85rem;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.lang:hover, .lang:focus-visible { color: var(--text); border-color: var(--accent); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  border-bottom: 1px solid var(--line);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 70% at 70% 40%, transparent 30%, var(--bg) 100%);
  pointer-events: none;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 32px;
  align-items: center;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 48px 64px;
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    padding-block: 72px 96px;
  }
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 20px;
}

.kicker::before {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 1.04;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 0 0 20px;
}

h1 .dot { color: var(--accent); }

.lead {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  color: var(--muted);
  max-width: 34rem;
  margin: 0 0 32px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.2s, transform 0.2s;
}

.btn:hover, .btn:focus-visible { border-color: var(--accent); transform: translateY(-1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.arrow { display: inline-block; }

[dir="rtl"] .arrow { transform: scaleX(-1); }

/* The drawing */

.drawing {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  direction: ltr;
}

.drawing .stroke { stroke: var(--faint); fill: none; }
.drawing .accent { stroke: var(--accent); fill: none; }
.drawing .fill-accent { fill: var(--accent); }
.drawing .node { fill: var(--surface); stroke: var(--line); }
.drawing .hub { fill: var(--surface); stroke: var(--accent); stroke-width: 1.5; }
.drawing text {
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  fill: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.drawing .label-strong { fill: var(--text); font-size: 13px; font-weight: 700; }
.drawing .label-accent { fill: var(--accent); }

.draw {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: draw 1.6s ease-out 0.2s forwards;
}

.orbit { transform-origin: 240px 210px; animation: spin 40s linear infinite; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .draw { animation: none; stroke-dashoffset: 0; }
  .orbit { animation: none; }
  .btn { transition: none; }
}

/* ---------- Pillars ---------- */

.pillars {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
  .pillars { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.pillars div {
  padding: 28px 16px;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
  .pillars div { padding: 36px 28px; border-bottom: 0; border-inline-end: 1px solid var(--line); }
  .pillars div:last-child { border-inline-end: 0; }
}

.pillars .mono { color: var(--accent); font-size: 0.78rem; }

.pillars b {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  margin: 6px 0 6px;
}

.pillars p { color: var(--muted); margin: 0; font-size: 0.95rem; }

/* ---------- Projects ---------- */

.section { padding: 72px 0 24px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 0;
}

.section-head .mono { color: var(--faint); font-size: 0.78rem; }

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 24px;
}

@media (min-width: 900px) {
  .projects { grid-template-columns: 1fr 1fr; }
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color 0.25s, transform 0.25s;
}

.card:hover, .card:focus-visible { border-color: var(--accent); transform: translateY(-3px); }

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

.frame {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 12px 12px 0;
}

.frame-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 10px;
  direction: ltr;
}

.frame-bar i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
}

.frame-bar .addr {
  margin-inline-start: 8px;
  flex: 1;
  font-size: 0.72rem;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1280 / 680;
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 24px;
  flex: 1;
}

.card-top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.card-top .mono { color: var(--accent); font-size: 0.8rem; }

.card h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
}

.card p { color: var(--muted); margin: 0; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chips span {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.go {
  margin-top: auto;
  padding-top: 8px;
  font-weight: 700;
  color: var(--accent);
}

/* The empty slot for the next club */

.slot {
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  padding: 32px;
  background: transparent;
  border: 1.5px dashed var(--line);
  box-shadow: none;
}

.slot:hover { transform: none; border-color: var(--line); }

.slot-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px dashed var(--faint);
  color: var(--faint);
  font-size: 1.4rem;
}

.slot h3 { font-size: 1.5rem; font-weight: 800; margin: 0; }
.slot p { color: var(--muted); margin: 0; }
.addr-hint { color: var(--faint); font-size: 0.8rem; }

.section + .section { padding-top: 48px; }

/* ---------- Footer ---------- */

footer {
  margin-top: 72px;
  border-top: 1px solid var(--line);
  padding: 32px 0 48px;
  color: var(--muted);
  font-size: 0.9rem;
}

footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
}

footer p { margin: 0; }

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

/* ---------- Guides list (home) ---------- */

.guides {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px;
}

@media (min-width: 900px) {
  .guides { grid-template-columns: 1fr 1fr; }
}

.guides a {
  display: grid;
  gap: 8px;
  height: 100%;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  transition: border-color 0.25s;
}

.guides a:hover, .guides a:focus-visible { border-color: var(--accent); }
.guides b { font-size: 1.2rem; font-weight: 800; line-height: 1.35; }
.guides span { color: var(--muted); font-size: 0.95rem; }
.guides .go { color: var(--accent); font-weight: 700; }

/* ---------- Article ---------- */

.article {
  max-width: 44rem;
  padding-top: 40px;
}

.article .kicker a { text-decoration: none; }

.article h1 {
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  line-height: 1.12;
  margin-bottom: 12px;
}

.byline {
  color: var(--faint);
  font-size: 0.9rem;
  margin: 0 0 28px;
}

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

.article .lead {
  font-size: 1.2rem;
  color: var(--text);
  max-width: none;
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 18px;
}

.article h2 {
  font-size: 1.5rem;
  margin: 44px 0 12px;
}

.article p { margin: 0 0 16px; }

.related {
  margin-top: 48px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.related .mono { color: var(--faint); font-size: 0.78rem; margin: 0 0 8px; text-transform: uppercase; }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.related a { color: var(--accent); font-weight: 700; text-decoration: none; }

/* ---------- Student tools ---------- */

.tool-page { max-width: 52rem; }

.tool {
  margin: 8px 0 28px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.tool-head, .tool-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr) minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

.tool-exam .tool-head, .tool-exam .tool-row {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto 36px;
}

.tool-head { color: var(--faint); font-size: 0.8rem; padding: 0 2px 6px; }
.tool-row { margin-bottom: 8px; }

.tool input[type="number"], .tool input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.tool-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.tool-check input { width: 18px; height: 18px; accent-color: var(--accent); }

.tool-remove {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  font-size: 1.1rem;
  cursor: pointer;
}

.tool-remove:hover { color: var(--text); border-color: var(--accent); }

.tool-add {
  margin: 4px 0 16px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.tool-out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  margin-bottom: 12px;
}

.tool-out > div, .tool-out label { display: grid; gap: 4px; }
.tool-out span { color: var(--muted); font-size: 0.85rem; }
.tool-out b { font-size: 1.9rem; font-weight: 900; line-height: 1.1; }
.tool-main b { color: var(--accent); }
.tool-sub { margin: 12px 0 4px; font-weight: 700; }

.formula {
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  overflow-x: auto;
}

@media (max-width: 560px) {
  .tool { padding: 14px; }
  .tool-head { display: none; }
  .tool-row, .tool-exam .tool-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
  }
  .tool-row input[type="text"] { grid-column: 1 / -1; }
}

/* ---------- Math explainers ---------- */

.equations {
  display: grid;
  gap: 4px;
  margin: 8px 0 24px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}

.eq .katex-display { margin: 0.6em 0; }
.eq .katex { font-size: 1.1em; color: var(--text); }

.tool-inputs select {
  width: 100%;
  height: 44px;
  padding: 0 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tool-out .wide { grid-column: 1 / -1; }
.tool-out .wide b { font-size: 1.1rem; font-weight: 700; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

.mistakes { padding-inline-start: 20px; }
.mistakes li { margin-bottom: 8px; }

.m { white-space: nowrap; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 0.92em; }
[data-out="kind"] { font-family: inherit !important; }

/* Numbers and math labels read left to right, even on the Hebrew pages. */
.tool input[type="number"] { direction: ltr; }
[dir="rtl"] .tool input[type="number"] { text-align: right; }
.tool-out span, .tool-head span { unicode-bidi: plaintext; }

/* ---------- Formula tables ---------- */

.ftable {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.ftable th {
  text-align: start;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--faint);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.ftable td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.ftable tr:last-child td { border-bottom: 0; }
.ftable td:first-child { width: 45%; }
.ftable .katex { direction: ltr; font-size: 1.08em; color: var(--text); }
.ftable .fx { display: inline-block; direction: ltr; unicode-bidi: isolate; }
.ftable-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.ftable-wrap .ftable { margin: 0; border: 0; border-radius: 0; min-width: 100%; }
.ftable td { white-space: nowrap; }
@media (max-width: 560px) {
  .ftable th, .ftable td { padding: 8px 10px; }
  .ftable .katex { font-size: 0.98em; }
}

/* ---------- Print: the formula sheet on paper ---------- */

.print-btn { margin: 0 0 8px; }

@media print {
  :root {
    --bg: #fff; --bg-2: #fff; --surface: #fff; --text: #000;
    --muted: #222; --faint: #444; --line: #bbb; --accent: #000;
  }
  @page { size: A4; margin: 10mm; }
  body { font-size: 10.5px; line-height: 1.3; background: #fff; }
  header.top, footer, .related, .kicker, .byline, .print-btn, .lead, .article > h2 + p, .article > p { display: none !important; }
  .wrap, .article { max-width: none; padding: 0; }
  .article h1 { font-size: 15px; margin: 0 0 6px; }
  .article h2 { font-size: 11.5px; margin: 8px 0 3px; break-after: avoid; }
  .ftable-wrap { overflow: visible; border: 1px solid #bbb; border-radius: 0; margin: 0 0 4px; }
  .ftable th, .ftable td { padding: 2px 8px; }
  .ftable th { background: #f2f2f2; }
  .ftable tr { break-inside: avoid; }
  .ftable .katex { font-size: 0.95em; color: #000; }
}
@media print {
  .article { columns: 2; column-gap: 6mm; }
  .article h1 { column-span: all; }
  .ftable-wrap { break-inside: avoid; }
  .ftable td:first-child { width: auto; }
}

/* ---------- Unit converter ---------- */

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.unit-grid div {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.unit-grid div.is-from { border-color: var(--accent); }
.unit-grid b { font-size: 1.05rem; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
.unit-grid span { color: var(--muted); font-size: 0.85rem; }
