/* ===================================================
   فصيح — Design System
   =================================================== */
:root {
  --gold: #c9a84c;
  --gold-light: #e8c96d;
  --gold-dim: rgba(201,168,76,0.15);
  --bg-dark: #0f0d09;
  --bg-mid: #1a1610;
  --bg-card: #201c14;
  --bg-glass: rgba(26,22,16,0.85);
  --border: rgba(201,168,76,0.18);
  --text-primary: #f0e8d0;
  --text-secondary: #a89870;
  --text-muted: #6b5f48;
  --green-olive: #5a7a4a;
  --ink: #1a1208;
  --sand: #d4b896;
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --transition: 0.35s cubic-bezier(0.4,0,0.2,1);
}

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

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

body {
  font-family: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  direction: rtl;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }

/* ===== PARTICLE CANVAS ===== */
#particleCanvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: 0.4;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; right: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 28px 20px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.logo-ar {
  font-family: 'Noto Kufi Arabic', sans-serif;
  font-size: 2rem; font-weight: 900;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}
.logo-dot { color: var(--gold); font-size: 0.7rem; }

.sidebar-nav {
  flex: 1; overflow-y: auto; padding: 12px 0;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: var(--text-secondary);
  text-decoration: none; font-size: 0.9rem; font-weight: 600;
  border-right: 3px solid transparent;
  transition: all var(--transition); cursor: pointer;
}
.nav-item:hover, .nav-item.active {
  color: var(--gold); background: var(--gold-dim);
  border-right-color: var(--gold);
}
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

/* Player Card */
.player-card {
  margin: 12px; padding: 16px;
  background: var(--gold-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.player-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8a6020);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 900; color: var(--ink);
  float: right; margin-left: 10px;
}
.player-name { font-weight: 700; font-size: 0.9rem; color: var(--text-primary); }
.player-level { font-size: 0.75rem; color: var(--gold); margin-top: 2px; }
.xp-bar-wrap { margin-top: 10px; clear: both; }
.xp-track {
  height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden; margin-bottom: 4px;
}
.xp-bar {
  height: 100%; width: var(--xp-pct,0%);
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 3px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1);
}
.xp-label { font-size: 0.7rem; color: var(--text-muted); }

.sidebar-toggle {
  display: none; position: fixed; top: 16px; right: 16px;
  z-index: 200; background: var(--bg-card);
  border: 1px solid var(--border); color: var(--gold);
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 1.2rem; cursor: pointer;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-right: var(--sidebar-w);
  position: relative; z-index: 1;
}

