@font-face {
    font-family: 'digitalkhaat-v2';
    src: url('assets/fonts/DigitalKhattV2.otf') format('opentype');
    font-style: normal;
    font-weight: 800;
    font-display: swap;
}

/* Allow reuse of reader shell inside annotation-detail */
.detail-reader-shell {
    --reader-ink: #161813;
    --reader-muted: #6c7368;
    --reader-line: rgba(29, 38, 31, 0.12);
    --reader-paper: #fffdf4;
    --reader-bg: #eef2e8;
    --reader-green: #1f5c46;
    --reader-blue: #2b4f82;
    --reader-red: #9f3e39;
    --reader-gold: #a77d2e;
    min-height: 0;
    background: transparent;
    width: min(1480px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-areas: 'rail main';
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 2rem;
    padding: 0;
    align-items: start;
}

html {
    scroll-behavior: smooth;
}

body[data-page="quran-reader"] {
    --reader-ink: #161813;
    --reader-muted: #6c7368;
    --reader-line: rgba(29, 38, 31, 0.12);
    --reader-paper: #fffdf4;
    --reader-bg: #eef2e8;
    --reader-green: #1f5c46;
    --reader-blue: #2b4f82;
    --reader-red: #9f3e39;
    --reader-gold: #a77d2e;
    min-height: 100dvh;
    color: var(--reader-ink);
    background:
        radial-gradient(circle at top left, rgba(31, 92, 70, 0.12), transparent 34%),
        radial-gradient(circle at 84% 8%, rgba(43, 79, 130, 0.08), transparent 26%),
        linear-gradient(180deg, #f7f8f2 0%, var(--reader-bg) 100%);
    background-attachment: scroll;
    position: relative;
    overflow-x: clip;
    color-scheme: light;
}

body[data-page="quran-reader"]::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(22, 24, 19, 0.03) 1px, transparent 1px 128px),
        linear-gradient(180deg, rgba(22, 24, 19, 0.025) 1px, transparent 1px 128px);
    opacity: 0.45;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 92%);
}

body[data-page="quran-reader"]::after {
    content: '';
    position: fixed;
    inset: auto -10vw -14vh auto;
    width: min(42rem, 85vw);
    height: min(42rem, 85vw);
    pointer-events: none;
    background: radial-gradient(circle, rgba(31, 92, 70, 0.08), transparent 68%);
    filter: blur(18px);
    opacity: 0.8;
}

body[data-page="quran-reader"] button:focus-visible,
body[data-page="quran-reader"] a:focus-visible,
body[data-page="quran-reader"] input:focus-visible {
    outline: 3px solid rgba(43, 79, 130, 0.24);
    outline-offset: 2px;
}

.reader-shell {
    width: min(1480px, 100%);
    min-height: 100dvh;
    margin: 0 auto;
    padding: 0.85rem 0.85rem 1.25rem;
    display: grid;
    grid-template-areas:
        'main'
        'rail';
    gap: 0.9rem;
    position: relative;
    z-index: 1;
}

.reader-control-rail {
    grid-area: rail;
    display: grid;
    gap: 0.9rem;
    align-content: start;
}

.reader-logo-link {
    width: clamp(56px, 12vw, 78px);
    display: inline-flex;
    align-self: start;
    border-radius: 18px;
    padding: 0.2rem;
}

.reader-brand-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.reader-account-area {
    min-width: 0;
    display: grid;
    justify-items: end;
    gap: 0.45rem;
}

