html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    overscroll-behavior-x: none;
    overscroll-behavior-y: none;
    -webkit-overflow-scrolling: auto;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fb 0%, #eef2f7 100%);
    color: #1c2742;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    width: 100%;
    padding: 10px 18px;        
    background: linear-gradient(135deg, #ffffff, #f3f6ff);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    border-radius: 0 0 16px 16px;
    box-sizing: border-box;
}

.logo-row {
    display: flex;
    align-items: center;
    gap: 10px;                 
}

.logo-icon {
    width: 34px;               
    height: 34px;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.07);
}

.app-title {
    font-size: 20px;          
    font-weight: 700;
    color: #0d1b3d;
    margin: 0;
    letter-spacing: -0.2px;
}



.subhead {
    margin: 8px 0 0;
    color: #4a5672;
}

.wizard {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 12px 16px 24px;
    flex: 1 1 auto;
    height: calc(100vh - 120px); 
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    gap: 12px;
    min-height: 0;
}

.steps-indicator {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 0 auto 16px;
    width: 100%;
    max-width: 720px;
}

.step-dot {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #dfe7ff;
    color: #1c2742;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px #c5d3ff;
    cursor: pointer;
    font-size: 15px;
    padding: 0 12px;
}

.step-dot.active {
    background: #1d5bff;
    color: #fff;
    box-shadow: 0 8px 18px rgba(29, 91, 255, 0.25);
}

.step-card {
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 14px 36px rgba(12, 25, 75, 0.08);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 12px;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    flex: 1 1 auto;
    height: auto;
    max-height: calc(100vh - 140px);
}

.step-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
    padding-bottom: 16px;
    max-height: calc(100vh - 260px);
}

#step-1 .tile-grid {
    overflow: visible;
    max-height: none;
    padding-right: 4px;
}
#step-1 .step-scroll {
    margin-bottom: 8px;
}
#step-2 .step-scroll {
}

/* Mobile-friendly sizing */
@media (max-width: 640px) {
    .wizard {
        height: calc(100vh - 90px);
        overflow: hidden;
    }
    .step-card {
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }
    .step-scroll {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    /* Hide bottom buttons on mobile; navigation via top tabs */
    #step-1 .step-actions,
    #step-2 .step-actions {
        display: none;
    }
    .tile {
        padding: 10px;
        font-size: 14px;
    }
    /* Hide right-swipe button (V) on mobile */
    #swipe-right-btn,
    .play-right .alt-right {
        display: none !important;
    }
}

.step-header {
    margin-bottom: 12px;
}


.step-header span {
    font-size: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #6c7aa0;
}

.step-header h2 {
    margin: 6px 0 6px;
    font-size: 21px;
    font-weight: 700;
    color: #0f213f;
    letter-spacing: 0.2px;
    padding-left: 0;
}

.step-header p {
    margin: 0 0 12px;
    color: #4a5672;
}

.step-title-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.step-title-row.triple {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 8px;
}

.reciter-inline {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid #d3dcf5;
    border-radius: 8px;
    background: #f8f9ff;
    cursor: pointer;
    font-weight: 500;
    color: #1c2742;
    min-height: 0;
    line-height: 1.2;
    font-size: 13px;
}

.reciter-inline:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.fab-reveal {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e5cff, #1446c7);
    border: 1px solid rgba(12, 45, 150, 0.18);
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 28px rgba(20, 70, 199, 0.28), 0 3px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    z-index: 20;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    margin: 12px auto 6px;
}

.fab-reveal:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 14px 32px rgba(20, 70, 199, 0.32), 0 4px 10px rgba(0, 0, 0, 0.1);
    filter: brightness(1.03);
}

.fab-reveal:active {
    transform: scale(0.95);
    box-shadow: 0 6px 14px rgba(20, 70, 199, 0.28);
}


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

.info-icon {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    position: relative;
}

.info-icon .info-tooltip {
    position: absolute;
    top: 110%;
    left: 0;
    color: #0d1b3d;
    padding: 8px 10px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border: 2px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    white-space: normal;
    min-width: 220px;
    max-width: 420px;
    font-size: 13px;
    line-height: 1.4;
    text-transform: none;
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
}

.info-icon:hover .info-tooltip,
.info-icon:focus-visible .info-tooltip {
    opacity: 1;
    transform: translateY(0);
}
.step-header .reciter-chip {
    margin-top: 0;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    gap: 12px;
}

.tile {
    background: #f4f5f7;
    border: 1px solid #d7dce5;
    border-radius: 12px;
    box-sizing:border-box;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, border 0.15s ease, color 0.15s ease;
    font-weight: 600;
    color: #1c2742;
}