/* ===== SECTIONS ===== */
.section {
  min-height: 100vh; padding: 80px 60px;
  position: relative; overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.section-header {
  text-align: center; margin-bottom: 60px;
}
.section-badge {
  display: inline-block; padding: 6px 18px;
  background: var(--gold-dim); border: 1px solid var(--border);
  border-radius: 20px; font-size: 0.8rem; color: var(--gold);
  margin-bottom: 16px; letter-spacing: 1px;
}
.section-title {
  font-family: 'Noto Kufi Arabic', sans-serif;
  font-size: 2.8rem; font-weight: 900;
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 14px;
}
.section-desc {
  color: var(--text-secondary); font-size: 1.1rem; max-width: 600px; margin: 0 auto;
}

/* ===== HERO ===== */
.hero-section {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #2a1f0a 0%, var(--bg-dark) 70%);
  min-height: 100vh;
}
.hero-bg-overlay {
  position: absolute; inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Ccircle cx='40' cy='40' r='1' fill='%23c9a84c' opacity='0.08'/%3E%3C/svg%3E") repeat,
    radial-gradient(ellipse at center top, rgba(201,168,76,0.08) 0%, transparent 60%);
}
.city-silhouette {
  position: absolute; bottom: 0; left: 0; right: 0; height: 280px;
  background: linear-gradient(to top, rgba(26,22,16,0.9), transparent);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1400 280'%3E%3Cpath d='M0,280 L0,180 L50,180 L50,120 L70,120 L70,100 L90,100 L90,60 L100,60 L100,100 L110,100 L110,80 L125,80 L115,80 L115,120 L130,120 L130,180 L180,180 L180,140 L200,140 L200,90 L215,90 L215,60 L230,60 L230,90 L245,90 L245,140 L280,140 L280,180 L350,180 L350,150 L370,150 L370,100 L385,100 L385,70 L400,70 L400,100 L415,100 L415,150 L450,150 L450,180 L520,180 L520,160 L540,160 L540,110 L555,110 L560,80 L565,110 L580,110 L580,160 L620,160 L620,180 L680,180 L680,130 L700,130 L700,80 L715,80 L715,50 L730,50 L730,80 L745,80 L745,130 L790,130 L790,180 L850,180 L850,155 L870,155 L870,105 L885,105 L885,85 L900,85 L900,105 L915,105 L915,155 L960,155 L960,180 L1020,180 L1020,160 L1040,160 L1040,115 L1055,115 L1060,90 L1065,115 L1080,115 L1080,160 L1120,160 L1120,180 L1180,180 L1180,145 L1200,145 L1200,95 L1215,95 L1215,70 L1230,70 L1230,95 L1245,95 L1245,145 L1290,145 L1290,180 L1400,180 L1400,280 Z' fill='%231a1610'/%3E%3C/svg%3E");
  mask-size: cover;
}

/* Lanterns */
.lantern {
  position: absolute; width: 20px; height: 28px;
  border-radius: 4px 4px 8px 8px;
  box-shadow: 0 0 30px 10px rgba(201,168,76,0.12);
  animation: lanternSway 4s ease-in-out infinite;
}
.lantern::before {
  content: ''; position: absolute; top: -14px; left: 50%;
  transform: translateX(-50%);
  width: 2px; height: 14px; background: var(--gold-dim);
}
.lantern-1 { top: 8%; left: 15%; background: rgba(201,168,76,0.15); animation-delay: 0s; }
.lantern-2 { top: 12%; left: 50%; background: rgba(201,168,76,0.1); animation-delay: 1.5s; }
.lantern-3 { top: 6%; left: 80%; background: rgba(201,168,76,0.13); animation-delay: 0.8s; }
@keyframes lanternSway {
  0%,100% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
}

.hero-content {
  position: relative; z-index: 2;
  text-align: center; max-width: 800px; padding: 20px;
}
.hero-badge {
  display: inline-block; padding: 8px 22px;
  border: 1px solid var(--border);
  background: var(--gold-dim); border-radius: 30px;
  font-size: 0.85rem; color: var(--gold);
  margin-bottom: 32px; letter-spacing: 1px;
  animation: fadeInDown 0.8s ease;
}
.hero-title {
  margin-bottom: 24px; animation: fadeInDown 0.9s ease 0.1s both;
}
.title-main {
  display: block;
  font-family: 'Noto Kufi Arabic', sans-serif;
  font-size: clamp(4rem, 10vw, 8rem);
  font-weight: 900; letter-spacing: 8px;
  background: linear-gradient(135deg, #fff 20%, var(--gold-light) 50%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 40px rgba(201,168,76,0.3));
  line-height: 1;
}
.title-sub {
  display: block; font-size: 1.3rem; color: var(--text-secondary);
  font-weight: 300; margin-top: 10px; letter-spacing: 3px;
}
.hero-desc {
  color: var(--text-secondary); font-size: 1.05rem;
  line-height: 2; margin-bottom: 40px;
  animation: fadeInDown 1s ease 0.2s both;
}
.hero-cta {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 60px; animation: fadeInDown 1.1s ease 0.3s both;
}

/* Buttons */
.btn-gold {
  padding: 14px 36px; background: linear-gradient(135deg, var(--gold), #a07030);
  border: none; border-radius: 50px; color: var(--ink);
  font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 1rem;
  cursor: pointer; position: relative; overflow: hidden;
  transition: all var(--transition);
  box-shadow: 0 4px 24px rgba(201,168,76,0.3);
  display: inline-flex; align-items: center; gap: 10px;
}
.btn-gold:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 36px rgba(201,168,76,0.45);
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
}
.btn-gold::after {
  content: ''; position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  transform: translateX(100%); transition: transform 0.4s;
}
.btn-gold:hover::after { transform: translateX(-100%); }
.btn-gold.btn-sm { padding: 10px 22px; font-size: 0.85rem; }
.btn-gold.btn-full { width: 100%; justify-content: center; }
.btn-arrow { font-size: 1.1rem; }

.btn-ghost {
  padding: 14px 36px; background: transparent;
  border: 1px solid var(--border); border-radius: 50px;
  color: var(--text-secondary); font-family: 'Cairo', sans-serif;
  font-weight: 600; font-size: 1rem; cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover {
  border-color: var(--gold); color: var(--gold);
  background: var(--gold-dim);
}
.btn-ghost.btn-sm { padding: 8px 18px; font-size: 0.82rem; }

.hero-stats {
  display: flex; align-items: center; justify-content: center; gap: 30px;
  animation: fadeInDown 1.2s ease 0.4s both;
}
.stat-item { text-align: center; }
.stat-num {
  display: block; font-size: 2rem; font-weight: 900;
  color: var(--gold); font-family: 'Noto Kufi Arabic', sans-serif;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

.floating-quote {
  position: absolute; bottom: 60px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 28px;
  font-size: 1rem; color: var(--text-secondary);
  font-style: italic; backdrop-filter: blur(10px);
  text-align: center; min-width: 300px;
  animation: floatUp 3s ease-in-out infinite;
}
.quote-mark { color: var(--gold); font-size: 1.4rem; }
.quote-author { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
@keyframes floatUp {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}

/* ===== ADVENTURE ===== */
.section-adventure { background: linear-gradient(180deg, var(--bg-dark), #120e07); }
.adventure-map {
  position: relative; width: 100%; height: 320px;
  background: radial-gradient(ellipse at 50% 80%, rgba(201,168,76,0.05), transparent),
              linear-gradient(135deg, #0d0b06, #1a1408);
  border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 40px; overflow: hidden;
}
.map-path {
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cpath d='M80,224 Q160,144 272,192 Q336,216 440,120 Q520,72 608,176 Q672,248 752,104 Q800,56 856,88' stroke='%23c9a84c' stroke-width='2' stroke-dasharray='8 6' fill='none' opacity='0.25'/%3E%3C/svg%3E") no-repeat center/cover;
}
.map-node {
  position: absolute; left: var(--x); top: var(--y);
  transform: translate(-50%, -50%);
  width: 70px; text-align: center; cursor: pointer;
  transition: all var(--transition);
}
.map-node:hover { transform: translate(-50%,-50%) scale(1.15); }
.node-icon {
  width: 54px; height: 54px; border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; margin: 0 auto 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: all var(--transition);
}
.map-node.completed .node-icon {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,0.3);
}
.map-node.active .node-icon {
  border-color: var(--gold-light);
  box-shadow: 0 0 30px rgba(201,168,76,0.5);
  animation: nodePulse 2s ease-in-out infinite;
}
.map-node.locked .node-icon { opacity: 0.4; cursor: not-allowed; }
.map-node.locked:hover { transform: translate(-50%, -50%); }
@keyframes nodePulse {
  0%,100% { box-shadow: 0 0 20px rgba(201,168,76,0.4); }
  50% { box-shadow: 0 0 40px rgba(201,168,76,0.8); }
}
.node-label {
  font-size: 0.68rem; color: var(--text-secondary);
  line-height: 1.3; white-space: nowrap;
}
.node-badge {
  position: absolute; top: 0; right: 8px;
  background: var(--gold); color: var(--ink);
  border-radius: 50%; width: 18px; height: 18px;
  font-size: 0.6rem; display: flex; align-items: center; justify-content: center;
}
.node-pulse {
  position: absolute; top: 0; left: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); animation: ping 1.5s ease-in-out infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}
.adventure-info { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.adv-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.adv-card-icon { font-size: 2rem; margin-bottom: 12px; }
.adv-card h3 { color: var(--gold); font-size: 1.3rem; margin-bottom: 8px; }
.adv-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.8; margin-bottom: 16px; }
.adv-progress { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 6px; overflow: hidden; }
.adv-progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); border-radius: 3px; }
.adv-progress-label { font-size: 0.75rem; color: var(--gold); display: block; margin-bottom: 16px; }
.adv-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adv-stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px; text-align: center;
}
.s-val { display: block; font-size: 1.8rem; font-weight: 900; color: var(--gold); }
.s-key { font-size: 0.78rem; color: var(--text-muted); }

/* ===== COUNCIL ===== */
.section-council {
  background: linear-gradient(180deg, #120e07, #0f0d09);
}
.council-container { display: grid; grid-template-columns: 260px 1fr; gap: 24px; }
.scholars-list { display: flex; flex-direction: column; gap: 12px; }
.scholar-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition); position: relative;
}
.scholar-card.active, .scholar-card:hover {
  border-color: var(--gold); background: var(--gold-dim);
}
.scholar-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800; color: var(--ink); flex-shrink: 0;
}
.s-gold { background: linear-gradient(135deg, var(--gold), #8a6020); }
.s-green { background: linear-gradient(135deg, #5a7a4a, #3a5a30); color: #fff; }
.s-blue { background: linear-gradient(135deg, #3a5a8a, #1a3a6a); color: #fff; }
.s-purple { background: linear-gradient(135deg, #6a3a8a, #4a1a6a); color: #fff; }
.scholar-name { font-weight: 700; font-size: 0.95rem; }
.scholar-role { font-size: 0.75rem; color: var(--text-muted); }
.scholar-indicator {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
  display: none;
}
.scholar-card.active .scholar-indicator { display: block; }

.chat-area {
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; min-height: 480px;
}
.chat-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--gold-dim);
}
.chat-scholar-name { font-weight: 700; font-size: 1rem; color: var(--gold); }
.chat-scholar-subtitle { font-size: 0.75rem; color: var(--text-muted); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #8a6020);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem; color: var(--ink); flex-shrink: 0;
}
.msg-bubble {
  background: rgba(201,168,76,0.08); border: 1px solid var(--border);
  border-radius: 0 12px 12px 12px; padding: 12px 16px;
  font-size: 0.9rem; line-height: 1.8; color: var(--text-primary);
  max-width: 85%;
}
.msg.msg-user { flex-direction: row-reverse; }
.msg.msg-user .msg-bubble {
  background: var(--gold-dim); border-color: var(--gold);
  border-radius: 12px 0 12px 12px;
}
.msg.msg-user .msg-avatar { background: linear-gradient(135deg, #3a5a4a, #1a3a2a); color: #fff; }
.msg-typing .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); margin: 0 2px;
  animation: typingBounce 1s infinite;
}
.msg-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%,80%,100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}
.chat-input-area {
  display: flex; gap: 10px; padding: 14px 16px;
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: 50px; padding: 10px 18px;
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 0.9rem; outline: none; direction: rtl;
  transition: border-color var(--transition);
}
.chat-input:focus { border-color: var(--gold); }
.chat-input::placeholder { color: var(--text-muted); }
.btn-send {
  background: linear-gradient(135deg, var(--gold), #a07030);
  border: none; border-radius: 50px; padding: 10px 22px;
  color: var(--ink); font-family: 'Cairo', sans-serif; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all var(--transition);
}
.btn-send:hover { transform: scale(1.05); }

/* ===== DIALECT ===== */
.section-dialect { background: linear-gradient(180deg, #0f0d09, #120e07); }
.dialect-container { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 0; align-items: stretch; min-height: 320px; }
.dialect-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.dialect-panel-header { padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--gold-dim); }
.dialect-select {
  background: transparent; border: none; color: var(--gold);
  font-family: 'Cairo', sans-serif; font-size: 0.9rem; font-weight: 700;
  outline: none; cursor: pointer; width: 100%;
}
.dialect-select option { background: var(--bg-card); }
.dialect-textarea {
  flex: 1; background: transparent; border: none;
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 1rem; line-height: 1.8; padding: 18px;
  resize: none; outline: none; direction: rtl;
}
.dialect-textarea::placeholder { color: var(--text-muted); }
.dialect-arrow-btn {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; cursor: pointer;
  transition: all var(--transition);
}
.dialect-arrow-btn:hover { transform: scale(1.1); }
.arrow-icon {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #a07030);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--ink);
  box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}
.arrow-label { font-size: 0.75rem; color: var(--gold); }
.dialect-output {
  flex: 1; padding: 18px; color: var(--text-primary);
  font-size: 1rem; line-height: 1.8;
}
.output-placeholder { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.output-placeholder span { display: block; font-size: 2rem; margin-bottom: 12px; }
.dialect-tips { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.tip-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 18px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: all var(--transition); flex: 1; min-width: 200px;
}
.tip-card:hover { border-color: var(--gold); background: var(--gold-dim); }
.tip-from { color: var(--text-secondary); font-size: 0.9rem; }
.tip-arrow { color: var(--gold); }
.tip-to { color: var(--gold); font-size: 0.9rem; font-weight: 700; }

/* ===== WRITER ===== */
.section-writer { background: linear-gradient(180deg, #120e07, #0f0d09); }
.writer-container { max-width: 1000px; margin: 0 auto; }
.writer-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.tool-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 50px; padding: 8px 18px; color: var(--text-secondary);
  font-family: 'Cairo', sans-serif; font-size: 0.82rem; cursor: pointer;
  transition: all var(--transition);
}
.tool-btn:hover, .tool-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }
.tool-btn.danger:hover { border-color: #c46a4a; color: #c46a4a; }
.writer-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.writer-editor-wrap { position: relative; }
.editor-label {
  font-size: 0.8rem; color: var(--gold); margin-bottom: 8px;
  font-weight: 600; display: block;
}
.writer-editor {
  width: 100%; min-height: 320px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 1rem; line-height: 1.9; padding: 20px;
  resize: vertical; outline: none; direction: rtl;
  transition: border-color var(--transition);
}
.writer-editor:focus { border-color: var(--gold); }
.editor-counter {
  position: absolute; bottom: 10px; left: 10px;
  font-size: 0.72rem; color: var(--text-muted);
}
.writer-analysis {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; min-height: 320px;
  overflow-y: auto;
}
.analysis-placeholder { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.analysis-icon { font-size: 2.5rem; margin-bottom: 12px; }
.analysis-result { display: flex; flex-direction: column; gap: 14px; }
.result-item {
  background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.result-type { font-size: 0.75rem; color: var(--gold); font-weight: 700; margin-bottom: 6px; }
.result-text { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; }
.result-item.error { border-color: #8a3a2a; }
.result-item.success { border-color: var(--green-olive); }

/* ===== SPEECH ===== */
.section-speech { background: linear-gradient(180deg, #0f0d09, #120e07); }
.speech-container { max-width: 800px; margin: 0 auto; }
.speech-visualizer {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px;
  text-align: center; margin-bottom: 24px;
}
.wave-bars { display: flex; align-items: center; justify-content: center; gap: 4px; height: 80px; margin-bottom: 16px; }
.wave-bar {
  width: 6px; background: linear-gradient(to top, var(--gold-dim), var(--gold));
  border-radius: 3px; height: 20%;
  transition: height 0.1s ease;
}
.wave-bar.active {
  animation: waveAnim 0.8s var(--delay) ease-in-out infinite alternate;
}
@keyframes waveAnim {
  from { height: 15%; }
  to { height: 100%; }
}
.speech-status { color: var(--text-muted); font-size: 0.9rem; }
.speech-controls { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 24px; }
.mic-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #a07030);
  border: none; font-size: 2rem; cursor: pointer;
  box-shadow: 0 6px 30px rgba(201,168,76,0.35);
  transition: all var(--transition);
}
.mic-btn:hover { transform: scale(1.1); box-shadow: 0 8px 40px rgba(201,168,76,0.55); }
.mic-btn.recording { background: linear-gradient(135deg, #c46a4a, #8a3a2a); animation: recordPulse 1s ease-in-out infinite; }
@keyframes recordPulse {
  0%,100% { box-shadow: 0 6px 30px rgba(196,106,74,0.4); }
  50% { box-shadow: 0 6px 50px rgba(196,106,74,0.8); }
}
.speech-timer { font-size: 1.5rem; font-weight: 800; color: var(--gold); font-family: 'Noto Kufi Arabic', sans-serif; }
.speech-prompt {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 24px;
}
.prompt-label { font-size: 0.8rem; color: var(--gold); margin-bottom: 12px; font-weight: 700; }
.prompt-text { font-size: 1.05rem; line-height: 2; color: var(--text-primary); margin-bottom: 14px; }
.speech-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.metric-ring {
  width: 80px; height: 80px; border-radius: 50%;
  border: 4px solid var(--border); margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  background: conic-gradient(var(--gold) var(--pct), var(--border) var(--pct));
}
.metric-ring::before {
  content: ''; position: absolute; inset: 6px; border-radius: 50%;
  background: var(--bg-card);
}
.metric-val { position: relative; z-index: 1; font-size: 1.1rem; font-weight: 800; color: var(--gold); }
.metric-label { font-size: 0.78rem; color: var(--text-muted); }

/* ===== STORIES ===== */
.section-stories { background: linear-gradient(180deg, #120e07, #0f0d09); }
.stories-container { display: grid; grid-template-columns: 320px 1fr; gap: 28px; }
.story-config {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.config-label { display: block; font-size: 0.8rem; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.age-btns, .genre-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.age-btn, .genre-btn {
  padding: 8px 14px; background: var(--bg-mid);
  border: 1px solid var(--border); border-radius: 50px;
  color: var(--text-secondary); font-family: 'Cairo', sans-serif;
  font-size: 0.82rem; cursor: pointer; transition: all var(--transition);
}
.age-btn.active, .genre-btn.active,
.age-btn:hover, .genre-btn:hover {
  border-color: var(--gold); color: var(--gold); background: var(--gold-dim);
}
.story-input {
  width: 100%; background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 0.9rem; outline: none; direction: rtl;
  transition: border-color var(--transition);
}
.story-input:focus { border-color: var(--gold); }
.story-input::placeholder { color: var(--text-muted); }
.story-output {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; min-height: 420px;
}
.story-placeholder { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.story-icon { font-size: 3rem; margin-bottom: 12px; }
.story-content h3 { color: var(--gold); font-size: 1.5rem; margin-bottom: 16px; }
.story-content p { color: var(--text-primary); line-height: 2.1; font-size: 1rem; }
.story-content .story-moral {
  margin-top: 20px; padding: 14px 18px;
  background: var(--gold-dim); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--gold); font-weight: 600;
}

/* ===== QURAN ===== */
.section-quran { background: linear-gradient(180deg, #0f0d09, #120e07); }
.quran-container { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.quran-verse-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px;
  text-align: center;
  box-shadow: 0 0 60px rgba(201,168,76,0.05);
}
.verse-arabic {
  font-family: 'Noto Kufi Arabic', serif;
  font-size: clamp(1.3rem, 3vw, 2rem);
  color: var(--text-primary); line-height: 2.2;
  margin-bottom: 20px;
}
.verse-ref { font-size: 0.85rem; color: var(--gold); margin-bottom: 16px; }
.quran-analysis {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.analysis-tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
  flex: 1; padding: 14px; background: transparent;
  border: none; color: var(--text-muted);
  font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 0.9rem;
  cursor: pointer; transition: all var(--transition);
  border-bottom: 2px solid transparent;
}
.tab-btn.active, .tab-btn:hover { color: var(--gold); border-bottom-color: var(--gold); }
.tab-content { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.analysis-item { display: flex; gap: 14px; align-items: flex-start; }
.ai-icon { color: var(--gold); font-size: 0.9rem; margin-top: 3px; flex-shrink: 0; }
.ai-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.8; }
.ai-text strong { color: var(--gold); }

/* ===== DETECTIVE ===== */
.section-detective { background: linear-gradient(180deg, #120e07, #0f0d09); }
.detective-container { display: grid; grid-template-columns: 1fr 280px; gap: 24px; }
.case-file {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.case-header { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.case-badge {
  background: var(--gold); color: var(--ink);
  border-radius: 50px; padding: 4px 12px; font-size: 0.75rem; font-weight: 800;
}
.case-number { color: var(--text-muted); font-size: 0.85rem; }
.case-title { font-size: 1.4rem; color: var(--gold); font-weight: 700; margin-bottom: 16px; }
.case-text { color: var(--text-secondary); font-size: 0.95rem; line-height: 2; margin-bottom: 24px; }
.broken-sentence {
  background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 20px;
  font-size: 1.1rem; color: var(--text-primary); line-height: 2.2;
  margin-top: 12px;
}
.error-word {
  color: var(--gold); cursor: pointer; padding: 2px 6px;
  border-radius: 4px; transition: all var(--transition);
  border-bottom: 2px dashed var(--gold-dim);
}
.error-word:hover { background: var(--gold-dim); }
.error-word.flagged { background: rgba(90,122,74,0.2); color: #7ab46a; border-bottom-color: #7ab46a; }
.clues-area {
  background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 20px;
}
.clue-header { font-size: 0.8rem; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.clue-empty { color: var(--text-muted); font-size: 0.85rem; }
.clue-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 0.85rem; color: var(--text-secondary);
}
.clue-item:last-child { border-bottom: none; }
.clue-num { color: var(--gold); font-weight: 800; flex-shrink: 0; }
.detective-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.case-score { margin-right: auto; color: var(--gold); font-weight: 800; }

.detective-sidebar {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 20px;
}
.ds-title { font-size: 0.85rem; color: var(--gold); font-weight: 700; margin-bottom: 10px; }
.detective-stats { display: flex; flex-direction: column; gap: 10px; }
.ds-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--bg-mid); border-radius: var(--radius-sm);
}
.ds-val { font-weight: 800; color: var(--gold); }
.ds-key { font-size: 0.78rem; color: var(--text-muted); }
.achievements { display: flex; flex-direction: column; gap: 8px; }
.achievement {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.82rem; transition: all var(--transition);
}
.achievement.unlocked { background: var(--gold-dim); border: 1px solid var(--border); color: var(--gold); }
.achievement.locked { background: var(--bg-mid); color: var(--text-muted); opacity: 0.5; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-glass); border: 1px solid var(--gold);
  border-radius: 50px; padding: 12px 28px;
  color: var(--gold); font-size: 0.9rem; font-weight: 600;
  backdrop-filter: blur(20px); z-index: 999;
  opacity: 0; transition: all 0.4s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px); z-index: 500;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px;
  max-width: 520px; width: 90%; position: relative;
  animation: modalSlide 0.3s ease;
}
@keyframes modalSlide { from { transform: scale(0.9) translateY(20px); } }
.modal-close {
  position: absolute; top: 16px; left: 16px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; transition: color var(--transition);
}
.modal-close:hover { color: var(--gold); }

/* ===== XP POPUP ===== */
.xp-popup {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: var(--ink);
  border-radius: 50px; padding: 10px 24px;
  font-weight: 800; font-size: 1rem; z-index: 998;
  opacity: 0; pointer-events: none;
  animation: none;
}
.xp-popup.show {
  animation: xpFloat 1.8s ease forwards;
}
@keyframes xpFloat {
  0% { opacity: 0; transform: translateX(-50%) translateY(0); }
  20% { opacity: 1; }
  80% { opacity: 1; transform: translateX(-50%) translateY(-60px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-80px); }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.section { opacity: 0; transform: translateY(30px); transition: opacity 0.7s ease, transform 0.7s ease; }
.section.visible { opacity: 1; transform: translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .council-container { grid-template-columns: 1fr; }
  .stories-container { grid-template-columns: 1fr; }
  .detective-container { grid-template-columns: 1fr; }
  .adventure-info { grid-template-columns: 1fr; }
  .writer-body { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); --sidebar-w: 260px; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .main-content { margin-right: 0; }
  .section { padding: 60px 20px; }
  .dialect-container { grid-template-columns: 1fr; }
  .dialect-arrow-btn { transform: rotate(90deg); }
  .speech-metrics { grid-template-columns: 1fr 1fr; }
  .adv-stats-grid { grid-template-columns: 1fr 1fr; }
  .hero-stats { gap: 16px; }
}
@media (max-width: 480px) {
  .title-main { font-size: 3.5rem; }
  .section-title { font-size: 2rem; }
  .speech-metrics { grid-template-columns: 1fr 1fr; }
}

/* ===== ONBOARDING ===== */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(10,8,4,0.97);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px);
  transition: opacity 0.6s ease;
}
.onboarding-overlay.hidden { opacity: 0; pointer-events: none; }
.onboarding-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 24px; padding: 48px 40px;
  max-width: 460px; width: 90%; text-align: center;
  box-shadow: 0 0 80px rgba(201,168,76,0.12);
  animation: modalSlide 0.5s ease;
}
.ob-logo {
  font-family: 'Noto Kufi Arabic', sans-serif;
  font-size: 3.5rem; font-weight: 900;
  background: linear-gradient(135deg, #fff 20%, var(--gold-light) 50%, var(--gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.ob-subtitle { color: var(--gold); font-size: 0.9rem; margin-bottom: 8px; letter-spacing: 2px; }
.ob-desc { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 32px; }
.ob-step { display: none; flex-direction: column; gap: 16px; }
.ob-step.active { display: flex; }
.ob-step-num { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 2px; }
.ob-label { font-size: 1rem; color: var(--text-primary); font-weight: 700; text-align: right; }
.ob-input {
  width: 100%; background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 1rem; outline: none; direction: rtl; text-align: right;
  transition: border-color var(--transition);
}
.ob-input:focus { border-color: var(--gold); }
.ob-input::placeholder { color: var(--text-muted); }
.ob-select {
  width: 100%; background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  color: var(--text-primary); font-family: 'Cairo', sans-serif;
  font-size: 0.95rem; outline: none; direction: rtl; cursor: pointer;
  transition: border-color var(--transition); appearance: none;
}
.ob-select:focus { border-color: var(--gold); }
.ob-select option, .ob-select optgroup { background: var(--bg-card); color: var(--text-primary); }
.ob-btn {
  padding: 14px 30px;
  background: linear-gradient(135deg, var(--gold), #a07030);
  border: none; border-radius: 50px; color: var(--ink);
  font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 1rem;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}
.ob-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(201,168,76,0.5); }
.ob-btn-back {
  background: transparent; border: none; color: var(--text-muted);
  font-family: 'Cairo', sans-serif; font-size: 0.85rem; cursor: pointer;
  transition: color var(--transition);
}
.ob-btn-back:hover { color: var(--gold); }

/* ===== LEARNING JOURNEY ===== */
.section-journey { background: linear-gradient(180deg, var(--bg-dark), #0d0b06); }
.journey-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.journey-phase {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: all var(--transition); cursor: pointer;
  position: relative; overflow: hidden;
}
.journey-phase::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 4px; height: 100%; background: var(--gold-dim);
  transition: background var(--transition);
}
.journey-phase:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 8px 32px rgba(201,168,76,0.12); }
.journey-phase:hover::before { background: var(--gold); }
.journey-phase.done { border-color: rgba(90,122,74,0.4); }
.journey-phase.done::before { background: var(--green-olive); }
.journey-phase.active-phase { border-color: var(--gold); box-shadow: 0 0 30px rgba(201,168,76,0.15); }
.journey-phase.active-phase::before { background: var(--gold); }
.jp-icon { font-size: 2rem; margin-bottom: 12px; }
.jp-level {
  font-size: 0.7rem; color: var(--gold); font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px;
}
.jp-title { font-size: 1.1rem; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }
.jp-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 14px; }
.jp-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.jp-topic {
  font-size: 0.72rem; padding: 3px 10px;
  background: var(--bg-mid); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-muted);
}
.jp-progress { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.jp-progress-bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); border-radius: 2px; transition: width 1s ease; }
.jp-status { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; }
.jp-status.done { color: var(--green-olive); }
.jp-status.active { color: var(--gold); }

/* ===== DETECTIVE EXTRAS ===== */
.case-diff {
  padding: 3px 12px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; margin-right: auto;
}
.case-diff.easy   { background: rgba(90,122,74,0.2); color: #7ab46a; }
.case-diff.medium { background: rgba(201,168,76,0.2); color: var(--gold); }
.case-diff.hard   { background: rgba(196,106,74,0.2); color: #c46a4a; }
.clue-area { margin-bottom: 20px; }

.detective-word {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.3s ease;
}
.detective-word:hover { background: rgba(201,168,76,0.2); }

.flagged-word {
  background-color: rgba(201,168,76, 0.4);
  color: var(--gold);
  border-bottom: 2px dashed var(--gold);
  border-radius: 4px;
  animation: pulseFade 1.5s infinite alternate;
  transition: all 0.4s ease-in-out;
}
@keyframes pulseFade {
  0% { background-color: rgba(201,168,76, 0.2); box-shadow: 0 0 5px rgba(201,168,76,0.1); }
  100% { background-color: rgba(201,168,76, 0.5); box-shadow: 0 0 12px rgba(201,168,76,0.4); }
}
