/* ============================================================
   lisp.css — AutoLISP Tools Guide for Israeli Architects
   architect.nadavc.ai/lisp
   Design system: matches questionnaire.html exactly
   RTL Hebrew | Assistant + Frank Ruhl Libre fonts
   ============================================================ */

/* ------------------------------------------------------------
   DESIGN TOKENS
   ------------------------------------------------------------ */
:root {
  --bg: #0e1116;
  --bg-2: #161a22;
  --bg-3: #1d2230;
  --line: #2a3142;
  --ink: #e7ecf3;
  --ink-dim: #a4adbe;
  --ink-mute: #6c7589;
  --gold: #d4af6a;
  --gold-2: #e8c887;
  --accent: #7aa2ff;
  --accent-2: #9bb8ff;
  --ok: #7bd389;
  --warn: #ffb454;
  --bad: #ff6b6b;
  --radius: 14px;
  --radius-s: 10px;
  --radius-l: 22px;
  --shadow: 0 24px 60px rgba(0, 0, 0, .45), 0 2px 4px rgba(0, 0, 0, .3);
  --tx: .18s cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 260px;
}

/* ------------------------------------------------------------
   RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  direction: rtl;
}

body {
  margin: 0;
  font-family: 'Assistant', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16px;
  background-image:
    radial-gradient(ellipse 800px 500px at 10% -10%, rgba(212, 175, 106, .08), transparent 60%),
    radial-gradient(ellipse 600px 400px at 110% 30%, rgba(122, 162, 255, .06), transparent 60%);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Frank Ruhl Libre', 'Assistant', serif;
  letter-spacing: -.01em;
  margin: 0;
}

h1 { font-size: clamp(26px, 3.5vw, 40px); font-weight: 900; line-height: 1.15; }
h2 { font-size: clamp(20px, 2.5vw, 28px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; color: var(--gold-2); }
h4 { font-size: 15px; font-weight: 600; color: var(--ink); }

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

p {
  margin: 0 0 14px;
  color: var(--ink-dim);
  line-height: 1.7;
}
p:last-child { margin-bottom: 0; }

ul, ol {
  margin: 0 0 14px;
  padding-inline-start: 22px;
  color: var(--ink-dim);
  line-height: 1.8;
}

code {
  font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--gold-2);
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

/* ------------------------------------------------------------
   PAGE LAYOUT — GRID
   ------------------------------------------------------------ */
.page-wrap {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   SIDEBAR
   ------------------------------------------------------------ */
.sidebar {
  position: fixed;
  inset-inline-start: 0;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  transition: transform var(--tx);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
}

/* Sidebar header / logo area */
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-logo {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-2);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: var(--bg);
  flex-shrink: 0;
}

.sidebar-tagline {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: .05em;
}

/* Sidebar navigation body */
.sidebar-nav {
  flex: 1;
  padding: 12px 0 24px;
}

/* Section labels */
.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 16px 16px 6px;
}

.sidebar-section:first-child {
  padding-top: 8px;
}

/* Individual links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 16px;
  color: var(--ink-dim);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: color var(--tx), background var(--tx);
  border-inline-start: 3px solid transparent;
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, .04);
  color: var(--ink);
  text-decoration: none;
}

.sidebar-link.active {
  color: var(--gold-2);
  background: rgba(212, 175, 106, .07);
  border-inline-start-color: var(--gold);
}

.sidebar-link .link-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 18px;
  text-align: center; /* icon centering, not text direction */ /* rtl-ok */
}

.sidebar-link .link-label {
  flex: 1;
  line-height: 1.35;
}

/* Sidebar badge pills */
.sidebar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: .03em;
  flex-shrink: 0;
}

.sidebar-badge.critical {
  background: rgba(255, 107, 107, .18);
  color: var(--bad);
  border: 1px solid rgba(255, 107, 107, .3);
}

.sidebar-badge.high {
  background: rgba(255, 180, 84, .18);
  color: var(--warn);
  border: 1px solid rgba(255, 180, 84, .3);
}

.sidebar-badge.new {
  background: rgba(123, 211, 137, .18);
  color: var(--ok);
  border: 1px solid rgba(123, 211, 137, .3);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-mute);
  transition: color var(--tx);
}

