/* На Севере — базовый стиль в духе VK */
:root {
    --bg: #edeef0;
    --card-bg: #ffffff;
    --accent: #0077ff;
    --accent-hover: #0066dd;
    --text: #000000;
    --text-secondary: #818c99;
    --border: #e7e8ec;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 990px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    min-width: 0;
}

.logo-img {
    height: 34px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-text {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar nav {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.topbar nav a {
    margin-left: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.topbar nav a:hover { color: var(--accent); }

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

.post-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    background: var(--accent);
}

.author { font-weight: 600; font-size: 14px; }
.date { font-size: 13px; color: var(--text-secondary); }

/* Ссылки в VK-стиле: цвет текста не меняется, underline при наведении */
.author a, .date a {
    color: inherit;
    text-decoration: none;
}
.author a:hover, .date a:hover {
    text-decoration: underline;
}

.post-body {
    font-size: 15px;
    line-height: 1.45;
    word-wrap: break-word;
}

.body-clip, .body-full, .body-text {
    white-space: pre-wrap;
}

.post-photos {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.post-photos a { color: var(--accent); text-decoration: none; }

.empty {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--text-secondary);
}

.pager { text-align: center; margin: 16px 0; }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 8px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
}

.btn:hover { background: var(--accent-hover); }

/* Кат «Показать ещё» в VK-стиле */
.post-body .body-full { display: none; }
.post-body.expanded .body-full { display: inline; }
.post-body.expanded .clip-fade, .post-body.expanded .body-clip-wrap { display: none; }
.show-more {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    cursor: pointer;
    padding: 0;
    margin-top: 4px;
    font-family: inherit;
    display: block;
    text-align: left;
}
.show-more:hover { text-decoration: underline; }
.body-clip-wrap { position: relative; }
.clip-fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.4em;
    background: linear-gradient(to bottom, rgba(255,255,255,0), #ffffff);
    pointer-events: none;
}

/* Tileboard: главное фото 2/3, мозаика остальных 1/3 */
.tileboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2px;
    margin-top: 8px;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 3 / 2;
}
.tile-main-wrap, .tile-s-wrap {
    display: block;
    position: relative;
    overflow: hidden;
    background: #dfe3e8;
}
.tile-main, .tile-s {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tile-side {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}
.tile-side .tile-s-wrap { height: 100%; }
.tile-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 22px;
    font-weight: 600;
}

/* Одно фото — без сетки, просто широкое */
.tileboard.t1 { display: block; aspect-ratio: 4 / 3; }

/* t2: две равные колонки — без дыр */
.tileboard.t2 { grid-template-columns: 1fr 1fr; aspect-ratio: 2 / 1; }
.tileboard.t2 .tile-side { grid-template-rows: 1fr; }

/* t3: большое слева + 2 справа (а не 3) — без дыр */
.tileboard.t3 .tile-side { grid-template-rows: repeat(2, 1fr); }

/* t5: большое слева + 2×2 справа, на последней «+N» */
.tileboard.t5 .tile-side { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }

.footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 24px 0 40px;
}

/* Бесконечная лента: сенсор догрузки + спиннер */
.load-sensor {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: none;
}

.htmx-request .spinner,
.spinner.htmx-request {
    display: block;
}

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

/* Панель действий между topbar и лентой */
.actionbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}

