:root {
    --primary: #b61028;
    --primary-dark: #8f0d21;
    --primary-red: #b61028;
    --text: #1b1b1b;
    --muted: #666;
    --text-dark: #1b1b1b;
    --text-grey: #666;
    --bg: #f4f6f8;
    --bg-light: #f4f6f8;
    --card: #ffffff;
    --white: #ffffff;
    --border: #e8eaed;
    --ok: #0b8f44;
    --radius: 12px;
    --shadow-card: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}

.site-header {
    background: var(--primary);
    position: sticky;
    top: 0;
    z-index: 99;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
}

.brand:hover {
    text-decoration: none;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-nav a {
    color: #fff;
    font-weight: 600;
    font-size: .95rem;
}

.btn-nav {
    background: #fff;
    color: var(--primary) !important;
    border-radius: 999px;
    padding: 8px 12px;
}

.page {
    padding-top: 24px;
    padding-bottom: 40px;
}

h1 {
    margin: 0 0 14px;
    font-size: 2rem;
}

h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
}

p {
    margin: 0 0 12px;
    color: #2f2f2f;
}

.hero-home {
    background: linear-gradient(135deg, #fff, #f9e9ec);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 26px;
}

.hero-home p {
    color: var(--muted);
    margin-bottom: 18px;
}

.search-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd4da;
    border-radius: 10px;
    background: #fff;
    padding: 11px 12px;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

button {
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    padding: 11px 16px;
    cursor: pointer;
}

button:hover {
    background: var(--primary-dark);
}

button.secondary {
    background: #eceff3;
    color: #1d1f22;
}

button.secondary:hover {
    background: #dbe1e8;
}

button[disabled] {
    background: #c7ccd3;
    cursor: not-allowed;
}

.alert {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid transparent;
}

.alert-success {
    background: #eaf8ef;
    border-color: #c6edcf;
    color: #0f6c33;
}

.alert-error {
    background: #fdecee;
    border-color: #f7c8ce;
    color: #8f2230;
}

.card {
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--border);
    padding: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.listing-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.listing-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.listing-card img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
}

.listing-card-body {
    padding: 12px;
}

.price {
    font-weight: 800;
    color: var(--primary);
}

.price.big {
    font-size: 1.7rem;
}

.meta {
    color: var(--muted);
    font-size: .9rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.filter-grid button {
    min-width: 120px;
}

.listing-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.listing-row {
    display: grid;
    grid-template-columns: 180px 1fr auto;
    gap: 14px;
    align-items: center;
}

.listing-row .thumb img,
.listing-row .thumb {
    width: 180px;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    overflow: hidden;
    display: block;
}

.listing-row .aside {
    text-align: right;
}

.detail-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.market-breadcrumbs {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 20px;
}

.market-breadcrumbs a {
    color: var(--primary-red);
}

.market-breadcrumbs span {
    color: var(--text-dark);
    font-weight: 600;
}

.market-detail-header-top {
    margin-bottom: 20px;
}

.market-detail-title {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 10px;
    color: var(--text-dark);
}

.market-detail-price {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-red);
}

.market-gallery {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 30px;
}

.gallery-main img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
    background: #f4f4f4;
}

.gallery-thumbs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.thumb-box img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid transparent;
    transition: 0.2s;
}

.thumb-box img:hover {
    border-color: var(--primary-red);
}

.market-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
    align-items: stretch;
}

.market-buy-box,
.market-seller-box {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.market-buy-box {
    border-top: 4px solid var(--primary-red);
}

.market-detail-date {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    margin-top: 15px;
}

.market-btn-primary,
.market-btn-secondary {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    font-size: 1rem;
    text-decoration: none;
}

.market-btn-primary {
    background: var(--primary-red);
    color: white;
    margin-bottom: 10px;
}

.market-btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.market-btn-secondary {
    background: #f0f0f0;
    color: var(--text-dark);
}

.market-btn-secondary:hover {
    background: #e0e0e0;
    text-decoration: none;
}

.market-btn-inline {
    width: auto;
    padding: 10px 20px;
    margin: 0;
}

.market-btn-link {
    margin-top: 0;
}

.market-message-form textarea {
    margin-bottom: 10px;
    min-height: 120px;
}

.seller-heading {
    font-size: 1.1rem;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.seller-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.seller-avatar {
    width: 50px;
    height: 50px;
    background: #ddd;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: #555;
}

.seller-name {
    font-weight: 700;
    margin-bottom: 3px;
}

.seller-meta {
    font-size: 0.8rem;
    color: #777;
}

.seller-link {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
}

.market-company-strip {
    margin-bottom: 15px;
}

.market-description-box {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.market-description-box h3 {
    font-size: 1.3rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 0;
}

.market-description-box h3:not(:first-child) {
    margin-top: 40px;
}

.market-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    font-size: 0.95rem;
    margin-bottom: 0;
    margin-left: 0;
    list-style: none;
}

.market-text {
    line-height: 1.8;
    color: #333;
}

.market-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--primary-red);
    padding-bottom: 15px;
}

