:root {
    /* surfaces */
    --bg: #FAF7F2;
    --surface: #FFFFFF;
    --surface-hover: #F0EAE0;
    --border: #E5E0D5;

    /* text */
    --text: #2C2C2C;
    --text-muted: #6B6B6B;

    /* accent (academic navy) */
    --accent: #1E3A8A;
    --accent-hover: #1E40AF;

    /* witness colors (deep, scholarly) */
    --blue:   #1E40AF;
    --green:  #15803D;
    --orange: #B45309;

    /* shadows */
    --shadow-sm: 0 1px 2px rgba(28, 28, 28, 0.06);
    --shadow-md: 0 4px 12px rgba(28, 28, 28, 0.08);
    --shadow-lg: 0 10px 30px rgba(28, 28, 28, 0.12);

    /* radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;

    /* type */
    --font: 'Tajawal', 'Cairo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* ===== Layout ===== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px 40px;
}

.container.full-mode {
    max-width: 100%;
    padding: 0;
}

/* ===== Quick-jump bar ===== */

.qjbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 0 0;
    background: var(--bg);
    border-bottom: none;
    margin-bottom: 0;
}

.qj-brand {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text);
    text-decoration: none;
    line-height: 0;
    margin-top: 8px;
    transition: transform 0.15s;
}

.qj-brand:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.qj-logo {
    width: 50px;
    height: 75px;
    object-fit: contain;
}

.qj-title { font-weight: 700; font-size: 15px; }

.qj-search {
    position: relative;
    flex: 1;
    max-width: 480px;
}

#qjInput {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#qjInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.qj-list {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    max-height: 320px;
    overflow-y: auto;
    display: none;
    z-index: 1100;
}

.qj-suggestion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
}

.qj-suggestion:hover,
.qj-suggestion.active {
    background: var(--surface-hover);
}

.qj-num {
    font-weight: 800;
    color: var(--accent);
    min-width: 32px;
}

.qj-name { color: var(--text); flex: 1; }

.qj-icon {
    font-size: 16px;
    line-height: 1;
    min-width: 32px;
    text-align: center;
}

.qj-witness {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.qj-witness-blue   { background: rgba(30, 100, 200, 0.12); color: var(--blue); }
.qj-witness-green  { background: rgba(46, 139, 87, 0.14); color: var(--green); }
.qj-witness-orange { background: rgba(217, 119, 6, 0.14); color: var(--orange); }

.qj-badge { flex-shrink: 0; }

/* ===== Intro Banner (above hero on home) ===== */

.intro-banner {
    margin: -6px 0 14px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--r-md);
    border: 1px solid rgba(255, 255, 255, 0.9);
    text-align: center;
}

.intro-banner p {
    max-width: 820px;
    margin: 0 auto;
    color: #4A4A4A;
    font-size: 13px;
    line-height: 1.7;
    font-weight: 500;
    letter-spacing: 0.005em;
}

[data-theme="dark"] .intro-banner p { color: #D6CFC2; }

[data-theme="dark"] .intro-banner {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

@media (max-width: 768px) {
    .intro-banner { padding: 8px 14px; }
    .intro-banner p { font-size: 12.5px; line-height: 1.7; }
}


/* ===== Hero ===== */

.hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px 28px 24px;
    margin-bottom: 20px;
    text-align: center;
}

.hero-title {
    font-family: 'Aref Ruqaa', 'Amiri', 'Tajawal', serif;
    margin: 0 0 30px;
    color: var(--accent);
    font-size: 60px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0;
}

.hero-subtitle {
    font-family: 'Amiri', 'Tajawal', serif;
    margin: 0 0 8px;
    color: var(--text);
    font-size: 19px;
    font-weight: 400;
    line-height: 1.6;
}

.hero-text {
    font-family: 'Amiri', 'Tajawal', serif;
    max-width: 760px;
    margin: 0 auto 8px;
    color: var(--text);
    font-size: 19px;
    line-height: 1.6;
    font-weight: 400;
}

.hero-text-aside {
    font-family: 'Amiri', 'Tajawal', serif;
    margin: 0 auto 32px;
    text-align: center;
    color: var(--text);
    font-size: 19px;
    font-weight: 400;
    line-height: 1.6;
}

.hero-witnesses-label {
    font-family: 'Amiri', 'Tajawal', serif;
    margin: 18px 0 10px;
    text-align: center;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
    position: relative;
}

.hero-witnesses-label::before,
.hero-witnesses-label::after {
    content: "";
    display: inline-block;
    width: 36px;
    height: 1px;
    background: var(--border);
    vertical-align: middle;
    margin: 0 14px;
}

.hero-witnesses {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.witness {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-weight: 700;
    font-size: 14.5px;
}

.witness-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.witness-tag { font-weight: 800; }

.witness-l { color: var(--blue); }
.witness-l .witness-dot { background: var(--blue); }
.witness-a { color: var(--green); }
.witness-a .witness-dot { background: var(--green); }
.witness-s { color: var(--orange); }
.witness-s .witness-dot { background: var(--orange); }


/* ===== Home cards ===== */

.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
    font-family: inherit;
    color: var(--text);
}

.card:hover,
.card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
    background: var(--surface-hover);
    outline: none;
}

