:root {
    --bg-deep: #070e17;
    --panel-bg: #101926;
    --panel-border: #1e2c40;
    --gold: #f59e0b;
    --blue: #38bdf8;
    --emerald: #10b981;
    --text-main: #f8fafc;
    --text-sub: #8896a6;
    --border-purple: #1e2c40;
    --selected-border: #10b981;
}

body.light-mode {
    --bg-deep: #f8fafc;
    --panel-bg: #ffffff;
    --panel-border: #cbd5e1;
    --text-main: #0f172a;
    --text-sub: #64748b;
    --border-purple: #cbd5e1;
    --selected-border: #059669;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Myanmar", sans-serif;
    transition: background 0.2s, border-color 0.2s;
}

body {
    min-height: 100vh;
    background: var(--bg-deep);
    color: var(--text-main);
    padding: 16px 14px calc(240px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.back-link {
    color: var(--text-sub);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.back-link:hover { color: var(--blue); }

.tab-segmented-container {
    display: flex;
    background: #0b1420;
    border: 1px solid var(--border-purple);
    border-radius: 14px;
    padding: 4px;
    gap: 6px;
}

body.light-mode .tab-segmented-container {
    background: #e2e8f0;
}

.tab-segmented-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-sub);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.tab-segmented-btn.active {
    background: #1e293b;
    color: #ffffff;
}

body.light-mode .tab-segmented-btn.active {
    background: #ffffff;
    color: #0f172a;
}

.book-list-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Clickable Novel Book Card */
.novel-meta-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 18px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.novel-meta-card:hover {
    transform: translateY(-2px);
    border-color: var(--blue);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2);
}

.novel-meta-card.opened {
    border-color: var(--emerald);
    background: rgba(16, 185, 129, 0.04);
}

.meta-cover-img {
    width: 84px;
    height: 114px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}

.meta-title-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.meta-novel-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.25;
}
body.light-mode .meta-novel-name { color: #0f172a; }

.meta-access-label {
    font-size: 0.86rem;
    color: var(--text-sub);
    font-weight: 600;
}

.meta-choose-tag {
    font-size: 0.88rem;
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-weight: 700;
}

.meta-arrow-icon {
    font-size: 1.2rem;
    color: var(--text-sub);
    transition: transform 0.25s ease, color 0.2s ease;
}

.novel-meta-card.opened .meta-arrow-icon {
    transform: rotate(90deg);
    color: var(--emerald);
}

/* Editions Section */
#editions-selection-section {
    display: none;
    flex-direction: column;
    gap: 14px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Currency Selector Header Row */
.selection-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 4px 0 2px;
}

.section-selection-label {
    font-size: 1.12rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.3;
}
body.light-mode .section-selection-label { color: #0f172a; }

.currency-switch-box {
    display: inline-flex;
    align-items: center;
    background: #09121d;
    border: 1px solid var(--border-purple);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}
body.light-mode .currency-switch-box { background: #e2e8f0; }

.currency-pill-btn {
    border: none;
    background: transparent;
    color: var(--text-sub);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.currency-pill-btn.active {
    background: var(--blue);
    color: #070e17;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.4);
}

.edition-card-option {
    background: var(--panel-bg);
    border: 1.5px solid var(--panel-border);
    border-radius: 16px;
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.2s ease;
}

.edition-card-option:hover {
    border-color: rgba(56, 189, 248, 0.45);
}

.edition-card-option.selected {
    border-color: var(--selected-border);
    background: rgba(16, 185, 129, 0.05);
}

.edition-radio-icon {
    font-size: 1.3rem;
    color: #475569;
    margin-top: 2px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.edition-card-option.selected .edition-radio-icon {
    color: var(--selected-border);
}

.edition-content-wrap {
    flex: 1;
    min-width: 0;
}

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

.edition-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}
body.light-mode .edition-name { color: #0f172a; }

.discount-badge-pill {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
}

.edition-subname {
    font-size: 0.84rem;
    color: var(--text-sub);
    margin: 3px 0 8px;
}

.edition-price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.price-kyats {
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}
body.light-mode .price-kyats { color: #0f172a; }

.price-stars-meta {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-sub);
}

.edition-strike-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.85rem;
}

.strike-price {
    color: #64748b;
    text-decoration: line-through;
    font-weight: 600;
}

.percent-off-tag {
    color: var(--blue);
    font-weight: 700;
}

/* Fixed Bottom Checkout Bar */
.bottom-checkout-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(9, 18, 29, 0.98);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-purple);
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    display: none;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.65);
}
body.light-mode .bottom-checkout-panel {
    background: rgba(255, 255, 255, 0.98);
}

.checkout-inner-wrap {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkout-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}

.summary-label-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-label-col .label-title {
    color: var(--text-sub);
    font-size: 0.86rem;
    font-weight: 600;
}

