:root {
    --bg: #000;
    --surface: #fff;
    --muted: #dedcde;
    --text: #3c3a3d;
    --subtext: #666;
    --primary: #0d3323;
    --danger: #d93838;
    --blue: #1769e0;
    --line: rgba(0, 0, 0, .1);
    --soft-primary: rgba(13, 51, 35, .08);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

button,
input {
    font: inherit;
}

button,
a {
    color: inherit;
}

.icon {
    display: block;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-wrapper,
.images-page {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow-y: auto;
    background: #eff5f1;
}

.login-page {
    display: flex;
    min-height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 36px 24px;
    background: #f1f1f1;
    text-align: center;
}

.start-page {
    position: relative;
    display: flex;
    min-height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 30px 22px 34px;
    background:
        radial-gradient(circle at 50% 12%, rgba(255, 255, 255, .08), transparent 34%),
        linear-gradient(180deg, #2f7455 0%, #1f5a41 100%);
    text-align: center;
}

.start-location-action {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    background: rgba(10, 45, 31, .28);
    color: white;
    cursor: pointer;
}

.start-location-action .icon {
    width: 20px;
    height: 20px;
}

.start-card {
    width: 100%;
    display: grid;
    gap: 18px;
    border-radius: 18px;
    padding: 22px;
    background: rgba(10, 45, 31, .86);
    border: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 18px 42px rgba(4, 28, 18, .28);
    text-align: left;
}

.start-art {
    width: 118px;
    max-width: 38vw;
    margin: 2px 0 8px;
    filter: drop-shadow(0 12px 18px rgba(4, 28, 18, .2));
}

.start-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: rgba(255, 255, 255, .92);
    font-size: 14px;
}

.start-time {
    color: white;
    font-size: 42px;
    font-weight: 750;
    letter-spacing: .2px;
    text-align: center;
}

.hijri-date {
    margin-top: -8px;
    color: rgba(255, 255, 255, .86);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.prayer-now,
.next-prayers {
    border-top: 1px solid rgba(255, 255, 255, .08);
    padding-top: 16px;
}

.prayer-now {
    text-align: center;
}

.prayer-now span {
    display: block;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, .88);
    font-size: 13px;
}

.prayer-now strong {
    display: block;
    color: white;
    font-size: 22px;
}

.prayer-now .intaha-time {
    margin-top: 8px;
    font-size: 18px;
}

.next-prayers p {
    margin: 8px 0;
    color: rgba(255, 255, 255, .9);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.4;
    text-align: center;
}

.location-btn {
    display: flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    color: white;
    font-size: 13px;
    font-weight: 750;
}

.start-enter {
    width: min(280px, 86%);
    margin-inline: auto;
}

.welcome-art {
    width: min(220px, 55vw);
    margin-bottom: 28px;
}

.welcome p {
    margin: 0 0 8px;
    font-size: 16px;
}

.welcome h1 {
    margin: 0;
    font-size: 25px;
    font-weight: 500;
}

.continue-btn,
.primary-btn {
    display: flex;
    width: 100%;
    min-height: 80px;
    align-items: center;
    justify-content: space-between;
    border: 0;
    border-radius: 6px;
    padding: 12px 16px;
    background: transparent;
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.primary-btn {
    width: 100%;
    justify-content: center;
}

.start-enter.continue-btn {
    justify-content: space-between;
    border-radius: 15px;
    background: transparent;
    color: white;
    font-weight: 700;
    box-shadow: 0 12px 28px rgba(5, 32, 21, .5);
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    height: 54px;
    min-height: 54px;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 8px rgba(5, 32, 21, .08);
}

.top-bar-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border: 0;
    background: transparent;
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.top-bar-spacer {
    cursor: default;
}

.top-bar-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
    font-weight: 650;
}

.top-actions {
    display: flex;
    align-items: center;
}

.favorite-top.active .icon {
    fill: currentColor;
}

.menu-wrap {
    position: relative;
}

.dropdown {
    position: absolute;
    top: 52px;
    right: 8px;
    display: none;
    min-width: 172px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}

.dropdown.open {
    display: block;
}

.dropdown button {
    display: block;
    width: 100%;
    border: 0;
    padding: 12px 16px;
    background: white;
    text-align: left;
    cursor: pointer;
    color: #2f2f38;
    font-size: 15px;
}

.dropdown button:hover {
    background: #f6f6f8;
}

.cat-list {
    min-height: 90vh;
    padding-bottom: 96px;
    background: linear-gradient(180deg, #edf5f0 0, #f8faf8 240px);
}

.fab-wrap {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 10;
    display: grid;
    justify-items: end;
    gap: 10px;
}

.fab-main {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 24px rgba(5, 32, 21, .28);
    line-height: 1;
}

.fab-main .icon {
    width: 30px;
    height: 30px;
}

.fab-main .fab-x,
.fab-main.open .fab-plus {
    display: none;
}

.fab-main.open .fab-x {
    display: block;
}

.fab-menu {
    display: none;
    gap: 8px;
}

.fab-menu.open {
    display: grid;
}

.fab-menu button {
    display: flex;
    min-width: 118px;
    min-height: 42px;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    border: 1px solid #e2e2e8;
    border-radius: 999px;
    padding: 8px 14px;
    background: white;
    color: var(--primary);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .14);
    font-weight: 700;
}

.fab-menu button.active {
    border-color: var(--primary);
    background: var(--soft-primary);
}

.fab-menu button.danger {
    color: var(--danger);
}

.fab-menu button.active.danger {
    border-color: rgba(217, 56, 56, .4);
    background: rgba(217, 56, 56, .08);
}

.done-mode-btn {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(90px, calc(env(safe-area-inset-bottom) + 90px));
    z-index: 11;
    min-height: 42px;
    border: 0;
    border-radius: 999px;
    padding: 0 22px;
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 24px rgba(5, 32, 21, .24);
    font-weight: 750;
}

.cat-list-wrapper {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cat-list-link {
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .86);
}

.cat-main {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    border: 0;
    background: transparent;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.cat-icon,
.action-icon {
    display: grid;
    width: 62px;
    min-width: 62px;
    height: 62px;
    place-items: center;
    background: #dceee4;
    color: var(--primary);
}

.cat-icon .icon {
    width: 26px;
    height: 26px;
}

.cat-text {
    min-width: 0;
    padding: 0 12px;
}

.cat-text h3 {
    margin: 0;
    overflow: hidden;
    color: #3f3f46;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.3;
}

.cat-text p {
    margin: 2px 0 0;
    overflow: hidden;
    color: #595959;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.3;
}

.action-icon {
    border: 0;
    background: transparent;
    text-decoration: none;
    cursor: pointer;
}

.edit-action {
    color: var(--blue);
}

.delete-action {
    color: var(--danger);
}

.favorite-action.active .icon {
    fill: currentColor;
}

.reorder-actions {
    display: flex;
}

.reorder-actions.hidden {
    display: none;
}

.reorder-actions .action-icon {
    width: 44px;
    min-width: 44px;
}

.hidden {
    display: none;
}

.empty-state {
    padding: 48px 24px;
    color: var(--subtext);
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 20px;
}

.empty-state p {
    margin: 0 auto 18px;
    max-width: 260px;
}

.empty-state .continue-btn {
    margin: 0 auto;
}

.compact-empty {
    padding-block: 28px;
}

.images-page {
    position: relative;
    display: grid;
    grid-template-rows: 1fr;
    background: #04170f;
}

.image-top-bar {
    position: absolute;
    width: 100%;
    background: linear-gradient(180deg, rgba(4, 23, 15, .84), rgba(4, 23, 15, 0));
    box-shadow: none;
    color: white;
}

.image-top-bar .top-bar-icon,
.image-top-bar .top-bar-title {
    color: white;
}

.image-actions {
    display: flex;
    min-width: 92px;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-right: 10px;
}

.gallery-count,
.upload-icon {
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(13, 51, 35, .72);
    color: white;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
}

.gallery-count {
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
}

.upload-icon {
    width: 38px;
    height: 38px;
    font-size: 26px;
}

.slides {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding-top: 10vh;
    scroll-snap-type: y mandatory;
}

.zoom {
    position: relative;
    display: flex;
    height: 100vh;
    height: 100dvh;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    scroll-snap-align: start;
}

.zoom img {
    max-width: 94%;
    max-height: 82%;
    object-fit: contain;
}

.scroll-hint {
    position: absolute;
    top: 72px;
    left: 50%;
    display: flex;
    align-items: center;
    gap: 6px;
    transform: translateX(-50%);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(13, 51, 35, .82);
    color: white;
    font-size: 13px;
    font-weight: 700;
    animation: scroll-hint 1.2s ease-in-out 3;
}

.image-reorder {
    position: absolute;
    top: 72px;
    right: 14px;
    display: grid;
    gap: 8px;
}

.image-reorder.hidden {
    display: none;
}

.gallery-done {
    bottom: max(18px, env(safe-area-inset-bottom));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.image-reorder button,
.read-img-btn {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(13, 51, 35, .78);
    color: white;
}

.share-img-btn,
.del-img-btn {
    position: absolute;
    bottom: 18px;
    display: flex;
    min-width: 88px;
    height: 40px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 999px;
    background: rgba(217, 56, 56, .86);
    color: white;
    font-size: 14px;
    font-weight: 650;
}

.share-img-btn {
    left: 14px;
    background: rgba(13, 51, 35, .86);
}

.del-img-btn {
    right: 14px;
}

.read-img-btn {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
}

.reading-mode .image-top-bar,
.reading-mode .share-img-btn,
.reading-mode .del-img-btn,
.reading-mode .read-img-btn,
.reading-mode .image-reorder,
.reading-mode .scroll-hint {
    display: none;
}

.reading-mode .slides {
    padding-top: 0;
}

.reading-mode .zoom img {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

.empty-gallery {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    color: white;
    text-align: center;
}

.empty-gallery .continue-btn {
    width: min(280px, 80vw);
}

.empty-gallery .continue-btn,
.modal .primary-btn {
    background: var(--primary);
}

.modal {
    width: min(92vw, 360px);
    border: 0;
    border-radius: 10px;
    padding: 0;
}

.modal::backdrop {
    background: rgba(0, 0, 0, .55);
}

.modal-panel {
    position: relative;
    display: grid;
    gap: 16px;
    padding: 22px;
}

.modal-panel h2 {
    margin: 0;
    font-size: 20px;
}

.confirm-panel p {
    margin: 0;
    color: var(--subtext);
    line-height: 1.45;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.ghost-btn,
.danger-btn {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}

.ghost-btn {
    background: #edf2ef;
    color: #173d2b;
}

.danger-btn {
    background: var(--danger);
    color: white;
}

.settings-panel {
    gap: 10px;
}

.settings-row {
    min-height: 44px;
    border: 1px solid #dfe8e2;
    border-radius: 8px;
    padding: 0 14px;
    background: #f8fbf9;
    color: #173d2b;
    text-align: left;
    font-weight: 700;
    cursor: pointer;
}

@keyframes scroll-hint {
    50% {
        transform: translate(-50%, -12px);
    }
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: #edf2ef;
    color: var(--primary);
    cursor: pointer;
}

.modal-close .icon {
    width: 22px;
    height: 22px;
}

.field {
    display: grid;
    gap: 7px;
}

.field span,
.check-field {
    color: var(--subtext);
    font-size: 14px;
}

.field input,
.field select {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 7px;
    padding: 11px 12px;
    background: white;
    font: inherit;
}

.check-field {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 20;
    max-width: min(340px, 90vw);
    transform: translate(-50%, 20px);
    border-radius: 999px;
    padding: 11px 16px;
    background: rgba(30, 30, 35, .94);
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: .2s ease;
}

.toast.show {
    transform: translate(-50%, 0);
    opacity: 1;
}

@media (min-width: 992px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .app-wrapper,
    .images-page {
        width: 375px;
        height: 667px;
        max-height: 92vh;
        box-shadow: 1px 2px 10px 3px rgba(0, 0, 0, .15);
    }

    .slides,
    .zoom {
        height: 667px;
        max-height: 92vh;
    }
}
