/* ==================== المتغيرات الأساسية ==================== */
:root {
    --bg: #08101e;
    --bg2: #0e1829;
    --card: #141f35;
    --brd: #1c2e4a;
    --txt: #dce8f8;
    --muted: #4e6a88;
    --acc: #3b82f6;
    --grn: #10b981;
    --gld: #f59e0b;
    --py: #ffd43b;
    --red: #ef4444;
    --purple: #a855f7;
}

[data-theme="light"] {
    --bg: #f3f6ff;
    --bg2: #e6ecfa;
    --card: #ffffff;
    --brd: #d4ddf0;
    --txt: #18273e;
    --muted: #6b7fa0;
}

/* ==================== إعادة تعيين ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--txt);
    direction: rtl;
    min-height: 100vh;
    font-size: 0.94rem;
    overflow-x: hidden;
    width: 100%;
    padding-bottom: 70px;
    line-height: 1.6;
}

/* ==================== شريط التمرير ==================== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--acc);
    border-radius: 3px;
}

::-webkit-scrollbar-track {
    background: var(--bg2);
}

/* ==================== الشريط العلوي ==================== */
#topbar {
    position: sticky;
    top: 0;
    z-index: 999;
    background: rgba(8, 16, 30, 0.97);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--brd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4%;
    height: 56px;
}

[data-theme="light"] #topbar {
    background: rgba(243, 246, 255, 0.97);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 900;
    font-size: 1.1rem;
    color: var(--py);
    cursor: pointer;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.85;
}

.logo .ld {
    background: linear-gradient(135deg, #ffd43b, #f97316);
    border-radius: 9px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.logo span {
    color: var(--acc);
}

.tbr {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tbtn {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    color: var(--txt);
    font-family: 'Cairo', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.tbtn:hover {
    background: var(--acc);
    color: white;
    border-color: var(--acc);
}

/* ==================== شريط التنقل السفلي ==================== */
#botnav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 998;
    background: rgba(8, 16, 30, 0.98);
    backdrop-filter: blur(20px);
    border-top: 2px solid var(--brd);
    display: flex;
    justify-content: space-around;
    padding: 6px 4px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] #botnav {
    background: rgba(243, 246, 255, 0.98);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.nb {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 10px;
    min-width: 60px;
    font-family: 'Cairo', sans-serif;
    color: var(--txt);
    transition: all 0.2s;
}

.nb .ni {
    font-size: 1.4rem;
    line-height: 1;
}

.nb .nl {
    font-size: 0.65rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.nb .nd {
    width: 0;
    height: 3px;
    background: var(--acc);
    border-radius: 2px;
    transition: 0.25s;
    margin-top: 2px;
}

.nb.active {
    background: rgba(59, 130, 246, 0.18);
}

.nb.active .nl {
    color: var(--acc);
    font-weight: 700;
}

.nb.active .nd {
    width: 24px;
}

.nb:hover {
    background: rgba(59, 130, 246, 0.1);
}

/* ==================== الصفحات ==================== */
.pg {
    display: none;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 4% 100px;
    width: 100%;
    animation: fadeIn 0.3s ease;
}

.pg.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== العناوين ==================== */
.page-title {
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--txt), var(--acc));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--muted);
    text-align: center;
    margin-bottom: 28px;
    font-size: 0.95rem;
}

/* ==================== البطاقات ==================== */
.card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 16px;
    transition: all 0.2s;
}

.card:hover {
    border-color: var(--acc);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* ==================== الأزرار ==================== */
.btn {
    background: var(--acc);
    color: #fff;
    border: none;
    padding: 10px 22px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.91rem;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--acc);
}

.btn-success {
    background: var(--grn);
}

.btn-outline {
    background: transparent;
    color: var(--txt);
    border: 2px solid var(--brd);
}

.btn-outline:hover {
    border-color: var(--acc);
    color: var(--acc);
    background: transparent;
}

.btn-danger {
    background: var(--red);
}

.btn-outline-sm {
    background: transparent;
    color: var(--txt);
    border: 2px solid var(--brd);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s;
    flex: 1;
}

.btn-outline-sm:hover {
    border-color: var(--acc);
    color: var(--acc);
}