.sidebar-footer a:hover {
  color: var(--ink-dim);
  text-decoration: none;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 150;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.visible {
  display: block;
}

/* Mobile sidebar open state */
.sidebar.open {
  transform: translateX(0) !important;
  box-shadow: 4px 0 40px rgba(0, 0, 0, .6);
  z-index: 200;
}

/* Hamburger / sidebar toggle */
#sidebarToggle {
  display: none;
  position: fixed;
  top: 12px;
  inset-inline-start: 12px;
  z-index: 300;
  width: 44px;
  height: 44px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink);
  font-size: 18px;
  align-items: center;
  justify-content: center;
  transition: background var(--tx), border-color var(--tx);
}

#sidebarToggle:hover {
  background: var(--bg-3);
  border-color: var(--gold);
}

/* ------------------------------------------------------------
   MAIN CONTENT AREA
   ------------------------------------------------------------ */
.main-content {
  grid-column: 2;
  max-width: 860px;
  padding: 32px 40px 80px;
  min-width: 0;
}

/* ------------------------------------------------------------
   HERO SECTION
   ------------------------------------------------------------ */
.lisp-hero {
  padding: 40px 0 32px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.lisp-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(212, 175, 106, .04) 0 1px,
    transparent 1px 60px
  );
  border-radius: var(--radius-l);
}

.hero-eyebrow {
  font-size: 12px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 12px;
}

.lisp-hero h1 {
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(135deg, var(--gold-2) 0%, var(--gold) 50%, var(--ink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}

.lisp-hero .lead {
  color: var(--ink-dim);
  font-size: 16px;
  max-width: 640px;
  line-height: 1.7;
  margin-bottom: 24px;
}

/* Hero stats row */
.hero-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-stat .n {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold-2);
  font-family: 'Frank Ruhl Libre', serif;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hero-stat .l {
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .15em;
  margin-top: 2px;
}

/* Hero action buttons */
.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-s);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: var(--tx);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-gold {
  background: var(--gold);
  color: #0e1116;
  border-color: var(--gold);
}

.btn-gold:hover {
  background: var(--gold-2);
  border-color: var(--gold-2);
  color: #0e1116;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 175, 106, .3);
}

.btn-outline {
  background: transparent;
  color: var(--ink-dim);
  border-color: var(--line);
}

.btn-outline:hover {
  background: var(--bg-3);
  color: var(--ink);
  border-color: var(--gold);
  text-decoration: none;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ------------------------------------------------------------
   FILTER BAR
   ------------------------------------------------------------ */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  min-height: 44px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
  transition: var(--tx);
  white-space: nowrap;
}

.filter-btn:hover {
  background: var(--bg-3);
  color: var(--ink);
  border-color: var(--gold);
}

.filter-btn.active {
  background: var(--gold);
  color: #0e1116;
  border-color: var(--gold);
  font-weight: 700;
}

.filter-btn .filter-count {
  font-size: 11px;
  opacity: .75;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------
   TOOL CARD
   ------------------------------------------------------------ */
.tool-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  margin-bottom: 40px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color var(--tx);
}

.tool-card:hover {
  border-color: rgba(212, 175, 106, .25);
}

/* Tool header */
.tool-header {
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--line);
  position: relative;
  background: linear-gradient(180deg, rgba(212, 175, 106, .04), transparent);
}

/* Gold accent bar on inline-start (right in RTL = visual right) */
.tool-header::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  border-radius: 0 2px 2px 0;
}

.tool-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-header h2 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.25;
}

.tool-subtitle {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.6;
  max-width: 640px;
}

/* Header badges row */
.tool-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Law reference badge */
.law-ref {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(122, 162, 255, .12);
  border: 1px solid rgba(122, 162, 255, .3);
  color: var(--accent-2);
  letter-spacing: .02em;
  white-space: nowrap;
}

.law-ref::before {
  content: "§";
  opacity: .7;
  font-size: 10px;
}

/* Category badge on card header */
.tool-category-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
}

.tool-category-badge.areas {
  background: rgba(123, 211, 137, .12);
  color: var(--ok);
  border: 1px solid rgba(123, 211, 137, .25);
}

.tool-category-badge.tama {
  background: rgba(255, 180, 84, .12);
  color: var(--warn);
  border: 1px solid rgba(255, 180, 84, .25);
}

