.tawafuq-hero{
    padding:20px 22px;
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(460px,720px);
    gap:18px;
    align-items:center;
    margin-bottom:16px;
    background:linear-gradient(135deg,rgba(255,250,240,.96),rgba(255,240,205,.9));
}

.tawafuq-kicker{
    display:inline-flex;
    background:#fff;
    border:1px solid rgba(185,138,47,.32);
    color:#8e5d22;
    border-radius:999px;
    padding:7px 12px;
    font-weight:900;
    margin-bottom:8px;
}

.tawafuq-hero h2{
    margin:0;
    color:#5b3a18;
    font-size:34px;
    font-weight:900;
}

.tawafuq-hero p{
    margin:8px 0 0;
    color:#746956;
    font-size:16px;
    line-height:1.8;
}

.tawafuq-form{
    display:grid;
    gap:12px;
}

.tawafuq-search-line{
    display:flex;
    gap:10px;
    background:#fff;
    border:2px solid rgba(185,138,47,.28);
    border-radius:22px;
    padding:8px;
    box-shadow:0 12px 26px rgba(80,52,18,.10);
}

.tawafuq-search-line input{
    width:100%;
    border:0;
    outline:0;
    background:transparent;
    padding:14px;
    font-size:25px;
    font-weight:900;
    color:#5b3a18;
    font-family:Tajawal,Arial,sans-serif;
}

