:root {
  /* === خلفية الصفحة === */
  --bg-gradient-start: #0f4c5c;
  --bg-gradient-end: #020617;
  /* === نص === */
  --color-text: #ffffff;
  /* === نص ذهبي (عناوين مميزة) === */
  --gold-start: #fbbf24;
  --gold-end: #b45309;
  --gold-shadow: rgba(180, 83, 9, 0.5);
  /* === بطاقة زجاجية (Glass Card) === */
  --card-bg: rgba(15, 23, 42, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --muted: rgba(255, 255, 255, 0.72);
  --soft: rgba(255, 255, 255, 0.08);
  --soft-strong: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 14px 36px rgba(0, 0, 0, 0.22);
  --radius-organic: 46% 54% 58% 42% / 46% 38% 62% 54%;
  --radius-organic-alt: 58% 42% 44% 56% / 42% 56% 44% 58%;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-gradient-end);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--color-text);
  font-family:
    "Segoe UI",
    Tahoma,
    Arial,
    sans-serif;
  background:
    radial-gradient(900px 660px at 84% -6%, rgba(15, 76, 92, 0.82), transparent 66%),
    radial-gradient(620px 540px at 12% 12%, rgba(251, 191, 36, 0.18), transparent 68%),
    radial-gradient(760px 560px at 48% 100%, rgba(251, 191, 36, 0.1), transparent 72%),
    linear-gradient(145deg, var(--bg-gradient-start), var(--bg-gradient-end) 68%);
  line-height: 1.8;
}

body::before,
body::after {
  position: fixed;
  inset: auto;
  z-index: -1;
  content: "";
  pointer-events: none;
}

body::before {
  top: 120px;
  right: -120px;
  width: 360px;
  height: 430px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-organic);
  background: rgba(255, 255, 255, 0.035);
  transform: rotate(18deg);
}

body::after {
  bottom: -180px;
  left: -140px;
  width: 420px;
  height: 500px;
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: var(--radius-organic-alt);
  background: rgba(251, 191, 36, 0.075);
  transform: rotate(-22deg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border: 1px solid var(--card-border);
  border-radius: 56% 44% 48% 52% / 45% 56% 44% 55%;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
  transition:
    transform 180ms ease,
    border-radius 260ms ease;
}

.brand-mark:hover {
  border-radius: 46% 54% 60% 40% / 52% 42% 58% 48%;
  transform: translateY(-2px);
}

.brand-mark img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.topbar-copy {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.35;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.18rem;
}

.eyebrow,
.example-card h3,
.site-footer a,
.topic-card h3 {
  color: transparent;
  background: linear-gradient(90deg, var(--gold-start), var(--gold-end));
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 10px 26px var(--gold-shadow);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold-start);
  font-size: 0.86rem;
  font-weight: 900;
  letter-spacing: 0;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  text-shadow:
    0 0 16px rgba(251, 191, 36, 0.55),
    0 10px 26px var(--gold-shadow);
}

.ghost-link,
.ghost-button,
.icon-text-button,
.primary-button {
  min-height: 44px;
  border: 1px solid var(--card-border);
  color: var(--color-text);
  text-decoration: none;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.ghost-link,
.ghost-button,
.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.primary-button {
  padding: 11px 22px;
  border: 0;
  border-radius: 999px;
  color: #160f02;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-start), var(--gold-end));
  box-shadow: 0 16px 38px rgba(180, 83, 9, 0.28);
}

.ghost-link:hover,
.ghost-button:hover,
.icon-text-button:hover,
.primary-button:hover {
  border-color: rgba(251, 191, 36, 0.34);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.glass-panel,
.hero-panel,
.topic-card,
.section-nav,
.accordion-item,
.question-card,
.example-card,
.text-card {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 340px);
  min-height: 300px;
  align-items: center;
  gap: 24px;
  margin-bottom: 30px;
  padding: clamp(24px, 5vw, 56px);
  border-radius: 36px 78px 42px 88px / 54px 38px 82px 42px;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(15, 23, 42, 0.84), rgba(15, 76, 92, 0.42)),
    radial-gradient(420px 360px at 24% 18%, rgba(251, 191, 36, 0.12), transparent 72%);
}

.hero-panel::before {
  position: absolute;
  right: -80px;
  bottom: -130px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(251, 191, 36, 0.16);
  border-radius: var(--radius-organic);
  background: rgba(255, 255, 255, 0.04);
  content: "";
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.hero-copy h2 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.18;
}

.hero-copy p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.bio-orbit {
  position: relative;
  z-index: 1;
  aspect-ratio: 1;
  min-width: 180px;
}

