:root {
    color-scheme: light;
    --ink: #17211f;
    --muted: #66736f;
    --line: #dfe7e2;
    --paper: #ffffff;
    --soft: #f6f8f4;
    --teal: #007c73;
    --teal-dark: #005e58;
    --amber: #c88211;
    --rose: #b64b60;
    --shadow: 0 18px 42px rgba(23, 33, 31, .10);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--soft);
    color: var(--ink);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.6;
}

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

img {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.primary-action,
.secondary-action,
.open-store {
    min-height: 42px;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

.site-header,
.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0;
}

.brand {
    font-weight: 800;
    letter-spacing: 0;
}

.site-header nav a {
    color: var(--muted);
    font-weight: 700;
}

main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 48px;
}

.site-footer {
    display: flex;
    justify-content: space-between;
    padding: 28px 0;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--teal);
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: 1.06;
    letter-spacing: 0;
}

h2 {
    font-size: 1.2rem;
    letter-spacing: 0;
}

.directory-shell,
.checkout-shell,
.success-shell {
    padding: 28px 0 64px;
}

.directory-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
    gap: 24px;
    align-items: end;
    margin-bottom: 28px;
    padding: 36px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.directory-copy {
    max-width: 560px;
    color: var(--muted);
    font-size: 1.08rem;
}

.store-search,
.catalog-toolbar {
    display: flex;
    gap: 10px;
}

.store-search input,
.catalog-toolbar input,
.catalog-toolbar select,
.checkout-form input,
.checkout-form textarea,
.qty-form input,
.buy-box input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    padding: 10px 12px;
    color: var(--ink);
}

.store-search button,
.catalog-toolbar button,
.card-action button,
.buy-box button,
.qty-form button,
.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--teal);
    color: #fff;
    padding: 0 18px;
    font-weight: 800;
}

.store-search button:hover,
.catalog-toolbar button:hover,
.card-action button:hover,
.buy-box button:hover,
.qty-form button:hover,
.primary-action:hover {
    background: var(--teal-dark);
}

button:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.store-card,
.product-card,
.order-summary,
.checkout-form,
.cart-line {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.store-card {
    display: grid;
    grid-template-rows: 160px 1fr auto;
    overflow: hidden;
    min-height: 360px;
}

.store-card-media,
.product-media,
.product-gallery,
.line-media,
.store-logo {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #e8f3ef, #fff6e3);
    color: var(--teal);
    font-weight: 900;
}

.store-card-media img,
.product-media img,
.line-media img,
.store-logo img,
.product-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.store-card-media span,
.product-media span,
.line-media span,
.product-gallery span,
.store-logo span {
    font-size: 3rem;
}

.store-card-body {
    padding: 18px;
}

.store-card-title {
    display: block;
    margin-bottom: 8px;
    font-size: 1.12rem;
    font-weight: 900;
}

.store-card-body p,
.store-card-meta,
.muted,
.order-summary p,
.product-description {
    color: var(--muted);
}

.store-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .9rem;
}

.open-store {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 18px 18px;
    background: #f0f5f2;
    color: var(--teal-dark);
    font-weight: 800;
}

.empty-state {
    padding: 44px;
    text-align: center;
    background: var(--paper);
    border: 1px dashed #b9c9c2;
    border-radius: var(--radius);
}

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

.service-state {
    border-color: #e2b3bd;
    background: #fff7f8;
}

.service-state code {
    display: block;
    overflow-x: auto;
    margin-top: 16px;
    padding: 12px;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
    direction: ltr;
    text-align: left;
    white-space: nowrap;
}

.store-hero {
    position: relative;
    min-height: 340px;
    margin-bottom: 28px;
    overflow: hidden;
    border-radius: var(--radius);
    background: #dcebe5;
    border: 1px solid var(--line);
}

.store-hero-media {
    position: absolute;
    inset: 0;
}

.store-hero-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,.96), rgba(255,255,255,.72));
}

[dir="rtl"] .store-hero-media::after {
    background: linear-gradient(270deg, rgba(255,255,255,.96), rgba(255,255,255,.72));
}

.store-hero-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.store-hero-content {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) auto;
    gap: 18px;
    align-items: end;
    min-height: 340px;
    padding: 34px;
}

.store-logo {
    width: 96px;
    height: 96px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow: hidden;
}

.store-contact-row,
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.store-contact-row span,
.detail-meta span,
.stock {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eef6f3;
    color: var(--teal-dark);
    font-size: .9rem;
    font-weight: 700;
}