.tool-category-badge.access {
  background: rgba(122, 162, 255, .12);
  color: var(--accent-2);
  border: 1px solid rgba(122, 162, 255, .25);
}

.tool-category-badge.parking {
  background: rgba(212, 175, 106, .12);
  color: var(--gold-2);
  border: 1px solid rgba(212, 175, 106, .25);
}

/* Tool body */
.tool-body {
  padding: 28px 32px;
}

/* Warning box inside tool */
.tool-warning {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(255, 180, 84, .07);
  border: 1px solid rgba(255, 180, 84, .35);
  border-radius: var(--radius-s);
  margin-bottom: 24px;
  line-height: 1.6;
}

.tool-warning .warn-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.tool-warning .warn-text {
  font-size: 13px;
  color: var(--warn);
}

.tool-warning .warn-text strong {
  display: block;
  font-weight: 700;
  margin-bottom: 3px;
}

/* ------------------------------------------------------------
   LEGAL WARNING BOX
   ------------------------------------------------------------ */
.legal-warn {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  background: rgba(255, 107, 107, .07);
  border: 1px solid rgba(255, 107, 107, .35);
  border-radius: var(--radius-s);
  margin-bottom: 28px;
}

.legal-warn .legal-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-warn .legal-content {
  flex: 1;
}

.legal-warn .legal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--bad);
  margin-bottom: 5px;
}

.legal-warn .legal-body {
  font-size: 13px;
  color: rgba(255, 107, 107, .85);
  line-height: 1.65;
}

/* ------------------------------------------------------------
   TAB SYSTEM
   ------------------------------------------------------------ */
.tabs-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
  transition: var(--tx);
  white-space: nowrap;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, .06);
  color: var(--ink);
  border-color: rgba(212, 175, 106, .4);
}

.tab-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #0e1116;
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ------------------------------------------------------------
   CODE BLOCK
   ------------------------------------------------------------ */
.code-block {
  position: relative;
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  margin-bottom: 20px;
  overflow: hidden;
}

/* Code block toolbar */
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

/* Language tag */
.lang-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(212, 175, 106, .1);
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid rgba(212, 175, 106, .2);
}

/* Copy button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
  transition: var(--tx);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  border-color: var(--gold);
}

.copy-btn.copied {
  background: rgba(123, 211, 137, .15);
  color: var(--ok);
  border-color: rgba(123, 211, 137, .35);
}

/* Code content area — always LTR for AutoLISP source code */
.code-block pre {
  margin: 0;
  padding: 18px 20px;
  direction: ltr; /* rtl-ok */
  text-align: start;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  tab-size: 2;
}

.code-block pre::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.code-block pre::-webkit-scrollbar-track {
  background: transparent;
}
.code-block pre::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
}

.code-block code {
  font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink);
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
  white-space: pre;
  display: block;
}

/* Syntax highlighting — AutoLISP tokens */
.code-block .s-comment  { color: var(--ink-mute); font-style: italic; }
.code-block .s-string   { color: var(--ok); }
.code-block .s-number   { color: var(--warn); }
.code-block .s-keyword  { color: var(--accent-2); font-weight: 600; }
.code-block .s-fn       { color: var(--gold-2); }
.code-block .s-symbol   { color: var(--ink-dim); }

/* Optional line numbers */
.code-block.line-nums pre {
  padding-inline-start: 52px;
  position: relative;
}

.code-block.line-nums .line-numbers {
  position: absolute;
  top: 18px;
  inset-inline-start: 0;
  width: 40px;
  text-align: end;
  padding-inline-end: 12px;
  color: var(--ink-mute);
  font-size: 12px;
  line-height: 1.65;
  font-family: 'Consolas', monospace;
  user-select: none;
  pointer-events: none;
}

/* ------------------------------------------------------------
   CALCULATOR BOX
   ------------------------------------------------------------ */
.calc-box {
  background: rgba(212, 175, 106, .04);
  border: 1px solid rgba(212, 175, 106, .25);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.calc-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-2);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-desc {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Calculator input grid */
.calc-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.calc-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: .02em;
}