.bio-orbit span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-organic);
}

.bio-orbit span:nth-child(1) {
  background: rgba(255, 255, 255, 0.055);
  transform: rotate(8deg);
}

.bio-orbit span:nth-child(2) {
  inset: 32px;
  border-color: rgba(251, 191, 36, 0.26);
  background: rgba(251, 191, 36, 0.1);
  transform: rotate(-28deg);
}

.bio-orbit span:nth-child(3) {
  inset: 70px;
  border-color: rgba(251, 191, 36, 0.32);
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(36deg);
}

.content-band {
  margin-top: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
}

#topicCount {
  color: var(--muted);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.topic-card {
  position: relative;
  min-height: 184px;
  padding: 24px;
  border-color: rgba(251, 191, 36, 0.34);
  border-radius: 24px 44px 22px 40px / 34px 24px 46px 22px;
  color: var(--color-text);
  text-align: right;
  overflow: hidden;
  background:
    radial-gradient(240px 180px at 18% 14%, rgba(251, 191, 36, 0.2), transparent 68%),
    linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(15, 76, 92, 0.56));
  box-shadow:
    0 0 0 1px rgba(251, 191, 36, 0.1) inset,
    0 24px 70px rgba(0, 0, 0, 0.34),
    0 0 34px rgba(251, 191, 36, 0.12);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.topic-card::before {
  position: absolute;
  top: -54px;
  left: -46px;
  width: 180px;
  height: 180px;
  border-radius: var(--radius-organic-alt);
  background: rgba(255, 255, 255, 0.11);
  filter: blur(2px);
  content: "";
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.topic-card::after {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px 36px 16px 34px / 28px 18px 38px 16px;
  content: "";
  pointer-events: none;
  transition: border-color 180ms ease;
}

.topic-card:hover,
.topic-card:focus-visible {
  border-color: rgba(251, 191, 36, 0.74);
  box-shadow:
    0 0 0 1px rgba(251, 191, 36, 0.22) inset,
    0 28px 80px rgba(0, 0, 0, 0.42),
    0 0 54px rgba(251, 191, 36, 0.22);
  transform: translateY(-4px);
  outline: none;
}

.topic-card:hover::before {
  transform: scale(1.28) rotate(12deg);
}

.topic-card:hover::after,
.topic-card:focus-visible::after {
  border-color: rgba(251, 191, 36, 0.28);
}

.topic-card h3,
.topic-card p,
.topic-card .meta {
  position: relative;
}

.topic-card p {
  color: var(--muted);
}

.topic-card h3 {
  margin-bottom: 10px;
  color: #ffffff;
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.35;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 22px rgba(251, 191, 36, 0.36);
}

.topic-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.9rem;
}

.reader-section {
  margin-top: 28px;
}

.reader-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.section-nav {
  position: sticky;
  top: 18px;
  padding: 22px;
  border-radius: 34px 18px 42px 22px / 22px 36px 20px 44px;
}

.section-links {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.section-group-link {
  margin: 14px 0 4px;
  color: transparent;
  font-size: 0.9rem;
  font-weight: 900;
  background: linear-gradient(90deg, var(--gold-start), var(--gold-end));
  -webkit-background-clip: text;
  background-clip: text;
}

.section-link {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  text-align: right;
}

.section-link.active {
  color: var(--color-text);
  border-color: rgba(251, 191, 36, 0.38);
  background: rgba(251, 191, 36, 0.12);
}

.accordion {
  display: grid;
  gap: 12px;
}

.accordion-group-heading {
  position: relative;
  margin: 18px 0 2px;
  padding: 16px 20px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 28px 12px 28px 12px / 14px 28px 14px 28px;
  background: rgba(251, 191, 36, 0.08);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.accordion-group-heading::before {
  position: absolute;
  inset: auto -20px -44px auto;
  width: 120px;
  height: 96px;
  border-radius: var(--radius-organic);
  background: rgba(251, 191, 36, 0.12);
  content: "";
}

.accordion-group-heading span {
  position: relative;
  color: transparent;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 900;
  background: linear-gradient(90deg, var(--gold-start), var(--gold-end));
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 10px 26px var(--gold-shadow);
}

.accordion-item {
  border-radius: 24px 14px 28px 16px / 16px 28px 14px 24px;
  overflow: hidden;
}

.accordion-trigger {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border: 0;
  color: var(--color-text);
  background: transparent;
  text-align: right;
}

.accordion-trigger strong {
  font-size: 1.1rem;
}

.accordion-trigger span {
  flex: 0 0 auto;
  color: var(--muted);
}

.accordion-panel {
  display: grid;
  max-height: 0;
  gap: 12px;
  overflow: hidden;
  padding: 0 18px;
  opacity: 0;
  transition:
    max-height 240ms ease,
    padding 240ms ease,
    opacity 180ms ease;
}

.accordion-item.open .accordion-panel {
  max-height: 2000px;
  padding: 0 18px 18px;
  opacity: 1;
}

.question-card,
.example-card,
.text-card {
  border-radius: 18px;
  box-shadow: none;
}

.question-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px;
  background: rgba(255, 255, 255, 0.075);
}

.question-card .number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  color: #150f02;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-start), var(--gold-end));
}