.section-heading {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
}

.market-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.market-search-input,
.market-select {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
}

.market-search-input {
    flex-grow: 1;
}

.market-feed {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.market-feed-item {
    display: flex;
    gap: 20px;
    background: var(--white);
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: 0.2s;
    text-decoration: none;
    color: inherit;
}

.market-feed-item:hover {
    box-shadow: var(--shadow-card);
    transform: translateX(3px);
    text-decoration: none;
}

.market-feed-img {
    width: 160px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
}

.market-feed-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.market-feed-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    justify-content: space-between;
    padding: 5px 0;
}

.market-feed-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-red);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.market-feed-desc {
    font-size: 0.9rem;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

.market-feed-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 10px;
    gap: 16px;
}

.market-feed-price {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-dark);
}

.market-feed-meta {
    font-size: 0.8rem;
    color: #888;
    text-align: right;
}

.detail-gallery img {
    width: 100%;
    border-radius: 10px;
    max-height: 460px;
    object-fit: cover;
}

.company-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.company-strip img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.hint {
    color: #8f2230;
    font-size: .9rem;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stack-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

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

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

.checkbox-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.checkbox-row input {
    width: auto;
}

.professional-fields {
    border: 1px dashed #d5dae2;
    border-radius: 10px;
    padding: 12px;
}

.listing-image-manager {
    border: 1px solid #eadfd5;
    border-radius: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #fffdfa 0%, #faf4ee 100%);
}

.listing-image-manager-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.image-manager-toolbar {
    display: flex;
    gap: 10px;
}

.listing-image-manager-head strong {
    display: block;
    margin-bottom: 4px;
}

.listing-image-manager-head p {
    margin: 0;
    color: #6f675f;
    font-size: 0.92rem;
}

.image-manager-add {
    white-space: nowrap;
}

.image-manager-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-manager-dropzone {
    border: 2px dashed #d9c4b4;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    color: #6f675f;
    background: rgba(255, 255, 255, 0.7);
    margin-bottom: 14px;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.image-manager-dropzone strong,
.image-manager-dropzone span {
    display: block;
}

.image-manager-dropzone strong {
    margin-bottom: 6px;
}

.image-manager-dropzone.is-dragover {
    border-color: var(--primary-red);
    background: #fff3ea;
    transform: translateY(-1px);
}

.image-manager-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 14px;
    border: 1px solid #ebdfd4;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 16px;
    padding: 14px;
    cursor: grab;
}

.image-manager-row.dragging {
    opacity: 0.55;
}

.image-manager-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-manager-position {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-red);
}

.image-manager-preview-frame {
    height: 120px;
    border-radius: 12px;
    border: 1px dashed #d8c6b8;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #8a827b;
    font-size: 0.88rem;
}

.image-manager-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-manager-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-manager-row-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.image-manager-kind {
    font-size: 0.82rem;
    font-weight: 700;
    color: #8a5a44;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.image-manager-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.image-manager-drag-handle {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    background: #f7ede5;
    color: #6d5648;
    font-size: 0.88rem;
    font-weight: 700;
}

.image-manager-empty {
    border: 1px dashed #e0d0c3;
    border-radius: 14px;
    padding: 14px;
    color: #6f675f;
    background: rgba(255, 255, 255, 0.72);
}

.card-lite {
    border-radius: 14px;
    border: 1px solid #e7d8cc;
    padding: 12px 14px;
    background: #fffaf6;
}

.card-lite p,
.card-lite strong {
    margin: 0;
}

.card-lite p {
    color: #6f675f;
    margin-top: 6px;
    font-size: 0.92rem;
}

.form-action-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.auth-wrap.narrow {
    max-width: 520px;
}

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

.account-links .card {
    display: block;
}

.pill {
    background: #fdecef;
    color: #8f2230;
    border: 1px solid #f5ccd3;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .85rem;
}

.messages-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.market-chat-layout {
    align-items: start;
}

.market-chat-header-flex {
    margin-bottom: 24px;
}

