/* ============================================================
   Barter — общая тема оформления
   Стиль: дружелюбный (Avito-style), акцент — зелёный
   ============================================================ */

:root {
    /* Цвета — светлая тема (по умолчанию) */
    --bg:               #f6f7f9;
    --bg-elevated:      #ffffff;
    --bg-soft:          #f0f1f4;
    --bg-hover:         #e8eaee;

    --text:             #1a1d23;
    --text-secondary:   #5a626d;
    --text-muted:       #8b919c;

    --border:           #e3e5ea;
    --border-strong:    #d0d3da;

    --accent:           #27a047;
    --accent-hover:     #208a3c;
    --accent-light:     #e8f5ed;
    --accent-text:      #ffffff;

    --danger:           #e54545;
    --danger-hover:     #c93838;
    --danger-light:     #fdecec;

    --warning:          #f59e0b;
    --warning-light:    #fef5e0;

    --info:             #3b82f6;
    --info-light:       #e3eefc;

    --success:          #27a047;
    --success-light:    #e8f5ed;

    /* Размеры */
    --radius:           12px;
    --radius-sm:        8px;
    --radius-lg:        16px;

    --shadow-sm:        0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow:           0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg:        0 12px 24px rgba(0, 0, 0, 0.08);

    /* Контейнер */
    --container:        1200px;
    --container-narrow: 800px;
    --header-height:    64px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg:               #0f1115;
        --bg-elevated:      #1a1d23;
        --bg-soft:          #22262e;
        --bg-hover:         #2a2f38;

        --text:             #e8eaee;
        --text-secondary:   #9ba3af;
        --text-muted:       #6b7280;

        --border:           #2a2f38;
        --border-strong:    #353c47;

        --accent:           #3bbf5e;
        --accent-hover:     #2fa84e;
        --accent-light:     #1a3220;

        --danger-light:     #3a1d1d;
        --warning-light:    #3a2c14;
        --info-light:       #1c2a44;
        --success-light:    #1a3220;
    }
}

[data-theme="dark"] {
    --bg:               #0f1115;
    --bg-elevated:      #1a1d23;
    --bg-soft:          #22262e;
    --bg-hover:         #2a2f38;

    --text:             #e8eaee;
    --text-secondary:   #9ba3af;
    --text-muted:       #6b7280;

    --border:           #2a2f38;
    --border-strong:    #353c47;

    --accent:           #3bbf5e;
    --accent-hover:     #2fa84e;
    --accent-light:     #1a3220;

    --danger-light:     #3a1d1d;
    --warning-light:    #3a2c14;
    --info-light:       #1c2a44;
    --success-light:    #1a3220;
}

/* ============================================================
   Сброс и базовая типографика
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0 0 16px; font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 22px; letter-spacing: -0.01em; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p { margin: 0 0 12px; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

small { color: var(--text-muted); font-size: 13px; }

code {
    font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    background: var(--bg-soft);
    padding: 2px 6px;
    border-radius: 4px;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ============================================================
   Layout: container, header, footer
   ============================================================ */

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.container-narrow {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 0 20px;
}

.site-header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.site-logo:hover { text-decoration: none; color: var(--text); }
.site-logo__icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.site-city {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    background: transparent;
    flex-shrink: 0;
}
.site-city:hover { background: var(--bg-soft); }
.site-city::before { content: "📍"; margin-right: 4px; }

.site-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}
.site-search input {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    background: var(--bg-soft);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    transition: all 0.15s;
}
.site-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}
.site-nav__link {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-decoration: none;
    position: relative;
    white-space: nowrap;
}
.site-nav__link:hover {
    background: var(--bg-soft);
    color: var(--text);
    text-decoration: none;
}
.site-nav__badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 10px;
    line-height: 1.4;
}

.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 16px;
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--text); }

/* мобильное меню */
.site-nav__toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    font-size: 22px;
    color: var(--text);
}

