/* ============================
   SHIPMENT WHITE PAPER — MODERN DOCS
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&family=Crimson+Pro:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --bg: #FFFFFF;
  --bg-secondary: #F8FAFC;
  --bg-tertiary: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --text: #334155;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --heading: #0F172A;
  --primary: #0EA5E9;
  --primary-light: #38BDF8;
  --primary-bg: #F0F9FF;
  --primary-border: #BAE6FD;
  --green: #059669;
  --green-bg: #ECFDF5;
  --green-border: #A7F3D0;
  --yellow: #D97706;
  --yellow-bg: #FFFBEB;
  --yellow-border: #FDE68A;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --red-border: #FECACA;
  --purple: #7C3AED;
  --purple-bg: #F5F3FF;
  --cyan: #0891B2;
  --code-bg: #F8FAFC;
  --sidebar-bg: #F8FAFC;
  --sidebar-hover: #F1F5F9;
  --sidebar-active: #F0F9FF;
  --topbar-bg: rgba(255,255,255,0.80);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-width: 270px;
  --topbar-height: 60px;
  --toc-width: 220px;
  --content-max: 760px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0B1120;
  --bg-secondary: #131C2E;
  --bg-tertiary: #1A2540;
  --surface: #131C2E;
  --border: #1E2D4A;
  --border-light: #172035;
  --text: #CBD5E1;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --heading: #F1F5F9;
  --primary: #38BDF8;
  --primary-light: #7DD3FC;
  --primary-bg: rgba(14,165,233,0.1);
  --primary-border: rgba(14,165,233,0.2);
  --green: #34D399;
  --green-bg: rgba(52,211,153,0.1);
  --green-border: rgba(52,211,153,0.2);
  --yellow: #FBBF24;
  --yellow-bg: rgba(251,191,36,0.1);
  --yellow-border: rgba(251,191,36,0.2);
  --red: #F87171;
  --red-bg: rgba(248,113,113,0.1);
  --red-border: rgba(248,113,113,0.2);
  --purple: #A78BFA;
  --purple-bg: rgba(167,139,250,0.1);
  --cyan: #22D3EE;
  --code-bg: #131C2E;
  --sidebar-bg: #0D1526;
  --sidebar-hover: #1A2540;
  --sidebar-active: rgba(14,165,233,0.1);
  --topbar-bg: rgba(11,17,32,0.85);
}

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

html { scroll-behavior: smooth; font-size: 16px; scroll-padding-top: 80px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ======== ACCESS GATE ======== */
.access-gate {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 999999;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
.access-gate.hidden { display: none; }
.access-gate__logo { margin-bottom: 32px; display: flex; align-items: center; gap: 12px; }
.access-gate__logo img { width: 48px; height: 48px; }
.access-gate__logo span { font-size: 1.6rem; font-weight: 800; color: var(--heading); }
.access-gate__subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 28px; }
.pin-inputs { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; }
.pin-digit {
  width: 52px; height: 58px;
  border: 2px solid var(--border); border-radius: 12px;
  background: var(--bg-secondary); color: var(--heading);
  font-size: 1.5rem; font-weight: 800; font-family: 'JetBrains Mono', monospace;
  text-align: center; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  caret-color: var(--primary);
}
.pin-digit:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); transform: scale(1.05); }
.pin-digit.error { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); animation: pin-shake 0.4s ease; }
.pin-digit.success { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-bg); transform: scale(1.1); }
.pin-error { color: var(--red); font-size: 0.82rem; font-weight: 600; opacity: 0; height: 20px; transition: opacity 0.2s; }
.pin-error.visible { opacity: 1; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ======== TOPBAR ======== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 100;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 12px; }
.topbar__logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); }
.logo-mark { width: 32px; height: 32px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-mark img { width: 100%; height: 100%; object-fit: cover; }
.logo-text { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.logo-divider { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.logo-label { font-size: 0.78rem; color: var(--text-tertiary); font-weight: 500; }

.sidebar-toggle {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-secondary); padding: 6px; border-radius: var(--radius-xs); transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-tertiary); }

/* Search */
.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: text; min-width: 260px; transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.search-box svg { color: var(--text-tertiary); flex-shrink: 0; }
.search-box input {
  border: none; background: none; outline: none;
  font-family: inherit; font-size: 0.82rem; color: var(--text); flex: 1; min-width: 0;
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem;
  padding: 2px 6px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-tertiary); letter-spacing: 0.3px;
}

