:root {
    --ink: #1e2a3a;
    --muted: #667085;
    --cream: #f7f4ed;
    --paper: #fffdf8;
    --line: #e6e0d4;
    --orange: #d9673b;
    --orange-dark: #b74c25;
    --green: #2f6b56;
    --shadow: 0 18px 45px rgba(30, 42, 58, .08);
}

* { box-sizing: border-box; }

html { background: var(--cream); }

body {
    margin: 0;
    color: var(--ink);
    background: var(--cream);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--orange-dark); }

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

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 253, 248, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.header-main {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    gap: 28px;
    align-items: center;
    min-height: 78px;
}

.brand { font-family: Georgia, serif; font-size: 1.65rem; font-weight: 700; letter-spacing: -.04em; white-space: nowrap; }
.brand span { display: block; color: var(--orange); font: 600 .68rem/1 Inter, sans-serif; letter-spacing: .16em; text-transform: uppercase; }

.search-form { display: flex; gap: 8px; }
.search-form input { flex: 1; min-width: 0; }

.header-links { display: flex; gap: 18px; align-items: center; font-size: .92rem; font-weight: 650; white-space: nowrap; }
.basket-pill { padding: 9px 13px; border-radius: 999px; color: #fff; background: var(--ink); }
.basket-pill:hover { color: #fff; background: var(--orange-dark); }

nav.category-nav { border-top: 1px solid #f0ece4; }
.category-nav-inner { display: flex; gap: 20px; align-items: center; min-height: 42px; overflow-x: auto; color: var(--muted); font-size: .86rem; white-space: nowrap; }

main { min-height: calc(100vh - 190px); }
.hero { padding: 76px 0 64px; background: radial-gradient(circle at 75% 20%, #f4d8bf 0, transparent 32%), var(--cream); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 54px; align-items: center; }
.eyebrow { color: var(--orange-dark); font-size: .74rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3 { margin: 0 0 14px; font-family: Georgia, serif; line-height: 1.08; letter-spacing: -.03em; }
h1 { font-size: clamp(2.7rem, 7vw, 5.5rem); max-width: 700px; }
h2 { font-size: clamp(1.8rem, 3vw, 2.65rem); }
h3 { font-size: 1.18rem; }
.hero p { max-width: 620px; margin: 0 0 26px; color: #536172; font-size: 1.1rem; }
.hero-card { min-height: 300px; padding: 32px; border: 1px solid #e5cfb9; border-radius: 28px; background: #f0dfc9; box-shadow: var(--shadow); }
.hero-card strong { display: block; margin-bottom: 8px; font: 700 2.6rem/1 Georgia, serif; }
.hero-card p { margin: 0; font-size: .98rem; }
.hero-card .stamp { display: inline-flex; margin-top: 58px; padding: 10px 14px; border: 1px solid rgba(30, 42, 58, .18); border-radius: 999px; color: var(--green); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.section { padding: 48px 0; }
.section-head { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 22px; }
.section-head p { margin: 0; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.product-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 6px 18px rgba(30,42,58,.03); transition: transform .18s ease, box-shadow .18s ease; }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.product-card a { display: block; }
.cover { display: grid; place-items: center; aspect-ratio: 1 / 1.18; overflow: hidden; background: #ece8df; }
.cover img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.cover-placeholder { color: #a19b8e; font: 700 1.7rem Georgia, serif; letter-spacing: .08em; }
.card-body { padding: 15px; }
.card-type { margin-bottom: 7px; color: var(--orange-dark); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.card-title { display: -webkit-box; min-height: 2.9em; overflow: hidden; color: var(--ink); font-weight: 750; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.card-author { min-height: 1.5em; overflow: hidden; color: var(--muted); font-size: .88rem; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 14px; }
.price { color: var(--green); font-weight: 800; }
.stock { color: var(--muted); font-size: .78rem; }

.category-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.category-tile { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,253,248,.68); }
.category-tile strong { display: block; margin-bottom: 5px; font-family: Georgia, serif; font-size: 1.15rem; }
.category-tile span { color: var(--muted); font-size: .82rem; }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: center; padding: 22px 0; border-bottom: 1px solid var(--line); }
.toolbar p { margin: 0; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--paper); font-size: .82rem; }
.filter.active, .filter:hover { border-color: var(--orange); color: #fff; background: var(--orange); }

input, select, button, .button { min-height: 42px; padding: 9px 13px; border: 1px solid #d8d1c5; border-radius: 9px; color: var(--ink); background: #fff; font: inherit; }
button, .button { display: inline-flex; justify-content: center; align-items: center; border-color: var(--orange); color: #fff; background: var(--orange); cursor: pointer; font-weight: 750; }
button:hover, .button:hover { border-color: var(--orange-dark); color: #fff; background: var(--orange-dark); }
.button.secondary { border-color: var(--line); color: var(--ink); background: var(--paper); }
.button.secondary:hover { border-color: var(--ink); color: var(--ink); background: #fff; }

.breadcrumbs { padding: 25px 0 0; color: var(--muted); font-size: .84rem; }
.product-layout { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(0, 1.25fr); gap: 56px; padding: 32px 0 62px; }
.product-image { display: grid; place-items: center; min-height: 450px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: #eeeae2; }
.product-image img { max-height: 520px; object-fit: contain; mix-blend-mode: multiply; }
.product-kicker { margin-bottom: 12px; color: var(--orange-dark); font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.product-title { font-size: clamp(2.2rem, 4.5vw, 4.4rem); }
.product-author { margin: 0 0 22px; color: var(--muted); font-size: 1.08rem; }
.product-description { color: #536172; }
.product-description p { white-space: pre-line; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 24px; margin: 26px 0; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact dt { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.fact dd { margin: 2px 0 0; font-weight: 650; }
.category-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 17px 0; }
.tag { padding: 5px 9px; border-radius: 999px; color: var(--green); background: #e1eee8; font-size: .76rem; }
.offer-list { display: grid; gap: 10px; margin-top: 25px; }
.offer { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 17px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.offer-condition { font-weight: 750; }
.offer-note { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.offer-price { color: var(--green); font-weight: 850; white-space: nowrap; }
.offer-form { display: flex; gap: 7px; align-items: center; }
.offer-form input { width: 60px; min-height: 38px; padding: 5px 8px; }
.offer-form button { min-height: 38px; padding: 6px 10px; }

.notice { margin: 20px 0; padding: 14px 16px; border: 1px solid #e9cda8; border-radius: 10px; color: #795331; background: #fff3df; }
.notice.success { border-color: #b9d9ca; color: #245b47; background: #e8f4ed; }
.error-page { padding: 90px 0; text-align: center; }
.empty { padding: 55px 20px; border: 1px dashed #cfc6b8; border-radius: 16px; color: var(--muted); text-align: center; }
.info-page { max-width: 820px; }
.info-section { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); }
.info-section p { color: #536172; }

.admin-page { max-width: 1060px; }
.admin-auth-page { max-width: 620px; }
.admin-heading { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 25px; }
.admin-heading h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); }
.admin-heading .product-author { margin-bottom: 0; }
.admin-panel { margin-top: 22px; padding: 25px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 6px 18px rgba(30,42,58,.03); }
.admin-panel h2 { font-size: 1.75rem; }
.admin-muted { color: var(--muted); font-size: .88rem; }
.admin-form { display: grid; gap: 9px; }
.admin-form label, .admin-form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.admin-form button { margin-top: 8px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: end; }
.admin-form-action { display: flex; align-items: end; min-height: 69px; }
.admin-form-action button { width: 100%; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.admin-stat { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.admin-stat span { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.admin-stat strong { display: block; margin-top: 9px; color: var(--green); font: 700 2.1rem/1 Georgia, serif; }
.admin-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 22px; }
.admin-card { display: block; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); }
.admin-card:hover { border-color: var(--orange); box-shadow: var(--shadow); }
.admin-card strong { display: block; margin-bottom: 5px; font-family: Georgia, serif; font-size: 1.3rem; }
.admin-card span { color: var(--muted); font-size: .9rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 13px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.admin-table td { font-size: .9rem; }
.admin-status { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.admin-status.active { color: #245b47; background: #e8f4ed; }
.admin-status.inactive { color: #795331; background: #fff3df; }
.small-button { min-height: 34px; padding: 5px 9px; font-size: .78rem; }
button.danger, .button.danger { border-color: #b64e42; background: #b64e42; }
button.danger:hover, .button.danger:hover { border-color: #963b31; background: #963b31; }
.admin-password-panel { max-width: 820px; }

.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 30; }
.chat-toggle { min-height: 48px; padding: 10px 17px; border-radius: 999px; box-shadow: 0 10px 28px rgba(30,42,58,.2); }
.chat-toggle-dot, .chat-status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #9b958a; vertical-align: middle; }
.chat-toggle-dot.online, .chat-status-dot.online { background: #3c9a72; }
.chat-toggle-dot.offline, .chat-status-dot.offline { background: #b77b4b; }
.chat-panel { display: flex; flex-direction: column; width: min(370px, calc(100vw - 24px)); max-height: min(650px, calc(100vh - 100px)); margin-bottom: 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: 0 18px 45px rgba(30,42,58,.2); }
.chat-panel-heading { display: flex; justify-content: space-between; gap: 12px; padding: 16px 17px 12px; color: #fff; background: var(--ink); }
.chat-panel-heading strong { display: block; font-family: Georgia, serif; font-size: 1.15rem; }
.chat-status { display: block; margin-top: 3px; color: #cbd4dc; font-size: .78rem; font-weight: 700; }
.chat-status.online { color: #8fdbb6; }
.chat-status.offline { color: #f1c18d; }
.chat-close { min-height: 30px; padding: 1px 7px; border: 0; color: #fff; background: transparent; font-size: 1.55rem; line-height: 1; }
.chat-close:hover { border: 0; color: #fff; background: rgba(255,255,255,.14); }
.chat-hours { margin: 0; padding: 10px 17px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: 10px; min-height: 90px; max-height: 290px; padding: 14px 15px; overflow-y: auto; background: #f8f5ef; }
.chat-empty { margin: auto; color: var(--muted); font-size: .88rem; text-align: center; }
.chat-message { display: flex; flex-direction: column; max-width: 88%; }
.chat-message.visitor { align-self: flex-end; align-items: flex-end; }
.chat-message.staff { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 9px 11px; border-radius: 12px; color: var(--ink); background: #fff; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message.visitor .chat-bubble { color: #fff; background: var(--green); }
.chat-message-meta { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.chat-follow-up { padding: 9px 15px 0; color: var(--muted); font-size: .76rem; }
.chat-form { display: grid; gap: 6px; padding: 10px 15px 15px; }
.chat-form label { color: var(--muted); font-size: .76rem; font-weight: 750; }
.chat-form label span { font-weight: 500; }
.chat-form textarea { resize: vertical; }
.chat-form button { margin-top: 3px; }
.chat-error { color: #a53f31; font-size: .78rem; }
.chat-closed-note { margin: 0; color: var(--muted); font-size: .78rem; text-align: center; }
.support-admin-status { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 17px; color: var(--muted); font-size: .84rem; }
.support-admin-status .chat-status-dot { margin-right: 2px; }
.support-admin-layout { display: grid; grid-template-columns: minmax(240px, .65fr) minmax(0, 1.35fr); min-height: 560px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.support-conversation-list { border-right: 1px solid var(--line); background: #fbf8f2; }
.support-list-heading { display: flex; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); font-family: Georgia, serif; font-size: 1.15rem; }
.support-list-heading span { min-width: 25px; padding: 2px 7px; border-radius: 999px; color: #fff; background: var(--green); font: 700 .76rem/1.5 Inter, sans-serif; text-align: center; }
.support-conversation { display: grid; width: 100%; min-height: 100px; padding: 13px 15px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--ink); background: transparent; cursor: pointer; font-weight: 500; text-align: left; }
.support-conversation:hover, .support-conversation.selected { color: var(--ink); background: #f1e9dc; }
.support-conversation.needs-reply { border-left: 4px solid var(--orange); padding-left: 11px; }
.support-conversation strong, .support-conversation-email, .support-conversation-preview, .support-conversation-meta { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.support-conversation strong { font-size: .9rem; }
.support-conversation-email, .support-conversation-meta { color: var(--muted); font-size: .72rem; }
.support-conversation-preview { margin: 7px 0 5px; color: #536172; font-size: .8rem; }
.support-thread { display: flex; min-width: 0; flex-direction: column; }
.support-thread > .chat-empty { padding: 30px; }
.support-thread-heading { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.support-thread-heading strong, .support-thread-heading a { display: block; }
.support-thread-heading strong { font-family: Georgia, serif; font-size: 1.2rem; }
.support-thread-heading a { margin-top: 3px; color: var(--green); font-size: .82rem; }
.admin-thread-messages { flex: 1; max-height: none; min-height: 300px; }
.admin-reply-form { margin-top: auto; border-top: 1px solid var(--line); background: var(--paper); }
.admin-reply-actions { display: flex; gap: 12px; align-items: center; }
.admin-reply-actions button { flex: 0 0 auto; }

.basket-table { width: 100%; border-collapse: collapse; background: var(--paper); }
.basket-table th, .basket-table td { padding: 15px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.basket-table th { color: var(--muted); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.basket-item { display: flex; gap: 13px; align-items: center; }
.basket-item .mini-cover { width: 52px; height: 64px; overflow: hidden; background: #ece8df; }
.basket-item .mini-cover img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.basket-total { display: flex; justify-content: flex-end; gap: 26px; padding: 25px 0; font-size: 1.2rem; font-weight: 800; }
.basket-total-small { padding: 7px 0; color: var(--muted); font-size: .98rem; font-weight: 650; }

.pagination { display: flex; justify-content: center; gap: 8px; margin: 34px 0 10px; }
.pagination a, .pagination span { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: .88rem; }
.pagination .current { border-color: var(--ink); color: #fff; background: var(--ink); }

footer { padding: 42px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.footer-grid { display: flex; justify-content: space-between; gap: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
    .header-main { grid-template-columns: 1fr auto; gap: 15px; padding: 12px 0; }
    .header-main .search-form { grid-column: 1 / -1; grid-row: 2; }
    .header-links { gap: 10px; }
    .hero-grid, .product-layout { grid-template-columns: 1fr; gap: 28px; }
    .hero-card { min-height: 220px; }
    .hero-card .stamp { margin-top: 28px; }
    .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .container { width: min(100% - 22px, 1180px); }
    .hero { padding: 48px 0 40px; }
    h1 { font-size: 3.1rem; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section { padding: 34px 0; }
    .section-head { display: block; }
    .section-head p { margin-top: 7px; }
    .product-layout { padding-top: 20px; }
    .product-image { min-height: 300px; }
    .offer { grid-template-columns: 1fr auto; gap: 9px; }
    .offer-form { grid-column: 1 / -1; justify-content: flex-end; }
    .basket-table { display: block; overflow-x: auto; white-space: nowrap; }
    .footer-grid { display: block; }
    .admin-heading { display: block; }
    .admin-heading .button, .admin-heading form { margin-top: 16px; }
    .admin-stat-grid, .admin-card-grid, .admin-form-grid { grid-template-columns: 1fr; }
    .admin-panel { padding: 18px; }
    .chat-widget { right: 11px; bottom: 11px; }
    .support-admin-layout { grid-template-columns: 1fr; }
    .support-conversation-list { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
    .support-thread { min-height: 520px; }
    .support-thread-heading { align-items: start; flex-direction: column; }
}