.card-icon {
    font-size: 34px;
    margin-bottom: 10px;
}

.card-title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 800;
}

.card-desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.card-witnesses {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    align-items: center;
}

.card-witnesses .witness {
    font-size: 12.5px;
    padding: 4px 10px;
}

.card-witnesses .witness-tag {
    margin-right: 4px;
}

/* ===== Sections (general) ===== */

.section {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.section-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.section h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    color: var(--text);
}

.top-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    transition: background 0.15s, border-color 0.15s;
}

.top-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== Rawi index ===== */

.rawis-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 240px;
    max-width: 560px;
}

#search {
    width: 100%;
    height: 48px;
    padding: 0 18px;
    padding-inline-end: 100px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg);
    font-family: var(--font);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

#search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.rawis-counter {
    position: absolute;
    inset-inline-end: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    padding-inline-start: 10px;
    border-inline-start: 1px solid var(--border);
}

.rawis-fullpdf-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-inline-start: auto;
    gap: 4px;
}

.rawis-fullpdf {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 22px;
    background: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: var(--r-md);
    color: #fff !important;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.18);
}

.rawis-fullpdf:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 58, 138, 0.28);
    text-decoration: none;
    color: #fff !important;
}

.rawis-ranges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.range-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.range-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.hint {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 16px;
    padding: 12px 16px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: var(--r-md);
    color: #78350F;
    font-size: 13.5px;
    line-height: 1.7;
}

.hint-icon {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1.4;
}

.hint strong { color: #78350F; }

.hint-fullpdf {
    width: fit-content;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11.5px;
    line-height: 1.5;
    white-space: nowrap;
    gap: 5px;
    justify-content: center;
}

.hint-fullpdf .hint-icon { font-size: 11.5px; opacity: 0.8; }
.hint-fullpdf strong { color: var(--text); }

@media (max-width: 768px) {
    .hint-fullpdf { white-space: normal; }
}

.rawi-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rawi-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s, background 0.12s;
}

.rawi-row:hover,
.rawi-row:focus-visible {
    transform: translateX(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--accent);
    background: var(--surface-hover);
    outline: none;
}