/* Theme toggle */
.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); width: 36px; height: 36px;
  border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center;
  transition: var(--transition); text-decoration: none;
}
.theme-toggle:hover { background: var(--bg-secondary); color: var(--heading); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* Btn */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-weight: 600; font-size: 0.8rem;
  border: none; border-radius: var(--radius-xs); cursor: pointer; text-decoration: none;
  transition: var(--transition);
}
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn--sm { padding: 7px 16px; }

/* ======== SIDEBAR ======== */
.sidebar {
  position: fixed; top: var(--topbar-height); left: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  border-right: 1px solid var(--border); overflow-y: auto; z-index: 90;
  display: flex; flex-direction: column; transition: transform 0.3s ease;
}
.sidebar__nav { flex: 1; padding: 20px 14px; overflow-y: auto; }
.nav-group { margin-bottom: 24px; }
.nav-group__title {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-tertiary); padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  font-size: 0.82rem; color: var(--text-secondary); text-decoration: none;
  border-radius: var(--radius-xs); transition: var(--transition); font-weight: 500; margin-bottom: 1px;
}
.nav-item svg { flex-shrink: 0; opacity: 0.5; width: 15px; height: 15px; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-item.active { background: var(--sidebar-active); color: var(--primary); font-weight: 700; }
.nav-item.active svg { opacity: 1; color: var(--primary); }

/* Sidebar footer */
.sidebar__footer { padding: 14px 18px; border-top: 1px solid var(--border); }
.sidebar__version { font-size: 0.68rem; color: var(--text-tertiary); margin-bottom: 10px; }
.progress-bar { height: 3px; background: var(--bg-tertiary); border-radius: 2px; overflow: hidden; }
.progress-bar__fill {
  height: 100%; background: linear-gradient(90deg, var(--primary), var(--cyan));
  border-radius: 2px; width: 0%; transition: width 0.3s ease;
}
.progress-label { font-size: 0.65rem; color: var(--text-tertiary); margin-top: 6px; display: block; }

/* ======== MAIN ======== */
.main {
  margin-left: var(--sidebar-width); margin-top: var(--topbar-height);
  display: flex; min-height: calc(100vh - var(--topbar-height));
}
.content { flex: 1; max-width: calc(var(--content-max) + 100px); padding: 48px 50px 100px; min-width: 0; }

/* ======== RIGHT TOC ======== */
.toc-sidebar {
  width: var(--toc-width); flex-shrink: 0; padding: 48px 20px 40px 0;
  position: sticky; top: var(--topbar-height); max-height: calc(100vh - var(--topbar-height)); overflow-y: auto;
}
.toc-sidebar__title {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-tertiary); margin-bottom: 14px;
}
.toc-sidebar__nav a {
  display: block; font-size: 0.76rem; color: var(--text-tertiary); text-decoration: none;
  padding: 5px 0 5px 14px; border-left: 2px solid transparent; transition: var(--transition); line-height: 1.5;
}
.toc-sidebar__nav a:hover { color: var(--text-secondary); }
.toc-sidebar__nav a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 700; }

/* ======== DOCUMENT SECTIONS ======== */
.doc-section { padding-bottom: 56px; margin-bottom: 56px; border-bottom: 1px solid var(--border-light); }
.doc-section:last-of-type { border-bottom: none; }

.section-header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 36px; }
.section-number {
  font-size: 0.72rem; font-weight: 700; color: var(--primary);
  background: var(--primary-bg); padding: 4px 12px; border-radius: 100px;
  letter-spacing: 0.5px; border: 1px solid var(--primary-border);
}
.section-header h2 { font-size: 1.85rem; font-weight: 800; color: var(--heading); letter-spacing: -0.03em; line-height: 1.3; }

/* Content typography */
.content h3 { font-size: 1.25rem; font-weight: 700; color: var(--heading); margin: 36px 0 16px; letter-spacing: -0.02em; }
.content h4 { font-size: 1.05rem; font-weight: 600; color: var(--heading); margin: 24px 0 10px; }
.content p { margin-bottom: 16px; font-size: 0.92rem; line-height: 1.85; color: var(--text); }
.content strong { color: var(--heading); font-weight: 600; }
.content ul, .content ol { margin: 12px 0 20px 24px; font-size: 0.92rem; }
.content li { margin-bottom: 8px; line-height: 1.75; }

