:root {
    --ivory: #f6efe4;
    --paper: #fffaf3;
    --ink: #2b1a12;
    --muted: #7a5d4d;
    --berry: #c64545;
    --berry-dark: #9c2f2f;
    --pistachio: #3f6d55;
    --cream: #f3d7a2;
    --line: rgba(43, 26, 18, 0.12);
    --shadow: 0 18px 50px rgba(80, 42, 24, 0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: Manrope, sans-serif;
    color: var(--ink);
    background: var(--ivory);
}

.page-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(circle at 12% -10%, #f8d5c4 0, transparent 32%),
        radial-gradient(circle at 92% 8%, #d9eadc 0, transparent 28%),
        linear-gradient(180deg, #fbf4ea 0%, #f3e6d4 100%);
}

h1, h2, strong {
    font-family: Fraunces, serif;
}

h1 {
    margin: 0 0 8px;
    font-size: clamp(32px, 5vw, 48px);
    letter-spacing: -0.03em;
}

h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 24px auto 64px;
}

.shell-narrow {
    width: min(560px, calc(100% - 32px));
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav account";
    align-items: center;
    gap: 12px 24px;
    padding: 12px clamp(12px, 2.5vw, 22px);
    background: rgba(255, 250, 243, 0.88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand {
    grid-area: brand;
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: min(46vw, 280px);
}

.brand-logo {
    display: block;
    height: clamp(16px, 4vw, 36px);
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.brand small,
.account-toggle small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.top-nav {
    grid-area: nav;
    display: flex;
    gap: 8px;
}

.top-nav a,
.ghost,
.ghost-link,
.chip,
.chip-button,
.primary,
.danger {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}

.top-nav a,
.ghost,
.ghost-link {
    padding: 10px 14px;
    background: transparent;
    color: var(--ink);
}

.top-nav a.is-active,
.chip.is-active {
    background: var(--ink);
    color: white;
}

.cart-link {
    position: relative;
}

.badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--berry);
    color: white;
    font-size: 12px;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account {
    grid-area: account;
    position: relative;
    justify-self: end;
}

.account-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(48vw, 240px);
    padding: 6px 10px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: right;
    cursor: pointer;
}

.account-toggle span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-toggle:hover,
.account.is-open .account-toggle {
    background: var(--paper);
}

.account-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 20;
    min-width: 180px;
    padding: 8px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.account-menu[hidden] {
    display: none;
}

.account-menu button {
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.account-menu button:hover {
    background: #f4ead8;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 24px;
}

.hero.compact {
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--berry);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lead, p {
    color: var(--muted);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.catalog-search {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: min(100%, 420px);
}

.catalog-search input {
    margin: 0;
}

.catalog-search .primary {
    flex: 0 0 auto;
    padding: 12px 16px;
}

.chip,
.chip-button {
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--line);
}

.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    background: var(--berry);
    color: white;
    font-weight: 700;
}

.primary:hover,
.chip-button:hover {
    background: var(--berry-dark);
    color: white;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.card,
.login-card,
.success-card,
.cart-row,
.empty,
.summary {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.card,
.cart-row,
.empty,
.summary,
.success-card,
.login-card {
    padding: 20px;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card[hidden],
.grid[hidden],
.empty[hidden] {
    display: none !important;
}

.card.in-cart {
    border-color: #7fb392;
    background: #f4faf5;
}

.card {
    transition: background 0.2s ease, border-color 0.2s ease;
}

.card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.price {
    color: var(--pistachio);
    font-weight: 700;
}

.price {
    margin: 0 0 10px;
}

.card-footer {
    margin-top: auto;
    padding-top: 16px;
}

.add-form,
.stack {
    display: grid;
    gap: 12px;
}

.buy-bar {
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.buy-btn {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    white-space: nowrap;
    transition:
        flex-grow 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background 0.35s ease,
        color 0.35s ease;
}

.buy-bar.is-open .buy-btn,
.buy-bar.is-open .buy-btn:hover {
    background: var(--pistachio);
    color: #fff;
}

.buy-check {
    display: none;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.buy-btn.is-compact .buy-label {
    display: none;
}

.buy-btn.is-compact .buy-check {
    display: block;
}

.stepper-slot {
    flex: 0 0 auto;
    width: 152px;
    max-width: 0;
    margin-left: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    transition:
        max-width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        margin-left 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.28s ease,
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.buy-bar.is-open .stepper-slot {
    max-width: 152px;
    margin-left: 8px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.stepper {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 4px;
    width: 152px;
}

.stepper-btn {
    width: 40px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    color: var(--ink);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.stepper-btn:hover:not(:disabled) {
    background: #f4ead8;
}

.stepper-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.stepper-value {
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: white;
    border: 1px solid var(--line);
    font-family: Fraunces, serif;
    font-size: 20px;
    font-weight: 700;
}

label {
    display: grid;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

input, textarea, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
    font: inherit;
    font-size: 16px;
    color: var(--ink);
}

.cart-list {
    display: grid;
    gap: 12px;
}

.cart-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.cart-row-info {
    flex: 1 1 180px;
    min-width: 0;
}

.cart-row-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cart-qty-form {
    margin: 0;
}

.danger {
    padding: 10px 14px;
    background: #f4e4dd;
    color: var(--berry-dark);
}

button.ghost {
    border: 1px solid var(--line);
    background: white;
}

.actions {
    margin-top: 20px;
}

.actions-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stock-notice {
    margin: 0 0 20px;
    padding: 16px 18px;
    background: #fbe6e2;
    border: 1px solid rgba(198, 69, 69, 0.28);
    border-radius: 20px;
    color: var(--berry-dark);
    text-align: left;
}

.stock-notice h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.stock-notice p {
    margin: 0 0 10px;
}

.stock-notice ul {
    margin: 0;
    padding-left: 18px;
}

.stock-notice li + li {
    margin-top: 8px;
}

.cart-row.is-stock-warning {
    border-color: rgba(198, 69, 69, 0.45);
    background: #fff6f3;
}

.summary p {
    display: flex;
    justify-content: space-between;
    margin: 0 0 10px;
    color: var(--ink);
}

.dot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.toast {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    margin: 0;
    max-width: min(92vw, 420px);
    padding: 12px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    text-align: center;
    white-space: pre-line;
    pointer-events: none;
    animation: toast-in 0.18s ease;
}

.toast.is-out {
    animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(-50%);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
}

.toast-success {
    background: #e4f3ea;
    color: var(--pistachio);
}

.toast-error {
    background: #fbe6e2;
    color: var(--berry-dark);
}

.toast-info {
    background: #f4ead8;
}

.login-card {
    text-align: center;
}

.login-visual {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 4px auto 20px;
}

.login-logo {
    display: block;
    width: 33.333%;
    max-width: 200px;
    min-width: 120px;
    height: auto;
    object-fit: contain;
}

.hint {
    margin-top: 18px;
    font-size: 14px;
}

.login-card a {
    color: var(--berry);
    font-weight: 700;
}

.empty {
    text-align: center;
}

@media (max-width: 800px) {
    .topbar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "brand account"
            "nav nav";
    }

    .top-nav {
        width: 100%;
    }

    .hero, .cart-row {
        flex-wrap: wrap;
    }

    .hero {
        align-items: start;
        flex-direction: column;
    }

    .catalog-search {
        width: 100%;
    }
}

.card.is-hidden,
.grid.is-hidden,
.empty.is-hidden,
.cart-list.is-hidden,
.actions.is-hidden,
.card[hidden],
.grid[hidden],
.empty[hidden],
.cart-list[hidden],
.actions[hidden] {
    display: none !important;
}