.btn-back {
    background: transparent;
    border: 2px solid var(--brd);
    color: var(--txt);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.btn-back:hover {
    border-color: var(--acc);
    color: var(--acc);
}

/* ==================== الصفحة الرئيسية ==================== */
.home-container {
    max-width: 900px;
    margin: 0 auto;
}

.home-hero {
    text-align: center;
    padding: 20px 0 30px;
}

.hero-icon {
    font-size: 3.8rem;
    margin-bottom: 8px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.hero-badge {
    display: inline-block;
    background: rgba(255, 212, 59, 0.13);
    border: 1px solid rgba(255, 212, 59, 0.4);
    border-radius: 50px;
    padding: 6px 18px;
    font-size: 0.85rem;
    color: var(--py);
    margin-bottom: 18px;
    font-weight: 700;
}

.home-hero h1 {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 900;
    line-height: 1.3;
    margin-bottom: 14px;
}

.gradient-text {
    background: linear-gradient(135deg, #3b82f6, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-desc {
    color: var(--muted);
    font-size: 1rem;
    max-width: 520px;
    margin: 0 auto 24px;
    line-height: 1.9;
}

.hero-desc strong {
    color: var(--txt);
}

.hero-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== شبكة الإحصائيات ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 30px 0;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--acc);
    transform: translateY(-3px);
}

.stat-number {
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ==================== شبكة المميزات ==================== */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

.feature-card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 16px;
    padding: 22px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.feature-card:hover {
    border-color: var(--acc);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.feature-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 1rem;
}

.feature-desc {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.6;
}

/* ==================== شبكة الدروس ==================== */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.progress-container {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 24px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: var(--brd);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--acc), var(--grn));
    border-radius: 4px;
    transition: width 0.4s ease;
}

.lesson-card {
    padding: 20px;
    cursor: pointer;
}

.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.lesson-num {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 900;
    font-size: 0.9rem;
}

.lesson-tag {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

.tag-beginner {
    background: rgba(16, 185, 129, 0.15);
    color: var(--grn);
}

.tag-intermediate {
    background: rgba(245, 158, 11, 0.15);
    color: var(--gld);
}

.lesson-title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 1rem;
}

.lesson-desc {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 12px;
}

.lesson-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lesson-time {
    background: rgba(59, 130, 246, 0.12);
    color: var(--acc);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

.lesson-completed {
    color: var(--grn);
    font-size: 1.2rem;
}

/* ==================== النوافذ المنبثقة ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 18px;
    width: 100%;
    max-width: 750px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== أقسام الدرس ==================== */
.lesson-section {
    margin-bottom: 24px;
}

.lesson-section h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--acc);
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-block {
    background: #0d1117;
    border: 1px solid #2a3f55;
    border-radius: 12px;
    padding: 16px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    margin: 12px 0;
}

.code-block pre {
    color: #c9d1d9;
    line-height: 1.8;
    margin: 0;
    white-space: pre-wrap;
}

.tip-box {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    padding: 14px 18px;
    margin: 14px 0;
    font-size: 0.88rem;
    line-height: 1.8;
}

.exercise-box {
    background: rgba(16, 185, 129, 0.07);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
}

.exercise-box h5 {
    color: var(--grn);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.common-mistake {
    background: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    padding: 14px 18px;
    margin: 14px 0;
}

.common-mistake h5 {
    color: var(--red);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 8px;
}

/* ==================== المحرر ==================== */
.editor-container {
    border-radius: 18px;
    overflow: hidden;
    background: #1a1e2e;
    border: 1px solid var(--brd);
}

.editor-header {
    padding: 10px 16px;
    background: #252b3d;
    border-bottom: 1px solid #3a4256;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.editor-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #abb2bf;
}

.editor-logo-icon {
    background: #61afef;
    color: #1a1e2e;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.editor-logo span {
    color: #61afef;
}

.editor-view-toggle {
    display: flex;
    gap: 3px;
    background: #1e2437;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #3a4256;
}

.view-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    border: none;
    background: transparent;
    color: #abb2bf;
}

.view-btn.active {
    background: #61afef;
    color: #1a1e2e;
}

.view-btn:hover:not(.active) {
    background: #2c344b;
}

.editor-actions {
    display: flex;
    gap: 5px;
}

.editor-btn {
    padding: 6px 10px;
    border-radius: 7px;
    font-family: 'Cairo', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    border: none;
}