/* ======== COVER ======== */
.cover { text-align: center; padding: 60px 0 40px; }
.cover__logo { margin-bottom: 32px; }
.cover__logo img { width: 72px; height: 72px; border-radius: 16px; box-shadow: var(--shadow-md); }
.cover__badge {
  display: inline-block; padding: 6px 18px;
  background: var(--primary-bg); border: 1px solid var(--primary-border);
  border-radius: 100px; font-size: 0.7rem; font-weight: 600;
  color: var(--primary); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 28px;
}
.cover__title {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 3.5rem; font-weight: 700; color: var(--heading);
  margin-bottom: 12px; letter-spacing: -0.03em; line-height: 1.1;
}
.cover__subtitle {
  font-size: 1.15rem; color: var(--text-secondary);
  margin-bottom: 40px; font-weight: 400; line-height: 1.6;
}
.cover__description { max-width: 600px; margin: 0 auto 48px; text-align: left; }
.cover__description p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.85; }
.cover__toc {
  text-align: left; max-width: 560px; margin: 0 auto;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 36px;
}
.cover__toc h3 { font-size: 0.82rem; font-weight: 700; color: var(--heading); margin: 0 0 16px; }
.toc-list { list-style: none; counter-reset: toc; margin: 0; padding: 0; }
.toc-list li { counter-increment: toc; margin-bottom: 4px; }
.toc-list li a {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  font-size: 0.84rem; color: var(--text-secondary); padding: 5px 0;
  transition: var(--transition); border-radius: 4px;
}
.toc-list li a:hover { color: var(--primary); }
.toc-list li a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; font-weight: 600;
  color: var(--text-tertiary); min-width: 22px;
}
.toc-list ul { list-style: none; padding-left: 32px; margin-top: 4px; }
.toc-list ul li a::before { content: none; }
.toc-list ul li a { font-size: 0.8rem; padding: 3px 0; }

/* ======== CALLOUTS ======== */
.callout { padding: 20px 24px; border-radius: var(--radius-sm); margin: 20px 0; border-left: 4px solid; }
.callout__title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.callout p { margin-bottom: 0; font-size: 0.9rem; }
.callout--blue { background: var(--primary-bg); border-color: var(--primary); }
.callout--blue .callout__title { color: var(--primary); }
.callout--green { background: var(--green-bg); border-color: var(--green); }
.callout--green .callout__title { color: var(--green); }
.callout--gray { background: var(--bg-secondary); border-color: var(--border); }
.callout--gray .callout__title { color: var(--text-secondary); }
.callout--yellow { background: var(--yellow-bg); border-color: var(--yellow); }
.callout--yellow .callout__title { color: var(--yellow); }
.callout--red { background: var(--red-bg); border-color: var(--red); }
.callout--red .callout__title { color: var(--red); }

/* ======== INFO GRID ======== */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 28px 0; }
.info-card {
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 22px 16px; text-align: center; transition: var(--transition);
}
.info-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); }
.info-card__value { font-size: 1.55rem; font-weight: 800; color: var(--heading); display: block; letter-spacing: -0.02em; }
.info-card__label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; }

/* ======== FEATURE GRID ======== */
.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 24px 0 32px; }
.feature-card {
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); transition: var(--transition);
}
.feature-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.feature-card__icon { font-size: 1.5rem; margin-bottom: 10px; }
.feature-card h4 { font-size: 0.92rem; font-weight: 700; color: var(--heading); margin: 0 0 8px; }
.feature-card p { font-size: 0.84rem; color: var(--text-secondary); margin: 0; line-height: 1.65; }

