/* الأساس: الخطوط، العناصر، التمرير، الحركة */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-family: var(--font-sans);
  letter-spacing: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: 1.65;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
bdi, .ltr { direction: ltr; unicode-bidi: isolate; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
::selection { background: var(--accent-subtle); color: var(--text-primary); }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

.ic { display: inline-flex; flex-shrink: 0; line-height: 0; }
.ic svg { display: block; }
.spin svg { animation: spin 0.9s linear infinite; }

/* شريط تمرير رفيع */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.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;
}
.skip-link {
  position: absolute; inset-inline-start: 12px; top: -48px; z-index: 900;
  background: var(--accent); color: var(--accent-fg); padding: 8px 14px; border-radius: var(--radius-md);
}
.skip-link:focus { top: 12px; }

/* أدوات تخطيط */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.tight { gap: 6px; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.stack.loose { gap: 24px; }
.grid { display: grid; gap: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.small { font-size: var(--text-sm); }
.xs { font-size: var(--text-xs); }
.bold { font-weight: 700; }
.ok-text { color: var(--ok-text); }
.warn-text { color: var(--warn-text); }
.err-text { color: var(--err-text); }
.accent-text { color: var(--accent-text); }
.hide-sm { }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes stripes { to { background-position: 28px 0; } }

.page-enter { animation: fade-up var(--duration-normal) var(--ease-spring) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 720px) {
  .hide-sm { display: none !important; }
}
