:root {
    --theme-bg: #f8fafc;
    --theme-bg-rgb: 248, 250, 252;
    --theme-surface: #ffffff;
    --theme-surface-soft: #f1f5f9;
    --theme-text: #0f172a;
    --theme-muted: #64748b;
    --theme-border: #e2e8f0;
    --theme-accent: #0f766e;
    --theme-accent-rgb: 15, 118, 110;
    --theme-accent-soft: #ccfbf1;
    --theme-shadow: rgba(15, 23, 42, .10);
    --theme-surface-muted: #e8eef5;
    --theme-focus: rgba(15, 118, 110, .22);
    --theme-action: #0f766e;
    --theme-action-text: #ffffff;
}

html[data-user-theme="night"] {
    --theme-bg: #0b1220; --theme-bg-rgb: 11, 18, 32; --theme-surface: #121c2d;
    --theme-surface-soft: #19263a; --theme-text: #e7edf6; --theme-muted: #9babc0;
    --theme-border: #29384d; --theme-accent: #5eead4; --theme-accent-rgb: 94, 234, 212;
    --theme-accent-soft: #173b3c; --theme-shadow: rgba(0, 0, 0, .35);
    --theme-surface-muted: #223149; --theme-focus: rgba(94, 234, 212, .28);
    --theme-action: #16847f; --theme-action-text: #ffffff;
}
html[data-user-theme="saudi"] {
    --theme-bg: #eff8f2; --theme-bg-rgb: 239, 248, 242; --theme-surface: #ffffff;
    --theme-surface-soft: #e0f1e6; --theme-text: #102d22; --theme-muted: #547064;
    --theme-border: #628970; --theme-accent: #006c35; --theme-accent-rgb: 0, 108, 53;
    --theme-accent-soft: #d5eddf; --theme-shadow: rgba(0, 78, 39, .13);
    --theme-surface-muted: #d1e7d9; --theme-focus: rgba(0, 108, 53, .26);
    --theme-action: #006c35; --theme-action-text: #ffffff;
}
html[data-user-theme="ocean"] {
    --theme-bg: #eef7fa; --theme-bg-rgb: 238, 247, 250; --theme-surface: #fbfeff;
    --theme-surface-soft: #dff1f5; --theme-text: #123044; --theme-muted: #557383;
    --theme-border: #c7e2e9; --theme-accent: #087e8b; --theme-accent-rgb: 8, 126, 139;
    --theme-accent-soft: #cceef0; --theme-shadow: rgba(18, 78, 91, .13); --theme-surface-muted: #cfe9ee; --theme-focus: rgba(8, 126, 139, .22);
}
html[data-user-theme="sand"] {
    --theme-bg: #f6f1e7; --theme-bg-rgb: 246, 241, 231; --theme-surface: #fffdf8;
    --theme-surface-soft: #eee5d5; --theme-text: #3b3025; --theme-muted: #786956;
    --theme-border: #dfd2bd; --theme-accent: #a15c31; --theme-accent-rgb: 161, 92, 49;
    --theme-accent-soft: #f2ddc8; --theme-shadow: rgba(74, 52, 31, .13); --theme-surface-muted: #e7dcc8; --theme-focus: rgba(161, 92, 49, .22);
}
html[data-user-theme="lavender"] {
    --theme-bg: #f5f2f8; --theme-bg-rgb: 245, 242, 248; --theme-surface: #fefcff;
    --theme-surface-soft: #ece6f2; --theme-text: #332b3d; --theme-muted: #71657f;
    --theme-border: #ddd3e6; --theme-accent: #76558f; --theme-accent-rgb: 118, 85, 143;
    --theme-accent-soft: #e8dcf0; --theme-shadow: rgba(69, 45, 86, .13); --theme-surface-muted: #e1d8e9; --theme-focus: rgba(118, 85, 143, .22);
}