/* ======== TABLES ======== */
.table-scroll { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-sm); }
.doc-table {
  width: 100%; border-collapse: collapse; font-size: 0.84rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: visible;
}
.doc-table thead { background: var(--bg-secondary); }
.doc-table th {
  padding: 12px 16px; text-align: left; font-weight: 600; font-size: 0.75rem;
  color: var(--text-secondary); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.doc-table td { padding: 11px 16px; border-bottom: 1px solid var(--border-light); color: var(--text); }
.doc-table tbody tr { transition: var(--transition); }
.doc-table tbody tr:hover { background: var(--bg-secondary); }
.doc-table--striped tbody tr:nth-child(even) { background: var(--bg-secondary); }
.row--highlight { background: var(--primary-bg) !important; font-weight: 600; }

/* ======== ARCHITECTURE DIAGRAM ======== */
.arch-diagram {
  margin: 28px 0 36px; padding: 28px;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
}
.arch-layer { margin-bottom: 10px; }
.arch-layer__label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-tertiary); margin-bottom: 8px;
}
.arch-layer__items { display: flex; gap: 8px; flex-wrap: wrap; }
.arch-block {
  padding: 10px 14px; border-radius: var(--radius-xs); font-size: 0.78rem; font-weight: 600;
  border: 1px solid; flex: 1; min-width: 100px; text-align: center; transition: var(--transition);
}
.arch-block:hover { transform: translateY(-1px); box-shadow: var(--shadow-xs); }
.arch-block small { display: block; font-weight: 400; font-size: 0.66rem; opacity: 0.7; margin-top: 2px; }
.arch-block--blue { background: var(--primary-bg); border-color: var(--primary-border); color: var(--primary); }
.arch-block--green { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }
.arch-block--purple { background: var(--purple-bg); border-color: rgba(124,58,237,0.2); color: var(--purple); }
.arch-block--gray { background: var(--bg); border-color: var(--border); color: var(--text); }
.arch-block--dark { background: var(--bg-tertiary); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] .arch-block--blue { background: rgba(14,165,233,0.1); border-color: rgba(14,165,233,0.2); color: var(--primary-light); }
[data-theme="dark"] .arch-block--green { background: rgba(52,211,153,0.1); border-color: rgba(52,211,153,0.2); color: var(--green); }
[data-theme="dark"] .arch-block--purple { background: rgba(167,139,250,0.1); border-color: rgba(167,139,250,0.2); color: var(--purple); }
.arch-arrow { text-align: center; font-size: 1.2rem; color: var(--text-tertiary); padding: 4px 0; }

/* ======== BLOCKQUOTE ======== */
.doc-quote {
  border-left: 3px solid var(--primary); padding: 20px 28px; margin: 28px 0;
  background: var(--bg-secondary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: 'Crimson Pro', Georgia, serif; font-size: 1.08rem; font-style: italic;
  color: var(--text-secondary); line-height: 1.75;
}
.doc-quote cite {
  display: block; margin-top: 10px; font-family: 'Inter', sans-serif;
  font-size: 0.76rem; font-style: normal; color: var(--text-tertiary);
}

/* ======== CODE BLOCKS ======== */
.code-block {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 20px 24px; margin: 20px 0; overflow-x: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; line-height: 1.7; color: var(--text);
}
.code-block .code-title {
  font-family: 'Inter', sans-serif; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary);
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light);
}
code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.82em;
  background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; color: var(--primary);
}