.editor-btn-outline {
    background: #3a4256;
    color: #abb2bf;
}

.editor-btn-outline:hover {
    background: #4a5368;
}

.editor-btn-primary {
    background: #61afef;
    color: #1a1e2e;
}

.editor-btn-primary:hover {
    background: #7bc4ff;
}

.editor-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.editor-panel {
    display: block;
    width: 100%;
    overflow: hidden;
}

.cm-editor-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.cm-editor-panel.hidden {
    display: none;
}

.cm-panel-header {
    padding: 8px 16px;
    background: #2c344b;
    border-bottom: 1px solid #3a4256;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #abb2bf;
    font-size: 0.85rem;
}

.char-counter {
    color: #5c677a;
    font-size: 0.75rem;
}

.editor-wrapper {
    overflow: hidden;
    width: 100%;
}

.CodeMirror {
    height: 280px !important;
    font-family: 'Fira Code', 'Courier New', monospace !important;
    font-size: 0.88rem !important;
    line-height: 1.6 !important;
    background: #282c34 !important;
    direction: ltr;
    width: 100% !important;
}

.CodeMirror-gutters {
    background: #21252b !important;
    border-right: 1px solid #3a4256 !important;
}

.cm-terminal-panel {
    display: flex;
    flex-direction: column;
    background: #1e2437;
    overflow: hidden;
}

.cm-terminal-panel.hidden {
    display: none;
}

.cm-terminal-header {
    padding: 8px 16px;
    background: #2c344b;
    border-bottom: 1px solid #3a4256;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #abb2bf;
    font-size: 0.85rem;
}

.cm-terminal-body {
    overflow-y: auto;
    padding: 14px 16px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    direction: ltr;
    text-align: left;
    color: #abb2bf;
    background: #1a1e2e;
    height: 280px;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-word;
}

.terminal-placeholder {
    color: #5c677a;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    margin-top: 6px;
}

.terminal-prompt {
    color: #98c379;
    font-weight: bold;
    margin-right: 8px;
    user-select: none;
}

#cmTerminalInput {
    flex: 1;
    background: transparent;
    border: none;
    color: #abb2bf;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.88rem;
    outline: none;
    padding: 0;
    caret-color: #61afef;
}

.cursor-blink {
    display: inline-block;
    width: 2px;
    height: 18px;
    background: #61afef;
    margin-left: 3px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.editor-footer {
    padding: 6px 18px;
    background: #252b3d;
    border-top: 1px solid #3a4256;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #abb2bf;
    font-size: 0.75rem;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #98c379;
    transition: background 0.3s;
}

.status-dot.offline {
    background: #f59e0b;
}

.shortcuts-info {
    display: flex;
    gap: 8px;
    color: #5c677a;
}

/* ==================== snippets ==================== */
.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.snippet-card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.2s;
}

.snippet-card:hover {
    border-color: var(--acc);
    background: rgba(59, 130, 246, 0.05);
}

.snippet-icon {
    font-size: 1.3rem;
}

.snippet-title {
    font-weight: 700;
    font-size: 0.85rem;
}

.snippet-desc {
    font-size: 0.72rem;
    color: var(--muted);
}

/* ==================== تنبيهات الاتصال ==================== */
.connection-alert {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 12px 24px;
    text-align: center;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.connection-alert.show {
    transform: translateY(0);
}

.alert-offline {
    background: #1e1e2e;
    color: #fbbf24;
    border-bottom: 2px solid #f59e0b;
}

.alert-online {
    background: #064e3b;
    color: #a7f3d0;
    border-bottom: 2px solid #10b981;
}

.alert-close {
    margin-right: auto;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.alert-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==================== الاختبارات ==================== */
.unit-tests-section {
    margin-bottom: 24px;
}

.unit-tests-section h3 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: var(--txt);
}

.unit-tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.unit-test-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid var(--brd);
    border-radius: 14px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.unit-test-card:hover {
    border-color: var(--acc);
    transform: translateY(-3px);
}

.unit-test-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.unit-test-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.unit-test-desc {
    font-size: 0.75rem;
    color: var(--muted);
}

.final-test-section {
    margin: 24px 0 32px;
}

.btn-final-test {
    width: 100%;
    background: linear-gradient(135deg, var(--gld), #d97706);
    border: none;
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 900;
    font-size: 1.2rem;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    transition: all 0.2s;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-final-test:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
}

.quiz-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.quiz-header h3 {
    font-size: 1.2rem;
    font-weight: 900;
    flex: 1;
}

.quiz-level-badge {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.level-basic {
    background: rgba(16, 185, 129, 0.15);
    color: var(--grn);
}

.level-intermediate {
    background: rgba(59, 130, 246, 0.15);
    color: var(--acc);
}

.level-advanced {
    background: rgba(245, 158, 11, 0.15);
    color: var(--gld);
}

.quiz-card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 18px;
    padding: 26px;
    max-width: 650px;
    margin: 0 auto;
}

.quiz-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 10px;
}

.quiz-progress-bar {
    height: 6px;
    background: var(--brd);
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--acc), var(--grn));
    border-radius: 3px;
    transition: width 0.4s;
}