@media (max-width: 900px) {
    .site-search { max-width: 100%; }
    .site-nav__link span:not(.site-nav__badge) { display: none; }
    .site-nav__link { padding: 8px; font-size: 18px; }
    /* Город НЕ прячем — это ключевой фильтр. Делаем компактнее:
       сокращаем отступы и ограничиваем длину названия. */
    .site-city {
        padding: 6px 6px;
        font-size: 13px;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 600px) {
    .site-header__inner { gap: 8px; padding: 0 12px; }
    .site-logo span { display: none; }
    .site-search { order: 99; flex-basis: 100%; }
    .site-header { height: auto; padding: 10px 0; }
}

.site-footer {
    margin-top: 60px;
    padding: 30px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}
.site-footer a { color: var(--text-secondary); margin: 0 8px; }

/* Хлебные крошки */
.breadcrumbs {
    font-size: 13px;
    margin-bottom: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs__sep { margin: 0 6px; color: var(--text-muted); }
.breadcrumbs__current { color: var(--text); font-weight: 600; }

/* ============================================================
   Карточки и сетки
   ============================================================ */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card--soft { background: var(--bg-soft); border: none; }
.card--accent { border-color: var(--accent); background: var(--accent-light); }

.page-wrap {
    padding: 24px 0;
    min-height: calc(100vh - var(--header-height) - 120px);
}

/* Сетка карточек объявлений */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.item-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
}
.item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-strong);
}
.item-card a { color: inherit; text-decoration: none; }
.item-card a:hover { text-decoration: none; }
.item-card__photo {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--bg-soft);
    overflow: hidden;
    position: relative;
}
.item-card__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.item-card__photo--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.item-card__photo--empty .item-card__photo-icon {
    font-size: 36px;
}
/* Счётчик "Нет фото" / "N фото" — всегда в правом верхнем углу */
.card-gallery__counter,
.item-card__photo--empty .card-gallery__counter {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 11px;
    line-height: 1.4;
    padding: 2px 7px;
    border-radius: 10px;
    z-index: 2;
}
.item-card__body {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.item-card__title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 6px;
    line-height: 1.3;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    /* Всегда резервируем место под 2 строки — чтобы мета не "гуляла" */
    height: calc(1.3em * 2);
}
.item-card__wants {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    /* Фиксированная высота под 2 строки — одинаково во всех карточках */
    height: calc(1.4em * 2);
}
/* Распорка: занимает всё свободное место, прижимая мету к низу */
.item-card__spacer {
    flex: 1 1 auto;
}
.item-card__meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 8px;
}

/* ============================================================
   Формы
   ============================================================ */

.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="tel"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: all 0.15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

textarea { min-height: 100px; resize: vertical; line-height: 1.5; }

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235a626d' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input[type="checkbox"], input[type="radio"] {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 6px;
    accent-color: var(--accent);
}

.form-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 14px;
    border-left: 3px solid var(--danger);
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================================
   Кнопки
   ============================================================ */

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-strong);
    white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--accent-text);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: #fff;
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { display: flex; width: 100%; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    background: var(--bg-soft);
    color: var(--text-secondary);
}
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-info     { background: var(--info-light); color: var(--info); }
.badge-danger   { background: var(--danger-light); color: var(--danger); }

.badge-pending      { background: var(--warning-light); color: var(--warning); }
.badge-accepted     { background: var(--success-light); color: var(--success); }
.badge-active       { background: var(--success-light); color: var(--success); }
.badge-rejected     { background: var(--danger-light); color: var(--danger); }
.badge-cancelled    { background: var(--bg-soft); color: var(--text-muted); }
.badge-completed    { background: var(--info-light); color: var(--info); }

/* Статусы объявлений */
.badge-draft        { background: var(--bg-soft); color: var(--text-muted); }
.badge-reserved     { background: var(--warning-light); color: var(--warning); }
.badge-exchanged    { background: var(--info-light); color: var(--info); }
.badge-archived     { background: var(--bg-soft); color: var(--text-muted); }
.badge-expired      { background: var(--bg-soft); color: var(--text-muted); }
.badge-reserved     { background: var(--warning-light); color: var(--warning); }
.badge-exchanged    { background: var(--info-light); color: var(--info); }
.badge-archived     { background: var(--bg-soft); color: var(--text-muted); }
.badge-draft        { background: var(--bg-soft); color: var(--text-muted); }

/* ============================================================
   Flash messages
   ============================================================ */

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border-left: 4px solid;
}
.flash-success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.flash-error   { background: var(--danger-light); color: var(--danger); border-color: var(--danger); }
.flash-info    { background: var(--info-light); color: var(--info); border-color: var(--info); }

/* ============================================================
   Чат
   ============================================================ */

.chat-thread {
    background: var(--bg-soft);
    border-radius: var(--radius);
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}
.message { margin-bottom: 12px; display: flex; }
.message__bubble {
    max-width: 70%;
    padding: 8px 14px;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}
.message__bubble small { display: block; margin-top: 4px; font-size: 11px; opacity: 0.7; }

.message--mine { justify-content: flex-end; }
.message--mine .message__bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message--theirs .message__bubble {
    background: var(--bg-elevated);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message--system { justify-content: center; }
.message--system .message__bubble {
    background: var(--warning-light);
    color: var(--warning);
    font-size: 13px;
    font-style: italic;
    text-align: center;
}

/* ============================================================
   Виджет городов (для формы создания объявления)
   ============================================================ */

.city-widget { position: relative; }
.city-detected {
    background: var(--success-light);
    color: var(--success);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    border-left: 3px solid var(--success);
}
.city-detected .change {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    width: auto;
}
.city-major-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.city-major-btn {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    width: auto;
    color: var(--text);
    transition: all 0.15s;
}
.city-major-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.city-search-box { position: relative; }
.city-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    box-shadow: var(--shadow-lg);
    margin-top: 4px;
}
.city-suggestion {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.city-suggestion:last-child { border-bottom: none; }
.city-suggestion:hover, .city-suggestion.active { background: var(--bg-soft); }
.city-suggestion .city-name { font-weight: 600; color: var(--text); }
.city-suggestion .region-name { color: var(--text-muted); font-size: 12px; }
.city-selected {
    background: var(--accent-light);
    color: var(--accent);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ============================================================
   Утилиты
   ============================================================ */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flex-gap { display: flex; gap: 12px; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* Списки без булитов */
.list-clean { list-style: none; padding: 0; margin: 0; }
.list-clean li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-clean li:last-child { border-bottom: none; }

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    margin: 24px 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.pagination a:hover { background: var(--bg-soft); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Empty state */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty__icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }

/* ============================================================
   Модальное окно
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow-lg);
}
.modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal__close:hover { background: var(--bg-soft); color: var(--text); }
.modal h2 { margin-top: 0; padding-right: 30px; }

/* ============================================================
   Drag-and-drop загрузка фото
   ============================================================ */

.photo-uploader {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-soft);
    transition: all 0.15s;
    margin-bottom: 12px;
}
.photo-uploader:hover,
.photo-uploader.is-drag {
    border-color: var(--accent);
    background: var(--accent-light);
}
.photo-uploader__icon { font-size: 36px; margin-bottom: 8px; opacity: 0.5; }
.photo-uploader__text { color: var(--text-secondary); font-size: 14px; }
.photo-uploader__hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.photo-uploader input[type="file"] { display: none; }

.photo-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.photo-preview {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-soft);
    border: 1px solid var(--border);
}
.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-preview__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-preview__remove:hover { background: var(--danger); }
.photo-preview__status {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    text-align: center;
}
.photo-preview__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    transition: width 0.2s;
}