.rawi-row-num {
    flex-shrink: 0;
    width: 56px;
    text-align: center;
    font-size: 19px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    padding: 4px 8px;
    background: var(--bg);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.rawi-row-name {
    flex: 1;
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.6;
}

.rawi-row-witnesses {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.rwc-chip {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    font-size: 16px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.rwc-chip:hover {
    transform: scale(1.12);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.15);
}

.rwc-l { background: var(--blue); }
.rwc-a { background: var(--green); }
.rwc-s { background: var(--orange); }

/* ===== Rawi viewer (compare + focus) ===== */

.viewer-mode {
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: transparent;
}

.viewer-mode .section-top {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.viewer-mode .section-top h2 {
    font-size: 17px;
    flex: 1;
    text-align: center;
}

.rawi-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-btn:not(:disabled):hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.visibility-toggles {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin: 0 16px 12px;
    flex-wrap: wrap;
}

.vt-label {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 13px;
    margin-left: 4px;
}

.vt-btn {
    width: 44px;
    height: 38px;
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    font-family: inherit;
    font-weight: 800;
    font-size: 17px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.vt-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.vt-btn.active.vt-l { background: var(--blue);   color: #fff; border-color: var(--blue); }
.vt-btn.active.vt-a { background: var(--green);  color: #fff; border-color: var(--green); }
.vt-btn.active.vt-s { background: var(--orange); color: #fff; border-color: var(--orange); }

.viewer-hint {
    margin: 0 16px 12px;
}

.rawi-viewer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 0 16px;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.rawi-col {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
}

.compare-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    color: #fff;
    font-weight: 800;
}

.head-l { background: var(--blue); }
.head-a { background: var(--green); }
.head-s { background: var(--orange); }

.head-tag { font-size: 16px; }

.iframe-full {
    width: 100%;
    flex: 1;
    border: none;
    background: #fff;
}

.kbd-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    margin: 14px 16px 0;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    line-height: 1.7;
}

.kbd-icon {
    font-size: 18px;
    margin-left: 6px;
}

.kbd-hint kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: 'Tajawal', monospace;
    font-weight: 800;
    font-size: 13px;
    color: var(--accent);
    line-height: 1.2;
    text-align: center;
}

/* ===== Manuscripts page ===== */

.ms-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    padding: 8px 0;
}

.ms-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 18px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    text-decoration: none !important;
    color: var(--text);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}

.ms-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    background: var(--surface-hover);
}

.ms-l:hover { border-color: var(--blue); }
.ms-a:hover { border-color: var(--green); }
.ms-s:hover { border-color: var(--orange); }

.ms-name {
    font-size: 22px;
    font-weight: 800;
    white-space: nowrap;
}

.ms-l .ms-name { color: var(--blue); }
.ms-a .ms-name { color: var(--green); }
.ms-s .ms-name { color: var(--orange); }

@media (max-width: 768px) {
    .ms-card { padding: 18px 14px; gap: 10px; }
    .ms-name { font-size: 18px; }
}

/* ===== Thesis page ===== */

.thesis-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    max-width: 680px;
    margin: 0 auto;
    padding: 40px 20px 32px;
}

.file-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 32px;
    padding: 0;
    border-radius: 4px;
    font-family: 'Arial', sans-serif;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    flex-shrink: 0;
    box-sizing: border-box;
}

.file-pdf  { background: #DC2626; font-size: 13px; letter-spacing: 0.4px; }
.file-word { background: #2563EB; font-size: 20px; letter-spacing: 0; }

.thesis-primary,
.thesis-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 18px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    text-decoration: none !important;
    color: var(--text) !important;
    font-weight: 800;
    font-size: 22px;
    box-sizing: border-box;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
}

.thesis-primary:hover,
.thesis-secondary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    background: var(--surface-hover);
    color: var(--text) !important;
    text-decoration: none !important;
}