.reader-auth-status {
    color: var(--reader-muted);
    font: 800 0.72rem var(--font-ui);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.reader-auth-status a,
.reader-authenticated-indicator {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--reader-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    color: var(--reader-green);
    text-decoration: none;
}

.reader-authenticated-indicator::before {
    content: '';
    width: 0.45rem;
    height: 0.45rem;
    margin-right: 0.38rem;
    border-radius: 50%;
    background: var(--reader-green);
    box-shadow: 0 0 0 3px rgba(31, 92, 70, 0.13);
}

.reader-auth-nav {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.reader-auth-nav[hidden] {
    display: none;
}

.reader-auth-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 1.85rem;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    background: rgba(31, 92, 70, 0.08);
    color: var(--reader-green);
    font: 800 0.68rem var(--font-ui);
    letter-spacing: 0.035em;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.reader-auth-nav a:hover {
    color: #fff;
    background: var(--reader-green);
    transform: translateY(-1px);
}

.reader-logo {
    width: 100%;
    height: auto;
    display: block;
    filter: drop-shadow(0 10px 20px rgba(26, 34, 27, 0.12));
}

.reader-panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(29, 38, 31, 0.12);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 253, 244, 0.9));
    box-shadow: 0 18px 42px rgba(35, 47, 38, 0.08);
    border-radius: 1.3rem;
    padding: 1rem;
    backdrop-filter: blur(14px);
}

.reader-panel::before,
.mushaf-page::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--reader-green), var(--reader-gold), var(--reader-blue));
    opacity: 0.9;
}

.reader-nav-panel,
.reader-review-panel {
    display: grid;
    gap: 0.95rem;
    animation: readerRise 0.7s ease both;
}

.reader-detail-meta {
    display: grid;
    gap: 0.35rem;
}

.reader-detail-meta > label {
    color: var(--reader-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.reader-nav-panel {
    animation-delay: 0.04s;
}

.reader-mobile-review-link,
.reader-mobile-back-link,
.reader-mobile-recitation-dock {
    display: none;
}

.reader-review-panel {
    animation-delay: 0.12s;
}

.reader-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--reader-green);
}

.reader-panel h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 2.9rem);
    line-height: 0.95;
    letter-spacing: -0.03em;
    color: var(--reader-ink);
    text-wrap: balance;
}

.reader-page-meta,
.reader-review-state {
    margin: 0.4rem 0 0;
    color: var(--reader-muted);
    line-height: 1.5;
    font-size: 0.95rem;
}

.reader-page-jump {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 0.6rem;
    align-items: end;
}

.reader-icon-button,
.reader-primary-button,
.reader-secondary-button {
    appearance: none;
    border: 1px solid var(--reader-line);
    background: rgba(255, 255, 255, 0.96);
    color: var(--reader-ink);
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font: 800 0.92rem var(--font-ui);
    cursor: pointer;
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.reader-icon-button,
.reader-page-input-label input {
    border-radius: 0.95rem;
}

.reader-primary-button,
.reader-secondary-button {
    border-radius: 999px;
    padding: 0 1rem;
    box-shadow: 0 10px 22px rgba(31, 92, 70, 0.06);
}

.reader-icon-button svg,
.reader-primary-button svg,
.reader-secondary-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.reader-icon-button:hover:not(:disabled),
.reader-primary-button:hover:not(:disabled),
.reader-secondary-button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(31, 92, 70, 0.36);
    box-shadow: 0 14px 28px rgba(31, 92, 70, 0.08);
}

.reader-icon-button:disabled,
.reader-primary-button:disabled,
.reader-secondary-button:disabled,
.reader-page-input-label input:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.reader-page-input-label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.72rem;
    color: var(--reader-muted);
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.reader-page-input-label input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--reader-line);
    background: rgba(255, 255, 255, 0.98);
    color: var(--reader-ink);
    padding: 0 0.8rem;
    font: 800 1rem var(--font-ui);
    font-variant-numeric: tabular-nums;
}

.reader-page-input-label input::-webkit-outer-spin-button,
.reader-page-input-label input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.reader-page-input-label input[type='number'] {
    -moz-appearance: textfield;
}

.reader-review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.reader-review-head .reader-kicker {
    margin: 0;
}

.reader-review-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
}

