/* ═════════════════════════════════════════════════════════════
   Storismo Universe — واجهة المدينة (HUD، اللوحات، النوافذ، الاختبار، الجولة)
   Mobile-first · RTL/LTR عبر الخصائص المنطقية · فاتح/داكن عبر رموز app.css
   ═════════════════════════════════════════════════════════════ */
[hidden] { display: none !important; }
.city-body { overflow: hidden; background: #0b4a7d; height: 100dvh; }
.city-app { position: fixed; inset: 0; overflow: hidden; --glass: color-mix(in srgb, var(--surface) 86%, transparent); --hud-r: 16px; }
.city-stage { position: absolute; inset: 0; touch-action: none; }
.city-canvas { position: absolute; inset: 0; display: block; outline: none; cursor: grab; }
.city-canvas.is-dragging { cursor: grabbing; }
.city-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }
.hud-top, .hud-journey, .hud-tools, .hud-dock, .bpanel { z-index: 10; }
.glass, .hud-top, .jcard, .hud-tools, .hud-dock, .bpanel {
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent); box-shadow: var(--shadow); color: var(--text);
}
.icon-btn {
  min-width: 40px; min-height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 18px; line-height: 1; position: relative; padding: 0 8px;
}
.icon-btn:hover { border-color: var(--brand); }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 2px 0; text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-danger { background: var(--red); color: #fff; }
body .input { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; min-height: 44px; }
body .input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
body textarea.input { resize: vertical; line-height: 1.7; }
textarea.big { min-height: 220px; }
.form.inline, form.inline { display: inline; margin: 0; }

/* ───── الشريط العلوي ───── */
.hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); inset-inline: 8px; border-radius: var(--hud-r); padding: 6px 8px; display: flex; align-items: center; gap: 8px; }
.city-brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; min-width: 0; }
.city-brand b { display: block; font-size: 14px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.city-brand small { display: none; color: var(--muted); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: linear-gradient(135deg, #2563eb, #06b6d4); color: #fff; font-weight: 700; }
.search-wrap { position: relative; flex: 1; min-width: 0; display: none; }
body .input.search { min-height: 38px; padding-block: 6px; border-radius: 999px; }
.search-results { position: absolute; top: calc(100% + 6px); inset-inline: 0; list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; }
.search-results button { width: 100%; text-align: start; background: none; border: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; color: var(--text); font: inherit; }
.search-results button:hover, .search-results button:focus-visible { background: var(--surface-2); }
.search-results small { color: var(--muted); font-size: 12px; }
.hud-chips { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; border-radius: 999px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.xp-chip { display: none; flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1.15; }
.xp-chip small { color: var(--muted); font-size: 11px; }
.mini-ring { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--border) 0); mask: radial-gradient(circle, transparent 6px, #000 7px); -webkit-mask: radial-gradient(circle, transparent 6px, #000 7px); }
.bell .count { position: absolute; top: -4px; inset-inline-end: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 4px; }
@media (min-width: 760px) {
  .city-brand small { display: block; }
  .search-wrap { display: block; max-width: 380px; }
  .xp-chip { display: inline-flex; }
}

/* ───── بطاقة الرحلة ───── */
.hud-journey { position: absolute; inset-inline-start: 8px; top: 70px; width: min(320px, calc(100vw - 16px)); pointer-events: none; }
.jcard { border-radius: var(--hud-r); padding: 12px 14px; pointer-events: auto; position: relative; }
.jcard header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-inline-end: 34px; }
.jcard h2 { margin: 0; font-size: 15px; }
.jcard p { margin: 6px 0; font-size: 13px; }
.jc-toggle { position: absolute; top: 8px; inset-inline-end: 8px; min-width: 30px; min-height: 30px; font-size: 14px; }
.hud-journey.is-collapsed .jcard > :not(header):not(.jc-toggle) { display: none; }
.hud-journey.is-collapsed .jc-toggle { transform: rotate(180deg); }
.jc-row { display: block; width: 100%; text-align: start; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; margin-block: 6px; cursor: pointer; color: var(--text); font: inherit; }
.jc-row small { display: block; color: var(--muted); font-size: 11px; }
.jc-row strong { display: block; font-size: 14px; }
.jc-state { font-size: 12px; color: var(--text-2); }
.meter { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--border) 70%, transparent); overflow: hidden; margin-block: 8px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #06b6d4); border-radius: inherit; transition: width .4s; }
@media (max-width: 759px) { .hud-journey { top: auto; bottom: 84px; } .hud-journey:not(.is-collapsed) .jcard { max-height: 42vh; overflow: auto; } }

/* ───── الأدوات + الخريطة المصغرة ───── */
.hud-tools { position: absolute; inset-inline-end: 8px; bottom: 84px; border-radius: var(--hud-r); padding: 6px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
#city-minimap { width: 180px; height: 120px; border-radius: 10px; cursor: pointer; display: none; }
.tool-row { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.tool-row .icon-btn { min-width: 36px; min-height: 36px; font-size: 16px; }
@media (min-width: 760px) { #city-minimap { display: block; } .hud-tools { bottom: 16px; } }

/* ───── الشريط السفلي (7 أزرار) ───── */
.hud-dock { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); border-radius: 20px; padding: 6px; display: flex; gap: 2px; max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
.dock-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; min-height: 56px; border-radius: 14px; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; padding: 4px 6px; }
.dock-btn span { font-size: 21px; line-height: 1; }
.dock-btn small { font-size: 11px; white-space: nowrap; }
.dock-btn:hover, .dock-btn:focus-visible { background: var(--surface-2); }
@media (min-width: 760px) { .dock-btn { min-width: 70px; } .dock-btn small { font-size: 12px; } }

/* ───── التسميات ───── */
.city-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl, .lbl-district, .lbl-home { position: absolute; top: 0; left: 0; will-change: transform; pointer-events: auto; font: inherit; cursor: pointer; }
.lbl { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 4px; border-radius: 999px; border: 1px solid rgba(255,255,255,.65);
  background: rgba(15,23,42,.78); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; box-shadow: 0 6px 16px -8px rgba(0,0,0,.6); }
.lbl-num { min-width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #0f172a; font-size: 11px; font-family: var(--font-lat); }
.lbl-ico:empty { display: none; }
.lbl-prog { width: 34px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.25); overflow: hidden; }
.lbl-prog i { display: block; height: 100%; background: #22d3ee; }
.lbl.is-compact .lbl-name, .lbl.is-compact .lbl-prog { display: none; }
.lbl.is-compact { padding: 2px; gap: 2px; }
.lbl[data-state="locked"] { background: rgba(71,85,105,.8); color: #e2e8f0; }
.lbl[data-state="available"], .lbl[data-state="in_progress"] { background: rgba(8,145,178,.9); border-color: #a5f3fc; }
.lbl[data-state="assessment_ready"] { background: rgba(126,34,206,.9); }
.lbl[data-state="assessment_failed"] { background: rgba(194,65,12,.92); }
.lbl[data-state="completed"] { background: rgba(21,128,61,.9); }
.lbl[data-state="mastered"] { background: linear-gradient(90deg, #b45309, #ca8a04); border-color: #fde68a; }
.lbl.is-selected { outline: 3px solid #facc15; outline-offset: 1px; z-index: 2; }
.lbl-marker { font-size: 12px; }
.lbl-district { padding: 6px 14px; border-radius: 12px; border: 2px solid var(--c); background: rgba(15,23,42,.72); color: #fff; font-size: 15px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.lbl-home { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; background: #facc15; color: #422006; font-weight: 700; font-size: 12px; border: 2px solid #fff; }
.city-labels[data-zoom="far"] .lbl { display: none; }
.city-tip { position: absolute; top: 0; left: 0; z-index: 9; pointer-events: none; background: rgba(15,23,42,.92); color: #fff; padding: 6px 10px; border-radius: 10px; font-size: 13px; max-width: 280px; }
@media (hover: none) { .city-tip { display: none; } }

/* ───── لوحة المبنى ───── */
.bpanel { position: absolute; z-index: 12; inset-inline: 0; bottom: 0; max-height: 64dvh; border-radius: 22px 22px 0 0; transform: translateY(105%); transition: transform .28s ease; display: flex; flex-direction: column; background: var(--surface); }
.bpanel.is-open { transform: none; }
.bp-close { position: absolute; top: 10px; inset-inline-end: 10px; z-index: 2; }
.bp-body { overflow: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
@media (min-width: 760px) {
  .bpanel { inset-inline-start: auto; inset-inline-end: 12px; top: 72px; bottom: 12px; width: 410px; max-height: none; border-radius: 20px; }
  [dir="ltr"] .bpanel { transform: translateX(calc(100% + 24px)); }
  [dir="rtl"] .bpanel { transform: translateX(calc(-100% - 24px)); }
  .bpanel.is-open { transform: none !important; }
}
.bp-head { border-inline-start: 4px solid var(--c); padding-inline-start: 12px; margin-block-end: 8px; padding-inline-end: 40px; }
.bp-kicker { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.bp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bp-no { font-family: var(--font-lat); }
.bp-head h2 { margin: 4px 0; font-size: 20px; line-height: 1.35; display: flex; gap: 8px; align-items: center; }
.bp-head h2:focus { outline: none; }
.bp-state { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.bp-state[data-state="completed"] { color: var(--green); }
.bp-state[data-state="mastered"] { color: #b45309; }
.bp-state[data-state="available"], .bp-state[data-state="in_progress"] { color: var(--cyan); }
.bp-state[data-state="assessment_failed"] { color: #c2410c; }
.bp-desc { color: var(--text-2); font-size: 14px; }
.bp-meta { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.bp-meta li { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.bp-meta li.warn { color: var(--amber); }
.bp-sec { border-top: 1px solid var(--border); padding-block: 12px; }
.bp-sec h3 { margin: 0 0 8px; font-size: 15px; }
.bp-list { margin: 0; padding-inline-start: 20px; font-size: 14px; }
.bp-list.todo li::marker { content: "○  "; color: var(--amber); }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.req-list li { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.req-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.req-list li.ok .req-ico { background: var(--green); color: #fff; border-color: transparent; }
.lesson-list, .task-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.lesson-row, .task-row { width: 100%; display: flex; gap: 10px; align-items: center; text-align: start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-size: 14px; min-height: 48px; }
.lesson-row:hover, .task-row:hover { border-color: var(--brand); }
.lesson-row small, .task-row small { margin-inline-start: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.task-row > span:nth-child(2) { flex: 1; min-width: 0; }
.l-title { flex: 1; }
.l-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.lesson-list li[data-status="completed"] .l-ico { background: var(--green); color: #fff; border-color: transparent; }
.note { font-size: 14px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--amber) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent); margin: 8px 0; }
.note.info { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.note.ok { background: color-mix(in srgb, var(--green) 10%, var(--surface)); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.bp-cta { display: grid; gap: 8px; margin-top: 12px; }
.bp-cta p { margin: 0; }

/* ───── النوافذ ───── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(2,6,23,.55); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet { background: var(--surface); color: var(--text); width: 100%; max-height: 94dvh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); transform: translateY(24px); transition: transform .2s; }
.sheet-backdrop.is-open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sheet-title { margin: 0; font-size: 18px; flex: 1; line-height: 1.4; }
.sheet-body { padding: 16px; overflow: auto; flex: 1; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.sheet-foot:empty { display: none; }
@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; max-height: 88dvh; }
  .sheet-sm { max-width: 440px; } .sheet-md { max-width: 640px; } .sheet-lg { max-width: 880px; }
}
.reader .sheet-body { padding: 20px clamp(16px, 4vw, 40px); }
.reader-kicker { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.prose { font-size: 16.5px; line-height: 1.95; max-width: 72ch; }
.prose h2 { font-size: 20px; margin: 26px 0 8px; }
.prose h3 { font-size: 17px; margin: 20px 0 6px; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: start; }
.prose th { background: var(--surface-2); }
.prose .callout, .prose blockquote { border-inline-start: 4px solid var(--brand); background: var(--surface-2); padding: 10px 14px; border-radius: 10px; margin: 14px 0; }
.prose .callout.warn { border-color: var(--amber); }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 14px; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.resources ul { padding-inline-start: 18px; }
.read-meter { flex: 1; min-width: 160px; margin-inline-end: auto; }
.read-meter .meter { margin: 0 0 2px; }
.read-meter small { color: var(--muted); font-size: 12px; }

/* ───── الاختبار ───── */
.rules { padding-inline-start: 20px; display: grid; gap: 4px; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.quiz-clock { font-family: var(--font-lat); font-weight: 700; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.quiz-clock:empty { visibility: hidden; }
.quiz-clock.warn { color: #fff; background: var(--red); border-color: transparent; }
.quiz-attempt { color: var(--muted); font-size: 13px; }
.quiz-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.qdot { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-family: var(--font-lat); font-weight: 600; }
.qdot[data-done] { background: color-mix(in srgb, var(--brand) 15%, var(--surface)); border-color: var(--brand); }
.qdot[aria-current="step"] { outline: 3px solid var(--brand); outline-offset: 1px; }
.q-count { color: var(--muted); font-size: 13px; margin: 0; }
.q-prompt { font-size: 18px; line-height: 1.6; margin: 6px 0 14px; }
.scenario { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.scenario p { margin: 4px 0 0; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); cursor: pointer; background: var(--surface); }
.opt:hover { border-color: var(--brand); }
.opt input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); flex: none; }
.opt:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--surface)); }
.num-ans { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body .num-ans .input { max-width: 260px; font-family: var(--font-lat); font-size: 18px; }
.num-ans .unit { font-weight: 700; }
.num-ans small { flex-basis: 100%; }
.q-actions { display: flex; justify-content: space-between; margin-top: 18px; gap: 8px; }
.result { text-align: center; padding: 18px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 14px; }
.result[data-ok="1"] { background: color-mix(in srgb, var(--green) 10%, var(--surface)); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.result-score { font-size: 46px; font-weight: 800; font-family: var(--font-lat); line-height: 1.1; }
.result h3 { margin: 6px 0; }
.review { display: grid; gap: 10px; padding-inline-start: 22px; }
.review > li { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.review > li[data-ok="1"] { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.review > li[data-ok="0"] { border-color: color-mix(in srgb, var(--red) 50%, transparent); }
.review .q-prompt { font-size: 15px; margin: 0 0 6px; }
.rev-opts { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 14px; }
.rev-opts li { padding: 4px 8px; border-radius: 8px; }
.rev-opts li.correct { background: color-mix(in srgb, var(--green) 15%, transparent); }
.rev-opts li.mine:not(.correct) { background: color-mix(in srgb, var(--red) 13%, transparent); }
.expl { font-size: 14px; color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; margin: 6px 0 0; }

/* ───── المهمة والمحاكاة ───── */
.hist ol { list-style: none; padding: 0; display: grid; gap: 8px; }
.hist li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.hist-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hist-head small { color: var(--muted); margin-inline-start: auto; }
small.ok { color: var(--green); font-weight: 700; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-family: var(--font-lat); text-align: end; }
@media (min-width: 640px) { .facts { grid-template-columns: repeat(2, 1fr auto); } }
.sim-form { display: grid; gap: 4px; margin-top: 10px; }
@media (min-width: 640px) { .sim-form { grid-template-columns: 1fr 1fr; gap: 4px 14px; } .sim-form fieldset { grid-column: 1 / -1; } }
fieldset.field { border: 0; padding: 0; margin: 0 0 12px; }
fieldset.field legend { font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.sim-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.sim-table th, .sim-table td { padding: 8px; border-bottom: 1px solid var(--border); text-align: start; }
.sim-table tr.ok td:first-child::before { content: "✓ "; color: var(--green); }
.sim-table tr.bad td:first-child::before { content: "✗ "; color: var(--red); }
.chat { display: grid; gap: 8px; margin: 10px 0; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 86%; font-size: 15px; }
.msg.them { background: var(--surface-2); border: 1px solid var(--border); justify-self: start; }
.msg.me { background: var(--brand); color: #fff; justify-self: end; }
.chat-opts { display: grid; gap: 6px; }
.chat-opt { text-align: start; justify-content: flex-start; white-space: normal; }

/* ───── المساحات الشخصية ───── */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 12px 0; scrollbar-width: thin; }
.tab { white-space: nowrap; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; min-height: 40px; }
.tab[aria-selected="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.house-card { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.house-card h3 { margin: 0; }
.house-art { width: 104px; height: 104px; border-radius: 22px; display: grid; place-items: center; font-size: 56px; background: linear-gradient(160deg, #bae6fd, #fef3c7); flex: none; }
.house-art[data-level="4"], .house-art[data-level="5"] { background: linear-gradient(160deg, #c7d2fe, #fde68a); }
.house-art.sm { width: 80px; height: 80px; font-size: 42px; }
.chips { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.check { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; cursor: pointer; }
.check small { flex-basis: 100%; }
.link-list { padding-inline-start: 18px; }
.notes { list-style: none; padding: 0; display: grid; gap: 8px; }
.notes li { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.notes p { margin: 4px 0; white-space: pre-wrap; }
.note-form { display: grid; gap: 6px; }
.journey-top, .project-head, .level-card { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.ring { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--green) calc(var(--p) * 1%), var(--border) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-family: var(--font-lat); }
.project-head .grow { display: grid; gap: 6px; }
.journey-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.j-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; color: var(--text); font: inherit; text-align: start; }
.j-row small { margin-inline-start: auto; color: var(--muted); font-size: 12px; }
.j-name { flex: 1; }
.journey-list li[data-state="locked"] .j-row { opacity: .7; }
.journey-list li[data-state="completed"] .j-row, .journey-list li[data-state="mastered"] .j-row { border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.psec { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.psec header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.psec h3 { margin: 0; font-size: 16px; }
.psec[data-open="0"] { opacity: .75; }
.psec .feedback blockquote { margin: 8px 0 0; border-inline-start: 3px solid var(--brand); padding: 6px 10px; background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.versions { list-style: none; padding: 0; display: grid; gap: 10px; }
.vbody { white-space: pre-wrap; font: inherit; font-size: 14px; background: var(--surface-2); padding: 8px; border-radius: 8px; max-height: 200px; overflow: auto; }
.lv-no { width: 64px; height: 64px; border-radius: 18px; background: linear-gradient(135deg, #f59e0b, #facc15); color: #422006; font-size: 30px; font-weight: 800; display: grid; place-items: center; font-family: var(--font-lat); }
.level-card h3 { margin: 0; }
.badge-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge-grid li { border: 1px solid var(--border); border-radius: 14px; padding: 12px; text-align: center; display: grid; gap: 4px; }
.badge-grid li[data-earned="1"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.badge-grid li[data-earned="0"] { opacity: .6; }
.bdg-ico { font-size: 30px; }
.badge-grid small { color: var(--muted); font-size: 12px; }
.badge-row { list-style: none; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; font-size: 22px; }
.xp-list { list-style: none; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.xp-list li { display: flex; gap: 10px; align-items: center; }
.xp-list b { color: var(--green); font-family: var(--font-lat); min-width: 44px; }
.xp-list small { margin-inline-start: auto; color: var(--muted); }
.cal { list-style: none; padding: 0; display: grid; gap: 8px; }
.cal li { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.cal time { display: block; color: var(--muted); font-size: 12px; }
.cal li[data-type="deadline"] { border-inline-start: 4px solid var(--amber); }
.cal li[data-type="live_session"] { border-inline-start: 4px solid var(--red); }
.notif-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.notif { width: 100%; text-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--text); font: inherit; }
.notif p { margin: 2px 0; font-size: 14px; color: var(--text-2); }
.notif small { color: var(--muted); font-size: 12px; }
.notif-list li[data-unread="1"] .notif { border-inline-start: 4px solid var(--brand); }
.lb { padding-inline-start: 22px; display: grid; gap: 6px; }
.lb li { display: flex; justify-content: space-between; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); }
.seg input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); }
.link-row { display: flex; gap: 16px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--text-2); }
.empty-state h3 { margin: 6px 0; color: var(--text); }
.empty-ico { font-size: 40px; }
.sk-wrap { display: grid; gap: 10px; padding: 6px 0; }
.sk-line { height: 16px; }

/* ───── التحميل والجولة والاحتفال ───── */
.city-loading { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; text-align: center; gap: 10px; background: radial-gradient(circle at 50% 40%, #145a8f, #062a4a); color: #e0f2fe; }
.loader-city { display: flex; gap: 6px; align-items: flex-end; justify-content: center; height: 70px; }
.loader-city i { width: 14px; border-radius: 3px 3px 0 0; background: linear-gradient(#7dd3fc, #2563eb); animation: rise 1.2s ease-in-out infinite; }
.loader-city i:nth-child(1) { height: 30px; } .loader-city i:nth-child(2) { height: 52px; animation-delay: .1s; } .loader-city i:nth-child(3) { height: 70px; animation-delay: .2s; }
.loader-city i:nth-child(4) { height: 44px; animation-delay: .3s; } .loader-city i:nth-child(5) { height: 24px; animation-delay: .4s; }
@keyframes rise { 0%, 100% { transform: scaleY(.6); transform-origin: bottom; } 50% { transform: scaleY(1); } }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; background: #062a4a; color: #fff; z-index: 50; }
.ob-wrap { position: fixed; inset: 0; z-index: 35; pointer-events: none; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px 96px; }
.ob-card { pointer-events: auto; width: min(520px, 100%); background: var(--surface); color: var(--text); border-radius: 22px; padding: 20px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6); position: relative; border: 1px solid var(--border); }
.ob-card h2 { margin: 6px 0; font-size: 20px; }
.ob-card p { margin: 0 0 12px; color: var(--text-2); }
.ob-ico { font-size: 40px; }
.ob-skip { position: absolute; top: 14px; inset-inline-end: 16px; }
.ob-dots { display: flex; gap: 6px; margin: 8px 0 14px; }
.ob-dots span { width: 28px; height: 5px; border-radius: 5px; background: var(--border); }
.ob-dots span.on { background: var(--brand); }
.ob-actions { display: flex; justify-content: space-between; gap: 8px; }
.unlock-banner { position: fixed; z-index: 36; top: 80px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 18px; background: linear-gradient(135deg, #1e3a8a, #0e7490); color: #fff; box-shadow: 0 24px 48px -16px rgba(0,0,0,.6); width: max-content; max-width: calc(100vw - 24px); flex-wrap: wrap; animation: pop .35s ease; }
.unlock-banner small { display: block; opacity: .85; }
.unlock-banner strong { font-size: 17px; }
.unlock-banner .link-btn { color: #e0f2fe; }
.ub-ico { font-size: 30px; }
@keyframes pop { from { transform: translate(-50%, -12px) scale(.96); opacity: 0; } to { transform: translate(-50%, 0) scale(1); opacity: 1; } }

/* ───── وضع القائمة ───── */
.city-list { position: absolute; inset: 0; overflow: auto; padding: 84px 12px 110px; background: var(--bg); z-index: 5; }
.city-app.is-simple .hud-tools { display: none; }
.cl-district { max-width: 820px; margin: 0 auto 18px; background: var(--surface); border: 1px solid var(--border); border-inline-start: 5px solid var(--c); border-radius: 16px; padding: 14px 16px; }
.cl-district h2 { margin: 0; font-size: 18px; }
.cl-district p { margin: 4px 0 10px; font-size: 14px; }
.cl-district ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.cl-b { width: 100%; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: start; color: var(--text); font: inherit; min-height: 48px; }
.cl-b small { margin-inline-start: auto; color: var(--muted); }
.cl-district li[data-state="locked"] .cl-b { opacity: .7; }
.city-app.is-simple .hud-journey { display: none; }
@media (min-width: 1100px) { .city-app.is-simple .hud-journey { display: block; } .city-app.is-simple .city-list { padding-inline-start: 344px; } }

@media (prefers-reduced-motion: reduce) {
  .bpanel, .sheet, .sheet-backdrop, .meter i { transition: none; }
  .unlock-banner { animation: none; }
  .loader-city i { animation: none; }
}
