:root {
    --rb-teal-dark: #103b46;
    --rb-teal-mid: #174c5a;
    --rb-teal-pill: #0b2b34;
    --rb-gold: #e4a83b;
    --rb-gold-hover: #d49627;
    --rb-bg: #f1f4f6;
    --rb-surface: #ffffff;
    --rb-text: #0f172a;
    --rb-muted: #64748b;
    --rb-border: #e2e8f0;
    --rb-danger: #dc2626;
    --rb-font-size: 38px;

    --blue: #2563eb;
    --teal: #0d9488;
    --amber: #d97706;
    --purple: #7c3aed;
    --green: #16a34a;
}

* { box-sizing: border-box; }

html, body.rb-body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    background: #e8ecef;
    color: #1e293b;
    font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

.rb-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* الترويسة العلوية المزدوجة باللون الكحلي-الفيروزي الداكن */
.rb-top-header {
    background: var(--rb-teal-dark);
    color: #fff;
    z-index: 25;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
}

.rb-app.is-bars-hidden .rb-top-header,
.rb-app.is-bars-hidden .rb-bottom-footer {
    display: none;
}

.rb-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 14px;
}

.rb-header-row--primary {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rb-header-row--tools {
    background: var(--rb-teal-mid);
    padding: 6px 14px;
}

.rb-brand-cluster {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rb-grade-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #e2e8f0;
    padding: 3px 10px;
    border-radius: 6px;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
}

.rb-lesson-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.rb-lenses-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.rb-lens-btn {
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    padding: 4px 11px;
    border-radius: 99px;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
}

.rb-lens-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.rb-lens-btn.is-active {
    background: var(--rb-gold);
    color: #0f172a;
    border-color: var(--rb-gold);
    font-weight: 700;
}

.rb-tool-cluster {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    background: rgba(0, 0, 0, 0.16);
    padding: 3px 6px;
    border-radius: 99px;
}

.rb-tool-cluster--end {
    margin-inline-start: auto;
    background: transparent;
    padding: 0;
}

.rb-dark-btn, .rb-dark-pill {
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    padding: 4px 10px;
    border-radius: 99px;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}

.rb-dark-btn:hover, .rb-dark-pill:hover {
    background: rgba(255, 255, 255, 0.2);
}

.rb-dark-btn--icon {
    padding: 4px 8px;
}

.rb-dark-btn--accent {
    background: #0ea5e9;
    border-color: #0ea5e9;
    color: #fff;
}

.rb-dark-btn.is-active {
    background: var(--rb-gold);
    color: #0f172a;
    border-color: var(--rb-gold);
}

.rb-speed-label {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    padding: 0 4px;
    color: #e2e8f0;
}

.rb-pen-capsule {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 6px;
}

.rb-pen-label {
    font-family: system-ui, sans-serif;
    font-size: 12px;
    color: #e2e8f0;
}

.rb-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    cursor: pointer;
    padding: 0;
}