.reader-vad-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.75rem;
    padding: 0.28rem 0.62rem;
    border: 1px solid rgba(31, 92, 70, 0.22);
    border-radius: 999px;
    background: rgba(31, 92, 70, 0.09);
    color: var(--reader-forest);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.reader-review-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.reader-source-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.reader-source-picker legend {
    margin-bottom: 0.45rem;
    color: var(--reader-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.reader-source-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    padding: 0.28rem;
    border: 1px solid var(--reader-line);
    border-radius: 0.85rem;
    background: rgba(248, 245, 236, 0.72);
}

.reader-source-option {
    position: relative;
    cursor: pointer;
}

.reader-source-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.reader-source-option span {
    display: grid;
    min-height: 38px;
    place-items: center;
    border-radius: 0.62rem;
    color: var(--reader-muted);
    font-size: 0.78rem;
    font-weight: 800;
    transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.reader-source-option input:checked + span {
    background: #fffdf8;
    color: var(--reader-green);
    box-shadow: 0 2px 10px rgba(35, 47, 38, 0.09);
}

.reader-source-option input:focus-visible + span {
    outline: 2px solid var(--reader-gold);
    outline-offset: 2px;
}

.reader-source-option:has(input:disabled) {
    cursor: not-allowed;
    opacity: 0.55;
}

.reader-vad-duration {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--reader-line);
    border-radius: 0.85rem;
    background: rgba(248, 245, 236, 0.72);
}

.reader-vad-duration > span:first-child {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

.reader-vad-duration strong {
    color: var(--reader-ink);
    font-size: 0.78rem;
    font-weight: 800;
}

.reader-vad-duration small {
    color: var(--reader-muted);
    font-size: 0.67rem;
    line-height: 1.3;
}

.reader-select-wrap {
    position: relative;
    flex: 0 0 100px;
}

.reader-select-wrap select {
    width: 100%;
    min-height: 38px;
    appearance: none;
    border: 1px solid rgba(31, 92, 70, 0.2);
    border-radius: 0.62rem;
    background: #fffdf8;
    color: var(--reader-green);
    cursor: pointer;
    padding: 0 1.75rem 0 0.65rem;
    font: 800 0.75rem var(--font-ui);
    font-variant-numeric: tabular-nums;
}

.reader-select-wrap select:focus-visible {
    outline: 2px solid var(--reader-gold);
    outline-offset: 2px;
}

.reader-select-wrap select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.reader-select-wrap svg {
    position: absolute;
    top: 50%;
    right: 0.55rem;
    width: 15px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--reader-green);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    pointer-events: none;
}

.reader-upload-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.55rem;
    padding: 0.65rem;
    border: 1px dashed rgba(31, 92, 70, 0.28);
    border-radius: 0.85rem;
    background: rgba(31, 92, 70, 0.045);
}

.reader-upload-panel[hidden] {
    display: none;
}

.reader-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.reader-file-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 36px;
    padding: 0 0.65rem;
    border: 1px solid rgba(31, 92, 70, 0.2);
    border-radius: 0.62rem;
    background: #fffdf8;
    color: var(--reader-green);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 800;
}