.tile:hover {
    background: #eef3ff;
    border-color: #c5d3ff;
}

.tile.selected {
    border-color: #1d5bff;
    background: #e9f0ff;
    color: #0f2f87;
    box-sizing: border-box;
    box-shadow: none;
}

.pill-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
    gap: 8px;
    width: 100%;
    max-height: calc(100vh - 340px); 
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.pill {
    padding: 8px 12px;
    border: 1px solid #d3d8e1;
    border-radius: 12px;
    background: #fafbfc;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    word-break: break-word;
    box-sizing: border-box;
    max-width: 100%;
    color: #22304f;
}

.pill.selected {
    background: #e6f1ff;
    border-color: #1d5bff;
    color: #0f2f87;
}

.pill:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.step-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

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

.action-top,
.action-bottom {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    gap: 10px;
    align-items: center;
    position: relative;
    padding: 0 12px;
}

.action-top.reciter-row {
    position: relative;
}

.action-top.reciter-row .primary {
    margin: 0 auto;
    min-width: 180px;
}

.action-top.reciter-row .reciter-chip {
    position: absolute;
    right: 0;
}

.action-bottom .fab-reveal {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.play-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.swipe-alternatives {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.swipe-alternatives button {
    min-width: 44px;
    height: 44px;
    padding: 10px;
    font-size: 18px;
    border-radius: 10px;
}

.swipe-alternatives .alt-left {
    border: 1px solid #d3dce5;
    color: inherit;
}

.swipe-alternatives .alt-right {
    border: 1px solid #d3dce5;
    color: inherit;
}

.swipe-alternatives .alt-left:hover {
    color: #e53e3e;
}

.swipe-alternatives .alt-right:hover {
    color: #1b8d68;
}

@media (max-width: 640px) {
    .steps-indicator {
        width: 100%;
    }
    .step-dot {
        height: 36px;
        font-size: 14px;
    }
    .swipe-alternatives {
        display: none;
    }
    .action-top.reciter-row {
        flex-direction: column;
        gap: 8px;
        position: static;
        align-items: stretch;
    }
    .action-top.reciter-row .primary {
        margin: 0;
        width: 100%;
    }
    .action-top.reciter-row .reciter-chip {
        position: static;
        width: 100%;
        justify-content: center;
        text-align: center;
        margin: 0;
        padding: 8px 12px;
        box-sizing: border-box;
    }
}

button {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary {
    background: #1d5bff;
    color: #fff;
    box-shadow: 0 10px 24px rgba(29, 91, 255, 0.25);
}

.primary:hover:not(:disabled) {
    background: #0c4ae6;
}

/* New Verse button styled like the reveal fab */
#new-verse-btn {
    background: linear-gradient(145deg, #1e5cff, #1446c7);
    border: 1px solid rgba(12, 45, 150, 0.18);
    box-shadow: 0 12px 28px rgba(20, 70, 199, 0.28), 0 3px 8px rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    font-size: 15px;
    padding: 12px 20px;
    min-width: 180px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

#new-verse-btn:hover:not(:disabled) {
    filter: brightness(1.03);
    box-shadow: 0 14px 32px rgba(20, 70, 199, 0.32), 0 4px 10px rgba(0, 0, 0, 0.1);
}

#new-verse-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 8px 18px rgba(20, 70, 199, 0.26);
}

.secondary {
    background: #edf1ff;
    color: #1c2742;
    border: 1px solid #d3dcf5;
}

.secondary:hover:not(:disabled) {
    background: #e3e9ff;
}

.ghost {
    background: #fff;
    border: 1px solid #d3dcf5;
    color: #1c2742;
}

.ghost:hover:not(:disabled) {
    background: #eef3ff;
}

.play-compact {
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.1;
}

.ayah {
    font-size: 24px;
    margin: 0 0 6px;
    color: #333;
    line-height: 2;
    direction: rtl;
    text-align: center;
}

.verse-key {
    font-size: 16px;
    color: #4a5672;
    margin-top: -2px;
    text-align: center;
}

.ayah-list {
    max-width: 100%;
    margin-top: 10px;
    margin-bottom: 14px;
    max-height: 360px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    touch-action: auto;
    transition: transform 0.2s ease, opacity 0.2s ease;
    will-change: transform, opacity;
    user-select: none;
}

.ayah-list.dragging {
    border-color: transparent;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    transition: none;
}

.ayah-list.swipe-left {
    border: 3px solid #e53e3e;
    box-shadow: 0 0 14px 2px rgba(229, 62, 62, 0.45);
}

.ayah-list.swipe-right {
    border: 3px solid #21a179;
    box-shadow: 0 0 14px 2px rgba(33, 161, 121, 0.45);
}

.ayah-list.swipe-left-anim {
    transform: translateX(-160%) rotate(-6deg);
    opacity: 0;
}

.ayah-list.swipe-right-anim {
    transform: translateX(160%) rotate(6deg);
    opacity: 0;
}

/* Prevent iOS swipe-back / overscroll interference */
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow-x: hidden;
    overflow: hidden;
    overscroll-behavior-x: none;
    -webkit-overflow-scrolling: auto;
}

#ayah-list {
    touch-action: pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: auto;
}