.thesis-primary:hover { border-color: #DC2626; }
.thesis-secondary:hover { border-color: #2563EB; }

.dl-arrow {
    font-size: 18px;
    line-height: 1;
    color: var(--accent);
    opacity: 0.85;
}

/* ===== Footer ===== */

.footer {
    margin-top: 40px;
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.8;
}

.footer p { margin: 4px 0; }

/* ===== Responsive ===== */

@media (max-width: 1024px) {
    .cards     { grid-template-columns: repeat(3, 1fr); }
    .ms-cards  { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .cards        { grid-template-columns: 1fr; }
    .ms-cards     { grid-template-columns: 1fr; }
    .thesis-actions { grid-template-columns: 1fr; max-width: 360px; }
    .thesis-primary, .thesis-secondary { padding: 18px 14px; gap: 10px; font-size: 18px; }
    .qj-title { display: none; }
    .qj-search { max-width: none; }
    .hero { padding: 24px 16px 20px; }
    .qj-logo { width: 42px; height: 63px; }
    .hero-title { font-size: 44px; line-height: 1.4; }
    .hero-subtitle { font-size: 17px; line-height: 1.65; }
    .hero-text { font-size: 17px; line-height: 1.65; }
    .hero-witnesses { gap: 6px; }
    .witness { font-size: 12px; padding: 4px 10px; }
    .rawi-row { gap: 10px; padding: 10px 12px; }
    .rawi-row-name { font-size: 14px; }
    .rawi-row-num { width: 44px; font-size: 16px; }
}

@media (max-width: 480px) {
    .container { padding: 12px; }
    .rawi-row-witnesses { gap: 4px; }
}

/* ===== Quick-jump a11y controls ===== */

.qj-a11y {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.a11y-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-weight: 800;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.a11y-btn:not(:disabled):hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.a11y-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.a11y-icon { padding: 0; }
.a11y-icon svg { display: block; width: 20px; height: 20px; }

.a11y-theme { font-size: 16px; }

@media (max-width: 480px) {
    .qjbar { gap: 8px; padding: 10px 12px; }
    .qj-a11y { gap: 4px; }
    .a11y-btn { width: 32px; height: 32px; font-size: 12px; }
    .a11y-icon svg { width: 17px; height: 17px; }
    .a11y-theme { font-size: 14px; }
}

/* ===== Download rawi button (in viewer toolbar) ===== */

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 14px;
    margin-inline-start: auto;
    background: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: var(--r-md);
    color: #fff !important;
    font-weight: 800;
    font-size: 13px;
    text-decoration: none !important;
    transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(30, 58, 138, 0.18);
}

.download-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 138, 0.28);
}

.download-btn .dl-icon { font-size: 15px; line-height: 1; }

.download-btn .file-badge {
    width: 38px;
    height: 22px;
    font-size: 11px;
    letter-spacing: 0.3px;
}

@media (max-width: 480px) {
    .download-btn { font-size: 12px; padding: 6px 10px; }
    .download-btn .file-badge { width: 32px; height: 20px; font-size: 10px; }
}

/* ===== Tashkeel (Arabic diacritics) — softened to reduce visual noise ===== */

.tashkeel {
    opacity: 0.5;
}

/* ===== Dark theme ===== */

[data-theme="dark"] {
    --bg: #1F1B17;
    --surface: #2A2520;
    --surface-hover: #38322B;
    --border: #4A4239;

    --text: #F0EAE0;
    --text-muted: #B5AB9D;

    --accent: #A8C0FF;
    --accent-hover: #C4D4FF;

    --blue:   #A8C0FF;
    --green:  #6EE7B7;
    --orange: #FCD34D;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* In dark mode, accent backgrounds are light — text on them must be dark for contrast. */
[data-theme="dark"] .top-btn:hover,
[data-theme="dark"] .nav-btn:not(:disabled):hover,
[data-theme="dark"] .range-btn:hover,
[data-theme="dark"] .a11y-btn:not(:disabled):hover,
[data-theme="dark"] .vt-btn.active.vt-l,
[data-theme="dark"] .vt-btn.active.vt-a,
[data-theme="dark"] .vt-btn.active.vt-s,
[data-theme="dark"] .compare-head,
[data-theme="dark"] .rwc-chip {
    color: #1A1614;
}

[data-theme="dark"] .download-btn,
[data-theme="dark"] .rawis-fullpdf {
    color: #1A1614 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .download-btn:hover,
[data-theme="dark"] .rawis-fullpdf:hover {
    color: #1A1614 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Hint box (yellow on light) → warm amber on dark */
[data-theme="dark"] .hint {
    background: #3A3024;
    border-color: #5A4A30;
    color: #F0DDB6;
}

[data-theme="dark"] .hint strong { color: #FFE9B8; }

[data-theme="dark"] .hint-fullpdf {
    background: transparent;
    border: none;
    color: var(--text-muted);
}

[data-theme="dark"] .hint-fullpdf strong { color: var(--text); }

/* PDF iframes stay on a light backing so the PDF page (white) blends naturally */
[data-theme="dark"] .iframe-full { background: #2A2520; }

/* File badges keep their brand colors but darken text-on-color is unnecessary (white on red/blue is fine) */
[data-theme="dark"] .file-pdf  { background: #DC2626; color: #fff; }
[data-theme="dark"] .file-word { background: #2563EB; color: #fff; }

/* Focus ring color in dark mode */
[data-theme="dark"] #qjInput:focus,
[data-theme="dark"] #search:focus {
    box-shadow: 0 0 0 3px rgba(168, 192, 255, 0.18);
}

/* Keyboard hint kbd keys in dark mode */
[data-theme="dark"] .kbd-hint kbd { color: var(--accent); }