.reader-file-button svg {
    width: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.reader-file-name {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--reader-muted);
    font-size: 0.72rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-primary-button {
    background: linear-gradient(180deg, var(--reader-green), #184936);
    border-color: rgba(31, 92, 70, 0.9);
    color: #fffdf8;
}

.reader-secondary-button {
    background: linear-gradient(180deg, #fffaf4, #fff5ef);
    border-color: rgba(159, 62, 57, 0.18);
    color: var(--reader-red);
}

.reader-save-status {
    margin: 0.15rem 0 0;
    padding: 0.55rem 0.7rem;
    border-radius: 0.85rem;
    font: 700 0.84rem var(--font-ui);
    line-height: 1.35;
    display: none;
}

.reader-save-status-saving {
    color: var(--reader-blue);
    background: rgba(43, 79, 130, 0.08);
}

.reader-save-status-saved {
    color: var(--reader-green);
    background: rgba(31, 92, 70, 0.1);
}

.reader-save-status-error {
    color: var(--reader-red);
    background: rgba(159, 62, 57, 0.1);
    cursor: pointer;
}

.reader-review-panel .fc-ready-badge {
    background: rgba(167, 125, 46, 0.12);
    border: 1px solid rgba(167, 125, 46, 0.22);
    color: #7c5c19;
    box-shadow: none;
}

.reader-review-panel .fc-live-badge {
    background: rgba(31, 92, 70, 0.1);
    border: 1px solid rgba(31, 92, 70, 0.18);
    color: var(--reader-green);
}

.reader-review-panel .fc-processing-badge {
    background: rgba(43, 79, 130, 0.08);
    border: 1px solid rgba(43, 79, 130, 0.16);
    color: var(--reader-blue);
}

.reader-review-panel .fc-done-badge {
    background: rgba(31, 92, 70, 0.1);
    border: 1px solid rgba(31, 92, 70, 0.16);
    color: var(--reader-green);
}

.reader-review-panel .fc-live-badge .live-dot {
    background: var(--reader-green);
}

.reader-review-panel .fc-spinner {
    border-top-color: var(--reader-gold);
}

.reader-main {
    grid-area: main;
    min-width: 0;
    display: grid;
    place-items: start center;
}

.mushaf-page {
    position: relative;
    width: 100%;
    max-width: 1040px;
    min-height: 68svh;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(29, 38, 31, 0.12);
    border-radius: 1.5rem;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 250, 0.98), rgba(255, 252, 244, 0.94)),
        var(--reader-paper);
    box-shadow:
        0 24px 70px rgba(35, 47, 38, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.76);
    animation: readerRise 0.75s ease both;
    animation-delay: 0.1s;
}

.mushaf-page-header,
.mushaf-page-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    color: var(--reader-muted);
    font-size: 0.73rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(248, 245, 236, 0.84);
    backdrop-filter: blur(8px);
}

.mushaf-page-header {
    border-bottom: 1px solid rgba(29, 38, 31, 0.1);
}

.mushaf-page-footer {
    border-top: 1px solid rgba(29, 38, 31, 0.1);
    margin-top: auto;
}

.mushaf-page-header span,
.mushaf-page-footer span {
    min-width: 0;
}

.mushaf-page-header span:last-child,
.mushaf-page-footer span:last-child {
    text-align: right;
}

.mushaf-text {
    flex: 1;
    padding: clamp(1.1rem, 3.8vw, 2.45rem);
    font-family: 'digitalkhaat-v2';
    direction: rtl;
    text-align: justify;
    text-align-last: center;
    color: #10140f;
    line-height: 2.2;
    font-size: clamp(1.42rem, 4.2vw, 2.15rem);
    word-spacing: 0.06em;
    letter-spacing: 0;
    text-wrap: pretty;
}

.reader-loading {
    color: var(--reader-muted);
    font: 700 1rem var(--font-ui);
    text-align: center;
}

.mushaf-surah-break {
    margin: 1.1rem 0 0.7rem;
    display: grid;
    gap: 0.45rem;
    text-align: center;
    text-align-last: center;
}

.mushaf-surah-name {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.7vw, 1.65rem);
    font-weight: 700;
    color: var(--reader-blue);
    border-block: 1px solid rgba(43, 79, 130, 0.2);
    padding: 0.42rem 0.55rem;
    letter-spacing: 0.01em;
}

.mushaf-bismillah {
    font-size: clamp(1.25rem, 3vw, 1.7rem);
    color: var(--reader-green);
}

.mushaf-ayah {
    display: inline;
}

.mushaf-ayah.is-current {
    background: rgba(43, 79, 130, 0.09);
    border-radius: 0.45rem;
    box-shadow: inset 0 0 0 1px rgba(43, 79, 130, 0.18);
}

.mushaf-ayah-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.85em;
    height: 1.85em;
    margin: 0 0.2em;
    border: 1px solid rgba(167, 125, 46, 0.42);
    border-radius: 999px;
    color: var(--reader-gold);
    background: rgba(255, 255, 250, 0.82);
    font-family: var(--font-ui);
    font-size: 0.52em;
    font-weight: 800;
    vertical-align: middle;
}