.question-text {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.8;
}

.code-preview {
    background: #0d1117;
    border: 1px solid #2a3f55;
    border-radius: 10px;
    padding: 14px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
    margin-bottom: 18px;
    color: #c9d1d9;
    white-space: pre-wrap;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    background: transparent;
    border: 2px solid var(--brd);
    color: var(--txt);
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: right;
    width: 100%;
    transition: all 0.15s;
}

.quiz-option:hover {
    border-color: var(--acc);
    background: rgba(59, 130, 246, 0.05);
}

.quiz-option.correct {
    border-color: var(--grn) !important;
    background: rgba(16, 185, 129, 0.12) !important;
    color: var(--grn) !important;
}

.quiz-option.wrong {
    border-color: var(--red) !important;
    background: rgba(239, 68, 68, 0.12) !important;
    color: var(--red) !important;
}

.fill-input {
    width: 100%;
    background: var(--bg2);
    border: 2px solid var(--brd);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--txt);
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    outline: none;
    margin: 16px 0;
    direction: ltr;
    text-align: left;
}

.fill-input:focus {
    border-color: var(--acc);
}

.tf-buttons {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.tf-btn {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    border: 2px solid var(--brd);
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.15s;
    background: transparent;
    color: var(--txt);
}

.tf-btn.true:hover {
    border-color: var(--grn);
    background: rgba(16, 185, 129, 0.1);
    color: var(--grn);
}

.tf-btn.false:hover {
    border-color: var(--red);
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.quiz-feedback {
    padding: 14px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.7;
    margin-top: 18px;
    display: none;
}

.quiz-feedback.correct {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--grn);
    display: block;
}

.quiz-feedback.wrong {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    display: block;
}

.quiz-next {
    text-align: left;
    margin-top: 18px;
}

/* ==================== نتائج الاختبار ==================== */
.result-card {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.result-lesson {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 16px;
}

.result-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 6px solid var(--acc);
    display: grid;
    place-items: center;
    margin: 0 auto 20px;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--acc);
}

.result-message {
    font-size: 1.3rem;
    font-weight: 900;
    margin-bottom: 10px;
}

.result-details {
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.8;
}

.result-breakdown {
    background: var(--bg2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: right;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--brd);
}

.breakdown-item:last-child {
    border-bottom: none;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== المشاريع ==================== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

.project-card {
    padding: 22px;
    cursor: pointer;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.project-icon {
    font-size: 2.5rem;
}

.project-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.project-desc {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 14px;
}

.project-lessons {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 14px;
}

/* ==================== الإعدادات ==================== */
.settings-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 26px;
    flex-wrap: wrap;
}

.settings-tab {
    padding: 10px 18px;
    border-radius: 10px;
    border: 2px solid var(--brd);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.settings-tab:hover {
    border-color: var(--acc);
    color: var(--acc);
}

.settings-tab.active {
    border-color: var(--acc);
    background: rgba(59, 130, 246, 0.12);
    color: var(--acc);
}

.settings-content {
    display: none;
}

.settings-content.active {
    display: block;
}

.settings-section {
    background: var(--card);
    border: 1px solid var(--brd);
    border-radius: 18px;
    padding: 26px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--brd);
}

.section-header span:first-child {
    font-size: 1.8rem;
}

.section-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.section-desc {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 2px;
}

.setting-item {
    margin-bottom: 24px;
}

.setting-item label {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--muted);
}

.color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.color-option {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.15s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #fff;
    outline: 3px solid var(--acc);
}