/* ======== NUMBERED LIST ======== */
.numbered-list { margin: 24px 0; }
.numbered-item { display: flex; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--border-light); }
.numbered-item:last-child { border-bottom: none; }
.numbered-item__num {
  width: 32px; height: 32px; background: var(--primary-bg); color: var(--primary);
  border: 1px solid var(--primary-border); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.numbered-item h4 { margin: 0 0 4px; font-size: 0.95rem; }
.numbered-item p { margin: 0; font-size: 0.86rem; color: var(--text-secondary); line-height: 1.65; }

/* ======== FORMULA ======== */
.formula-block {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 24px; margin: 20px 0;
  font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; line-height: 1.9;
  color: var(--heading); overflow-x: auto;
}

/* ======== SEARCH MODAL ======== */
.search-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 9999; display: none; align-items: flex-start; justify-content: center; padding-top: 120px;
}
.search-modal.visible { display: flex; }
.search-modal__inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 560px; max-height: 480px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.search-modal__input {
  width: 100%; padding: 16px 20px; border: none; border-bottom: 1px solid var(--border);
  background: none; font-family: inherit; font-size: 0.95rem; color: var(--heading); outline: none;
}
.search-modal__results { overflow-y: auto; max-height: 400px; padding: 8px; }
.search-result {
  padding: 12px 16px; border-radius: var(--radius-xs); cursor: pointer; transition: var(--transition);
}
.search-result:hover { background: var(--bg-secondary); }
.search-result__title { font-size: 0.88rem; font-weight: 600; color: var(--heading); }
.search-result__preview { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.search-result__no { padding: 20px; text-align: center; color: var(--text-tertiary); font-size: 0.85rem; }

/* ======== RESPONSIVE ======== */
@media (max-width: 1100px) {
  .toc-sidebar { display: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: flex; }
  .main { margin-left: 0; }
  .content { padding: 32px 20px 80px; }
  .search-box { min-width: 180px; }
  .search-box kbd { display: none; }
  .cover__title { font-size: 2.2rem; }
  .feature-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .topbar { padding: 0 16px; }
}

/* ======== RTL SUPPORT (Arabic) ======== */
[dir="rtl"] {
  font-family: 'IBM Plex Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  direction: rtl;
}
[dir="rtl"] body { text-align: right; }

/* Sidebar → right side */
[dir="rtl"] .sidebar {
  left: auto; right: 0;
  border-right: none; border-left: 1px solid var(--border);
}
[dir="rtl"] .sidebar__nav { direction: rtl; text-align: right; }
[dir="rtl"] .nav-group__title { text-align: right; padding: 0 10px; }
[dir="rtl"] .nav-item { direction: rtl; text-align: right; }
[dir="rtl"] .sidebar__footer { text-align: right; }

/* Main → margin on right */
[dir="rtl"] .main { margin-left: 0; margin-right: var(--sidebar-width); }

/* Topbar */
[dir="rtl"] .topbar { direction: rtl; }
[dir="rtl"] .topbar__left, [dir="rtl"] .topbar__right { direction: rtl; }

/* Section headers — number on right, title on left */
[dir="rtl"] .section-header {
  direction: rtl;
  flex-direction: row;
}

/* Callouts — border on right */
[dir="rtl"] .callout {
  border-left: none !important;
  border-right: 4px solid;
}
[dir="rtl"] .callout--blue { border-right-color: var(--primary); }
[dir="rtl"] .callout--green { border-right-color: var(--green); }
[dir="rtl"] .callout--gray { border-right-color: var(--border); }
[dir="rtl"] .callout--yellow { border-right-color: var(--yellow); }
[dir="rtl"] .callout--red { border-right-color: var(--red); }

/* Blockquotes — border on right */
[dir="rtl"] .doc-quote {
  border-left: none;
  border-right: 3px solid var(--primary);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-family: 'IBM Plex Sans Arabic', Georgia, serif;
  text-align: right;
}

/* Tables */
[dir="rtl"] .doc-table th,
[dir="rtl"] .doc-table td { text-align: right; }

/* Numbered items — number on right */
[dir="rtl"] .numbered-item { direction: rtl; }

/* Content typography */
[dir="rtl"] .content h3,
[dir="rtl"] .content h4,
[dir="rtl"] .content p,
[dir="rtl"] .content li { text-align: right; }
[dir="rtl"] .content ul,
[dir="rtl"] .content ol { margin: 12px 24px 20px 0; padding-right: 0; }

/* Cover */
[dir="rtl"] .cover__title { font-family: 'IBM Plex Sans Arabic', Georgia, serif; }
[dir="rtl"] .cover__subtitle { font-family: 'IBM Plex Sans Arabic', sans-serif; }
[dir="rtl"] .cover__toc { text-align: right; }
[dir="rtl"] .cover__description { text-align: right; }
[dir="rtl"] .toc-list li a { direction: rtl; }

/* Right TOC sidebar */
[dir="rtl"] .toc-sidebar { padding: 48px 0 40px 20px; }
[dir="rtl"] .toc-sidebar__nav a {
  padding: 5px 14px 5px 0;
  border-left: none;
  border-right: 2px solid transparent;
  text-align: right;
}
[dir="rtl"] .toc-sidebar__nav a.active { border-right-color: var(--primary); border-left-color: transparent; }

/* Keep code/formulas LTR */
[dir="rtl"] .search-box { direction: ltr; }
[dir="rtl"] .formula-block { direction: ltr; text-align: left; }
[dir="rtl"] code { direction: ltr; display: inline-block; }

/* Arch diagram blocks stay centered */
[dir="rtl"] .arch-diagram { direction: rtl; }
[dir="rtl"] .arch-layer__label { text-align: right; }
[dir="rtl"] .arch-block { direction: rtl; }

/* Feature cards */
[dir="rtl"] .feature-card { text-align: right; }
[dir="rtl"] .feature-card h4 { text-align: right; }
[dir="rtl"] .feature-card p { text-align: right; }

/* Info cards stay centered */
[dir="rtl"] .info-card { text-align: center; }

/* Progress bar */
[dir="rtl"] .progress-bar__fill {
  background: linear-gradient(270deg, var(--primary), var(--cyan));
}

@media (max-width: 860px) {
  [dir="rtl"] .sidebar { transform: translateX(100%); left: auto; right: 0; }
  [dir="rtl"] .sidebar.open { transform: translateX(0); }
  [dir="rtl"] .main { margin-right: 0; }
}