.calc-field input,
.calc-field select {
  height: 46px;
  padding: 0 14px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--tx), box-shadow var(--tx);
  outline: none;
  direction: rtl; /* rtl-ok — explicit RTL for form inputs */
  width: 100%;
}

.calc-field input:focus,
.calc-field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 106, .15);
}

.calc-field input::placeholder {
  color: var(--ink-mute);
}

/* Calculator actions */
.calc-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.calc-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-s);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  background: var(--gold);
  color: #0e1116;
  border: none;
  cursor: pointer;
  transition: var(--tx);
  min-height: 46px;
}

.calc-btn:hover {
  background: var(--gold-2);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 175, 106, .35);
}

.calc-btn:active {
  transform: translateY(0);
}

.calc-reset {
  padding: 10px 16px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  color: var(--ink-mute);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--tx);
  min-height: 46px;
}

.calc-reset:hover {
  border-color: var(--bad);
  color: var(--bad);
}

/* Result display */
.calc-result {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 16px 20px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color var(--tx), background var(--tx);
}

.calc-result.has-result {
  background: rgba(123, 211, 137, .05);
  border-color: rgba(123, 211, 137, .3);
}

.calc-result.error {
  background: rgba(255, 107, 107, .06);
  border-color: rgba(255, 107, 107, .35);
}

.result-label {
  font-size: 12px;
  color: var(--ink-mute);
  font-weight: 600;
  letter-spacing: .05em;
}

/* Numeric result — LTR so digits read correctly even in RTL layout */
.result-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--ok);
  font-family: 'Frank Ruhl Libre', serif;
  font-variant-numeric: tabular-nums;
  direction: ltr; /* rtl-ok — numbers always LTR */
  text-align: start;
  transition: color var(--tx);
}

.calc-result.error .result-value {
  color: var(--bad);
  font-size: 14px;
  font-family: 'Assistant', sans-serif;
  font-weight: 600;
  direction: rtl; /* rtl-ok — restore RTL for Hebrew error message */
}

.result-unit {
  font-size: 14px;
  color: var(--ink-mute);
  font-weight: 500;
}

/* ------------------------------------------------------------
   STEPS / INSTRUCTIONS
   ------------------------------------------------------------ */
.steps {
  counter-reset: step-counter;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.steps.horizontal {
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
}

.step-item {
  display: flex;
  gap: 16px;
  position: relative;
  counter-increment: step-counter;
  padding-bottom: 24px;
}

.step-item:last-child {
  padding-bottom: 0;
}

/* Connector line — inline-start offset for RTL */
.step-item:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: 19px;
  top: 40px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--line), transparent);
}

.step-num {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  font-family: 'Frank Ruhl Libre', serif;
  position: relative;
  z-index: 1;
}

.step-item.done .step-num {
  background: rgba(123, 211, 137, .12);
  border-color: var(--ok);
  color: var(--ok);
}

.step-body {
  flex: 1;
  padding-top: 6px;
}

.step-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.65;
}

/* Horizontal steps on desktop */
.steps.horizontal .step-item {
  flex-direction: column;
  align-items: center;
  text-align: center; /* rtl-ok — intentional centering for step labels */
  flex: 1;
  padding-bottom: 0;
  gap: 10px;
}

.steps.horizontal .step-item:not(:last-child)::after {
  inset-inline-start: 50%;
  width: calc(100% - 38px);
  top: 19px;
  bottom: auto;
  height: 2px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.steps.horizontal .step-body {
  padding-top: 0;
}

/* ------------------------------------------------------------
   INFO BOXES / CALLOUTS
   ------------------------------------------------------------ */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-s);
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.65;
}

.callout-icon {
  font-size: 17px;
  flex-shrink: 0;
  margin-top: 1px;
}

.callout-body { flex: 1; }

.callout-title {
  font-weight: 700;
  margin-bottom: 3px;
}

.callout.info {
  background: rgba(122, 162, 255, .07);
  border: 1px solid rgba(122, 162, 255, .25);
  color: var(--accent-2);
}

.callout.tip {
  background: rgba(123, 211, 137, .07);
  border: 1px solid rgba(123, 211, 137, .25);
  color: var(--ok);
}

.callout.warn {
  background: rgba(255, 180, 84, .07);
  border: 1px solid rgba(255, 180, 84, .3);
  color: var(--warn);
}