.button-group {
    display: flex;
    gap: 10px;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--brd);
}

#sbanner {
    display: none;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    color: var(--grn);
    font-weight: 700;
    text-align: center;
}

.progress-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.progress-stats {
    background: var(--bg2);
    border-radius: 12px;
    padding: 18px;
}

.progress-stats h4 {
    margin-bottom: 14px;
    color: var(--acc);
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg2);
    border-radius: 10px;
}

.shortcut-item span:first-child {
    background: var(--acc);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

.info-card {
    display: flex;
    gap: 14px;
    padding: 18px;
    background: var(--bg2);
    border-radius: 14px;
    margin-bottom: 14px;
}

.info-card.highlight {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.info-icon {
    font-size: 2rem;
}

.info-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.info-desc {
    font-size: 0.85rem;
    color: var(--muted);
}

.info-footer {
    font-size: 0.8rem;
    color: var(--acc);
    margin-top: 8px;
    font-weight: 500;
}

.social-links {
    margin-top: 20px;
}

.social-links h4 {
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: rgba(66, 103, 178, 0.1);
    border: 1px solid rgba(66, 103, 178, 0.3);
    border-radius: 12px;
    text-decoration: none;
    color: var(--txt);
    margin-bottom: 10px;
    transition: all 0.2s;
}

.social-link:hover {
    background: rgba(66, 103, 178, 0.2);
}

.about-content {
    text-align: center;
    padding: 28px 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.08));
    border-radius: 18px;
    border: 1px solid var(--brd);
}

.about-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--acc), var(--grn));
    display: grid;
    place-items: center;
    font-size: 2.5rem;
    margin: 0 auto 18px;
    color: white;
}

.about-name {
    font-weight: 900;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.about-content p {
    font-size: 0.9rem;
    color: var(--muted);
    line-height: 1.9;
    max-width: 450px;
    margin: 0 auto;
}

.lock-message {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 22px;
}

.support-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.support-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg2);
    border-radius: 12px;
    border: 1px solid var(--brd);
}

.support-card span:first-child {
    font-size: 1.5rem;
}

/* ==================== التذييل ==================== */
#site-footer {
    position: fixed;
    bottom: 70px;
    left: 0;
    right: 0;
    z-index: 997;
    background: rgba(8, 16, 30, 0.93);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(220, 232, 248, 0.5);
    font-family: 'Cairo', sans-serif;
    border-top: 1px solid var(--brd);
}

[data-theme="light"] #site-footer {
    background: rgba(243, 246, 255, 0.93);
    color: rgba(24, 39, 62, 0.6);
}

