
  /* ---------- language: RTL + Arabic typography ---------- */
  html[dir="rtl"] body, body.ar {
    font-family: 'Segoe UI', Tahoma, 'Geeza Pro', 'Noto Naskh Arabic', 'Arial', sans-serif;
  }
  /* keep the brand wordmark and code-like bits LTR even in Arabic */
  body.ar .brand-title, body.ar .pk-eq, body.ar code, body.ar pre { direction: ltr; }

  /* ---------- language toolbar button ---------- */
  #langBtn .nav-ico { display: inline-flex; align-items: center; justify-content: center; }
  #langBtn .nav-ico svg { width: 16px; height: 16px; display: block; }
  #langBtn .lang-code { font-weight: 700; }

  /* ---------- notebook floating button ---------- */
  .nb-fab {
    position: fixed;
    inset-block-end: 22px;
    inset-inline-end: 22px;
    z-index: 4000;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 1.5px solid var(--bdr);
    background: var(--ac);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 99, 235, .35);
    transition: transform .16s, box-shadow .16s, background .16s;
  }
  .nb-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 10px 26px rgba(37, 99, 235, .45); }
  .nb-fab svg { width: 24px; height: 24px; }
  @media (max-width: 768px) { .nb-fab { width: 48px; height: 48px; inset-block-end: 16px; inset-inline-end: 16px; } .nb-fab svg { width: 22px; height: 22px; } }

  /* ---------- notebook panel ---------- */
  .nb-scrim {
    position: fixed; inset: 0; z-index: 4001;
    background: rgba(15, 23, 42, .38);
    opacity: 0; pointer-events: none; transition: opacity .25s;
  }
  .nb-scrim.open { opacity: 1; pointer-events: auto; }
  .nb-panel {
    position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 4002;
    width: min(420px, 92vw);
    display: flex; flex-direction: column;
    background: var(--bg, #fff);
    border-inline-start: 1.5px solid var(--bdr);
    box-shadow: -12px 0 40px rgba(15, 23, 42, .18);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.5, 0, .2, 1);
  }
  html[dir="rtl"] .nb-panel { box-shadow: 12px 0 40px rgba(15, 23, 42, .18); transform: translateX(-100%); }
  .nb-panel.open { transform: none; }
  html[dir="rtl"] .nb-panel.open { transform: none; }

  .nb-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--bdr);
    flex-shrink: 0;
  }
  .nb-head-ico {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--acl); color: var(--ac);
  }
  .nb-head-ico svg { width: 18px; height: 18px; }
  .nb-title { font-weight: 700; font-size: 16px; color: var(--tx); margin-inline-end: auto; }
  .nb-title-wrap { margin-inline-end: auto; min-width: 0; }
  .nb-topic { font-size: 11.5px; color: var(--tx3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
  .nb-x {
    border: 0; background: transparent; color: var(--tx3); cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px; font-size: 20px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .nb-x:hover { background: var(--bg2); color: var(--tx); }

  .nb-tools { padding: 12px 16px; border-bottom: 1px solid var(--bdr); flex-shrink: 0; }
  .nb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .nb-row + .nb-row { margin-top: 10px; }
  .nb-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tx3); min-width: 46px; }
  .nb-swatch {
    width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
    border: 2px solid var(--bdr); padding: 0; transition: transform .12s;
  }
  .nb-swatch:hover { transform: scale(1.12); }
  .nb-swatch.on { border-color: var(--ac); box-shadow: 0 0 0 2px var(--ac); }
  .nb-font,
  .nb-tool {
    border: 1.5px solid var(--bdr); background: var(--bg2); color: var(--tx);
    border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
    min-height: 28px;
  }
  .nb-font.on,
  .nb-tool.on { border-color: var(--ac); background: var(--acl); color: var(--ac); }
  .nb-tool:hover,
  .nb-font:hover { border-color: var(--ac); color: var(--ac); }
  .nb-size {
    border: 1.5px solid var(--bdr);
    background: var(--bg2);
    color: var(--tx);
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 700;
    min-height: 28px;
  }
  .nb-tool.danger:hover { border-color: #dc2626; color: #dc2626; background: rgba(220, 38, 38, .06); }
  .nb-tool.muted { color: var(--tx3); }
  .nb-tool-hint { font-size: 10.5px; color: var(--tx3); padding-inline-start: 46px; margin-top: 6px; line-height: 1.45; }
  .nb-reset {
    margin-inline-start: auto; border: 1.5px solid var(--bdr); background: transparent;
    color: var(--tx2); border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  }
  .nb-reset:hover { border-color: #dc2626; color: #dc2626; background: rgba(220, 38, 38, .06); }

  .nb-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px 18px;
    background:
      radial-gradient(circle at 20% 0%, rgba(96, 165, 250, .08), transparent 30%),
      var(--bg3, #f8fafc);
  }
  .nb-pages {
    --nb-paper: #fffef7;
    --nb-ink: #1f2937;
    --nb-font: var(--font), system-ui, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
  }
  .nb-page {
    position: relative;
    width: min(100%, 360px);
    aspect-ratio: 210 / 297;
    background: var(--nb-paper);
    color: var(--nb-ink);
    font-family: var(--nb-font);
    font-size: var(--nb-font-size, 15px);
    line-height: 1.55;
    white-space: pre-wrap;
    overflow: hidden;
    outline: none;
    padding: 24px 22px 30px;
    border: 1px solid rgba(15, 23, 42, .18);
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .16);
    caret-color: var(--nb-ink);
  }
  .nb-page::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 22px,
      rgba(148, 163, 184, .18) 23px
    );
    mix-blend-mode: multiply;
  }
  .nb-page::after {
    content: 'Page ' attr(data-page);
    position: absolute;
    inset-inline-end: 16px;
    bottom: 9px;
    color: rgba(100, 116, 139, .75);
    font: 10px/1 var(--font), system-ui, sans-serif;
    pointer-events: none;
  }

  .nb-shape-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
  }
  .nb-shape {
    position: absolute;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: move;
    --shape-color: #1f2937;
    touch-action: none;
  }
  .nb-shape.selected {
    outline: 2px dashed var(--ac);
    outline-offset: 3px;
  }
  .nb-shape-rect {
    border: 2px solid var(--shape-color);
    border-radius: 4px;
    background: transparent;
  }
  .nb-shape-circle {
    border: 2px solid var(--shape-color);
    border-radius: 999px;
    background: transparent;
  }
  .nb-shape-line,
  .nb-shape-arrow {
    border-top: 3px solid var(--shape-color);
    min-height: 8px;
    transform-origin: left center;
  }
  .nb-shape-arrow::after {
    content: '';
    position: absolute;
    right: -1px;
    top: -7px;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid var(--shape-color);
  }
  .nb-shape-highlight {
    background: rgba(250, 204, 21, .34);
    border: 1px solid rgba(217, 119, 6, .35);
    border-radius: 4px;
    mix-blend-mode: multiply;
  }

  .nb-page:focus {
    border-color: var(--ac);
    box-shadow: 0 0 0 3px var(--acl), 0 10px 26px rgba(15, 23, 42, .16);
  }
  .nb-print-title { display: none; }
  .nb-foot { display: flex; align-items: center; gap: 10px; padding: 0 16px 12px; }
  .nb-status { font-size: 11px; color: var(--tx3); }
  .nb-count { font-size: 11px; color: var(--tx3); margin-inline-start: auto; }
  .nb-print {
    border: 1.5px solid var(--bdr);
    background: var(--bg2);
    color: var(--tx2);
    border-radius: 8px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }
  .nb-print:hover { border-color: var(--ac); color: var(--ac); background: var(--acl); }

  body.nb-printing .nav,
  body.nb-printing .sidebar,
  body.nb-printing .main,
  body.nb-printing .nb-fab,
  body.nb-printing .nb-scrim,
  body.nb-printing .nb-head,
  body.nb-printing .nb-tools,
  body.nb-printing .nb-foot,
  body.nb-printing .overlay { display: none !important; }

  @media print {
    @page { size: A4; margin: 0; }
    html, body { background: #fff !important; }
    body.nb-printing { margin: 0 !important; }
    body.nb-printing #nbPanel {
      position: static !important;
      transform: none !important;
      width: auto !important;
      height: auto !important;
      inset: auto !important;
      display: block !important;
      background: #fff !important;
      border: 0 !important;
      box-shadow: none !important;
      overflow: visible !important;
    }
    body.nb-printing .nb-body {
      display: block !important;
      padding: 0 !important;
      overflow: visible !important;
      background: #fff !important;
    }
    body.nb-printing .nb-print-title {
      display: block !important;
      width: 210mm;
      box-sizing: border-box;
      padding: 10mm 18mm 0;
      font: 700 13px/1.3 Arial, sans-serif;
      color: #111827;
      break-after: avoid;
    }
    body.nb-printing .nb-pages { display: block !important; width: auto !important; }
    body.nb-printing .nb-page {
      width: 210mm !important;
      height: 297mm !important;
      aspect-ratio: auto !important;
      box-sizing: border-box !important;
      margin: 0 !important;
      padding: 18mm 18mm 16mm !important;
      border: 0 !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      overflow: hidden !important;
      page-break-after: always;
      break-after: page;
      font-size: 12pt !important;
      line-height: 1.55 !important;
      color: var(--nb-ink, #1f2937) !important;
      background: var(--nb-paper, #fffef7) !important;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
    body.nb-printing .nb-page::before { display: none !important; }
    body.nb-printing .nb-shape-layer { display: block !important; }
    body.nb-printing .nb-shape { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    body.nb-printing .nb-page::after {
      bottom: 8mm !important;
      inset-inline-end: 18mm !important;
      color: #6b7280 !important;
    }
  }