.callout.danger {
  background: rgba(255, 107, 107, .07);
  border: 1px solid rgba(255, 107, 107, .3);
  color: var(--bad);
}

/* ------------------------------------------------------------
   INLINE DETAIL / DEFINITION TABLE
   ------------------------------------------------------------ */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 20px;
}

.detail-table th {
  text-align: start;
  padding: 10px 14px;
  background: var(--bg-3);
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.detail-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(42, 49, 66, .5);
  color: var(--ink-dim);
  vertical-align: top;
  line-height: 1.5;
}

.detail-table td:first-child {
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}

.detail-table tr:last-child td {
  border-bottom: none;
}

.detail-table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

/* ------------------------------------------------------------
   SECTION HEADING (inside tool body)
   ------------------------------------------------------------ */
.section-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  margin-top: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-heading:first-child {
  margin-top: 0;
}

.section-heading::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--gold);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ------------------------------------------------------------
   TAG / CHIP COLLECTION
   ------------------------------------------------------------ */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--ink-dim);
}

.tag.gold {
  background: rgba(212, 175, 106, .1);
  border-color: rgba(212, 175, 106, .3);
  color: var(--gold-2);
}

.tag.blue {
  background: rgba(122, 162, 255, .1);
  border-color: rgba(122, 162, 255, .3);
  color: var(--accent-2);
}

.tag.green {
  background: rgba(123, 211, 137, .1);
  border-color: rgba(123, 211, 137, .3);
  color: var(--ok);
}

/* ------------------------------------------------------------
   BREADCRUMB / BACK LINK
   ------------------------------------------------------------ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--ink-dim);
}

.breadcrumb a:hover {
  color: var(--gold);
  text-decoration: none;
}

.breadcrumb .sep {
  color: var(--line);
  font-size: 11px;
}

/* ------------------------------------------------------------
   COLLAPSIBLE SECTION
   ------------------------------------------------------------ */
details.collapsible {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  margin-bottom: 12px;
  overflow: hidden;
}

details.collapsible summary {
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  user-select: none;
  transition: background var(--tx);
}

details.collapsible summary::-webkit-details-marker {
  display: none;
}

details.collapsible summary:hover {
  background: rgba(255, 255, 255, .03);
}

details.collapsible summary::after {
  content: "▾";
  margin-inline-start: auto;
  color: var(--ink-mute);
  font-size: 12px;
  transition: transform var(--tx);
}

details.collapsible[open] summary::after {
  transform: rotate(180deg);
}

details.collapsible .details-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------
   FLOATING BACK-TO-TOP
   ------------------------------------------------------------ */
.back-to-top {
  position: fixed;
  bottom: 28px;
  inset-inline-start: 28px;
  width: 44px;
  height: 44px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: var(--tx);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  text-decoration: none;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--bg-3);
  border-color: var(--gold);
  color: var(--gold);
  text-decoration: none;
  transform: translateY(-2px);
}

/* ------------------------------------------------------------
   SEARCH BAR (optional sidebar search)
   ------------------------------------------------------------ */
.search-wrap {
  position: relative;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--tx);
  direction: rtl; /* rtl-ok — explicit, inherits from html but clarifies intent */
}

.search-input:focus {
  border-color: var(--gold);
}

.search-input::placeholder {
  color: var(--ink-mute);
}

.search-icon {
  position: absolute;
  inset-inline-end: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-mute);
  font-size: 14px;
  pointer-events: none;
}

/* ------------------------------------------------------------
   UTILITY CLASSES
   ------------------------------------------------------------ */
.text-gold   { color: var(--gold); }
.text-gold-2 { color: var(--gold-2); }
.text-dim    { color: var(--ink-dim); }
.text-mute   { color: var(--ink-mute); }
.text-ok     { color: var(--ok); }
.text-warn   { color: var(--warn); }
.text-bad    { color: var(--bad); }
.text-accent { color: var(--accent); }

/* LTR utility — for code snippets, numbers, or filenames in RTL flow */
.ltr {
  direction: ltr; /* rtl-ok */
  unicode-bidi: embed;
}

.mono {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: .9em;
}

.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.mt-0  { margin-top: 0; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.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;
}