.rb-color-dot--red { background: #ef4444; }
.rb-color-dot--blue { background: #3b82f6; }
.rb-color-dot--yellow { background: #facc15; }

.rb-color-dot.is-active {
    transform: scale(1.25);
    box-shadow: 0 0 0 2px var(--rb-gold);
}

.rb-gold-btn {
    background: var(--rb-gold);
    color: #0f172a;
    border: none;
    padding: 5px 14px;
    border-radius: 99px;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.rb-gold-btn:hover {
    background: var(--rb-gold-hover);
}

/* مساحة العمل المقسّمة: منصة القراءة + القائمة الجانبية */
.rb-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.rb-stage {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rb-stage-topbar {
    width: 100%;
    max-width: 1020px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.rb-page-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rb-page-tab-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    padding: 6px 14px;
    border-radius: 8px;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.rb-page-tab-btn.is-active {
    background: var(--rb-teal-dark);
    color: #fff;
    border-color: var(--rb-teal-dark);
}

.rb-unit-pill {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 5px 14px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 700;
}

.rb-paper-wrapper {
    position: relative;
    width: 100%;
    max-width: 1020px;
}

.rb-draw-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    border-radius: 20px;
}

.rb-draw-canvas.is-drawing {
    pointer-events: auto;
    cursor: crosshair;
}

.rb-paper-card {
    background: var(--rb-surface);
    border: 1px solid #e6e0d2;
    border-radius: 18px;
    padding: 2.2rem 2.8rem 3rem;
    box-shadow: 0 10px 30px rgba(21, 68, 90, 0.06);
    position: relative;
    z-index: 5;
}

.rb-paper-full-title {
    margin: 0 0 1.4rem;
    padding-bottom: 0.85rem;
    border-bottom: 2px dashed #e2dac9;
    text-align: center;
    font-family: 'Amiri', serif;
    font-size: 2.15rem;
    font-weight: 700;
    color: var(--rb-teal-dark);
}

.rb-text-container {
    font-family: 'Amiri', serif;
    font-size: var(--rb-font-size);
    line-height: 2.38;
    color: #0f172a;
    text-align: justify;
}

.rb-text-container p {
    margin-top: 0;
    margin-bottom: 1.35rem;
}

.rb-text-container p:last-child {
    margin-bottom: 0;
}

.rb-page-divider {
    display: flex;
    justify-content: flex-start;
    margin: 0.4rem 0 1.1rem;
}

.rb-page-divider span {
    background: #f1ede4;
    border: 1px solid #d8cfb8;
    color: var(--rb-teal-dark);
    padding: 0.22rem 0.85rem;
    border-radius: 999px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
}

.rb-sentence {
    display: inline;
    border-radius: 10px;
    padding: 0.06rem 0.18rem;
    transition: opacity 0.25s ease, background-color 0.25s ease;
}

.rb-text-container.is-microscope .rb-sentence {
    opacity: 0.18;
}

.rb-text-container.is-microscope .rb-sentence.is-focused {
    opacity: 1;
    background: #fffbeb;
    box-shadow: 0 0 0 3px #fde68a, 0 4px 15px rgba(245, 158, 11, 0.18);
}

.rb-word-unit {
    display: inline;
}

.rb-word {
    display: inline;
    padding: 0 2px;
    border-radius: 6px;
    cursor: pointer;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.rb-word.has-skill-card {
    padding: 0 0.18rem;
}

.rb-word:hover {
    background: rgba(16, 59, 70, 0.08);
}

.rb-word.has-skill-card {
    border-bottom: 2px solid transparent;
}

.rb-word.is-lens-active {
    border-bottom-width: 2px;
    border-bottom-style: solid;
}

.rb-word.is-tracked {
    background: #fde047 !important;
    color: #0f172a !important;
    transform: scale(1.06);
}

.rb-word.is-spotlighted {
    background: #fef08a !important;
    box-shadow: 0 0 0 3px #eab308;
    border-radius: 8px;
    transform: scale(1.08);
}

.rb-word.is-cloze-hidden {
    background: #e2e8f0 !important;
    color: transparent !important;
    border-bottom: 3px dashed #64748b;
    user-select: none;
}

.rb-word.is-cloze-revealed {
    background: #dcfce7 !important;
    color: #166534 !important;
}

/* القائمة الجانبية اليسرى: نافذة المهارة وتدريبات الكتاب */
.rb-skill-sidebar {
    width: 340px;
    max-width: 34vw;
    background: #fff;
    border-right: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 18;
}

.rb-skill-sidebar[hidden] {
    display: none;
}

.rb-sidebar-header {
    background: var(--rb-teal-dark);
    color: #fff;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: system-ui, sans-serif;
}

.rb-sidebar-title {
    font-size: 13px;
    font-weight: 700;
}

.rb-sidebar-badge {
    background: rgba(255, 255, 255, 0.14);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}

.rb-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: system-ui, sans-serif;
}

.rb-sidebar-hint {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    color: #475569;
    line-height: 1.6;
    margin-bottom: 12px;
}

.rb-cloud-group {
    margin-bottom: 14px;
}

.rb-cloud-group__title {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.rb-cloud-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rb-cloud-word-btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-right: 4px solid var(--blue);
    border-radius: 8px;
    padding: 5px 10px;
    font-family: 'Amiri', serif;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}

.rb-cloud-word-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* التذييل السفلي */
.rb-bottom-footer {
    background: #fff;
    border-top: 1px solid #cbd5e1;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    z-index: 20;
}

.rb-color-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.rb-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #334155;
    font-weight: 600;
}

.rb-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.rb-shortcuts-hint {
    color: #64748b;
}

.rb-shortcuts-hint kbd {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 11px;
    color: #0f172a;
}

/* الأزرار العامة داخل البطاقات والنوافذ */
.rb-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
}

.rb-btn:hover { background: #f1f5f9; }
.rb-btn.is-active { background: var(--rb-teal-dark); color: #fff; border-color: var(--rb-teal-dark); }
.rb-btn--primary { background: var(--rb-teal-dark); color: #fff; border-color: var(--rb-teal-dark); }
.rb-btn--sm { padding: 4px 8px; font-size: 12px; }

/* البطاقة المركزية للتقطيع والمعاني */
.rb-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 16px;
}

.rb-modal[hidden] { display: none; }

.rb-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.rb-modal__card {
    position: relative;
    background: #fff;
    border-radius: 18px;
    padding: 26px 28px;
    min-width: 360px;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
    z-index: 2;
}

.rb-modal__close {
    position: absolute;
    top: 12px;
    left: 12px;
    border: none;
    background: #f1f5f9;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
}

.rb-modal__day-badge {
    display: inline-block;
    font-family: system-ui, sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: var(--rb-teal-dark);
    padding: 4px 12px;
    border-radius: 99px;
    margin-bottom: 8px;
}

.rb-modal__word {
    font-family: 'Amiri', serif;
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.rb-modal__syllables {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.rb-syllable-chip {
    font-family: 'Amiri', serif;
    font-size: 3rem;
    padding: 6px 18px;
    border-radius: 12px;
    background: #fffbeb;
    border: 2px solid #f59e0b;
    color: #78350f;
    transition: opacity 0.2s;
}

.rb-syllable-chip.is-hidden { opacity: 0.08; }

.rb-modal__actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.rb-modal__rich {
    text-align: right;
    font-family: system-ui, sans-serif;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    margin-top: 12px;
}

.rb-rich-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.rb-rich-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
}

.rb-rich-label {
    display: block;
    font-size: 12px;
    color: var(--rb-muted);
    margin-bottom: 4px;
    font-weight: 600;
}

.rb-rich-phonetics, .rb-rich-qa {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}

.rb-rich-phonetics ul {
    margin: 6px 0 0;
    padding-inline-start: 20px;
    font-size: 14px;
    line-height: 1.7;
}

.rb-rich-question {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.rb-rich-answer {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f0fdf4;
    border-right: 4px solid #16a34a;
    border-radius: 4px;
    color: #166534;
    font-size: 14px;
    font-weight: 600;
}

.rb-rich-book-badge {
    font-size: 12px;
    color: #0f766e;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 600;
}

.rb-modal__meta {
    font-family: system-ui, sans-serif;
    font-size: 13px;
    color: var(--rb-muted);
    margin-top: 10px;
}

/* البطاقات العائمة (المؤقت ودور القراءة) */
.rb-floating-restore {
    position: fixed;
    top: 10px;
    left: 14px;
    z-index: 40;
    background: var(--rb-teal-dark);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 99px;
    cursor: pointer;
    font-family: system-ui, sans-serif;
    font-size: 13px;
}

.rb-floating-card {
    position: fixed;
    bottom: 42px;
    z-index: 30;
    background: linear-gradient(135deg, #15445A 0%, #1D5570 100%);
    color: #FFFFFF;
    border: 2px solid #0DA9A6;
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
    font-family: system-ui, sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rb-floating-card[hidden] { display: none; }

.rb-timer-card { right: 16px; }
.rb-turn-card { right: 270px; }
@media (max-width: 960px) {
    .rb-skill-sidebar { position: fixed; left: 0; top: 88px; bottom: 34px; width: 300px; max-width: 85vw; box-shadow: 4px 0 20px rgba(0,0,0,0.15); }
    .rb-paper-card { padding: 20px 22px; }
    .rb-turn-card { right: 16px; bottom: 92px; }
}

.rb-timer-display {
    font-size: 20px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: center;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.26);
    padding: 2px 10px;
    border-radius: 8px;
}

.rb-timer-card.is-warning {
    border-color: #F59E0B;
    background: linear-gradient(135deg, #78350F 0%, #92400E 100%);
    color: #FDE68A;
}

.rb-timer-card.is-warning .rb-timer-display {
    color: #FDE68A;
    background: rgba(0, 0, 0, 0.35);
}

.rb-turn-label {
    font-size: 12px;
    font-weight: 600;
    color: #CBD5E1;
    margin-inline-end: 4px;
}

.rb-turn-card #rb-current-reader {
    background: #0DA9A6;
    color: #FFFFFF;
    padding: 2px 10px;
    border-radius: 8px;
    font-weight: 800;
}

.rb-turn-card #rb-next-reader {
    color: #FDE68A;
    font-weight: 700;
}

.rb-turn-round-badge {
    font-size: 11px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.14);
    color: #E0F2FE;
    border: 1px solid rgba(255, 255, 255, 0.28);
    padding: 2px 8px;
    border-radius: 99px;
}

#rb-turn-round-badge,
#rb-pill-round {
    display: none !important;
}

.rb-turn-card.is-round-ended {
    border-color: #34D399;
    background: linear-gradient(135deg, #065F46 0%, #047857 100%);
}

.rb-turn-card.is-round-ended .rb-turn-round-badge {
    background: #07A869;
    color: #FFFFFF;
    border-color: #6EE7B7;
}

.rb-floating-card .rb-btn {
    background: rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.25);
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.rb-floating-card .rb-btn:hover {
    background: rgba(255, 255, 255, 0.24);
}

.rb-floating-card .rb-btn.is-active,
#rb-turn-auto-btn.is-active {
    background: #F59E0B;
    border-color: #FDE68A;
    color: #15445A;
    font-weight: 800;
    box-shadow: 0 0 0 2px rgba(253, 230, 138, 0.45);
}

.rb-floating-card .rb-btn.is-active:hover,
#rb-turn-auto-btn.is-active:hover {
    background: #FBBF24;
    color: #15445A;
}

.rb-floating-card .rb-btn--primary {
    background: #07A869;
    border-color: #07A869;
    color: #FFFFFF;
}

.rb-floating-card .rb-btn--primary:hover {
    background: #059669;
}


/* قائمة ألوان القلم القابلة للطي */
.rb-pen-tools-sub {
    display: none;
    align-items: center;
    gap: 6px;
    padding-inline-start: 4px;
}

body.draw-mode-active .rb-pen-tools-sub {
    display: inline-flex;
}

.rb-dark-btn--sm {
    padding: 2px 8px;
    font-size: 11px;
}

/* تمييز الكلمات القابلة للتقطيع في وضع التقطيع */
body.syllable-mode-active .rb-word.has-syllables {
    cursor: pointer;
    border-bottom: 2px dotted rgba(13, 148, 136, 0.65);
}

body.syllable-mode-active .rb-word.has-syllables:hover {
    background-color: #ccfbf1 !important;
    color: #0f766e !important;
    outline: 2px solid #14b8a6;
}

/* شريط التنقل لمجهر الجمل في شاشة الطالب */
.rb-spotlight-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    padding: 4px 12px;
    border-radius: 99px;
    font-family: system-ui, sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: #92400e;
}

.rb-spotlight-nav[hidden] {
    display: none;
}

.rb-spot-btn {
    border: 1px solid #f59e0b;
    background: #fef3c7;
    color: #78350f;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.rb-spot-btn:hover {
    background: #fde68a;
}

/* بطاقة تفاصيل الكلمة داخل القائمة الجانبية لشاشة الطالب */
.rb-sb-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rb-sb-detail__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.rb-sb-back-btn {
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: var(--rb-teal-dark);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.rb-sb-back-btn:hover {
    background: #e2e8f0;
}

.rb-sb-day-pill {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 99px;
}

.rb-sb-showcase {
    background: #faf8f5;
    border: 2px solid #e5dec9;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.rb-sb-showcase__word {
    font-family: 'Amiri', serif;
    font-size: 36px;
    font-weight: 700;
    color: var(--rb-teal-dark);
}

.rb-sb-showcase__ref {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.rb-sb-syllables {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #dfd8c8;
}

.rb-sb-syl-pill {
    font-family: 'Amiri', serif;
    font-size: 22px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    border: 1.5px solid #f59e0b;
}

.rb-sb-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    font-size: 13px;
    line-height: 1.65;
}

.rb-sb-box h4 {
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--rb-teal-dark);
}

.rb-sb-book-box {
    background: #fdfbf7;
    border: 2px solid #c1b48a;
    border-radius: 12px;
    padding: 10px;
    font-size: 13px;
    line-height: 1.65;
}

/* نبض المؤقت عند الانتهاء */
.rb-timer-card.is-finished {
    background: linear-gradient(135deg, #991B1B 0%, #B91C1C 100%);
    border-color: #FCA5A5;
    color: #FFFFFF;
    animation: rbTimerPulse 0.85s infinite alternate;
}

@keyframes rbTimerPulse {
    from { transform: scale(1); }
    to { transform: scale(1.04); }
}

.rb-syllable-chip:nth-child(even) {
    background: #f0fdfa;
    border-color: #14b8a6;
    color: #115e59;
    box-shadow: 0 6px 16px rgba(20, 184, 166, 0.16);
}

.rb-sb-syl-pill:nth-child(even) {
    background: #f0fdfa;
    border-color: #14b8a6;
    color: #115e59;
}


/* ==================== التجاوب الاحترافي للهواتف والأجهزة الصغيرة (v1.7.0) ==================== */
.rb-mobile-only-btn,
.rb-mobile-tracker-dock,
.rb-sheet-grabber,
.rb-sheet-close-btn {
    display: none;
}

.rb-sidebar-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.rb-word {
    touch-action: manipulation;
}

/* الشاشات المتوسطة والأجهزة اللوحية (<= 960px) */
@media (max-width: 960px) {
    .rb-skill-sidebar {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        height: 56vh;
        max-height: 75dvh;
        border-right: none;
        border-top: 3px solid var(--rb-gold);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 35px rgba(15, 23, 42, 0.24);
        z-index: 45;
        animation: rbSheetSlideUp 0.22s ease-out;
    }

    .rb-skill-sidebar .rb-sidebar-body {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        -webkit-overflow-scrolling: touch;
    }

    @keyframes rbSheetSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .rb-sheet-grabber {
        display: flex;
        justify-content: center;
        padding: 7px 0 3px;
        background: var(--rb-teal-dark);
        border-radius: 17px 17px 0 0;
    }

    .rb-sheet-grabber span {
        width: 40px;
        height: 4px;
        border-radius: 99px;
        background: rgba(255, 255, 255, 0.35);
    }

    .rb-sheet-close-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.25);
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
    }

    .rb-paper-card {
        padding: 1.5rem 1.4rem 2.2rem;
    }
}

/* الهواتف الذكية والشاشات الصغيرة (<= 768px) */
@media (max-width: 768px) {
    html, body.rb-body {
        height: 100dvh;
    }

    .rb-app {
        height: 100dvh;
    }

    .rb-header-row--primary {
        padding: 6px 10px;
        gap: 6px;
    }

    .rb-brand-cluster {
        width: 100%;
        justify-content: space-between;
        gap: 6px;
    }

    .rb-grade-badge {
        display: none !important;
    }

    .rb-lesson-title {
        font-size: 16px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .rb-mobile-only-btn {
        display: inline-flex;
        flex-shrink: 0;
    }

    /* شريط عدسات قابل للتمرير الأفقي بسطر واحد */
    .rb-lenses-nav {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }

    .rb-lenses-nav::-webkit-scrollbar {
        display: none;
    }

    .rb-lens-btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 5px 11px;
    }

    /* قائمة أدوات التدريب القابلة للطي في الجوال */
    .rb-header-row--tools {
        display: none;
        padding: 8px 10px;
        gap: 6px;
        max-height: 45vh;
        overflow-y: auto;
    }

    .rb-header-row--tools.is-mobile-open {
        display: flex;
    }

    .rb-classroom-only,
    .rb-cluster-tracker,
    .rb-bottom-footer {
        display: none !important;
    }

    .rb-tool-cluster {
        width: 100%;
        justify-content: center;
        border-radius: 12px;
        padding: 5px;
    }

    .rb-stage {
        padding: 10px 10px 84px;
    }

    .rb-stage-topbar {
        margin-bottom: 8px;
        gap: 6px;
    }

    .rb-page-tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .rb-page-tabs::-webkit-scrollbar {
        display: none;
    }

    .rb-page-tab-btn {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 12px;
    }

    .rb-unit-pill {
        font-size: 12px;
        padding: 3px 10px;
    }

    .rb-paper-card {
        border-radius: 14px;
        padding: 1.15rem 0.95rem 1.8rem;
    }

    .rb-paper-full-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        padding-bottom: 0.6rem;
    }

    .rb-text-container {
        font-size: clamp(1.4rem, var(--rb-font-size), 3.2rem);
        line-height: 2.32;
        text-align: start;
    }

    .rb-text-container p {
        margin-bottom: 1.1rem;
    }

    /* شريط التحكم اللمسي السفلي المخصص لتدريب الطالب */
    .rb-mobile-tracker-dock {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 35;
        background: var(--rb-teal-dark);
        border-top: 2px solid rgba(228, 168, 59, 0.65);
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.2);
    }

    .rb-mob-dock-btn {
        min-width: 42px;
        min-height: 42px;
        padding: 0 11px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.18);
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
        font-family: 'Tajawal', sans-serif;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        touch-action: manipulation;
    }

    .rb-mob-dock-btn--primary {
        background: #0ea5e9;
        border-color: #0ea5e9;
        flex: 1;
        max-width: 155px;
    }

    .rb-mob-dock-btn--primary.is-playing {
        background: #f59e0b;
        border-color: #f59e0b;
        color: #0f172a;
    }

    .rb-mob-dock-btn--gold {
        background: var(--rb-gold);
        border-color: var(--rb-gold);
        color: #0f172a;
    }

    .rb-mob-speed-group {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        background: rgba(0, 0, 0, 0.22);
        padding: 2px 4px;
        border-radius: 12px;
    }

    .rb-mob-speed-val {
        font-family: 'IBM Plex Sans Arabic', sans-serif;
        font-size: 12px;
        font-weight: 700;
        color: #fde68a;
        min-width: 34px;
        text-align: center;
        direction: ltr;
    }

    /* بطاقة التقطيع الصوتي المتجاوبة */
    .rb-modal {
        padding: 10px;
    }

    .rb-modal__card {
        min-width: 0;
        width: 95vw;
        padding: 18px 14px;
        border-radius: 16px;
    }

    .rb-modal__word {
        font-size: 2.7rem;
        margin-bottom: 10px;
    }

    .rb-syllable-chip {
        font-size: 2.05rem;
        padding: 4px 12px;
    }

    .rb-floating-card {
        bottom: 66px;
        right: 10px;
        left: 10px;
        justify-content: space-between;
    }
}

