:root {
  color-scheme: light;
  --font-family: "Tajawal", system-ui, sans-serif;
  --page-bg: #f3f0e9;
  --page-bg-rgb: 243, 240, 233;
  --surface: rgba(255, 255, 255, 0.80);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(9, 27, 49, 0.045);
  --text: #152033;
  --muted: #647083;
  --line: rgba(18, 32, 54, 0.11);
  --accent: #087d83;
  --accent-2: #6658d7;
  --accent-rgb: 8, 125, 131;
  --shadow: 0 24px 80px rgba(39, 52, 65, 0.12);
  --card-pad: 18px;
  --card-gap: 15px;
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --page-bg: #07101f;
  --page-bg-rgb: 7, 16, 31;
  --surface: rgba(15, 27, 48, 0.76);
  --surface-strong: rgba(18, 33, 57, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.052);
  --text: #f7fbff;
  --muted: #9caec3;
  --line: rgba(255, 255, 255, 0.10);
  --accent: #61e7e5;
  --accent-2: #8075ff;
  --accent-rgb: 97, 231, 229;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

:root[data-theme="ocean"] {
  color-scheme: dark;
  --page-bg: #061b25;
  --page-bg-rgb: 6, 27, 37;
  --surface: rgba(8, 45, 56, 0.75);
  --surface-strong: rgba(9, 54, 67, 0.95);
  --surface-soft: rgba(255, 255, 255, 0.055);
  --text: #f3feff;
  --muted: #9bc2c7;
  --line: rgba(187, 248, 248, 0.12);
  --accent: #62f1da;
  --accent-2: #59a8ff;
  --accent-rgb: 98, 241, 218;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

:root[data-theme="violet"] {
  color-scheme: dark;
  --page-bg: #120b24;
  --page-bg-rgb: 18, 11, 36;
  --surface: rgba(38, 20, 68, 0.74);
  --surface-strong: rgba(48, 25, 84, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.06);
  --text: #fff9ff;
  --muted: #c2acd7;
  --line: rgba(244, 226, 255, 0.12);
  --accent: #ff8dd8;
  --accent-2: #8e7dff;
  --accent-rgb: 255, 141, 216;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

:root[data-density="compact"] {
  --card-pad: 13px;
  --card-gap: 10px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--page-bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -15%, rgba(var(--accent-rgb), 0.13), transparent 38%),
    var(--page-bg);
  color: var(--text);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
a { color: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  right: 50%;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--page-bg);
  transform: translate(50%, -160%);
  transition: transform 160ms ease;
}
.skip-link:focus { transform: translate(50%, 0); }

.page-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 420px;
  aspect-ratio: 1;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.14;
  pointer-events: none;
}
.ambient-one { top: -200px; right: -150px; background: var(--accent); }
.ambient-two { bottom: 5%; left: -220px; background: var(--accent-2); }

.shell {
  position: relative;
  z-index: 1;
  width: min(100% - 28px, 720px);
  margin-inline: auto;
  padding: 18px 0 max(32px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  margin-bottom: 30px;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  transition: color 160ms ease;
}
.home-link:hover { color: var(--text); }
.brand-mini {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--accent);
  direction: ltr;
  font: 800 12px/1 ui-monospace, monospace;
}

.topbar-actions { display: flex; gap: 8px; }
.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}
.icon-button:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb), .45); background: rgba(var(--accent-rgb), .09); }
.icon-button:focus-visible, .link-card:focus-visible, .search-box:focus-within, select:focus-visible, .reset-button:focus-visible {
  outline: 3px solid rgba(var(--accent-rgb), .34);
  outline-offset: 3px;
}
.icon-button svg, .search-box svg, .link-arrow svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.profile { text-align: center; }
.avatar-wrap {
  position: relative;
  width: 118px;
  height: 118px;
  margin: 0 auto 22px;
}
.avatar-ring {
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(var(--accent-rgb), .38);
  border-radius: 35px;
  transform: rotate(8deg);
}
.avatar {
  position: relative;
  z-index: 1;
  display: block;
  width: 112px;
  height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 31px;
  object-fit: contain;
  background: linear-gradient(145deg, var(--surface-strong), var(--surface));
  box-shadow: var(--shadow);
}
.status-dot {
  position: absolute;
  z-index: 2;
  bottom: 2px;
  left: 3px;
  width: 19px;
  height: 19px;
  border: 4px solid var(--page-bg);
  border-radius: 99px;
  background: #40db93;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: .025em;
}
.profile h1 {
  margin: 0;
  font-size: clamp(2.25rem, 8vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.045em;
  direction: ltr;
}
.profile h1 span {
  display: block;
  margin-top: 8px;
  background: linear-gradient(110deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bio {
  max-width: 580px;
  margin: 20px auto 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.85;
}
.profile-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.profile-meta span {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.search-wrap { margin-top: 32px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 35px rgba(0,0,0,.08);
  transition: border-color 160ms ease, background 160ms ease;
}
.search-box:focus-within { border-color: rgba(var(--accent-rgb), .45); background: var(--surface-strong); }
.search-box svg { flex: 0 0 auto; color: var(--muted); }
.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}
.search-box input::placeholder { color: var(--muted); opacity: .8; }
kbd {
  min-width: 27px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font: 600 12px/1.5 ui-monospace, monospace;
}

.links-root { margin-top: 32px; }
.link-section + .link-section { margin-top: 34px; }
.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 2px 13px;
}
.section-header h2 { margin: 0; font-size: 1.04rem; }
.section-header p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.section-count {
  color: var(--muted);
  font: 700 .76rem/1 ui-monospace, monospace;
  direction: ltr;
}
.link-list { display: grid; gap: var(--card-gap); }
.link-card {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 14px;
  min-height: 86px;
  padding: var(--card-pad);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, var(--surface), rgba(var(--page-bg-rgb), .6));
  box-shadow: 0 12px 38px rgba(0, 0, 0, .10);
  color: var(--text);
  text-decoration: none;
  isolation: isolate;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.link-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: 0;
  background: linear-gradient(100deg, rgba(var(--accent-rgb), .13), transparent 52%);
  transition: opacity 180ms ease;
}
.link-card:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), .36);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .16);
}
.link-card:hover::before { opacity: 1; }
.link-card.featured {
  border-color: rgba(var(--accent-rgb), .30);
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), .10), transparent 56%),
    var(--surface);
}
.link-logo {
  display: grid;
  width: 58px;
  height: 58px;
  padding: 11px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255,255,255,.92);
  color: #10203b;
}
.link-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.link-logo.logo-fallback::after {
  content: "↗";
  font: 800 20px/1 ui-monospace, monospace;
}
.link-content { min-width: 0; }
.link-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.link-title-row strong { overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.link-title-row small {
  padding: 4px 8px;
  border: 1px solid rgba(var(--accent-rgb), .25);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), .10);
  color: var(--accent);
  font-size: .67rem;
  font-weight: 800;
}
.link-description {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.55;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-arrow {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  transition: transform 180ms ease, color 180ms ease, background 180ms ease;
}
.link-card:hover .link-arrow { transform: translate(-2px, -2px); background: rgba(var(--accent-rgb), .12); color: var(--accent); }

.empty-state {
  margin: 34px 0;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.footer {
  margin-top: 42px;
  padding: 23px 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: .8rem;
}
.footer p { margin: 0; }
.footer a { color: var(--text); font-weight: 700; text-decoration: none; }
.footer span { margin-left: 4px; color: var(--accent); direction: ltr; font-family: ui-monospace, monospace; }
.footer-note { margin-top: 7px !important; opacity: .72; }

.settings-panel {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  width: min(390px, calc(100% - 26px));
  height: 100vh;
  height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  border-left: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: -25px 0 70px rgba(0,0,0,.25);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 220ms cubic-bezier(.22, 1, .36, 1), visibility 220ms;
}
.settings-panel[data-open="true"] { transform: translateX(0); visibility: visible; }
.settings-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  border: 0;
  background: rgba(1, 6, 15, .58);
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity 180ms ease;
}
.settings-backdrop.visible { opacity: 1; }
.settings-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 34px; }
.settings-header h2 { margin: 3px 0 0; font-size: 1.4rem; }
.settings-kicker { margin: 0; color: var(--accent); font-size: .72rem; font-weight: 800; }
.close-button { flex: 0 0 auto; }
.setting-group { display: grid; gap: 8px; margin-top: 20px; }
.setting-group label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.setting-group select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
}
.setting-group select option { background: var(--page-bg); color: var(--text); }
.reset-button {
  width: 100%;
  min-height: 48px;
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.settings-help { margin: 14px 5px 0; color: var(--muted); font-size: .74rem; line-height: 1.7; }

.toast {
  position: fixed;
  z-index: 50;
  right: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: .82rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.visible { opacity: 1; transform: translate(50%, 0); }
.noscript, .fatal-error { margin: 30px; padding: 18px; border-radius: 14px; background: #3f1d1d; color: #fff; text-align: center; }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  .shell { width: min(100% - 22px, 720px); padding-top: 10px; }
  .topbar { margin-bottom: 26px; }
  .home-link > span:last-child { display: none; }
  .profile h1 { font-size: clamp(2.15rem, 13vw, 3.25rem); }
  .bio { font-size: .94rem; line-height: 1.75; }
  .link-card { grid-template-columns: 50px minmax(0, 1fr) 30px; gap: 11px; border-radius: 19px; }
  .link-logo { width: 50px; height: 50px; padding: 9px; border-radius: 15px; }
  .link-arrow { width: 30px; height: 30px; }
  .link-description { font-size: .77rem; }
  kbd { display: none; }
}

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