.cart-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    font-weight: 900;
}

.cart-pill.inline {
    width: fit-content;
    margin-top: 18px;
}

.catalog-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.category-rail {
    position: sticky;
    top: 16px;
    display: grid;
    gap: 8px;
}

.category-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--muted);
    font-weight: 800;
}

.category-chip.is-active {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

.catalog-main {
    min-width: 0;
}

.catalog-toolbar {
    margin-bottom: 16px;
}

.catalog-toolbar select {
    max-width: 180px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.product-card {
    display: grid;
    grid-template-rows: 210px 1fr auto;
    overflow: hidden;
}

.product-media {
    min-height: 210px;
}

.product-body {
    display: grid;
    gap: 8px;
    padding: 16px;
}

.product-body a {
    font-weight: 900;
}

.price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.price-row strong {
    font-size: 1.08rem;
}

.price-row.large strong {
    font-size: 1.65rem;
}

del {
    color: var(--muted);
}

.stock {
    width: fit-content;
    background: #eef7ef;
    color: #237541;
}

.stock.out {
    background: #fff0f2;
    color: var(--rose);
}

.card-action {
    padding: 0 16px 16px;
}

.card-action button {
    width: 100%;
}

.product-detail {
    display: grid;
    grid-template-columns: minmax(300px, 560px) minmax(0, 1fr);
    gap: 26px;
    padding: 26px 0 64px;
}

.product-gallery {
    min-height: 560px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.product-panel {
    align-self: start;
    padding: 28px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.back-link {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--teal-dark);
    font-weight: 900;
}

.buy-box,
.checkout-form {
    display: grid;
    gap: 14px;
}

.buy-box {
    margin-top: 24px;
    grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
    align-items: end;
}

.buy-box label,
.checkout-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 800;
}

.section-title-row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.cart-layout,
.checkout-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}

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

.cart-line {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) 150px auto auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
}

.line-media {
    width: 84px;
    height: 84px;
    border-radius: var(--radius);
    overflow: hidden;
}

.line-media span {
    font-size: 1.7rem;
}

.line-info {
    display: grid;
    gap: 4px;
}

.line-info a {
    font-weight: 900;
}

.qty-form {
    display: flex;
    gap: 8px;
}

.qty-form input {
    max-width: 82px;
}

.ghost-danger {
    min-height: 38px;
    padding: 0 12px;
    color: var(--rose);
    background: #fff0f2;
    font-weight: 800;
}

.order-summary {
    display: grid;
    gap: 14px;
    padding: 18px;
    position: sticky;
    top: 16px;
}

.order-summary div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.summary-total {
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.checkout-form {
    padding: 18px;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.segmented label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.validation-box,
span.field-validation-error {
    color: var(--rose);
    font-weight: 800;
}

.success-shell {
    min-height: 60vh;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
}

.success-mark {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: #e8f7ef;
    color: #237541;
    font-size: 2.6rem;
    font-weight: 900;
}

.success-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 18px;
}

.primary-action,
.secondary-action {
    padding: 10px 18px;
    font-weight: 900;
}

.secondary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef3f0;
    color: var(--ink);
}

@media (max-width: 980px) {
    .directory-head,
    .catalog-shell,
    .product-detail,
    .cart-layout,
    .checkout-layout {
        grid-template-columns: 1fr;
    }

    .store-grid,
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-rail,
    .order-summary {
        position: static;
    }

    .category-rail {
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .category-chip {
        min-width: fit-content;
    }

    .product-gallery {
        min-height: 380px;
    }

    .cart-line {
        grid-template-columns: 76px minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    main,
    .site-header,
    .site-footer {
        width: min(100% - 22px, 1180px);
    }

    .site-header,
    .site-footer,
    .section-title-row,
    .store-search,
    .catalog-toolbar,
    .buy-box {
        flex-direction: column;
        display: flex;
        align-items: stretch;
    }

    h1 {
        font-size: 2.15rem;
    }

    .directory-head,
    .store-hero-content,
    .product-panel {
        padding: 20px;
    }

    .store-grid,
    .product-grid {
        grid-template-columns: 1fr;
    }

    .store-hero-content {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .store-logo {
        width: 72px;
        height: 72px;
    }

    .cart-pill {
        grid-column: 1 / -1;
    }

    .catalog-toolbar select {
        max-width: none;
    }
}