.tawafuq-search-line button{
    border:0;
    border-radius:16px;
    padding:13px 18px;
    min-width:155px;
    background:linear-gradient(135deg,#8e5d22,#c99a3e);
    color:#fff;
    font-weight:900;
    font-family:Tajawal,Arial,sans-serif;
    cursor:pointer;
}

.tawafuq-filters{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:9px;
}

.tawafuq-filters label{
    display:grid;
    gap:5px;
    background:rgba(255,255,255,.72);
    border:1px solid rgba(91,58,24,.18);
    border-radius:16px;
    padding:9px 10px;
}

.tawafuq-filters span{
    font-size:12px;
    color:#746956;
    font-weight:900;
}

.tawafuq-filters select,
.tawafuq-filters input{
    border:0;
    background:transparent;
    outline:0;
    font-size:15px;
    color:#5b3a18;
    font-weight:900;
    font-family:Tajawal,Arial,sans-serif;
}

.tawafuq-shell{
    display:grid;
    grid-template-columns:430px minmax(0,1fr);
    gap:16px;
    align-items:start;
    margin-bottom:16px;
}

.tawafuq-mushaf-panel{
    position:sticky;
    top:124px;
}

.tawafuq-mushaf-frame{
    position:relative;
    min-height:650px;
    background:#efe0bc;
    border-top:1px solid rgba(91,58,24,.14);
    border-bottom:1px solid rgba(91,58,24,.14);
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    padding:12px;
}

.tawafuq-mushaf-img{
    display:block;
    width:100%;
    max-height:780px;
    object-fit:contain;
    border-radius:14px;
    box-shadow:0 12px 30px rgba(80,52,18,.18);
}

.tawafuq-page-label{
    position:absolute;
    top:18px;
    left:18px;
    background:rgba(0,0,0,.72);
    color:#fff;
    border-radius:999px;
    padding:7px 12px;
    font-weight:900;
    font-size:13px;
}

.tawafuq-mushaf-tools{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
    padding:12px;
}

.tawafuq-mushaf-tools button{
    border:1px solid rgba(91,58,24,.18);
    background:#fff8e8;
    color:#5b3a18;
    border-radius:13px;
    padding:10px 12px;
    font-weight:900;
    cursor:pointer;
    font-family:Tajawal,Arial,sans-serif;
}

.tawafuq-page-list-wrap{
    padding:12px;
    border-bottom:1px solid rgba(91,58,24,.12);
    background:#fffaf0;
}

.tawafuq-page-list{
    display:flex;
    gap:8px;
    overflow:auto;
    padding-bottom:4px;
}

.tw-page-pill{
    flex:0 0 auto;
    min-width:82px;
    border:1px solid rgba(91,58,24,.18);
    background:#fff;
    border-radius:14px;
    padding:8px 10px;
    display:grid;
    gap:3px;
    text-align:center;
    cursor:pointer;
    font-family:Tajawal,Arial,sans-serif;
}

.tw-page-pill b{
    color:#5b3a18;
    font-size:19px;
    font-weight:900;
}

.tw-page-pill span{
    color:#746956;
    font-size:12px;
    font-weight:900;
}

.tw-page-pill em{
    font-style:normal;
    background:#eee;
    border-radius:999px;
    padding:2px 7px;
    font-size:12px;
    font-weight:900;
}

.tw-page-pill.active{
    background:linear-gradient(135deg,#8e5d22,#c99a3e);
    color:#fff;
}

.tw-page-pill.active b,
.tw-page-pill.active span{
    color:#fff;
}

.tw-page-pill.active em{
    background:rgba(255,255,255,.22);
    color:#fff;
}

.tawafuq-pages-empty{
    color:#746956;
    font-weight:900;
    padding:8px;
}

.tawafuq-grid-wrap{
    padding:18px;
    overflow:auto;
}

.tawafuq-grid{
    direction:rtl;
    display:grid;
    grid-template-columns:repeat(9, minmax(46px, 1fr));
    grid-auto-rows:46px;
    gap:7px;
    background:#f2f2f2;
    border:1px solid rgba(0,0,0,.08);
    padding:14px;
    border-radius:18px;
    min-width:520px;
}

.tw-cell{
    border:0;
    background:#bfbfbf;
    color:#777;
    border-radius:3px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:900;
    font-size:17px;
    cursor:pointer;
    transition:.16s;
    font-family:Tajawal,Arial,sans-serif;
}

.tw-cell:hover{
    transform:scale(1.04);
    box-shadow:0 8px 18px rgba(0,0,0,.12);
}

.tw-cell.has-hit{
    background:#d9d9d9;
    color:#555;
}

.tw-cell.has-hit span{
    display:flex;
    align-items:center;
    justify-content:center;
    width:26px;
    height:26px;
    border-radius:50%;
    background:#fff;
    color:#333;
    box-shadow:0 4px 10px rgba(0,0,0,.12);
}

.tw-cell.strong-hit span{
    background:#111;
    color:#fff;
}

.tw-cell.selected{
    outline:3px solid #b3342c;
    outline-offset:2px;
    background:#f2d7d2;
}

.tawafuq-loading{
    grid-column:1/-1;
    padding:40px;
    text-align:center;
    font-weight:900;
    color:#746956;
    direction:rtl;
}

.tawafuq-loading.error{
    color:#9b2b1f;
}

.tawafuq-details-panel{
    margin-bottom:16px;
}

.tawafuq-details{
    padding:14px;
}

.tawafuq-cell-summary{
    display:flex;
    align-items:center;
    gap:14px;
    background:#fff8e8;
    border:1px solid rgba(91,58,24,.18);
    border-radius:16px;
    padding:13px 15px;
    margin-bottom:12px;
}

.tawafuq-cell-summary b{
    width:48px;
    height:48px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    background:#b3342c;
    color:#fff;
    font-size:24px;
    font-weight:900;
}

.tawafuq-cell-summary span{
    color:#5b3a18;
    font-weight:900;
}

.tawafuq-hit-list{
    display:grid;
    gap:10px;
}

.tawafuq-hit-card{
    background:#fffdf7;
    border:1px solid rgba(91,58,24,.16);
    border-radius:18px;
    padding:14px;
}

.tw-hit-head{
    display:flex;
    justify-content:space-between;
    gap:10px;
    flex-wrap:wrap;
    margin-bottom:8px;
}

.tw-hit-head strong{
    color:#5b3a18;
    font-weight:900;
}

.tw-hit-head span{
    color:#746956;
    font-weight:900;
    font-size:13px;
}

.tw-word-row{
    display:flex;
    flex-wrap:wrap;
    gap:7px;
    margin-bottom:8px;
}

.tw-word-row span{
    background:#fff8e8;
    border:1px solid rgba(91,58,24,.12);
    border-radius:999px;
    padding:5px 9px;
    color:#746956;
    font-size:13px;
    font-weight:900;
}

.tw-word-row b{
    color:#5b3a18;
}

.tw-ayah-text{
    font-family:Amiri,serif;
    font-size:25px;
    line-height:2;
    color:#1f1a12;
    margin-top:8px;
}

.tw-actions{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-top:10px;
}

.tw-actions a{
    border:1px solid rgba(91,58,24,.18);
    background:#fff8e8;
    color:#5b3a18;
    border-radius:12px;
    padding:8px 11px;
    font-size:13px;
    font-weight:900;
}

@media(max-width:1200px){
    .tawafuq-hero,
    .tawafuq-shell{
        grid-template-columns:1fr;
    }

    .tawafuq-mushaf-panel{
        position:relative;
        top:auto;
    }

    .tawafuq-mushaf-frame{
        min-height:520px;
    }
}

@media(max-width:760px){
    .tawafuq-search-line{
        flex-direction:column;
    }

    .tawafuq-search-line button{
        width:100%;
    }

    .tawafuq-filters{
        grid-template-columns:1fr;
    }

    .tawafuq-grid{
        grid-template-columns:repeat(9, 42px);
        grid-auto-rows:42px;
        min-width:450px;
    }

    .tw-ayah-text{
        font-size:22px;
    }
}



.tw-search-mark{
    color:#d10000;
    background:rgba(255,0,0,.10);
    border-bottom:2px solid #d10000;
    padding:0 3px;
    border-radius:4px;
    font-weight:900;
}

.tw-image-box{
    position:relative;
    width:100%;
    display:flex;
    align-items:center;
    justify-content:center;
}

.tw-mushaf-overlay{
    position:absolute;
    inset:0;
    pointer-events:none;
}

.tw-mushaf-hit{
    position:absolute;
    transform:translate(-50%,-50%);
    width:30px;
    height:30px;
    border:2px solid rgba(210,0,0,.88);
    background:rgba(255,0,0,.18);
    color:#b00000;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    pointer-events:auto;
    box-shadow:0 0 0 4px rgba(255,0,0,.10), 0 8px 18px rgba(0,0,0,.18);
    transition:.18s;
    font-family:Tajawal,Arial,sans-serif;
    z-index:5;
}

.tw-mushaf-hit span{
    background:#fff;
    color:#b00000;
    width:22px;
    height:22px;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:12px;
    font-weight:900;
}

.tw-mushaf-hit:hover,
.tw-mushaf-hit.selected{
    background:rgba(255,0,0,.35);
    border-color:#ff0000;
    transform:translate(-50%,-50%) scale(1.18);
    z-index:9;
}

.tw-mushaf-hit.selected span{
    background:#d10000;
    color:#fff;
}

.tawafuq-hit-card.active{
    border-color:rgba(209,0,0,.55);
    background:linear-gradient(135deg,#fffdf7,#fff0ee);
    box-shadow:0 14px 30px rgba(209,0,0,.10);
}

.tw-cell.has-hit{
    position:relative;
}

.tw-cell.has-hit::after{
    content:attr(data-count);
    display:none;
}

.tw-cell.selected span{
    background:#d10000;
    color:#fff;
}

.tawafuq-cell-summary b{
    background:#d10000;
}

.tawafuq-grid{
    grid-template-columns:repeat(9, 70px);
    grid-auto-rows:70px;
    gap:10px;
    background:#fff;
    border:0;
    padding:10px;
    border-radius:0;
    min-width:max-content;
}

.tw-cell{
    background:#c9c9c9;
    border-radius:0;
    color:#8d8d8d;
    font-size:0;
    box-shadow:none;
}

.tw-cell strong{
    font-size:27px;
    line-height:1;
    font-weight:900;
    color:#8c8c8c;
}

.tw-cell.has-hit{
    background:#c9c9c9;
}

.tw-cell.has-hit strong{
    color:#858585;
}

.tw-cell.strong-hit strong{
    color:#222;
}

.tw-cell.selected{
    outline:3px solid #d10000;
    outline-offset:2px;
    background:#ead3cf;
}

.tw-cell.selected strong{
    color:#d10000;
}

.tw-cell.has-hit span{
    display:none;
}

.tawafuq-page-list{
    display:grid;
    grid-template-columns:repeat(2, minmax(220px, 1fr));
    gap:12px;
    overflow:visible;
}

.tw-side-pill{
    border:1px solid rgba(91,58,24,.18);
    background:#fff;
    border-radius:22px;
    padding:18px 20px;
    min-height:110px;
    display:grid;
    gap:8px;
    align-content:center;
    text-align:center;
    cursor:pointer;
    font-family:Tajawal,Arial,sans-serif;
    box-shadow:0 10px 24px rgba(80,52,18,.08);
}

.tw-side-pill b{
    color:#5b3a18;
    font-size:25px;
    font-weight:900;
}

.tw-side-pill span{
    color:#746956;
    font-size:16px;
    font-weight:900;
}

.tw-side-pill em{
    justify-self:center;
    min-width:140px;
    font-style:normal;
    background:#eee;
    border-radius:999px;
    padding:7px 14px;
    color:#333;
    font-size:15px;
    font-weight:900;
}

.tw-side-pill.active{
    background:linear-gradient(135deg,#8e5d22,#c99a3e);
    color:#fff;
}

.tw-side-pill.active b,
.tw-side-pill.active span{
    color:#fff;
}

.tw-side-pill.active em{
    background:rgba(255,255,255,.22);
    color:#fff;
}

.tw-mushaf-hit.single{
    width:26px;
    height:26px;
    border-radius:50%;
    background:rgba(209,0,0,.20);
    border:2px solid #d10000;
    box-shadow:0 0 0 6px rgba(209,0,0,.12), 0 0 18px rgba(209,0,0,.35);
}

.tw-mushaf-hit.single span{
    width:18px;
    height:18px;
    font-size:11px;
    background:#d10000;
    color:#fff;
}







/* ===== Final responsive fixes for Tawafuq page ===== */

.tawafuq-map-panel,
.tawafuq-mushaf-panel,
.tawafuq-details-panel{
    min-width:0;
}

.tawafuq-grid-wrap{
    width:100%;
    max-width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
}

.tawafuq-grid{
    direction:rtl !important;
    grid-template-columns:repeat(9, clamp(34px, 7vw, 70px)) !important;
    grid-auto-rows:clamp(34px, 7vw, 70px) !important;
    width:max-content;
    min-width:0 !important;
    max-width:none;
}

.tw-cell strong{
    font-size:clamp(15px, 4vw, 27px);
}

.tw-mushaf-hit.single{
    width:clamp(20px, 5vw, 26px);
    height:clamp(20px, 5vw, 26px);
}

.tw-mushaf-hit.single span{
    width:clamp(15px, 4vw, 18px);
    height:clamp(15px, 4vw, 18px);
    font-size:clamp(9px, 2.6vw, 11px);
}

@media(max-width:1200px){
    .tawafuq-hero,
    .tawafuq-shell{
        grid-template-columns:1fr !important;
    }

    .tawafuq-mushaf-panel{
        position:relative;
        top:auto;
    }

    .tawafuq-mushaf-frame{
        min-height:auto;
    }

    .tawafuq-mushaf-img{
        max-height:none;
        width:100%;
    }
}

@media(max-width:760px){
    .tawafuq-hero{
        padding:16px 14px;
    }

    .tawafuq-hero h2{
        font-size:27px;
    }

    .tawafuq-hero p{
        font-size:14px;
        line-height:1.7;
    }

    .tawafuq-search-line{
        flex-direction:column;
        border-radius:18px;
    }

    .tawafuq-search-line input{
        font-size:19px;
        padding:11px;
    }

    .tawafuq-search-line button{
        width:100%;
        min-width:0;
    }

    .tawafuq-filters{
        grid-template-columns:1fr !important;
    }

    .tawafuq-page-list{
        grid-template-columns:1fr !important;
    }

    .tw-side-pill{
        min-height:86px;
        padding:13px 14px;
        border-radius:18px;
    }

    .tw-side-pill b{
        font-size:21px;
    }

    .tw-side-pill span{
        font-size:14px;
    }

    .tw-side-pill em{
        font-size:13px;
        min-width:110px;
        padding:6px 12px;
    }

    .tawafuq-grid-wrap{
        padding:12px;
    }

    .tawafuq-mushaf-frame{
        padding:8px;
    }

    .tawafuq-page-label{
        top:10px;
        left:10px;
        font-size:11px;
        padding:5px 9px;
    }

    .tw-hit-head{
        display:grid;
        gap:5px;
    }

    .tw-ayah-text{
        font-size:21px;
        line-height:2;
    }

    .tw-actions a{
        width:100%;
        text-align:center;
    }
}

@media(max-width:420px){
    .tawafuq-hero h2{
        font-size:24px;
    }

    .tawafuq-search-line input{
        font-size:17px;
    }

    .tawafuq-grid{
        grid-template-columns:repeat(9, 32px) !important;
        grid-auto-rows:32px !important;
        gap:6px;
        padding:8px;
    }

    .tw-cell strong{
        font-size:14px;
    }

    .tawafuq-cell-summary{
        align-items:flex-start;
    }

    .tawafuq-cell-summary b{
        width:40px;
        height:40px;
        font-size:20px;
        flex:0 0 auto;
    }
}


.tw-mushaf-hit.tw-word-shadow{
    position:absolute;
    transform:none !important;
    background:rgba(210, 0, 0, .18) !important;
    border:0 !important;
    outline:0 !important;
    box-shadow:none !important;
    border-radius:7px;
    padding:0 !important;
    min-width:0 !important;
    min-height:0 !important;
    pointer-events:none;
}

.tw-mushaf-hit.tw-word-shadow::before,
.tw-mushaf-hit.tw-word-shadow::after,
.tw-mushaf-hit.tw-word-shadow span{
    display:none !important;
}

.tw-search-mark{
    background:rgba(210, 0, 0, .12) !important;
    color:#d00000 !important;
    border:0 !important;
    outline:0 !important;
    box-shadow:none !important;
    border-radius:5px;
    padding:0 3px;
    font-weight:900;
}


/* توسيع شبكة التوافق لتملأ المساحة */
#twGrid{
    width:100% !important;
    max-width:none !important;
    display:grid !important;
    grid-template-columns:repeat(9, minmax(0, 1fr)) !important;
    gap:8px !important;
    align-items:stretch !important;
}

/* المربعات نفسها تتمدد حسب عرض الشبكة */
#twGrid .tw-cell{
    width:100% !important;
    height:auto !important;
    aspect-ratio:1 / 1 !important;
    min-width:0 !important;
    min-height:0 !important;
    border-radius:0 !important;
}

/* الرقم جوه المربع يفضل في النص */
#twGrid .tw-cell strong{
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    height:100%;
}