:root {
    --banner-bg: #0b1726;
    --banner-text: #ffffff;
    --page-bg: #0b1726;
    --category-bg: #ffffff;
    --category-text: #0b1726;
    --accent: #c9a96e;
    --button-bg: #0b1726;
    --button-text: #ffffff;
    --card-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    --card-shadow-hover: 0 10px 28px rgba(201, 169, 110, 0.30), 0 4px 14px rgba(0, 0, 0, 0.4);
    --muted: #9aa6b8;
    --border: rgba(255, 255, 255, 0.08);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--page-bg);
    color: #e6ebf2;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
}

body {
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(77, 168, 218, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 100%, rgba(201, 169, 110, 0.06) 0%, transparent 55%),
        var(--page-bg);
}

.banner {
    background: var(--banner-bg);
    color: var(--banner-text);
    padding: calc(18px + var(--safe-top)) var(--safe-right) 18px var(--safe-left);
    text-align: center;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    position: sticky;
    top: 0;
    z-index: 10;
}

.banner-inner {
    display: inline-block;
    width: 100%;
    max-width: 520px;
    padding: 0 16px;
}

.logo-svg {
    width: 100%;
    max-width: 460px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.app {
    flex: 1 1 auto;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 22px max(16px, var(--safe-right)) 22px max(16px, var(--safe-left));
    display: flex;
    flex-direction: column;
}

.row-stack { max-width: 480px; margin-left: auto; margin-right: auto; }

.view {
    display: flex;
    flex-direction: column;
    flex: 1;
    animation: fadeSlideIn 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes spin { to { transform: rotate(360deg); } }

.view-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
    margin: 8px 0 20px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.view-categories { justify-content: center; }

.row-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: auto 0;
    padding: 8px 0;
}

.row-button {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    min-height: 120px;
    padding: 14px 22px;
    background: var(--category-bg);
    color: var(--category-text);
    border: 2px solid transparent;
    border-radius: 14px;
    font-size: 28px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    line-height: 1.1;
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.32s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.row-button::after {
    content: '›';
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-size: 28px;
    font-weight: 400;
    transition: transform var(--transition);
}

.row-button:hover,
.row-button:focus-visible {
    border-color: var(--accent);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    outline: none;
}

.row-button:hover::after { transform: translateY(-50%) translateX(4px); }

.row-button:active { transform: scale(0.98); }

.row-button.subcategory { min-height: 100px; font-size: 24px; }

.row-button .row-image {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    object-fit: contain;
    background: #eef1f6;
    flex-shrink: 0;
    padding: 4px;
}

.row-button .row-image-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f2f4f8, #e1e6ee);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 40px;
    font-weight: 800;
}

.row-button.subcategory .row-image,
.row-button.subcategory .row-image-placeholder { width: 84px; height: 84px; }
.row-button.subcategory .row-image-placeholder { font-size: 32px; }

.row-button .row-text { flex: 1; padding-right: 32px; }

.back-link {
    align-self: flex-start;
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 4px;
    cursor: pointer;
    margin-bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.back-link:hover { text-decoration: underline; }
.back-arrow { display: inline-block; transition: transform var(--transition); }
.back-link:hover .back-arrow { transform: translateX(-4px); }

.contact-strip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    color: #e6ebf2;
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.55;
    text-align: center;
}

.item-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.item-card {
    background: var(--category-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
    color: var(--category-text);
}

.item-photo-wrap {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #eef1f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.item-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    -webkit-user-select: none;
    user-select: none;
}

.item-photo-placeholder {
    color: #8a93a1;
    font-size: 14px;
    text-align: center;
    padding: 16px;
}

.item-body { padding: 16px 18px 18px; }

.item-name {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--category-text);
}

.item-desc {
    margin: 0 0 12px;
    color: #4a5566;
    font-size: 14px;
    line-height: 1.5;
}

.size-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.size-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #dde2ea;
    background: #f7f9fc;
    font-size: 13px;
    font-weight: 600;
    color: var(--category-text);
    min-height: 36px;
}

