
main {
    --section-background: #fff;
    --section-border: #d9e3d3;
    --text-h1: #2f4633;
    --text-h2: #4b6845;
    --text-h3: #35563b;
    --card-background: #f3f5f0;
    
    --button-background-green: #4b6845;
    --button-hover-green: #273f2b;
    --button-background-soft: #dad6be;
    --button-hover-soft: #a59a64;
    --button-background-light: #f4f7f2;
    --button-border-light: #d3dfcf;
    --button-hover-light: #eaf1e7;
    --focus-ring: rgba(75, 104, 69, 0.15);
    
    --stack-gap: 24px;

    max-width: 900px;
    margin: 40px auto 60px;
    padding: 0 20px;
}

main h1 {
    color: var(--text-h1);
    margin-bottom: 2rem;
    text-align: center;
}

main h2 {
    color: var(--text-h2);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #e5ece2;
    padding-bottom: 10px;
}

main h3 {
    color: var(--text-h3);
    margin: 0 0 12px;
}

main p {
    font-size: 1rem;
    margin: 10px 0;
}

main label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-h3);
}

.section-grid,
.section-grid-center {
    background: var(--section-background);
    border: 1px solid var(--section-border);
    border-radius: 8px;
    padding: 24px 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.section-grid-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.section-grid p {
    text-align: justify;
}

/* form */
.form-border,
.form-no-border {
    max-width: 500px;
    margin: 0 auto;
    padding: 30px;
}

.form-border {
    background: var(--section-background);
    border: 1px solid var(--section-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.form-border > div,
.form-no-border > div { /* only direct child elements */
    margin-bottom: 20px;
}

.form-border > div:last-of-type,
.form-no-border > div:last-of-type {
    margin-bottom: 28px;
}

/* error message */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 500px;
    margin: 0 auto 20px;
    padding: 14px 16px;
    background: #fdeaea;
    border: 1px solid #e4b8b8;
    border-radius: 8px;
    color: #9a2e2e;
}

.error-message h1 {
    margin-top: 0;
    color: #8f3030;
}

/* success message */
.success-message {
    background: #e8f5e9;
    color: #2e6b35;
    border: 1px solid #8bc48f;
    border-left: 5px solid #3f8f45;
    padding: 14px 16px;
    margin: 20px 0;
    border-radius: 8px;
    font-weight: 600;
}




/* -----------------------------login & register----------------------------- */
main input[type="email"],
main input[type="password"],
main input[type="text"],
main input[type="number"] {
    font-size: 1rem;
    padding: 12px 14px;
    border: 1px solid #cfd8ca;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

main input[type="email"],
main input[type="password"],
main input[type="text"] {
    width: 100%;
}

.button-first,
.buy-button,
.button-second {
    font-size: 1rem;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    padding: 12px 20px;
    margin-top: 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.button-first,
.buy-button {
    color: #fff;
    background: var(--button-background-green);
    border: none;
}

.button-first {
    display: block;
    width: 100%;
}

.buy-button,
.button-second {
    display: inline-block;
}

.button-first:hover,
.buy-button:hover {
    background: var(--button-hover-green);
}

.button-second {
    color: #444;
    background: var(--button-background-soft);
    border: 1px solid #d6d6d6;
}

.button-second:hover {
    background: var(--button-hover-soft);
}

main > p {
    margin-top: 30px;
    text-align: center;
}

main > p a {
    color: var(--text-h2);
    text-decoration: none;
    font-weight: 600;
}

main > p a:hover {
    text-decoration: underline;
}

.separate-links {
    display: flex;
    justify-content: center;
    gap: 50px;
    flex-wrap: wrap;
}

.required {
    color: #c0392b;
    font-weight: 700;
    margin-left: 4px;
}

/* Browser validation */
main input:invalid:not(:placeholder-shown) {
    border-color: #c0392b;
    background-color: #fff7f7;
}

main input:invalid:focus {
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.15);
}

main input:valid {
    border-color: #b8d4b0;
}



/* -----------------------------account----------------------------- */
.edition-bought {
    background: var(--card-background);
    border: 1px solid #dfe8da;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 18px;
    transition: box-shadow 0.2s ease;
}

.edition-bought:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.edition-bought p {
    margin: 6px 0;
}

.edition-bought:last-child {
    margin-bottom: 0;
}

/* Purchase current edition */
.current-edition {
    background: #fff9e8;
    border-color: #e6c86a;
}





/* -----------------------------account----------------------------- */
.purchase-modal[hidden] {
    display: none;
}

.purchase-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}





/* -----------------------------Payment processing----------------------------- */
.go-to-actions {
    display: flex;
    gap: 48px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.processing-box {
    background: #fff9e8;
    border: 1px solid #e6c86a;
    border-radius: 10px;
    padding: 30px;
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
}






/* -----------------------------modify account----------------------------- */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #555;
    padding: 4px;
}

.toggle-password:hover {
    color: #222;
}




/* -----------------------------purchase page----------------------------- */
.suggested-prices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 48px;
}

.price-button {
    font-size: 1.2rem;
    padding: 10px 12px;
    background: var(--button-background-light);
    border-radius: 8px;
    border: 1px solid var(--button-border-light);
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

.price-button:hover {
    background: var(--button-hover-light);
    transform: translateY(-1px);
}

.price-button:active {
    transform: translateY(0);
}

.price-button.selected {
    background: var(--button-background-green);
    color: #fff;
}

.custom-price {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 32px;
}

.custom-price label {
    margin: 0;
}

.price-input {
    display: flex;
    display: inline-flex;
    align-items: center;
}

.price-input input {
    color: #26352a;
    font-weight: 600;
    padding: 8px 12px 8px 12px;
    border-radius: 8px;
    box-sizing: border-box;
    height: 44px;
    
    background: #fff;
    border: 1px solid var(--button-border-light);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.price-input input::-webkit-inner-spin-button,
.price-input input::-webkit-outer-spin-button {
    opacity: 0.6;
}

.price-input span {
    color: #687568;
    font-size: 1rem;
    font-weight: 600;
    margin-left: 12px;
}

.purchase-action {
    display: flex;
    flex-direction: row;
    gap: 48px;
    margin-top: 60px;
}

.purchase-action .button-first,
.purchase-action .button-second {
    flex: 1 1 0;
    width: auto;
    box-sizing: border-box;
    margin-top: 0;
    text-align: center;
}




/* -----------------------------purchase popup modal----------------------------- */
.purchase-modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(25, 35, 27, 0.62);
    backdrop-filter: blur(3px);
}

.purchase-modal[hidden] {
    display: none;
}

.purchase-modal-content {
    position: relative;
    width: min(100%, 460px);
    padding: 34px;
    box-sizing: border-box;
    background: #fff;
    border: 1px solid #d9e3d3;
    border-radius: 14px;
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.08);
    animation: purchaseModalIn 0.18s ease-out;
}

@keyframes purchaseModalIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

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

.purchase-modal-content h2 {
    color: var(--text-h1);
    font-size: 1.2rem;
    border: none;
    padding: 0;
}

.purchase-modal-content p {
    line-height: 1.6;
}

.purchase-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: none;
    border-radius: 50%;

    color: #667168;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        color 0.18s ease;
}

.purchase-modal-close:hover {
    background: #f0f3ef;
    color: #273f2b;
}


.purchase-confirm-amount {
    display: flex;
    display: inline-flex;
    margin: 24px 0;
    text-align: center;
}


.purchase-modal-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.purchase-modal-buttons button {
    min-height: 32px;
    margin: 0;
}





@media (max-width: 768px) {
    .suggested-prices {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .custom-price label {
        margin: 0;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .purchase-action {
        flex-direction: column;
        gap: var(--stack-gap);
    }
    
    .purchase-action .button-first,
    .purchase-action .button-second {
        flex: none;
        width: 100%;
    }
}