/* ------------------------------------------------------------
   MOBILE — max-width: 768px
   ------------------------------------------------------------ */
@media (max-width: 768px) {
  /* Page layout collapses to single column */
  .page-wrap {
    grid-template-columns: 1fr;
  }

  /* Sidebar slides off-screen (RTL: start = right, so translate positive = off-right) */
  .sidebar {
    transform: translateX(-100%); /* rtl-ok — physical translate for overlay animation */
    z-index: 200;
  }

  /* When open, sidebar slides in */
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show hamburger button */
  #sidebarToggle {
    display: flex;
  }

  /* Main content fills full width */
  .main-content {
    grid-column: 1 / -1;
    max-width: 100%;
    padding: 16px 12px 80px;
  }

  /* Hero adjustments */
  .lisp-hero {
    padding: 56px 0 24px;
  }

  .lisp-hero h1 {
    font-size: 26px;
  }

  .hero-stats {
    gap: 16px;
  }

  .hero-stat .n {
    font-size: 22px;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
    width: 100%;
    min-height: 48px;
  }

  /* Filter bar: horizontal scroll on mobile */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0;
    min-height: 40px;
  }

  /* Tool card on mobile */
  .tool-header {
    padding: 20px 18px 16px;
  }

  .tool-body {
    padding: 20px 18px;
  }

  .tool-header h2 {
    font-size: 18px;
  }

  /* Code blocks on mobile — smaller font, still scrollable */
  .code-block code {
    font-size: 12px;
  }

  .code-block pre {
    padding: 14px 16px;
    max-height: 320px;
  }

  /* Calculator grid: single column on mobile */
  .calc-inputs {
    grid-template-columns: 1fr;
  }

  .calc-btn {
    width: 100%;
    justify-content: center;
  }

  /* Steps: vertical always on mobile */
  .steps.horizontal {
    flex-direction: column;
  }

  .steps.horizontal .step-item {
    flex-direction: row;
    text-align: start;
    align-items: flex-start;
  }

  .steps.horizontal .step-item:not(:last-child)::after {
    inset-inline-start: 19px;
    top: 40px;
    bottom: 0;
    width: 2px;
    height: auto;
    background: linear-gradient(180deg, var(--line), transparent);
  }

  .steps.horizontal .step-body {
    padding-top: 6px;
  }

  /* Touch targets — minimum 48px */
  .sidebar-link {
    min-height: 48px;
  }

  .tab-btn {
    min-height: 44px;
  }

  .copy-btn {
    min-height: 36px;
    padding: 6px 12px;
  }

  /* Prevent iOS input zoom — font-size must be 16px+ */
  .calc-field input,
  .calc-field select {
    height: 50px;
    font-size: 16px;
  }

  /* Detail table: horizontal scroll wrapper */
  .detail-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
  }

  .detail-table {
    min-width: 480px;
    margin-bottom: 0;
  }

  /* Back to top: safe inset on small screens */
  .back-to-top {
    bottom: 20px;
    inset-inline-start: 16px;
  }
}

/* ------------------------------------------------------------
   SMALL MOBILE — max-width: 480px
   ------------------------------------------------------------ */
@media (max-width: 480px) {
  .tool-header {
    padding: 16px 14px 14px;
  }

  .tool-body {
    padding: 16px 14px;
  }

  .tool-header::before {
    width: 3px;
  }

  .calc-box {
    padding: 16px 14px;
  }

  .tabs-nav {
    gap: 4px;
  }

  .tab-btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .tool-header-meta {
    gap: 5px;
  }

  .lisp-hero h1 {
    font-size: 22px;
  }

  .hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

/* ------------------------------------------------------------
   PRINT STYLES
   ------------------------------------------------------------ */
@media print {
  .sidebar,
  #sidebarToggle,
  .sidebar-overlay,
  .back-to-top,
  .copy-btn,
  .filter-bar,
  .tabs-nav,
  .hero-actions {
    display: none !important;
  }

  .page-wrap {
    grid-template-columns: 1fr;
  }

  .main-content {
    grid-column: 1 / -1;
    max-width: 100%;
    padding: 0;
  }

  .tool-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
    margin-bottom: 20px;
  }

  .code-block pre {
    max-height: none;
    overflow: visible;
  }
}