.ayah-card {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.ayah-card {
    padding: 12px;
    margin-bottom: 12px;
    background-color: #f9f9f9;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    position: relative;
    will-change: transform, opacity;
}

.ayah-card.slide-in {
    animation: ayahSlideIn 0.28s ease;
    animation-fill-mode: both;
}

@keyframes ayahSlideIn {
    0% {
        transform: translateY(-12px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.ayah-card.searching {
    background: linear-gradient(120deg, #eef3ff 25%, #f8f9ff 50%, #eef3ff 75%);
    background-size: 200% 200%;
    border: 1px dashed #b5c7ff;
    position: relative;
    overflow: hidden;
    animation: shimmer 1.2s ease-in-out infinite;
}

.ayah-card.searching .ayah,
.ayah-card.searching .verse-key {
    color: #1c2742;
}

.ayah-card.selected {
    border: 1.5px solid rgba(12, 45, 150, 0.6);
    box-shadow: 0 10px 22px rgba(20, 70, 199, 0.25), 0 4px 10px rgba(0, 0, 0, 0.08);
    background: linear-gradient(180deg, #fefeff 0%, #f5f8ff 100%);
}

.ayah-card.dragging.swipe-left {
    border-color: #e53e3e;
    box-shadow: 0 12px 24px rgba(229, 62, 62, 0.25);
}

.ayah-card.dragging.swipe-right {
    border-color: #21a179;
    box-shadow: 0 12px 24px rgba(33, 161, 121, 0.25);
}

.ayah-card.dragging {
    transition: none !important;
    cursor: grabbing;
    box-shadow: 0 12px 24px rgba(12, 25, 75, 0.22);
}

.ayah-card.swipe-right {
    transform: translateX(140%) rotate(8deg);
    opacity: 0;
}

.ayah-card.swipe-left {
    transform: translateX(-140%) rotate(-8deg);
    opacity: 0;
}

.ayah-card:last-child {
    margin-bottom: 0;
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.reciter-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border: 1px solid #d3dcf5;
    border-radius: 12px;
    background: #f8f9ff;
    cursor: pointer;
    font-weight: 600;
    color: #1c2742;
    margin-top: 8px;
    align-self: flex-end;
}

.reciter-chip:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    width: min(520px, 90vw);
    max-height: 80vh;
    box-shadow: 0 14px 36px rgba(12, 25, 75, 0.25);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal .small {
    padding: 4px 8px;
    font-size: 12px;
}

.close-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
    cursor: pointer;
}

.reciter-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.reciter-item {
    padding: 10px 12px;
    border: 1px solid #e1e6f0;
    border-radius: 10px;
    background: #f9f9fb;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reciter-item:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.reciter-item.selected {
    border-color: #1d5bff;
    background: #e6f1ff;
    color: #0f2f87;
    box-shadow: 0 6px 12px rgba(29, 91, 255, 0.12);
}

.modal-open .hero,
.modal-open .wizard {
    filter: blur(3px);
}

@media (max-width: 640px) {
    .step-header {
        margin-bottom: 4px;
    }
    .wizard {
        padding: 4px 12px 8px;
    }
    .modal-content {
        width: 85vw;
        max-height: 75vh;
        padding: 12px;
    }
    .tile-grid {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
    .pill-list {
        grid-template-columns: 1fr;
    }
    .pill {
        width: 100%;
        text-align: center;
    }
    .controls {
        flex-direction: column;
    }
    .step-actions {
        flex-direction: column;
        align-items: stretch;
    }
    button {
        width: 100%;
    }
    .action-top.reciter-row {
        flex-direction: column;
        gap: 8px;
        position: static;
        align-items: stretch;
    }
    .action-top.reciter-row .primary {
        margin: 0;
        width: 100%;
    }
    .action-top.reciter-row .reciter-chip {
        position: static;
        width: 100%;
        justify-content: center;
        text-align: center;
        margin: 0;
        padding: 8px 12px;
        box-sizing: border-box;
    }
}