.question-card p,
.text-card p,
.example-card p {
  margin: 0;
  white-space: pre-wrap;
}

.question-card p {
  font-size: clamp(1.05rem, 1.7vw, 1.28rem);
}

.example-card {
  padding: 18px;
  border-color: rgba(251, 191, 36, 0.22);
  background: rgba(251, 191, 36, 0.09);
}

.text-card {
  padding: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--soft-strong);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.045);
}

.site-footer {
  display: flex;
  justify-content: center;
  margin-top: 46px;
}

.site-footer a {
  padding: 10px 22px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.28);
  color: var(--gold-start);
  font-size: 1.15rem;
  font-weight: 900;
  text-decoration: none;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  text-shadow:
    0 0 18px rgba(251, 191, 36, 0.58),
    0 10px 26px var(--gold-shadow);
}

.hidden {
  display: none !important;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.glass-panel {
  padding: 22px;
  border-radius: 34px 18px 42px 22px / 22px 36px 20px 44px;
}

.login-panel {
  max-width: 520px;
  margin: 44px auto;
}

.form-grid,
.upload-panel {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

input:focus {
  border-color: rgba(251, 191, 36, 0.58);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.1);
}

.file-drop {
  min-height: 138px;
  justify-content: center;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 28px 16px 34px 18px / 18px 32px 16px 34px;
  text-align: center;
  background: rgba(255, 255, 255, 0.055);
}

.file-drop input {
  display: none;
}

.file-drop span {
  color: var(--color-text);
  font-weight: 900;
}

.file-drop small,
.soft-note {
  color: var(--muted);
}

.admin-list {
  display: grid;
  gap: 12px;
}

.topic-order-toolbar {
  display: flex;
  justify-content: flex-start;
}

.topic-sort-list {
  display: grid;
  gap: 12px;
}

.admin-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--card-border);
  border-radius: 20px 12px 26px 14px / 14px 24px 12px 24px;
  background: rgba(255, 255, 255, 0.055);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.admin-item.dragging {
  opacity: 0.58;
  transform: scale(0.99);
  border-color: rgba(251, 191, 36, 0.34);
}

.admin-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-item-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-actions button,
.replace-label {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.06);
}

.replace-label input {
  display: none;
}

.danger-button {
  border-color: rgba(248, 113, 113, 0.35) !important;
  color: #fecaca !important;
}

.section-sort-panel {
  display: grid;
  gap: 12px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.section-sort-list {
  display: grid;
  gap: 8px;
}

.section-sort-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.06);
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    border-color 160ms ease;
}

.section-sort-item.main-section {
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.09);
}

.section-sort-item.dragging {
  opacity: 0.55;
  transform: scale(0.99);
}

.drag-handle {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: #160f02;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold-start), var(--gold-end));
  cursor: grab;
}

.topic-drag-handle {
  flex: 0 0 auto;
  margin-top: 2px;
}

.section-sort-item small {
  color: var(--muted);
  white-space: nowrap;
}

.save-section-order {
  justify-self: start;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 18px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--color-text);
  background: rgba(2, 6, 23, 0.88);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(50%, 0);
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .topbar .ghost-link {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .section-heading,
  .admin-item-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-panel,
  .reader-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .bio-orbit {
    width: min(260px, 70vw);
    justify-self: center;
  }

  .section-nav {
    position: static;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .brand-mark {
    width: 68px;
    height: 68px;
  }

  .brand-mark img {
    width: 54px;
    height: 54px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .hero-copy h2 {
    font-size: 2rem;
  }

  .question-card {
    grid-template-columns: 34px 1fr;
    gap: 10px;
  }

  .question-card .number {
    width: 34px;
    height: 34px;
  }

  .accordion-trigger {
    padding: 15px;
  }

  .glass-panel,
  .topic-card {
    padding: 18px;
  }
}