.actionbar-inner {
    max-width: 660px;
    margin: 0 auto;
    padding: 0 12px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-create {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #5b7a99;
    color: #fff;
    border-radius: var(--radius);
    padding: 9px 16px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.btn-create:hover { background: #4e6b87; }

@media (max-width: 640px) {
    .actionbar-inner { padding: 0 10px; }
}

/* Панель фото в редактировании: сетка 2-в-ряд + крестик + плюс-плашка */
.edit-photos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 12px 0;
}

.edit-photo {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #f0f2f5;
    aspect-ratio: 4/3;
}

.edit-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #333;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.photo-x:hover { background: #ffe2e2; color: #c33; }

.photo-add-cell {
    aspect-ratio: 4/3;
    border: 2px dashed var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    background: #fafbfc;
    padding: 10px;
    text-align: center;
}

.photo-add-cell:hover { border-color: var(--accent); background: #f0f4f8; }

.photo-add-cell img {
    width: 20%;
    height: 20%;
    min-width: 28px;
    min-height: 28px;
    object-fit: contain;
    opacity: 0.85;
}

.photo-add-label {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Форма создания объявления */
.compose-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.compose-card h1 { font-size: 20px; margin: 0 0 14px; }

.compose-author {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 12px;
}

.compose-card textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font: inherit;
    resize: vertical;
}

.photo-picker { margin: 12px 0; }

.photo-add {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
}

.icon-add-photo {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.photo-add:hover { border-color: var(--accent); color: var(--accent); }

.photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.photo-thumb-cell {
    position: relative;
}

.photo-thumb {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 8px;
}

.compose-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.photo-count { color: var(--text-secondary); font-size: 13px; }

/* Кнопка VK на странице входа */
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    margin: 24px auto;
}
.login-card h1 { font-size: 20px; margin: 0 0 14px; }
.btn-vk {
    display: block;
    text-align: center;
    background: #0077FF;
    color: #fff;
    border-radius: var(--radius);
    padding: 10px 16px;
    text-decoration: none;
    font-weight: 600;
}
.btn-vk:hover { background: #0066dd; }
.login-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 16px 0 10px;
}
.login-local { display: flex; gap: 8px; }
.login-local input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font: inherit;
}
.login-note {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 10px;
}

/* Стрип действий в карточке (редактировать/удалить) */
.post-card { position: relative; }

.post-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
    gap: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
}

.post-card:hover .post-actions { display: flex; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}

.icon-btn img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.icon-btn:hover { background: rgba(91, 122, 153, 0.12); }

/* Нижний стрип: лайк/дизлайк/комментарий */
.post-strip {
    display: flex;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.strip-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    min-width: 0;
}

.strip-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    opacity: 0.85;
}

.strip-btn:hover { background: rgba(91, 122, 153, 0.10); }

.strip-btn.active img { opacity: 1; }
.strip-like.active .cnt { color: #e64646; font-weight: 600; }
.strip-dislike.active .cnt { color: #5b7a99; font-weight: 600; }

.cnt:empty { display: none; }

/* Комментарии (VK-стиль) */
.post-comments { margin-top: 10px; }

.comment {
    display: flex;
    gap: 10px;
    padding: 6px 0;
}

.comment .avatar { width: 32px; height: 32px; }

.comment-body {
    background: #f0f2f5;
    border-radius: 10px;
    padding: 7px 12px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.comment-author { font-weight: 600; }
.comment-text { white-space: pre-wrap; margin-top: 2px; }

.comment-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: 8px;
}

.comment-input-row .avatar { width: 32px; height: 32px; }

.comment-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f0f2f5;
    border-radius: 10px;
    padding: 0 6px 0 12px;
}

.comment-input-wrap textarea {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    font: inherit;
    font-size: 14px;
    padding: 9px 0;
    max-height: 120px;
    outline: none;
}

.send-btn {
    border: none;
    background: none;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
}

.send-btn img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    opacity: 0.35;
    transition: opacity 0.15s;
}

.send-btn.enabled img { opacity: 1; }
.send-btn.enabled:hover { background: rgba(91, 122, 153, 0.12); }