.mushaf-text .word {
    display: inline;
    border-radius: 0.35rem;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        opacity 0.2s ease,
        box-shadow 0.15s ease;
}

.mushaf-text .word-pending {
    color: inherit;
    font-weight: inherit;
}

.mushaf-text .word-correct {
    color: #1e293b;
    background: rgba(31, 92, 70, 0.15);
    box-shadow: inset 0 0 0 1px rgba(31, 92, 70, 0.1);
}

.mushaf-text .word-error {
    color: #c2413b;
    background: rgba(159, 62, 57, 0.07);
}

.mushaf-text .word-missing {
    color: #d97706;
    background: rgba(217, 119, 6, 0.08);
}

.mushaf-text .word-possible-skip {
    color: #967a2e;
    background: rgba(167, 125, 46, 0.08);
}

.mushaf-text .word-skip {
    color: #967a2e;
    background: rgba(167, 125, 46, 0.12);
    text-decoration: line-through;
    text-decoration-color: rgba(150, 122, 46, 0.85);
    text-decoration-thickness: 2px;
}

.mushaf-text .word-not-recited {
    color: #a09a91;
}

.mushaf-text .word-frontier {
    background: #fbf1d8;
    border-radius: 0.4rem;
    outline: 1.5px solid rgba(167, 125, 46, 0.68);
}

.reader-stream-raw {
    margin: 0;
    min-height: 2.75rem;
    padding: 0.7rem 0.8rem;
    border: 1px dashed rgba(29, 38, 31, 0.18);
    border-radius: 1rem;
    background: rgba(255, 255, 250, 0.65);
    color: var(--reader-ink);
    font-size: 0.93rem;
    line-height: 1.55;
    direction: rtl;
    text-align: right;
    word-break: break-word;
}

.reader-stream-raw:empty::before {
    content: 'Waiting for recitation...';
    color: var(--reader-muted);
    font-style: italic;
}

.reader-stream-raw .fc-transcript-range {
    display: grid;
    gap: 0.15rem;
    margin-bottom: 0.55rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.65rem;
    background: rgba(29, 38, 31, 0.055);
}

