/* ── Fallback font metrics (reduces CLS on font swap) ──────────────────────── */
@font-face {
  font-family: 'IBM Plex Arabic Fallback';
  src: local('Geeza Pro'), local('Noto Naskh Arabic'), local('Simplified Arabic'), local('Arial');
  size-adjust: 106%;
  ascent-override: 82%;
  descent-override: 20%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Courier New'), local('Courier');
  size-adjust: 112%;
  ascent-override: 83%;
  descent-override: 17%;
  line-gap-override: 0%;
}

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f5f4ef;
  --border: #ececea;
  --border-strong: #d9d8d2;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-faint: #9c9c9c;
  --accent: oklch(62% 0.19 25);
  --accent-soft: oklch(96% 0.03 25);
  --accent-border: oklch(88% 0.08 25);
  --success: oklch(60% 0.14 155);
  --info: oklch(60% 0.14 250);
  --warn: oklch(70% 0.14 75);
  --radius: 12px;
  --radius-lg: 18px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.10);
  --font-sans: 'IBM Plex Sans Arabic', 'IBM Plex Arabic Fallback', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, monospace;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; outline: none; }
a { color: inherit; text-decoration: none; }

/* ── Background gradient ───────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 70% 0%, oklch(96% 0.04 25 / 0.6), transparent 60%),
    radial-gradient(ellipse 50% 40% at 20% 100%, oklch(96% 0.03 75 / 0.5), transparent 60%);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 80px; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 10px; padding: 20px 0 24px; }
.brand-logo {
  display: flex; align-items: center; gap: 6px;
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
}
.brand-logo .emoji {
  display: inline-block; transform: rotate(-8deg);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.topbar .spacer { flex: 1; }
.top-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  transition: all 120ms; white-space: nowrap; cursor: pointer;
}
.top-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.top-icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: grid; place-items: center; transition: background 120ms;
}
.top-icon-btn:hover { background: var(--surface-2); }
.chip-user { padding: 4px 14px 4px 4px; }
.chip-user .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(75% 0.12 30), oklch(65% 0.15 55));
  color: white; display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}
.chip-user .handle { font-family: var(--font-mono); font-size: 12px; color: var(--info); }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* ── Now-playing bar ───────────────────────────────────────────────────────── */
#now-playing {
  display: none;
  position: fixed; bottom: 0; inset-inline: 0;
  background: var(--text); color: white;
  padding: 10px 16px; z-index: 50;
}
#now-playing.visible { display: block; }
.np-inner { max-width: 760px; margin: 0 auto; }
.np-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.np-title { font-size: 13px; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-controls { display: flex; gap: 6px; }
.np-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.15); display: grid; place-items: center; font-size: 13px;
}
.np-btn:hover { background: rgba(255,255,255,0.25); }
.np-progress { height: 3px; background: rgba(255,255,255,0.2); border-radius: 2px; cursor: pointer; }
.np-fill { height: 100%; background: white; border-radius: 2px; width: 0; transition: width 200ms linear; }

/* Also support .now-playing class (profile page) */
.now-playing {
  display: none;
  position: fixed; bottom: 0; inset-inline: 0;
  background: var(--text); color: white;
  padding: 10px 16px; z-index: 50;
}
.now-playing.visible { display: block; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 70px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: white;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 200; opacity: 0;
  transition: all 250ms ease; pointer-events: none;
  white-space: nowrap; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.toast-error { background: var(--accent); }
/* Dashboard toast variant */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--text); color: white; padding: 10px 18px;
  border-radius: 8px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms, transform 200ms; z-index: 9999; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.error { background: var(--accent); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pager { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 20px; }
.pager-btn {
  padding: 7px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13px; transition: all 120ms;
}
.pager-btn:hover { background: var(--surface-2); }
.pager-info { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

/* ── Focus rings ───────────────────────────────────────────────────────────── */
button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent-soft); outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible { outline: none; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .wrap { padding: 0 14px 100px; }
  .topbar { padding: 14px 0 16px; gap: 6px; flex-wrap: wrap; }
  .brand-logo { font-size: 19px; }
  .top-btn { padding: 6px 11px; font-size: 12px; }
  .chip-user { padding: 3px 10px 3px 3px; }
  .chip-user .avatar { width: 22px; height: 22px; font-size: 10px; }
}

/* ── Site footer ────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 20px 28px;
  margin-top: 40px;
}
.site-footer-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center;
}
.site-footer-links {
  display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap; justify-content: center;
}
.site-footer-links a {
  font-size: 12.5px; color: var(--text-muted); text-decoration: none;
  transition: color 120ms;
}
.site-footer-links a:hover { color: var(--text); }
.site-footer-sep {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--border-strong); flex-shrink: 0;
}
.site-footer-tagline {
  font-size: 11.5px; color: var(--text-faint); margin: 0;
}