/* ============================================================
   Аватары
   ============================================================ */

.avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-soft);
    vertical-align: middle;
    flex-shrink: 0;
    font-weight: 600;
    text-align: center;
    line-height: 40px;
    color: var(--text-secondary);
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar--lg { width: 80px; height: 80px; line-height: 80px; font-size: 28px; }
.avatar--xl { width: 120px; height: 120px; line-height: 120px; font-size: 40px; }
.avatar--sm { width: 28px; height: 28px; line-height: 28px; font-size: 12px; }

/* ============================================================
   Подсказка по выбору города в шапке
   ============================================================ */
.site-city::after {
    content: "▾";
    margin-left: 6px;
    font-size: 10px;
    opacity: 0.6;
}

/* ============================================================
   Мини-галерея в карточке товара (листание фото)
   ============================================================ */

.card-gallery {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--bg-soft);
    overflow: hidden;
}
.card-gallery__track {
    display: flex;
    height: 100%;
    transition: transform 0.25s ease;
}
.card-gallery__slide {
    min-width: 100%;
    height: 100%;
}
.card-gallery__slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Стрелки листания — появляются при наведении на карточку */
.card-gallery__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #1a1d23;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.item-card:hover .card-gallery__arrow { opacity: 1; }
.card-gallery__arrow:hover { background: #fff; }
.card-gallery__arrow--prev { left: 6px; }
.card-gallery__arrow--next { right: 6px; }
.card-gallery__arrow:disabled { opacity: 0 !important; cursor: default; }

/* Точки-индикаторы */
.card-gallery__dots {
    position: absolute;
    bottom: 6px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 4px;
    z-index: 2;
}
.card-gallery__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transition: background 0.15s;
}
.card-gallery__dot.is-active { background: #fff; }

/* На мобильных стрелки видны всегда (нет hover) */
@media (max-width: 700px) {
    .card-gallery__arrow { opacity: 0.85; }
}

/* Картинка-ссылка в слайде галереи занимает весь слайд */
.card-gallery__slide a {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================================
   Галерея на странице объявления (стрелки + клик для увеличения)
   ============================================================ */

.detail-gallery {
    position: relative;
    width: 100%;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 8px;
}
.detail-gallery__main {
    width: 100%;
    height: 460px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.detail-gallery__main img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    display: block;
}
.detail-gallery__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #1a1d23;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 2;
    transition: background 0.15s;
}
.detail-gallery__arrow:hover { background: #fff; }
.detail-gallery__arrow--prev { left: 12px; }
.detail-gallery__arrow--next { right: 12px; }
.detail-gallery__arrow:disabled { opacity: 0.35; cursor: default; }
.detail-gallery__counter {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    z-index: 2;
}

/* Лента миниатюр под главным фото */
.detail-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.detail-thumbs img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}
.detail-thumbs img.is-active { border-color: var(--accent); }

@media (max-width: 700px) {
    .detail-gallery__main { height: 300px; }
    .detail-gallery__arrow { width: 36px; height: 36px; font-size: 16px; }
}

/* ============================================================
   Лайтбокс (увеличенное фото поверх затемнённого сайта)
   ============================================================ */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    /* Отступы со всех сторон — картинка НИКОГДА не перекроет экран целиком,
       сайт за ней всегда виден по краям */
    padding: 48px;
    box-sizing: border-box;
    cursor: zoom-out;
}
.lightbox.is-open { display: flex; }
.lightbox__img {
    /* Жёсткие лимиты: не больше доступной области минус отступы */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}
.lightbox__close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.lightbox__arrow:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox__arrow--prev { left: 16px; }
.lightbox__arrow--next { right: 16px; }
.lightbox__counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 12px;
}

@media (max-width: 700px) {
    .lightbox { padding: 24px 12px; }
    .lightbox__arrow { width: 38px; height: 38px; font-size: 20px; }
}