html[data-user-theme]:not([data-user-theme="classic"]) body {
    background: radial-gradient(circle at 8% -8%, rgba(var(--theme-accent-rgb), .12), transparent 31rem), var(--theme-bg) !important;
    color: var(--theme-text);
    transition: background-color .3s ease, color .3s ease;
}
html[data-user-theme="saudi"] body {
    background:
        radial-gradient(circle at 8% -8%, rgba(var(--theme-accent-rgb), .14), transparent 31rem),
        repeating-linear-gradient(135deg, rgba(var(--theme-accent-rgb), .018) 0 1px, transparent 1px 22px),
        var(--theme-bg) !important;
}
/* طبقة التوافق العامة: تُكتب مع .admin-body لأنها تتغلب على قواعد لوحة الإدارة القديمة ذات !important. */
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body {
    --bg-primary: var(--theme-surface); --bg-secondary: var(--theme-surface-soft); --bg-tertiary: var(--theme-surface-muted);
    --bg-page: var(--theme-bg); --text-primary: var(--theme-text); --text-secondary: var(--theme-muted);
    --text-tertiary: var(--theme-muted); --text-muted: var(--theme-muted); --border-light: var(--theme-border);
    --border-default: var(--theme-border); --border-dark: var(--theme-border); --shadow-sm: 0 1px 3px var(--theme-shadow);
    --shadow-md: 0 8px 24px var(--theme-shadow);
    color: var(--theme-text) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-main,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body main { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-header,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .user-workspace-header,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .sapp-modal-shell,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body [role="dialog"] { background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important; }
/* القائمة الجانبية داكنة بتصميمها الأصلي (نصوص فاتحة) — لا تُطلى بسطح المظهر أبدًا وإلا اختفت نصوصها.
   في الليلي فقط نغمّقها لتنسجم مع بقية الصفحة. */
html[data-user-theme="night"] .admin-body :is(#user-sidebar, .admin-sidebar) {
    background: linear-gradient(180deg, #0a1626 0%, #0e1f33 100%) !important;
    border-left-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-header-action-btn,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .user-workspace-search-trigger,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .user-workspace-home { color: var(--theme-muted) !important; border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-header-action-btn:hover,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .user-workspace-search-trigger:hover { background: var(--theme-surface-soft) !important; color: var(--theme-accent) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(h1,h2,h3,h4,h5,h6,.text-gray-900,.text-gray-800,.text-slate-900,.text-slate-800) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(.text-gray-700,.text-gray-600,.text-gray-500,.text-slate-700,.text-slate-600,.text-slate-500) { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .bg-white,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .welcome-only-card,
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is([class*="workspace-card"],[class*="stat-card"],[class*="-card"],[class*="-panel"]) {
    background-color: var(--theme-surface) !important; border-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(.bg-gray-50,.bg-slate-50) { background-color: var(--theme-surface-soft) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(.bg-gray-100,.bg-slate-100,.bg-gray-200,.bg-slate-200) { background-color: var(--theme-surface-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(.border-gray-50,.border-gray-100,.border-gray-200,.border-gray-300,.border-slate-100,.border-slate-200,.border-slate-300) { border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(input,select,textarea) {
    background-color: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(input,select,textarea):focus { border-color: var(--theme-accent) !important; box-shadow: 0 0 0 3px var(--theme-focus) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body :is(table,th,td) { border-color: var(--theme-border); }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body thead :is(th,.bg-gray-50,.bg-slate-50) { background-color: var(--theme-surface-soft) !important; color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body tbody tr:nth-child(even) { background-color: rgba(var(--theme-bg-rgb), .38); }
html[data-user-theme="night"] .admin-body :is(.bg-blue-50,.bg-indigo-50,.bg-purple-50,.bg-emerald-50,.bg-green-50,.bg-amber-50,.bg-yellow-50,.bg-red-50) { filter: saturate(.72) brightness(.78); }

/* مساحة العمل (طبقتا lawyer-clone وuser-workspace): إعادة صبغ متغيراتهما بمتغيرات المظهر
   حتى تتبع الخلفيات والبطاقات والنصوص المظهرَ المختار بالكامل بدل الورقي الثابت. */
html[data-user-theme]:not([data-user-theme="classic"]) .user-workspace-body {
    --law-paper: var(--theme-bg);
    --law-paper-2: var(--theme-surface-soft);
    --law-panel: var(--theme-surface);
    --law-panel-soft: var(--theme-surface-soft);
    --law-ink: var(--theme-text);
    --law-muted: var(--theme-muted);
    --law-line: var(--theme-border);
    --law-line-soft: var(--theme-border);
    --law-gold-soft: rgba(var(--theme-accent-rgb), .14);
    --law-shadow: 0 1px 2px var(--theme-shadow), 0 10px 24px var(--theme-shadow);
    --twq-ink: var(--theme-text);
    --twq-ink-soft: var(--theme-muted);
    --twq-surface: var(--theme-surface);
    --twq-canvas: var(--theme-bg);
    --twq-line: var(--theme-border);
    --twq-green-soft: var(--theme-accent-soft);
    background: var(--theme-bg) !important;
    color: var(--theme-text) !important;
}
/* الطبقة الورقية الثابتة (::before) كانت تغطي خلفية المظهر بتدرج بيج مثبّت فوق الجسم. */
html[data-user-theme]:not([data-user-theme="classic"]) .user-workspace-body::before {
    background:
        radial-gradient(circle at 12% 8%, rgba(var(--theme-accent-rgb), .08), transparent 28rem),
        radial-gradient(circle at 88% 18%, rgba(var(--theme-accent-rgb), .05), transparent 30rem),
        var(--theme-bg);
}
/* بانر أعلى الصفحات (مساحة المدير/المعلم): خلفيته ورقية ثابتة بينما عناوينه كانت تتبع المظهر فيختفي النص. */
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    box-shadow: 0 12px 34px var(--theme-shadow) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner::after {
    background: linear-gradient(90deg, rgba(var(--theme-bg-rgb), 0.05) 0%, var(--theme-surface) 41%, var(--theme-surface) 100%) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner h1 { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner p { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner__eyebrow { color: var(--theme-accent) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner__eyebrow i { background: var(--theme-surface-soft) !important; border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .principal-page-banner__hint { color: var(--theme-muted) !important; }

/* في الليلي: ألوان الدلالة الورقية داكنة جدًا على خلفية داكنة — نرفع إضاءتها للقراءة. */
html[data-user-theme="night"] .user-workspace-body {
    --law-gold: #d4a84b;
    --law-green: #4ccb95;
    --law-red: #e08066;
    --law-blue: #6db3d9;
    --twq-gold: #d6a84b;
    --twq-green: #34c08f;
    --twq-blue: #66aede;
}

/* صفحات الأدوات القديمة تستخدم أسماء مكونات وألوانًا مكتوبة داخل الصفحة. هذه القواعد تجعلها تتبع المظهر من دون تغيير وظيفتها. */
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([class*="-card"],[class*="-panel"],[class*="-modal"],[class*="-section"],[class*="-box"],[class*="-zone"],[class*="-tabs"],[class*="-tab"],[class*="-table-wrap"]) {
    background-color: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([class*="-title"],[class*="-heading"],[class*="-label"]) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([class*="-tab"],[class*="-tab"] *) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is(p,[class*="-desc"],[class*="-meta"],[class*="-hint"],[class*="-empty"]) { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([style*="background:#fff"],[style*="background: #fff"],[style*="background:#ffffff"],[style*="background: #ffffff"],[style*="background:#fafafa"],[style*="background: #fafafa"]) { background-color: var(--theme-surface) !important; }
/* خلفيات inline فاتحة شائعة (درجات 50 الباستيلية + الورقي) — تُصبغ بسطح المظهر الخافت. */
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is(
    [style*="background:#f8fafc"],[style*="background: #f8fafc"],
    [style*="background:#f9fafb"],[style*="background: #f9fafb"],
    [style*="background:#f1f5f9"],[style*="background: #f1f5f9"],
    [style*="background:#f8fbff"],[style*="background: #f8fbff"],
    [style*="background:#eff6ff"],[style*="background: #eff6ff"],
    [style*="background:#f0f9ff"],[style*="background: #f0f9ff"],
    [style*="background:#ecfdf5"],[style*="background: #ecfdf5"],
    [style*="background:#f0fdf4"],[style*="background: #f0fdf4"],
    [style*="background:#fef2f2"],[style*="background: #fef2f2"],
    [style*="background:#fffbeb"],[style*="background: #fffbeb"],
    [style*="background:#fefce8"],[style*="background: #fefce8"],
    [style*="background:#fff7ed"],[style*="background: #fff7ed"],
    [style*="background:#f5f3ff"],[style*="background: #f5f3ff"],
    [style*="background:#faf5ff"],[style*="background: #faf5ff"],
    [style*="background:#f0fdfa"],[style*="background: #f0fdfa"],
    [style*="background:#f7fdf9"],[style*="background: #f7fdf9"],
    [style*="background:#f8fbff"],[style*="background: #f8fbff"],
    [style*="background:#f6f1e7"],[style*="background: #f6f1e7"],
    [style*="background:#fffdf8"],[style*="background: #fffdf8"],
    [style*="background:#fbf7ef"],[style*="background: #fbf7ef"]
) { background-color: var(--theme-surface-soft) !important; color: var(--theme-text); }

/* الليلي: البطاقات ذات التدرجات الفاتحة المكتوبة داخل الصفحة (hero/panel/card) تُسطّح لسطح المظهر
   حتى لا يبقى نص أبيض فوق خلفية فاتحة. تُستثنى الخلفيات الصورية url(). */
html[data-user-theme="night"] .admin-body .admin-content :is([class*="-hero"],[class*="-card"],[class*="-panel"],[class*="-section"],[class*="-box"],[class*="-zone"]):not([style*="url("]) {
    background-image: none !important;
}
html[data-user-theme="night"] .admin-body .admin-content [class*="-hero"] {
    background-color: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}
/* عناوين ونصوص BEM داخل المكونات المطلية (مثل ip-file__title بلونها الحبري الثابت) */
html[data-user-theme="night"] .admin-body .admin-content :is([class*="-panel"],[class*="-card"],[class*="-hero"],[class*="-section"],[class*="-row"]) :is([class*="__title"],[class*="__name"],[class*="__label"],strong,b,dt,th) { color: var(--theme-text) !important; }
html[data-user-theme="night"] .admin-body .admin-content :is([class*="-panel"],[class*="-card"],[class*="-hero"],[class*="-section"],[class*="-row"]) :is([class*="__meta"],[class*="__desc"],[class*="__hint"],[class*="__empty"],small) { color: var(--theme-muted) !important; }
html[data-user-theme="night"] .admin-body .admin-content [class*="-row"] { border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([style*="color:#0f172a"],[style*="color: #0f172a"],[style*="color:#111827"],[style*="color: #111827"],[style*="color:#1e293b"],[style*="color: #1e293b"],[style*="color:#18181b"],[style*="color: #18181b"],[style*="color:#374151"],[style*="color: #374151"]) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .admin-content :is([style*="color:#4b5563"],[style*="color: #4b5563"],[style*="color:#6b7280"],[style*="color: #6b7280"],[style*="color:#64748b"],[style*="color: #64748b"],[style*="color:#71717a"],[style*="color: #71717a"]) { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body [role="dialog"] { color: var(--theme-text) !important; }

/* التخطيط القديم ما زال مستخدمًا في بعض صفحات المستخدم؛ يحترم الاختيار نفسه ولا يعيده للوضع الفاتح. */
html[data-user-theme]:not([data-user-theme="classic"]) body.user-theme-shell {
    background: radial-gradient(circle at 8% -8%, rgba(var(--theme-accent-rgb), .12), transparent 31rem), var(--theme-bg) !important;
    color: var(--theme-text) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.bg-white,.bg-gray-50,.bg-gray-100,.bg-gray-200,.bg-slate-50,.bg-slate-100,.bg-slate-200) { border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.bg-white) { background-color: var(--theme-surface) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.bg-gray-50,.bg-slate-50) { background-color: var(--theme-surface-soft) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.bg-gray-100,.bg-gray-200,.bg-slate-100,.bg-slate-200) { background-color: var(--theme-surface-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.text-gray-900,.text-gray-800,.text-gray-700,.text-slate-900,.text-slate-800,.text-slate-700) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(.text-gray-600,.text-gray-500,.text-gray-400,.text-slate-600,.text-slate-500,.text-slate-400) { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(input,select,textarea) { background: var(--theme-surface) !important; color: var(--theme-text) !important; border-color: var(--theme-border) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .user-theme-shell :is(input,select,textarea):focus { border-color: var(--theme-accent) !important; box-shadow: 0 0 0 3px var(--theme-focus) !important; }

/* صفحة تقييم الأداء: كانت تفرض لوحة ورقية فاتحة مستقلة في أسفل القالب. */
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page {
    --tq-ink: var(--theme-text);
    --tq-navy: var(--theme-action);
    --tq-gold: var(--theme-accent);
    --tq-line: var(--theme-border);
    --tq-paper: var(--theme-surface);
    --tq-soft: var(--theme-surface-soft);
    --tq-muted: var(--theme-muted);
    background: var(--theme-bg) !important;
    color: var(--theme-text) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.page-header,.stat-card,.progress-card,.elements-section,.modal-content,.template-card,.template-carousel,.carousel-image,.carousel-placeholder,.ai-element-card) {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
    box-shadow: 0 12px 28px var(--theme-shadow) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.btn-secondary,.modal-close,.preview-close) {
    background: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.progress-bar,.progress-card div[style*="height: 12px"],.template-carousel,.carousel-placeholder) { background: var(--theme-surface-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.page-title h1,.stat-value,.section-title,.modal-title,.template-name,.progress-card h3) { color: var(--theme-text) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.page-title p,.stat-label,.progress-label,.progress-footer,.form-label,.link-result p) { color: var(--theme-muted) !important; }
html[data-user-theme]:not([data-user-theme="classic"]) .admin-body .eval-page :is(.btn-primary,.header-actions .btn[style*="background"],.progress-card div[style*="transition: width 0.8s ease"]) {
    background: var(--theme-action) !important;
    border-color: var(--theme-action) !important;
    color: var(--theme-action-text) !important;
}

/* نافذة الإعدادات (نمط سلة): متغيراتها --t-* ثابتة فاتحة — تُعاد صبغتها بمتغيرات المظهر. */
html[data-user-theme]:not([data-user-theme="classic"]) .sapp-backdrop {
    --t-green-tint: var(--theme-accent-soft);
    --t-ink: var(--theme-text);
    --t-soft: var(--theme-muted);
    --t-mute: var(--theme-muted);
    --t-dim: var(--theme-muted);
    --t-line: var(--theme-border);
    --t-hair: var(--theme-border);
    --t-hover: var(--theme-surface-soft);
    --t-side: var(--theme-surface-soft);
    --t-shadow: 0 24px 60px -24px var(--theme-shadow);
}
html[data-user-theme="night"] .sapp-backdrop { --t-green: var(--theme-action); }
html[data-user-theme]:not([data-user-theme="classic"]) :is(.sapp-modal, .sapp-modal-loading) {
    background: var(--theme-surface) !important;
    color: var(--theme-text);
}
html[data-user-theme]:not([data-user-theme="classic"]) .sapp-backdrop :is(input, select, textarea) {
    background: var(--theme-surface) !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}
/* حاويات المحتوى داخل النافذة كانت بيضاء ثابتة (background:#fff). */
html[data-user-theme]:not([data-user-theme="classic"]) :is(.sapp-main, .sapp-content, .sapp-panel) {
    background: var(--theme-surface) !important;
    color: var(--theme-text);
}
html[data-user-theme]:not([data-user-theme="classic"]) .sapp-backdrop :is(.sapp-card, .sapp-row-btn, .sapp-group) {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .sapp-backdrop .sapp-btn {
    background: var(--theme-surface-soft) !important;
    border-color: var(--theme-border) !important;
}
html[data-user-theme]:not([data-user-theme="classic"]) .sapp-backdrop .sapp-btn:not(.sapp-btn--danger):not(.sapp-btn--primary) {
    color: var(--theme-text) !important;
}

.appearance-picker { position: relative; }
.appearance-picker__trigger { position: relative; }
.appearance-picker__dot { position: absolute; width: 8px; height: 8px; left: 5px; bottom: 5px; border: 2px solid var(--theme-surface); border-radius: 50%; background: var(--theme-accent); }
.appearance-picker__menu {
    position: absolute; z-index: 70; top: calc(100% + 12px); left: 0; width: 288px; padding: 10px;
    background: var(--theme-surface); color: var(--theme-text); border: 1px solid var(--theme-border);
    border-radius: 16px; box-shadow: 0 18px 50px var(--theme-shadow); transform-origin: top left;
    max-height: calc(100dvh - 96px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.appearance-picker__menu:not([hidden]) { animation: appearance-in .18s ease-out; }
@keyframes appearance-in { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: none; } }
.appearance-picker__heading { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 7px 10px; border-bottom: 1px solid var(--theme-border); margin-bottom: 5px; }
.appearance-picker__heading span { font-size: 14px; font-weight: 800; }
.appearance-picker__heading small { color: var(--theme-muted); font-size: 10px; }
.appearance-option { width: 100%; min-height: 44px; border: 0; background: transparent; color: inherit; padding: 8px 7px; display: grid; grid-template-columns: 38px 1fr 18px; gap: 10px; align-items: center; text-align: right; border-radius: 10px; cursor: pointer; transition: background .18s ease, transform .18s ease; }
.appearance-option:hover { background: var(--theme-surface-soft); }
.appearance-option:focus-visible { background: var(--theme-surface-soft); outline: 2px solid var(--theme-accent); outline-offset: -2px; }
.appearance-option:active { transform: scale(.985); }
.appearance-option > span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.appearance-option strong { font-size: 13px; font-weight: 700; }
.appearance-option small { color: var(--theme-muted); font-size: 11px; margin-top: 2px; }
.appearance-option__preview { width: 38px; height: 32px; display: block; position: relative; overflow: hidden; border-radius: 9px; border: 1px solid rgba(100,116,139,.22); }
.appearance-option__preview i { position: absolute; right: 0; inset-block: 0; width: 11px; background: rgba(15,23,42,.15); }
.appearance-option__preview b { position: absolute; right: 15px; top: 8px; width: 15px; height: 5px; border-radius: 3px; background: currentColor; box-shadow: 0 9px 0 -1px currentColor; }
.appearance-option__preview--classic { background:#fff; color:#0f766e; }.appearance-option__preview--saudi { background:linear-gradient(135deg,#fff 0 58%,#e0f1e6 58%);color:#006c35;border-color:#9bc8ac;}.appearance-option__preview--saudi i{background:#006c35;}.appearance-option__preview--night { background:#121c2d; color:#5eead4; }.appearance-option__preview--ocean { background:#eef7fa; color:#087e8b; }.appearance-option__preview--sand { background:#f6f1e7; color:#a15c31; }.appearance-option__preview--lavender { background:#f5f2f8; color:#76558f; }
.appearance-option__check { color: var(--theme-accent); opacity: 0; font-size: 12px; }
.appearance-option[aria-checked="true"] { background: rgba(var(--theme-accent-rgb), .10); }
.appearance-option[aria-checked="true"] .appearance-option__check { opacity: 1; }
@media (max-width: 640px) { .appearance-picker__menu { position: fixed; top: 72px; left: 12px; right: 12px; width: auto; } }
@media (prefers-reduced-motion: reduce) { html[data-user-theme]:not([data-user-theme="classic"]) body, .appearance-picker__menu, .appearance-option { transition: none; animation: none !important; } }

.appearance-picker--locked .appearance-picker__trigger { opacity: .7; cursor: not-allowed; }
.appearance-picker--locked .appearance-picker__dot { background: #d4a72c; }
.seasonal-theme-banner { min-height: 38px; padding: 7px 18px; display: flex; align-items: center; justify-content: center; gap: 12px; text-align: center; color: #fff; font-size: 13px; position: relative; overflow: hidden; }
.seasonal-theme-banner::after { content: ''; position: absolute; inset: 0; opacity: .16; background-image: repeating-linear-gradient(120deg, transparent 0 24px, currentColor 25px 26px); }
.seasonal-theme-banner > * { position: relative; z-index: 1; }
.seasonal-theme-banner span { opacity: .86; }
.seasonal-theme-banner--national_day { background: #075e3b; color: #fff; }
.seasonal-theme-banner--founding_day { background: #60483f; color: #f4eada; }
.seasonal-theme-banner--teachers_day { background: #274c4f; color: #f7e7bd; }
.seasonal-theme-banner--ramadan { background: #182b4d; color: #efcf7b; }
.seasonal-theme-banner--eid { background: #175c45; color: #f4d47b; }
html[data-seasonal-theme="national_day"] { --theme-bg:#edf7f1; --theme-bg-rgb:237,247,241; --theme-surface:#fff; --theme-surface-soft:#dcefe3; --theme-text:#123428; --theme-muted:#547064; --theme-border:#c8dfd1; --theme-accent:#087747; --theme-accent-rgb:8,119,71; --theme-accent-soft:#d5f0df; }
html[data-seasonal-theme="founding_day"] { --theme-bg:#f4eee5; --theme-bg-rgb:244,238,229; --theme-surface:#fffdf9; --theme-surface-soft:#e9ddd0; --theme-text:#3f302a; --theme-muted:#756158; --theme-border:#ddcbbd; --theme-accent:#765548; --theme-accent-rgb:118,85,72; --theme-accent-soft:#eadbd0; }
html[data-seasonal-theme="teachers_day"] { --theme-bg:#f1f6f3; --theme-bg-rgb:241,246,243; --theme-surface:#fff; --theme-surface-soft:#e2ece7; --theme-text:#223936; --theme-muted:#637773; --theme-border:#cfddd7; --theme-accent:#386963; --theme-accent-rgb:56,105,99; --theme-accent-soft:#d9ebe7; }
html[data-seasonal-theme="ramadan"] { --theme-bg:#eef1f7; --theme-bg-rgb:238,241,247; --theme-surface:#fbfcff; --theme-surface-soft:#dfe5f0; --theme-text:#172943; --theme-muted:#65738a; --theme-border:#cdd5e3; --theme-accent:#9a7428; --theme-accent-rgb:154,116,40; --theme-accent-soft:#f1e7cb; }
html[data-seasonal-theme="eid"] { --theme-bg:#eff7f2; --theme-bg-rgb:239,247,242; --theme-surface:#fffefa; --theme-surface-soft:#dfede4; --theme-text:#18372c; --theme-muted:#62766e; --theme-border:#cddfd4; --theme-accent:#267055; --theme-accent-rgb:38,112,85; --theme-accent-soft:#d9eee5; }