/* Модальное окно подтверждения */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px 24px;
    max-width: 340px;
    width: calc(100% - 32px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 16px; color: var(--text-secondary); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.btn-secondary {
    border: 1px solid var(--border);
    background: none;
    border-radius: var(--radius);
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
    color: var(--text-secondary);
}
.btn-secondary:hover { background: rgba(0,0,0,0.04); }

.btn-danger {
    border: none;
    background: #e64646;
    color: #fff;
    border-radius: var(--radius);
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.btn-danger:hover { background: #d13c3c; }

@media (max-width: 640px) {
    /* на тач-экранах hover нет — показываем стрип сразу */
    .post-actions { display: flex; }
}

/* Статические страницы (О сайте, Правила, Тарифы) */
.static-page {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 24px;
    font-size: 15px;
    line-height: 1.55;
}

.static-page h1 {
    font-size: 22px;
    margin: 0 0 16px;
}

.static-page h2 {
    font-size: 18px;
    margin: 24px 0 8px;
}

.static-page h3 {
    font-size: 16px;
    margin: 16px 0 8px;
}

.static-page a { color: var(--accent); }

.static-page ul {
    padding-left: 20px;
    margin: 8px 0;
}

.price-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 10px 0;
    background: #fafbfc;
}

.price-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

@media (max-width: 640px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: 10px 10px;
        gap: 6px;
    }
    .container { padding: 0 8px; }
    .logo-text { font-size: 13px; }
    .topbar nav a { margin-left: 0; margin-right: 14px; font-size: 13px; }
    .topbar nav a:first-child { margin-right: 14px; }
}

/* Лайтбокс: полноэкранный просмотр фото поста */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox .lb-img {
    max-width: calc(100vw - 96px);
    max-height: calc(100vh - 96px);
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}

.lightbox .lb-close,
.lightbox .lb-nav {
    position: absolute;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.lightbox .lb-close:hover,
.lightbox .lb-nav:hover { background: rgba(255, 255, 255, 0.25); }

.lightbox .lb-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 26px;
    border-radius: 50%;
}

.lightbox .lb-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 72px;
    font-size: 34px;
    border-radius: 8px;
}

.lightbox .lb-prev { left: 16px; }
.lightbox .lb-next { right: 16px; }

.lightbox .lb-count {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 12px;
}

@media (max-width: 640px) {
    .lightbox .lb-img { max-width: calc(100vw - 24px); max-height: calc(100vh - 80px); }
    .lightbox .lb-nav { width: 40px; height: 56px; font-size: 26px; }
    .lightbox .lb-prev { left: 6px; }
    .lightbox .lb-next { right: 6px; }
}

/* Плашка источника репоста: аватар-кружок + название группы */
.repost-source {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 2px;
    padding: 4px 10px 4px 4px;
    background: #f0f2f5;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    max-width: 100%;
}

.repost-source:hover { background: #e5ebf1; }

.repost-source .rs-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.repost-source .rs-placeholder {
    background: #5b7a99;
    color: #fff;
    font-size: 13px;
}

.repost-source .rs-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* Страница поста: блок «Поделиться в VK» */
.share-block {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 14px 0 4px;
}

.btn-back {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
}

.btn-back:hover { color: var(--accent); }

/* Копирование ссылки: иконка-цепочка в стрипе + тост */
.strip-copylink svg { display: block; }

.ns-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%) translateY(16px);
    background: rgba(38, 50, 64, .92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 1200;
}

.ns-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Страница предложений: бар с сортировкой */
.offers-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sort-switch {
    display: inline-flex;
    border: 1px solid #d3dbe3;
    border-radius: 8px;
    overflow: hidden;
}

.sort-btn {
    padding: 7px 14px;
    font-size: 13px;
    color: var(--text-secondary, #5b7a99);
    text-decoration: none;
    background: #fff;
}

.sort-btn + .sort-btn { border-left: 1px solid #d3dbe3; }

.sort-btn.active {
    background: #eef3f8;
    color: var(--text, #26324a);
    font-weight: 600;
}

/* Просмотры: глаз + счётчик, прижат вправо в стрипе */
.strip-views {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    color: var(--text-secondary, #5b7a99);
    font-size: 13px;
    opacity: .85;
}