.size-chip .size-label { letter-spacing: 0.5px; }
.size-chip .size-qty {
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.2;
}

.size-chip.empty {
    color: #b3b8c2;
    background: #f1f3f7;
    text-decoration: line-through;
    text-decoration-color: #b3b8c2;
    opacity: 0.75;
}

.size-chip.empty .size-qty { background: #c4cad4; color: #fff; }

.empty-state {
    text-align: center;
    padding: 40px 12px;
    color: var(--muted);
    font-size: 15px;
}
.empty-state .small { font-size: 13px; opacity: 0.7; margin-top: 6px; }

.loading {
    text-align: center;
    padding: 60px 12px;
    color: var(--muted);
}

.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.lightbox-close {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 28px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
}

.footer {
    text-align: center;
    padding: 18px max(16px, var(--safe-right)) calc(18px + var(--safe-bottom)) max(16px, var(--safe-left));
    color: var(--muted);
    font-size: 12px;
    background: transparent;
    opacity: 0.7;
}

.footer p { margin: 4px 0; }
.footer-links { font-size: 12px; }
.footer-links a { color: var(--muted); text-decoration: none; margin: 0 4px; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Static policy pages (privacy/terms/sms-policy) ---------- */
.policy {
    background: var(--category-bg);
    color: var(--category-text);
    padding: 28px 26px;
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    line-height: 1.55;
    margin: 12px auto;
    max-width: 720px;
}
.policy h2 { color: var(--category-text); margin-top: 24px; margin-bottom: 8px; font-size: 19px; }
.policy p, .policy li { font-size: 15px; color: #2c3540; }
.policy ul, .policy ol { padding-left: 22px; }
.policy code { background: #f3f5f9; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.policy a { color: #6b4f1a; }
.policy a:hover { text-decoration: underline; }
.policy .back-link { color: #6b4f1a; }

/* ---------- Item photo with back-photo toggle ---------- */
.item-photo-wrap { position: relative; }
.photo-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(11, 23, 38, 0.78);
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
}
.photo-toggle:hover { background: rgba(11, 23, 38, 0.95); }

/* ---------- Reserve button on item ---------- */
.reserve-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 18px;
    border-radius: 10px;
    background: var(--accent);
    color: #0b1726;
    border: 0;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    transition: filter var(--transition), transform var(--transition);
}
.reserve-btn:hover { filter: brightness(1.06); }
.reserve-btn:active { transform: scale(0.98); }
.reserve-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- "Other useful Immac links" entry on home view ---------- */
.links-entry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    margin: 24px auto 0;
    padding: 14px 20px;
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition), color var(--transition);
}
.links-entry-btn:hover { background: var(--accent); color: #0b1726; }
.links-entry-icon { font-size: 20px; line-height: 1; }

/* ---------- Links grid (public view-links) ---------- */
.links-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 8px;
}
@media (min-width: 560px) {
    .links-grid { grid-template-columns: 1fr 1fr; }
}
.link-card {
    display: flex;
    flex-direction: column;
    background: var(--category-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    text-decoration: none;
    color: var(--category-text);
    transition: transform var(--transition), box-shadow var(--transition);
}
.link-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-hover); }
.link-card-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #eef1f6;
}
.link-card-img.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 40px;
    font-weight: 800;
}
.link-card-body { padding: 14px 18px 16px; }
.link-card-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.link-card-desc { margin: 0; color: #4a5566; font-size: 14px; line-height: 1.4; }

/* ---------- Root items (items at category root w/o subcategory) ---------- */
.root-items { display: flex; flex-direction: column; gap: 18px; margin-bottom: 22px; }
.root-items:empty { display: none; }

/* ---------- Checkout view ---------- */
.view-checkout .cart-items { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.view-checkout .form-row {
    background: var(--category-bg);
    color: var(--category-text);
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.view-checkout .form-row label { font-weight: 700; font-size: 14px; }
.view-checkout .form-row textarea,
.view-checkout .form-row select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dde2ea;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: var(--category-text);
    font-family: inherit;
    min-height: 44px;
}
.view-checkout .form-row textarea { resize: vertical; min-height: 96px; }
.view-checkout .form-row input[type="tel"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dde2ea;
    border-radius: 8px;
    font-size: 16px;
    min-height: 44px;
    background: #fff;
    color: var(--category-text);
    font-family: inherit;
}
.opt-in-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 10px !important;
    margin-top: 10px;
    font-weight: 400 !important;
    font-size: 12px !important;
    color: #4a5566 !important;
    line-height: 1.45;
}
.opt-in-row input[type="checkbox"] {
    width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px;
    accent-color: var(--accent); cursor: pointer;
}
.opt-in-row a { color: #6b4f1a; }

/* ---------- Floating cart button ---------- */
.cart-fab {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    z-index: 90;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: var(--accent);
    color: #0b1726;
    border: 0;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.cart-fab-icon { font-size: 22px; line-height: 1; }
.cart-fab-count {
    background: #0b1726;
    color: var(--accent);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    min-width: 22px;
    text-align: center;
}

/* ---------- Bottom sheet ---------- */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeOverlay 0.18s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
.sheet {
    background: #fff;
    color: var(--category-text);
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 18px 20px calc(28px + env(safe-area-inset-bottom, 0px));
    position: relative;
    animation: sheetUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: #c9d1de; border-radius: 2px; margin: 0 auto 14px; }
.sheet-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: 0;
    font-size: 28px;
    line-height: 1;
    width: 40px;
    height: 40px;
    color: var(--muted);
    cursor: pointer;
}
.sheet h3 { margin: 4px 0 6px; font-size: 20px; color: var(--category-text); }
.sheet-muted { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.sheet .form-row { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.sheet .form-row label { font-weight: 700; font-size: 13px; color: var(--category-text); }
.sheet textarea,
.sheet select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dde2ea;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    color: var(--category-text);
    min-height: 44px;
}
.sheet textarea { resize: vertical; min-height: 80px; }
.btn-large {
    width: 100%;
    margin-top: 16px;
    padding: 14px 20px;
    background: var(--accent);
    color: #0b1726;
    border: 0;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
}
.btn-large:hover { filter: brightness(1.06); }
.btn-large:active { transform: scale(0.98); }
.form-error { color: #b3261e; font-size: 14px; min-height: 18px; margin-top: 8px; }

/* Reserve size picker */
.reserve-sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.reserve-size-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 14px;
    border: 1.5px solid #dde2ea;
    background: #fff;
    color: var(--category-text);
    border-radius: 10px;
    cursor: pointer;
    min-width: 70px;
    min-height: 60px;
    font-weight: 700;
}
.reserve-size-btn:hover { border-color: var(--accent); }
.reserve-size-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.reserve-size-btn .sz-qty { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* Cart rows */
.cart-items { display: flex; flex-direction: column; gap: 8px; }
.cart-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 10px 12px;
    background: #f7f9fc;
    border: 1px solid #dde2ea;
    border-radius: 8px;
    align-items: center;
}
.cart-row .cart-name { font-weight: 700; font-size: 14px; }
.cart-row .cart-meta { font-size: 12px; color: var(--muted); }
.cart-row .cart-qty { font-weight: 700; }
.cart-row .cart-remove {
    background: transparent;
    border: 0;
    color: #b3261e;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
}
.cart-empty { text-align: center; color: var(--muted); padding: 18px 0; }

/* Confirmation */
.confirm-code {
    font-family: ui-monospace, "Courier New", monospace;
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    background: #0b1726;
    color: var(--accent);
    padding: 18px;
    border-radius: 12px;
    letter-spacing: 0.1em;
    margin: 16px 0 10px;
    user-select: all;
}
.confirm-meta { font-size: 13px; color: var(--muted); text-align: center; }

@media (min-width: 720px) {
    .item-card { flex-direction: row; }
    .item-photo-wrap { width: 240px; aspect-ratio: 1 / 1; flex-shrink: 0; }
    .item-body { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation-duration: 0.001s !important;
    }
}