.reader-stream-raw .fc-transcript-range strong {
    color: var(--reader-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.035em;
    direction: ltr;
    text-align: left;
    text-transform: uppercase;
}

.reader-stream-raw .fc-transcript-before span {
    color: var(--reader-muted);
}

.reader-stream-raw .fc-transcript-preface span {
    color: var(--reader-blue);
}

.reader-asr-responses {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
    padding: 0.8rem;
    border: 1px solid rgba(43, 79, 130, 0.2);
    border-radius: 1rem;
    background: #18211d;
    color: #eff5eb;
}

.reader-asr-responses[hidden] {
    display: none;
}

.reader-asr-responses-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.reader-asr-response-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.reader-asr-response-mode {
    appearance: none;
    min-height: 1.75rem;
    padding: 0.2rem 0.48rem;
    border: 1px solid rgba(188, 217, 189, 0.28);
    border-radius: 999px;
    background: transparent;
    color: #d9eed7;
    font: 800 0.67rem var(--font-ui);
    letter-spacing: 0.04em;
    cursor: pointer;
}

.reader-asr-response-mode:hover,
.reader-asr-response-mode[aria-pressed="true"] {
    background: rgba(188, 217, 189, 0.16);
}

.reader-asr-responses .reader-kicker {
    margin-bottom: 0.2rem;
    color: #bcd9bd;
}

.reader-asr-responses h2 {
    margin: 0;
    color: inherit;
    font: 700 1rem var(--font-ui);
}

.reader-asr-response-count {
    min-width: 1.75rem;
    padding: 0.22rem 0.45rem;
    border-radius: 999px;
    background: rgba(188, 217, 189, 0.16);
    color: #d9eed7;
    font: 800 0.72rem var(--font-ui);
    text-align: center;
}

.reader-asr-response-log {
    max-height: 16rem;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(239, 245, 235, 0.13);
    border-radius: 0.7rem;
    background: rgba(0, 0, 0, 0.22);
}

.reader-asr-response-entry {
    margin: 0;
    padding: 0.7rem;
    border-bottom: 1px solid rgba(239, 245, 235, 0.1);
    color: #eff5eb;
    font: 0.78rem/1.5 var(--font-ui);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    unicode-bidi: plaintext;
    direction: ltr;
    text-align: left;
}

.reader-asr-response-entry:last-child {
    border-bottom: 0;
}

.reader-asr-response-entry.is-raw {
    font: 0.72rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
}

.reader-asr-response-meta,
.reader-asr-response-field {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.65rem;
}

.reader-asr-response-meta {
    margin-bottom: 0.42rem;
    color: #bcd9bd;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.reader-asr-response-meta span {
    color: rgba(239, 245, 235, 0.56);
    font-weight: 700;
}

.reader-asr-response-field {
    padding: 0.18rem 0;
}

.reader-asr-response-label {
    flex: 0 0 auto;
    color: rgba(239, 245, 235, 0.56);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.reader-asr-response-text {
    min-width: 0;
    color: #eff5eb;
    text-align: right;
}

.reader-asr-response-field.is-primary .reader-asr-response-text {
    color: #fff;
    font-family: 'Noto Sans Arabic', var(--font-ui), sans-serif;
    font-size: 0.98rem;
    font-weight: 700;
}

.reader-audio-review {
    display: grid;
    gap: 0.45rem;
    padding-top: 0.15rem;
}

.reader-audio-review span {
    color: var(--reader-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.reader-audio-review audio {
    width: 100%;
    min-height: 40px;
}

@keyframes readerRise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 760px) {
    .reader-shell {
        padding: 1rem 1rem 1.35rem;
        gap: 1.1rem;
    }

    .reader-panel,
    .mushaf-page {
        border-radius: 1.4rem;
    }
}

@media (min-width: 1080px) {
    body[data-page="quran-reader"] {
        background-attachment: fixed;
    }

    .reader-shell {
        grid-template-areas: 'rail main';
        grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
        align-items: start;
        gap: 1.35rem;
        padding: 1.15rem 1.15rem 1.65rem;
    }

    .reader-control-rail {
        position: sticky;
        top: 1.15rem;
        align-self: start;
    }

    .reader-main {
        padding-top: 0.15rem;
    }

    .mushaf-page {
        min-height: calc(100dvh - 2.8rem);
    }
}

@media (min-width: 1360px) {
    .reader-shell {
        grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
        gap: 1.5rem;
    }

    .reader-main {
        padding-right: 0.3rem;
    }
}

@media (max-width: 759px) {
    .reader-shell {
        grid-template-areas:
            'brand'
            'nav'
            'main'
            'review';
        grid-template-columns: minmax(0, 1fr);
        padding: 0.5rem 0.5rem calc(6.5rem + env(safe-area-inset-bottom));
        gap: 0.6rem;
    }

    .reader-shell > .reader-control-rail {
        display: contents;
    }

    .reader-shell > .reader-control-rail > .reader-brand-row {
        grid-area: brand;
    }

    .reader-shell > .reader-control-rail > .reader-nav-panel {
        grid-area: nav;
    }

    .reader-shell > .reader-control-rail > .reader-review-panel {
        grid-area: review;
    }

    .reader-shell > .reader-main {
        grid-area: main;
    }

    .reader-brand-row {
        align-items: center;
        min-height: 2.2rem;
        padding-inline: 0.2rem;
    }

    .reader-logo-link {
        width: 42px;
        border-radius: 12px;
    }

    .reader-auth-status a,
    .reader-authenticated-indicator {
        min-height: 1.9rem;
        padding: 0.25rem 0.52rem;
        font-size: 0.66rem;
    }

    .reader-account-area {
        gap: 0.28rem;
    }

    .reader-auth-nav {
        gap: 0.25rem;
    }

    .reader-auth-nav a {
        min-height: 1.8rem;
        padding: 0.25rem 0.5rem;
        font-size: 0.64rem;
    }

    .reader-panel {
        padding: 0.85rem;
    }

    .reader-nav-panel {
        position: sticky;
        top: calc(0.35rem + env(safe-area-inset-top));
        z-index: 30;
        grid-template-areas: 'identity jump action';
        grid-template-columns: minmax(58px, 0.7fr) minmax(0, 1.6fr) auto;
        align-items: center;
        gap: 0.45rem;
        padding: 0.52rem;
        border-radius: 1rem;
        background: rgba(255, 253, 246, 0.94);
        box-shadow:
            0 12px 30px rgba(25, 33, 27, 0.14),
            inset 0 1px 0 rgba(255, 255, 255, 0.82);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }

    .reader-nav-panel::before {
        height: 3px;
    }

    .reader-page-identity {
        grid-area: identity;
        min-width: 0;
        padding-left: 0.18rem;
    }

    .reader-page-identity .reader-kicker {
        display: none;
    }

    .reader-page-identity .reader-page-meta {
        margin-top: 0.16rem;
        overflow: hidden;
        font-size: 0.67rem;
        line-height: 1.15;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .reader-page-jump {
        grid-area: jump;
        grid-template-columns: 42px minmax(56px, 72px) 42px;
        gap: 0.28rem;
        align-items: center;
    }

    .reader-icon-button,
    .reader-page-input-label input {
        min-height: 42px;
        border-radius: 0.72rem;
    }

    .reader-page-input-label {
        display: block;
    }

    .reader-page-input-label > span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .reader-page-input-label input {
        padding-inline: 0.35rem;
        text-align: center;
    }

    .reader-mobile-review-link {
        grid-area: action;
        width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.78rem;
        background: var(--reader-green);
        color: #fffdf8;
        text-decoration: none;
        box-shadow: 0 8px 18px rgba(31, 92, 70, 0.2);
    }

    .reader-mobile-review-link svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .reader-mobile-review-link span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .reader-mobile-back-link {
        width: fit-content;
        display: inline-flex;
        align-items: center;
        min-height: 38px;
        margin-bottom: -0.2rem;
        padding: 0 0.75rem;
        border-radius: 999px;
        background: rgba(31, 92, 70, 0.08);
        color: var(--reader-green);
        font-size: 0.75rem;
        font-weight: 800;
        text-decoration: none;
    }

    .reader-mobile-back-link::before {
        content: '↑';
        margin-right: 0.35rem;
        font-size: 0.9rem;
    }

    .reader-review-panel {
        position: static;
        max-width: none;
        margin: 0.25rem 0 0;
        border-radius: 1rem;
        box-shadow: 0 12px 30px rgba(25, 33, 27, 0.09);
        scroll-margin-top: 5rem;
    }

    .reader-mobile-recitation-dock {
        position: fixed;
        left: 50%;
        bottom: calc(0.5rem + env(safe-area-inset-bottom));
        z-index: 60;
        width: min(calc(100% - 1rem), 520px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) 48px;
        gap: 0.45rem;
        padding: 0.48rem;
        border: 1px solid rgba(29, 38, 31, 0.14);
        border-radius: 1.15rem;
        background: rgba(255, 253, 246, 0.94);
        box-shadow:
            0 18px 48px rgba(20, 31, 24, 0.24),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
        transform: translateX(-50%);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }

    .reader-mobile-action-button,
    .reader-mobile-dock-settings {
        min-height: 50px;
        border: 0;
        border-radius: 0.85rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.55rem;
        font: 800 0.9rem var(--font-ui);
    }

    .reader-mobile-action-button {
        background: linear-gradient(180deg, var(--reader-green), #184936);
        color: #fffdf8;
        cursor: pointer;
        box-shadow: 0 8px 20px rgba(31, 92, 70, 0.2);
    }

    .reader-mobile-action-button[data-mode='stop'] {
        background: linear-gradient(180deg, #a64740, #87342f);
        box-shadow: 0 8px 20px rgba(159, 62, 57, 0.22);
    }

    .reader-mobile-action-button:disabled {
        cursor: not-allowed;
        opacity: 0.52;
        box-shadow: none;
    }

    .reader-mobile-action-button svg,
    .reader-mobile-dock-settings svg {
        width: 20px;
        height: 20px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2.1;
        stroke-linecap: round;
        stroke-linejoin: round;
        flex: 0 0 auto;
    }

    .reader-mobile-action-stop-icon {
        display: none;
    }

    .reader-mobile-action-button[data-mode='stop'] .reader-mobile-action-start-icon {
        display: none;
    }

    .reader-mobile-action-button[data-mode='stop'] .reader-mobile-action-stop-icon {
        display: block;
    }

    .reader-mobile-dock-settings {
        color: var(--reader-green);
        background: rgba(31, 92, 70, 0.09);
        border: 1px solid rgba(31, 92, 70, 0.13);
        text-decoration: none;
    }

    .reader-review-panel .reader-review-head {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .reader-review-panel .reader-review-state {
        margin-top: 0.15rem;
        font-size: 0.84rem;
    }

    .reader-review-panel .reader-review-actions {
        display: none;
    }

    .reader-review-panel .reader-primary-button,
    .reader-review-panel .reader-secondary-button {
        min-height: 46px;
        padding-inline: 0.7rem;
        font-size: 0.82rem;
    }

    .reader-source-options {
        min-height: 44px;
    }

    .reader-vad-duration {
        padding: 0.6rem 0.65rem;
    }

    .reader-upload-panel {
        grid-template-columns: minmax(0, 1fr);
    }

    .reader-file-button {
        justify-content: center;
        min-height: 42px;
    }

    .reader-file-name {
        text-align: center;
    }

    .reader-panel h1 {
        font-size: 1.08rem;
        line-height: 1;
        letter-spacing: -0.02em;
    }

    .mushaf-page {
        min-height: calc(100svh - 6rem);
        border-radius: 0.9rem;
        scroll-margin-top: 5rem;
    }

    .mushaf-page-header {
        position: relative;
        top: auto;
        z-index: 1;
    }

    .mushaf-text {
        font-size: clamp(1.52rem, 6.7vw, 1.92rem);
        line-height: 2.16;
        padding: 1.05rem 0.72rem 1.4rem;
        text-align: right;
        text-align-last: center;
    }

    .mushaf-page-header {
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 0.6rem 0.75rem;
        font-size: 0.66rem;
        background: rgba(248, 245, 236, 0.94);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
    }

    .mushaf-page-header span:last-child {
        text-align: right;
    }

    .mushaf-page-footer {
        display: none;
    }

    .reader-stream-raw:empty::before {
        content: '';
    }
}

@media (max-width: 390px) {
    .reader-nav-panel {
        grid-template-columns: minmax(48px, 0.55fr) minmax(0, 1.7fr) 42px;
        gap: 0.3rem;
    }

    .reader-page-jump {
        grid-template-columns: 39px minmax(46px, 1fr) 39px;
        gap: 0.22rem;
    }

    .reader-icon-button,
    .reader-page-input-label input {
        min-height: 40px;
    }

    .reader-mobile-review-link {
        width: 42px;
        min-height: 42px;
    }

    .reader-vad-duration {
        align-items: flex-start;
    }

    .reader-vad-duration small {
        max-width: 12rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-nav-panel,
    .reader-review-panel,
    .mushaf-page,
    .reader-icon-button,
    .reader-primary-button,
    .reader-secondary-button,
    .mushaf-text .word {
        animation: none;
        transition: none;
    }

    html {
        scroll-behavior: auto;
    }
}