.market-chat-sidebar,
.market-chat-panel {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.market-chat-sidebar {
    padding: 20px;
}

.market-chat-sidebar-head {
    border-bottom: 1px solid #eee;
    margin-bottom: 14px;
    padding-bottom: 14px;
}

.market-chat-sidebar-head h2,
.market-chat-conversation-head h2 {
    margin: 0 0 6px;
}

.market-chat-sidebar-head p,
.market-chat-empty p,
.market-chat-empty-note,
.market-thread-item p,
.market-chat-ad-meta,
.market-page-intro {
    color: #666;
}

.thread-item {
    border-radius: 16px;
    border: 1px solid #eee;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fbf8f5;
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.thread-item:hover {
    border-color: #efc6a7;
    background: #fffdf9;
    text-decoration: none;
    transform: translateY(-1px);
}

.thread-item.active {
    border-color: #cf6845;
    background: linear-gradient(180deg, #fff4ed 0%, #fffaf6 100%);
}

.market-thread-topline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.market-thread-topline strong {
    color: var(--text-dark);
}

.market-thread-topline span {
    font-size: 0.82rem;
    color: #8a8a8a;
    white-space: nowrap;
}

.market-thread-owner {
    color: var(--primary-red);
    font-size: 0.9rem;
    font-weight: 700;
}

.thread-item em {
    font-style: normal;
    color: #8f2230;
    font-weight: 700;
    font-size: .85rem;
}

.market-chat-empty-note {
    background: #faf6f1;
    border: 1px dashed #e5d4c6;
    border-radius: 14px;
    padding: 14px;
}

.market-chat-panel {
    padding: 24px;
}

.market-chat-empty {
    padding: 28px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.market-chat-conversation-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    border-bottom: 1px solid #eee;
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.market-chat-ad-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    font-size: 0.92rem;
}

.message-stream {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 520px;
    overflow: auto;
    margin-bottom: 18px;
}

.market-message-stream {
    padding-right: 4px;
}

.message-bubble {
    border: 1px solid #eadfd5;
    border-radius: 18px;
    padding: 14px 16px;
    max-width: 85%;
    box-shadow: 0 12px 24px rgba(56, 36, 18, 0.05);
}

.message-bubble strong {
    display: block;
    margin-bottom: 8px;
}

.message-bubble p {
    margin: 0 0 8px;
}

.message-bubble small {
    color: #8a8a8a;
}

.message-bubble.mine {
    margin-left: auto;
    background: linear-gradient(180deg, #fff1ea 0%, #ffe8dc 100%);
    border-color: #efc6b2;
}

.message-bubble.theirs {
    background: #fffdfb;
}

.market-chat-form {
    border-top: 1px solid #eee;
    padding-top: 18px;
}

.market-chat-compose {
    display: block;
    font-weight: 700;
}

.market-chat-compose span {
    display: block;
    margin-bottom: 8px;
}

.market-chat-compose textarea {
    min-height: 140px;
}

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

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.moderation-item .status-ok {
    color: var(--ok);
    font-weight: 700;
}

.moderation-item .status-muted {
    color: var(--muted);
}

.ip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

@media (max-width: 980px) {
    .listing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .listing-row {
        grid-template-columns: 1fr;
    }

    .listing-row .thumb,
    .listing-row .thumb img {
        width: 100%;
        height: 220px;
    }

    .listing-row .aside {
        text-align: left;
    }

    .account-links {
        grid-template-columns: 1fr;
    }

    .messages-layout {
        grid-template-columns: 1fr;
    }

    .listing-image-manager-head,
    .image-manager-row {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .listing-image-manager-head {
        align-items: stretch;
    }

    .form-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .market-chat-conversation-head,
    .market-chat-actions,
    .market-thread-topline {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .market-action-row {
        grid-template-columns: 1fr;
    }

    .market-feed-item {
        flex-direction: column;
    }

    .market-feed-img {
        width: 100%;
        height: 220px;
    }

    .market-feed-bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .market-feed-meta {
        text-align: left;
    }

    .gallery-thumbs {
        grid-template-columns: repeat(2, 1fr);
    }

    .market-features {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 0;
    }

    .main-nav {
        flex-wrap: wrap;
    }

    .search-bar {
        grid-template-columns: 1fr;
    }

    .listing-grid {
        grid-template-columns: 1fr;
    }

    .market-header-flex {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .market-filters {
        flex-direction: column;
    }

    .gallery-main img {
        height: 260px;
    }
}