.summary-label-col .label-total {
    color: #ffffff;
    font-weight: 800;
    font-size: 1.05rem;
}
body.light-mode .summary-label-col .label-total { color: #0f172a; }

.summary-value-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.summary-value-col .pkg-name {
    color: #cbd5e1;
    font-weight: 700;
    font-size: 0.88rem;
}
body.light-mode .summary-value-col .pkg-name { color: #334155; }

.summary-value-col .total-amt {
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
}
body.light-mode .summary-value-col .total-amt { color: #0f172a; }

.btn-confirm-buy {
    width: 100%;
    padding: 13px;
    background: #34d399;
    color: #064e3b;
    border: none;
    border-radius: 12px;
    font-size: 1.08rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-confirm-buy:hover {
    background: #10b981;
    color: #ffffff;
}

/* Pop-up Modal UI */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    backdrop-filter: blur(5px);
}

.modal-card-box {
    background: #0f1826;
    border: 1px solid #1e2c40;
    border-radius: 20px;
    max-width: 440px;
    width: 100%;
    padding: 22px 20px 18px;
    color: var(--text-main);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    position: relative;
}

.modal-header-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-header-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header-title i {
    color: #34d399;
    font-size: 1.1rem;
}

.modal-close-icon {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.modal-close-icon:hover { color: #f8fafc; }

.modal-instruction-text {
    font-size: 0.88rem;
    color: var(--text-sub);
    margin-bottom: 16px;
}

.modal-novel-summary-card {
    background: #152233;
    border: 1px solid #20334c;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.modal-novel-title-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
}

.modal-novel-badge-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-pkg-pill {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
}

.modal-access-text {
    font-size: 0.82rem;
    color: #94a3b8;
    font-weight: 600;
}

.modal-price-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-price-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.modal-price-label {
    font-size: 0.95rem;
    color: #94a3b8;
    font-weight: 600;
}

.modal-amount-val {
    font-size: 1.55rem;
    font-weight: 800;
    color: #34d399;
    letter-spacing: -0.02em;
}

.modal-stars-val {
    font-size: 1.1rem;
    font-weight: 800;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-stars-val i {
    font-size: 1rem;
    color: #94a3b8;
}

.modal-methods-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 10px;
}

.modal-methods-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.pay-method-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #1e2c40;
    background: #131d2b;
    text-decoration: none;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pay-method-card.card-stars {
    background: #0f2420;
    border: 1.5px solid #10b981;
}

.pay-method-card:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.pay-method-info {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.pay-method-info i.method-icon {
    font-size: 1.25rem;
    color: #94a3b8;
}

.pay-method-card.card-stars .pay-method-info i.method-icon {
    color: #34d399;
}

.pay-method-text-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pay-method-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
}

.pay-method-sub {
    font-size: 0.78rem;
    color: #94a3b8;
}

.pay-method-arrow {
    font-size: 0.95rem;
    color: #64748b;
}

.pay-method-card.card-stars .pay-method-arrow {
    color: #34d399;
}

.modal-cancel-text-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    text-align: center;
    padding: 8px 0;
    margin-top: 4px;
}
.modal-cancel-text-btn:hover { color: #f8fafc; }

/* Purchased Box Card */
.purchased-box-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-top-header { display: flex; gap: 16px; align-items: center; }
.card-cover-art { width: 86px; height: 120px; border-radius: 14px; object-fit: cover; flex-shrink: 0; }
.card-title-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-novel-title { font-size: 1.25rem; font-weight: 800; color: var(--blue); }
.badge-full-tag { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); padding: 3px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; }
.card-divider-line { height: 1px; background: rgba(255, 255, 255, 0.08); }
.section-heading-row { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; font-weight: 800; }
.btn-read-main { width: 100%; padding: 13px; background: #10b981; color: #fff; border: none; border-radius: 12px; font-weight: 700; cursor: pointer; }

.empty-box {
    text-align: center; padding: 42px 20px; background: var(--panel-bg);
    border: 1px dashed var(--panel-border); border-radius: 14px; color: var(--text-sub);
}
/* Mobile purchase modal sizing and scrolling fix.
   Keeps the original cards, colors, typography, and purchase controls. */
.modal-overlay {
    padding: max(10px, env(safe-area-inset-top, 0px))
             10px max(10px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    overscroll-behavior: contain;
}
.modal-card-box {
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.modal-header-line {
    position: sticky;
    top: -1px;
    z-index: 2;
    background: #0f1826;
    padding: 4px 0 10px;
}
.modal-header-title { min-width: 0; line-height: 1.4; overflow-wrap: anywhere; }
.modal-header-title span { min-width: 0; }
.modal-close-icon { flex: 0 0 auto; min-width: 32px; min-height: 32px; }
.modal-options-scroll {
    max-height: min(250px, 29dvh);
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}
.modal-opt-title { gap: 8px; }
.modal-opt-title span:first-child { min-width: 0; overflow-wrap: anywhere; }
.modal-opt-prices { flex-wrap: wrap; }
body:has(#buy-choice-modal[style*="display: flex"]) { overflow: hidden; }
@media (max-width: 480px) {
    .modal-card-box {
        padding: 15px 15px 13px;
        border-radius: 17px;
    }
    .modal-header-title { font-size: 1.05rem; }
    .modal-instruction-text { margin-bottom: 10px; }
    .modal-options-scroll { margin: 8px 0 12px; }
    .modal-opt-card { padding: 10px 12px; }
    .modal-price-table { gap: 9px; margin-bottom: 13px; }
    .modal-amount-val { font-size: clamp(1.13rem, 5vw, 1.4rem); }
    .modal-methods-container { gap: 9px; margin-bottom: 9px; }
    .pay-method-card { padding: 12px 13px; }
    .modal-cancel-text-btn { padding: 8px 0; }
}
@media (max-height: 650px) {
    .modal-options-scroll { max-height: 24dvh; }
    .modal-card-box { padding-top: 12px; padding-bottom: 10px; }
}