/* ==================== تجاوب مع الشاشات الصغيرة ==================== */
@media (max-width: 640px) {
    body {
        font-size: 0.9rem;
        padding-bottom: 80px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .lessons-grid {
        grid-template-columns: 1fr;
    }
    
    .nb {
        min-width: 50px;
        padding: 5px 4px;
    }
    
    .nb .ni {
        font-size: 1.3rem;
    }
    
    .nb .nl {
        font-size: 0.55rem;
    }
    
    #site-footer {
        bottom: 68px;
        font-size: 0.6rem;
        padding: 4px 8px;
    }
    
    .editor-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .editor-actions {
        justify-content: center;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .quiz-card {
        padding: 18px;
    }
    
    .settings-tabs {
        justify-content: center;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    .shortcuts-info {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-buttons {
        flex-direction: column;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .editor-btn span:not(:first-child) {
        display: none;
    }
    
    .tf-buttons {
        flex-direction: column;
    }
}

/* ==================== تأثيرات إضافية ==================== */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.hidden {
    display: none !important;
}

/* ==================== تنسيقات النصوص ==================== */
.tb {
    background: rgba(16, 185, 129, 0.15);
    color: var(--grn);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

.tm {
    background: rgba(245, 158, 11, 0.15);
    color: var(--gld);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}

.tc {
    background: rgba(59, 130, 246, 0.12);
    color: var(--acc);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
}
/* ==================== تجاوب مع جميع الشاشات ==================== */

/* شاشات أقل من 1024px (تابلت صغير) */
@media (max-width: 1024px) {
    .pg {
        padding: 20px 3% 90px;
    }
    
    .page-title {
        font-size: 1.6rem;
    }
    
    .stats-grid {
        gap: 10px;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
}

/* شاشات أقل من 768px (تابلت - عمودي) */
@media (max-width: 768px) {
    body {
        font-size: 0.9rem;
        padding-bottom: 75px;
    }
    
    .pg {
        padding: 18px 3% 85px;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-subtitle {
        font-size: 0.88rem;
        margin-bottom: 20px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .lessons-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    
    .unit-tests-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #topbar {
        height: 52px;
        padding: 0 3%;
    }
    
    .logo {
        font-size: 1rem;
    }
    
    .logo .ld {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    .tbtn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .editor-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .editor-logo {
        font-size: 0.85rem;
    }
    
    .editor-view-toggle {
        order: 1;
    }
    
    .editor-actions {
        order: 2;
        margin-right: auto;
    }
    
    .cm-panel-header {
        padding: 6px 12px;
    }
    
    .CodeMirror {
        height: 250px !important;
        font-size: 0.85rem !important;
    }
    
    .cm-terminal-body {
        height: 250px;
        font-size: 0.85rem;
    }
    
    .snippets-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .quiz-card {
        padding: 20px;
    }
    
    .question-text {
        font-size: 1rem;
    }
    
    .settings-tabs {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 5px;
        flex-wrap: nowrap;
    }
    
    .settings-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .settings-section {
        padding: 20px;
    }
    
    #site-footer {
        bottom: 68px;
        font-size: 0.65rem;
        padding: 5px 10px;
    }
}

/* شاشات أقل من 640px (هواتف كبيرة) */
@media (max-width: 640px) {
    body {
        font-size: 0.88rem;
    }
    
    .pg {
        padding: 16px 4% 80px;
    }
    
    .page-title {
        font-size: 1.4rem;
    }
    
    .hero-icon {
        font-size: 3rem;
    }
    
    .hero-badge {
        font-size: 0.75rem;
        padding: 5px 14px;
    }
    
    .home-hero h1 {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }
    
    .hero-desc {
        font-size: 0.9rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 1.6rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .feature-card {
        padding: 18px;
    }
    
    .lessons-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .unit-tests-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .progress-container {
        padding: 12px 14px;
    }
    
    #botnav {
        padding: 5px 2px;
    }
    
    .nb {
        min-width: 50px;
        padding: 5px 2px;
        gap: 2px;
    }
    
    .nb .ni {
        font-size: 1.2rem;
    }
    
    .nb .nl {
        font-size: 0.55rem;
    }
    
    .editor-header {
        padding: 8px 10px;
    }
    
    .editor-logo-icon {
        width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }
    
    .view-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
    
    .editor-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    
    .CodeMirror {
        height: 220px !important;
        font-size: 0.8rem !important;
    }
    
    .cm-terminal-body {
        height: 220px;
        font-size: 0.8rem;
    }
    
    .editor-footer {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
        padding: 8px 12px;
    }
    
    .shortcuts-info {
        font-size: 0.7rem;
    }
    
    .snippets-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .snippet-card {
        padding: 10px 12px;
    }
    
    .quiz-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .quiz-header h3 {
        font-size: 1rem;
        width: 100%;
        order: -1;
    }
    
    .quiz-card {
        padding: 16px;
    }
    
    .question-text {
        font-size: 0.95rem;
    }
    
    .quiz-option {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
    
    .tf-btn {
        padding: 12px;
        font-size: 1rem;
    }
    
    .fill-input {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
    
    .result-card {
        padding: 20px;
    }
    
    .result-circle {
        width: 100px;
        height: 100px;
        font-size: 1.8rem;
    }
    
    .result-message {
        font-size: 1.1rem;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    .modal-content {
        padding: 18px;
        max-width: 95%;
    }
    
    .settings-section {
        padding: 16px;
    }
    
    .section-header {
        gap: 8px;
    }
    
    .section-header span:first-child {
        font-size: 1.5rem;
    }
    
    .section-title {
        font-size: 1rem;
    }
    
    .color-option {
        width: 30px;
        height: 30px;
    }
    
    .button-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-outline-sm {
        width: 100%;
    }
    
    .settings-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .settings-actions .btn {
        width: 100%;
    }
    
    .progress-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .progress-actions .btn {
        width: 100%;
    }
    
    .shortcut-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .info-card {
        flex-direction: column;
        text-align: center;
    }
    
    .social-link {
        padding: 10px 12px;
    }
    
    .support-card {
        flex-direction: column;
        text-align: center;
    }
    
    #site-footer {
        bottom: 64px;
        font-size: 0.6rem;
        padding: 4px 8px;
    }
}

/* شاشات أقل من 480px (هواتف صغيرة) */
@media (max-width: 480px) {
    body {
        font-size: 0.85rem;
    }
    
    .pg {
        padding: 14px 4% 75px;
    }
    
    .page-title {
        font-size: 1.3rem;
    }
    
    .page-subtitle {
        font-size: 0.8rem;
    }
    
    .hero-icon {
        font-size: 2.5rem;
    }
    
    .hero-badge {
        font-size: 0.7rem;
        padding: 4px 12px;
    }
    
    .stats-grid {
        gap: 6px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-number {
        font-size: 1.4rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    #topbar {
        height: 48px;
    }
    
    .logo {
        font-size: 0.9rem;
        gap: 6px;
    }
    
    .logo .ld {
        width: 26px;
        height: 26px;
        font-size: 0.9rem;
    }
    
    .tbtn {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    .nb {
        min-width: 45px;
    }
    
    .nb .ni {
        font-size: 1.1rem;
    }
    
    .nb .nl {
        font-size: 0.5rem;
    }
    
    .editor-header {
        padding: 6px 8px;
    }
    
    .editor-logo span {
        display: none;
    }
    
    .view-btn {
        padding: 4px 6px;
        font-size: 0.65rem;
    }
    
    .editor-btn {
        padding: 4px 6px;
        font-size: 0.7rem;
    }
    
    .editor-btn span:not(:first-child) {
        display: none;
    }
    
    .CodeMirror {
        height: 200px !important;
    }
    
    .cm-terminal-body {
        height: 200px;
    }
    
    .quiz-card {
        padding: 14px;
    }
    
    .question-text {
        font-size: 0.9rem;
    }
    
    .quiz-option {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .code-preview {
        padding: 10px;
        font-size: 0.75rem;
    }
    
    .btn-final-test {
        padding: 15px;
        font-size: 1rem;
    }
    
    .result-circle {
        width: 80px;
        height: 80px;
        font-size: 1.5rem;
        border-width: 4px;
    }
    
    .modal-content {
        padding: 14px;
    }
    
    .lesson-section h4 {
        font-size: 0.9rem;
    }
    
    .code-block {
        padding: 12px;
        font-size: 0.75rem;
    }
    
    .color-picker {
        justify-content: center;
    }
    
    .shortcuts-info {
        display: none;
    }
    
    #site-footer {
        bottom: 60px;
        font-size: 0.55rem;
    }
}

/* شاشات أقل من 360px (هواتف صغيرة جداً) */
@media (max-width: 360px) {
    body {
        font-size: 0.8rem;
    }
    
    .page-title {
        font-size: 1.2rem;
    }
    
    .hero-icon {
        font-size: 2rem;
    }
    
    .nb {
        min-width: 40px;
    }
    
    .nb .ni {
        font-size: 1rem;
    }
    
    .nb .nl {
        font-size: 0.45rem;
    }
    
    .editor-btn {
        padding: 4px 5px;
    }
    
    .view-btn {
        padding: 3px 5px;
        font-size: 0.6rem;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* ==================== دعم الوضع الأفقي (Landscape) ==================== */
@media (max-height: 500px) and (orientation: landscape) {
    #topbar {
        height: 45px;
    }
    
    .pg {
        padding-top: 10px;
        padding-bottom: 70px;
    }
    
    .hero-icon {
        font-size: 2rem;
        margin-bottom: 0;
    }
    
    .hero-badge {
        margin-bottom: 8px;
    }
    
    .home-hero h1 {
        margin-bottom: 8px;
    }
    
    .hero-desc {
        margin-bottom: 12px;
    }
    
    .stats-grid {
        margin: 15px 0;
    }
    
    #botnav {
        padding: 4px;
    }
    
    .nb {
        padding: 3px;
    }
    
    .CodeMirror {
        height: 180px !important;
    }
    
    .cm-terminal-body {
        height: 180px;
    }
    
    #site-footer {
        bottom: 52px;
    }
}