/* PostRed 2.0 — светлая тема в стиле VK */

:root {
    --vk-blue:       #0077FF;
    --vk-blue-hover: #0066DD;
    --vk-blue-light: #E8F3FF;
    --bg-page:       #EDEEF0;
    --bg-card:       #FFFFFF;
    --bg-input:      #F0F2F5;
    --text-primary:  #000000;
    --text-secondary:#818C99;
    --text-link:     #2A5885;
    --border:        #DCE1E6;
    --shadow:        0 1px 0 0 rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.04);
    --radius:        12px;
    --radius-sm:     8px;
    --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text-link);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* --- Оболочка приложения --- */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand__mark {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vk-blue);
    color: #fff;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 1;
}

.brand__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    line-height: 1.15;
}

.brand__name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.brand__kicker {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--vk-blue);
    text-decoration: none;
}
.app-logo:hover {
    text-decoration: none;
}

.app-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--vk-blue);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}

.app-main {
    flex: 1;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px;
}

.app-main--wide {
    max-width: 960px;
}

/* --- Навигация разделов --- */

.app-nav {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 64px;
    z-index: 90;
}

.app-nav__link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.app-nav__link:hover {
    background: var(--bg-input);
    text-decoration: none;
    color: var(--text-primary);
}

.app-nav__link.is-active {
    background: var(--vk-blue-light);
    color: var(--vk-blue);
}

/* --- Заголовок страницы --- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.page-header h1 {
    margin-bottom: 4px;
}

/* --- Настройки: боковое меню --- */

.settings-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    align-items: start;
}

.settings-nav {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px 12px 12px;
    position: sticky;
    top: 120px;
}

.settings-nav__group + .settings-nav__group {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.settings-nav__title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-secondary);
    padding: 8px 10px 6px;
}

.settings-nav__link {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    text-decoration: none;
}

.settings-nav__link:hover {
    background: var(--bg-input);
    text-decoration: none;
}

.settings-nav__link.is-active {
    background: var(--vk-blue-light);
    color: var(--vk-blue);
    font-weight: 500;
}

.settings-content {
    min-width: 0;
}

.settings-block-title {
    font-size: 16px;
    margin: 0 0 8px;
}

.settings-block-lead {
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 12px;
    color: var(--text-secondary);
}

.settings-howto {
    margin: 0 0 12px;
    padding-left: 1.25rem;
    font-size: 14px;
    line-height: 1.55;
}

.settings-howto li {
    margin: 0 0 8px;
}

.settings-howto-alt {
    font-size: 13px;
    line-height: 1.45;
    margin: 0 0 14px;
}

.settings-env-sample {
    white-space: pre-wrap;
    background: var(--bg-input);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    overflow: auto;
    margin: 0 0 12px;
}

/* --- Формы --- */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
    margin-top: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field--full {
    grid-column: 1 / -1;
}

.form-field--checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.form-field--radio {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.45;
    cursor: pointer;
}

.form-field--radio input {
    margin-top: 3px;
    flex-shrink: 0;
}

.source-credit-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.source-credit-fieldset .form-label {
    margin-bottom: 4px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font: inherit;
    color: var(--text-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--vk-blue);
    background: var(--bg-card);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

/* --- Список источников --- */

.source-list {
    list-style: none;
}

.source-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-input);
}

.source-item__order {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    padding-top: 2px;
}

.source-item__move {
    min-width: 36px;
    padding-left: 8px;
    padding-right: 8px;
    line-height: 1.2;
}

.source-item__move:disabled {
    opacity: 0.35;
    cursor: default;
}

.source-item:last-child {
    border-bottom: none;
}

.source-item__title {
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.source-item__url {
    font-size: 13px;
    word-break: break-all;
}

.source-item__meta {
    font-size: 12px;
    margin-top: 6px;
}

.source-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.inline-form {
    display: inline;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.badge--vk   { background: var(--vk-blue-light); color: var(--vk-blue); }
.badge--rss  { background: #FFF4E5; color: #B86E00; }
.badge--site { background: #E8F5E9; color: #2E7D32; }
.badge--off  { background: var(--bg-input); color: var(--text-secondary); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
}

.empty-state p + p {
    margin-top: 8px;
}

.empty-state .btn {
    margin-top: 16px;
}

/* --- Лента новостей --- */

.feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feed-sources {
    position: sticky;
    top: 0;
    z-index: 60;
    margin: 0 0 12px;
    padding: 4px 0 8px;
    background: linear-gradient(to bottom, var(--bg-page) 78%, rgba(237, 238, 240, 0));
}

.feed-sources__row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.feed-sources__track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0;
    flex: 1 1 auto;
    min-width: 0;
}

.feed-sources__track::-webkit-scrollbar {
    display: none;
}

.feed-sources__arrow {
    display: none;
}

@media (min-width: 769px) {
    .feed-sources__arrow {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border: 1px solid var(--border);
        border-radius: 50%;
        background: var(--bg-card);
        color: var(--text-primary);
        font-size: 22px;
        line-height: 1;
        cursor: pointer;
        padding: 0;
        transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    }

    .feed-sources__arrow:hover:not(:disabled) {
        border-color: var(--vk-blue);
        color: var(--vk-blue);
        background: var(--vk-blue-light, #e7f1ff);
    }

    .feed-sources__arrow:disabled,
    .feed-sources__arrow[hidden] {
        display: none;
    }

    .feed-sources__arrow:focus-visible {
        outline: 2px solid var(--vk-blue);
        outline-offset: 2px;
    }
}

.feed-sources__tab {
    flex: 0 0 auto;
    scroll-snap-align: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    padding: 9px 14px;
    cursor: pointer;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.feed-sources__tab.is-active {
    background: var(--vk-blue);
    border-color: var(--vk-blue);
    color: #fff;
}

.feed-source-info {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.45;
}

.feed-source-info__label {
    display: block;
    font-size: 12px;
    margin-bottom: 2px;
}

.feed-panel--source-filter .feed-card--source-active {
    box-shadow: inset 3px 0 0 var(--vk-blue);
}

.feed-card__source-credit {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--vk-blue-light);
    color: var(--vk-blue);
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
    border: 1px solid transparent;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    cursor: pointer;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.feed-card__source-credit:hover {
    border-color: rgba(0, 119, 255, 0.35);
}

.feed-card__source-credit--none {
    background: rgba(129, 140, 153, 0.12);
    color: var(--text-muted, #818c99);
}

.feed-card__source-credit--none:hover {
    border-color: rgba(129, 140, 153, 0.4);
}

.feed-card__source-credit:disabled {
    opacity: 0.7;
    cursor: default;
}

.feed-sources__tab:focus-visible {
    outline: 2px solid var(--vk-blue);
    outline-offset: 2px;
}

.feed-swipe {
    touch-action: pan-y;
}

.feed-panel {
    position: relative;
    min-height: 120px;
}

.feed-panel--loading {
    pointer-events: none;
}

.feed-panel--loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(237, 238, 240, 0.55);
    border-radius: var(--radius);
    z-index: 2;
}

.feed-panel--loading::before {
    content: '';
    position: absolute;
    top: 48px;
    left: 50%;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    border: 3px solid var(--vk-blue-light);
    border-top-color: var(--vk-blue);
    border-radius: 50%;
    animation: feed-collect-spin 0.75s linear infinite;
    z-index: 3;
}

.feed-empty {
    margin-top: 0;
}

.feed-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--vk-blue, #2787f5);
    padding: 4px 2px 0;
}

.feed-section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0 4px;
    color: var(--text-muted, #818c99);
    font-size: 12px;
}

.feed-section-divider::before,
.feed-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color, #e7e8ec);
}

.feed-new-count {
    color: var(--vk-blue, #2787f5);
    font-weight: 600;
}

.feed-card--seen {
    opacity: 0.72;
}

.feed-card--seen .feed-card__header,
.feed-card--seen .feed-card__text {
    color: inherit;
}

.feed-card__header-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.feed-card__badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 999px;
}

.feed-card__badge--new {
    background: rgba(39, 135, 245, 0.12);
    color: var(--vk-blue, #2787f5);
}

.feed-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 0;
}

.feed-card__author {
    padding: 8px 16px 0;
    font-size: 13px;
    color: var(--color-text-muted, #6d7885);
}

.feed-card__link-mode {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 4px 16px 0;
}

.link-mode-toggle {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    line-height: 1.35;
    font-weight: 500;
    color: var(--color-primary, #4a76a8);
    background: rgba(74, 118, 168, 0.1);
    border: 1px solid rgba(74, 118, 168, 0.35);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.link-mode-toggle:hover:not(:disabled) {
    background: rgba(74, 118, 168, 0.18);
    border-color: var(--color-primary, #4a76a8);
}

.link-mode-toggle:disabled {
    cursor: default;
    opacity: 0.85;
}

.link-mode-toggle--photo {
    color: #2a6a3a;
    background: rgba(42, 106, 58, 0.1);
    border-color: rgba(42, 106, 58, 0.35);
}

.link-mode-toggle--photo:hover:not(:disabled) {
    background: rgba(42, 106, 58, 0.18);
    border-color: #2a6a3a;
}

.link-mode-toggle--none {
    color: var(--text-muted, #818c99);
    background: rgba(129, 140, 153, 0.12);
    border-color: rgba(129, 140, 153, 0.35);
}

.link-mode-toggle--none:hover:not(:disabled) {
    background: rgba(129, 140, 153, 0.2);
    border-color: var(--text-muted, #818c99);
}

.feed-card__link-preview-url {
    font-size: 11px;
    line-height: 1.35;
    color: var(--color-link, #2a5885);
    word-break: break-all;
    text-decoration: none;
}

.feed-card__link-preview-url:hover {
    text-decoration: underline;
}

.feed-card__link-mode-status {
    flex: 1 1 100%;
    font-size: 11px;
}

.feed-card__source {
    font-weight: 600;
    font-size: 14px;
}

.feed-card__time {
    font-size: 12px;
    flex-shrink: 0;
}

.feed-card__text {
    padding: 10px 16px 0;
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-line;
    word-break: break-word;
}

.feed-card__media {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px;
    padding: 12px 16px 0;
}

.feed-card__media-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 0;
}

.feed-card__media-actions .media-action-btn.copied {
    border-color: var(--color-success, #4bb34b);
    color: var(--color-success, #4bb34b);
}

.feed-card__media-status {
    font-size: 12px;
    flex: 1 1 100%;
}

.feed-card__footer {
    padding: 12px 16px 14px;
    font-size: 13px;
}

.feed-card__edited {
    margin: 12px 16px 0;
    padding: 12px 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-primary, #5181b8);
}

.feed-card__text--edited {
    line-height: 1.45;
}

.feed-card__credit-line {
    padding: 8px 16px 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-muted, #818c99);
    white-space: pre-line;
}

.feed-card__edited .feed-card__credit-line {
    padding: 8px 0 0;
}

.feed-card__credit-line--preview {
    padding-top: 10px;
}

.feed-card__actions {
    padding: 12px 16px 14px;
}

.feed-card__actions .feed-copy-btn.copied {
    border-color: var(--color-success, #4bb34b);
    color: var(--color-success, #4bb34b);
}

.feed-card__editor {
    padding: 0 16px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feed-card__edited-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.feed-card__edited-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.feed-card__edited-form {
    margin-top: 4px;
}

.feed-card__edit-input {
    width: 100%;
    min-height: 140px;
    resize: vertical;
    font-size: 14px;
    line-height: 1.45;
}

.feed-card__edit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.feed-card__edited-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary, #5181b8);
}

.feed-card__edited-head .ai-copy-btn.copied {
    border-color: var(--color-success, #4bb34b);
    color: var(--color-success, #4bb34b);
}

.feed-card__ai {
    padding: 0 16px 14px;
}

.feed-card__ai-label {
    font-size: 12px;
    margin-bottom: 8px;
}

.feed-card__ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.feed-card__ai-status {
    font-size: 12px;
    margin-top: 8px;
    min-height: 16px;
}

.feed-card__ai-actions .btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

textarea.form-input {
    min-height: 120px;
    resize: vertical;
}

.feed-media {
    display: block;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
    aspect-ratio: 4 / 3;
}

.feed-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.feed-media--video {
    min-height: 160px;
}

.feed-media--video .feed-media__link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    color: #fff;
    position: relative;
}

.feed-media--video img {
    position: absolute;
    inset: 0;
    opacity: 0.85;
}

.feed-media__play {
    position: relative;
    z-index: 1;
    background: rgba(0, 0, 0, 0.55);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}

.feed-media--photo {
    aspect-ratio: auto;
}

.feed-media__link {
    display: block;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.feed-media__remove {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.feed-card.is-editing-media .feed-media__remove {
    display: inline-flex;
}

.feed-media__remove:hover,
.feed-media__remove:focus-visible {
    background: rgba(200, 40, 40, 0.92);
    outline: none;
}

.feed-media.is-removing {
    opacity: 0.45;
    pointer-events: none;
}

.feed-media--photo img {
    aspect-ratio: auto;
    height: auto;
    max-height: 480px;
}

/* --- Карточки --- */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-body {
    padding: 20px;
}

/* --- Кнопки --- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    text-decoration: none;
}
.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--vk-blue);
    color: #fff;
}
.btn-primary:hover {
    background: var(--vk-blue-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* --- Алерты --- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: left;
}

.alert-error {
    background: #FFECEC;
    color: #C0392B;
    border: 1px solid #F5C6C6;
}

.alert-success {
    background: #E8F8E8;
    color: #1E7E34;
    border: 1px solid #C3E6CB;
}

.alert-warn {
    background: #FFF8E6;
    color: #8A6100;
    border: 1px solid #FFE8A3;
}

/* --- Шапка приложения: пользователь --- */

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.header-name {
    font-size: 14px;
    color: var(--text-secondary);
}

@media (max-width: 480px) {
    .header-name {
        display: none;
    }
}

/* --- Текст --- */

.text-muted {
    color: var(--text-secondary);
    font-size: 14px;
}

.text-center {
    text-align: center;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* --- Страница входа --- */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
    text-align: center;
}

.login-card .brand {
    justify-content: center;
    margin: 0 auto 20px;
}

.login-card .brand__mark {
    width: 44px;
    height: 44px;
    font-size: 16px;
    border-radius: 13px;
}

.login-card .brand__name {
    font-size: 22px;
}

.login-card .brand__kicker {
    font-size: 12px;
    letter-spacing: 0.16em;
}

.login-card h1 {
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

.login-note {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}

.login-form .form-label {
    display: block;
    margin-bottom: 6px;
}

.login-form .btn {
    margin-top: 4px;
}

/* --- Статус системы (dev) --- */

.status-list {
    list-style: none;
    margin-top: 20px;
    text-align: left;
}

.status-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--bg-input);
}
.status-list li:last-child {
    border-bottom: none;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.ok   { background: #4BB34B; }
.status-dot.fail { background: #E64646; }
.status-dot.warn { background: #F5A623; }

/* --- Адаптив --- */

@media (max-width: 480px) {
    .login-card {
        padding: 32px 20px;
    }
    .app-main {
        padding: 16px 12px;
    }
    .settings-layout {
        grid-template-columns: 1fr;
    }
    .settings-nav {
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
    }
    .settings-nav__title {
        width: 100%;
    }
    .source-item {
        flex-direction: column;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
    }
}

.feed-card__publish {
    padding: 0 16px 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.editor-source-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.editor-source-back {
    margin-left: auto;
    font-size: 14px;
}

.feed-card__publish-status,
.feed-card__max-status,
.feed-card__city-status {
    font-size: 12px;
    flex: 1 1 100%;
}

.feed-card__city-publish {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.feed-card__city-ok {
    font-size: 13px;
    color: var(--color-success, #4bb34b);
}

.text-success {
    color: var(--color-success, #4bb34b);
}

.text-danger {
    color: var(--color-danger, #e64646);
}

.feed-load-more {
    display: flex;
    justify-content: center;
    padding: 8px 0 24px;
}

.feed-load-more .btn {
    min-width: 200px;
}

.feed-load-more .btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.feed-load-more .btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--vk-blue);
    border-radius: 50%;
    animation: feed-collect-spin 0.75s linear infinite;
}

.download-photos-hint {
    margin-bottom: 12px;
}

.download-photos-zip {
    margin: 0 0 16px;
}

.download-photos-list {
    display: grid;
    gap: 16px;
}

.download-photo {
    overflow: hidden;
}

.download-photo__img {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: var(--bg-input);
}

.download-photo__actions {
    padding: 14px 16px 16px;
}

.download-photo__tip {
    margin: 8px 0 0;
    font-size: 12px;
    text-align: center;
}

/* --- Редактор --- */

.editor-page .editor-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 900px;
}

.editor-field {
    display: block;
}

.editor-field__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.editor-field__head .form-label {
    margin-bottom: 0;
}

.editor-field__head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.editor-mode {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    flex-shrink: 0;
}

.editor-mode__chip {
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.editor-mode__chip:hover,
.editor-mode__chip:active,
.editor-mode__chip:focus {
    color: var(--text-primary);
    opacity: 1;
    outline: none;
}

.editor-mode__chip.is-active,
.editor-mode__chip.is-active:hover,
.editor-mode__chip.is-active:active,
.editor-mode__chip.is-active:focus {
    background: var(--vk-blue);
    color: #fff;
    opacity: 1;
}

.editor-field__head #editor-copy-text.copied {
    border-color: var(--color-success, #4bb34b);
    color: var(--color-success, #4bb34b);
}

.editor-textarea {
    width: 100%;
    min-height: 160px;
    padding: 14px 16px;
    font: inherit;
    font-size: 15px;
    line-height: 1.55;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    resize: vertical;
}

.editor-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(81, 129, 184, 0.2);
}

.editor-photos-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.editor-photo-add-mobile {
    display: none;
}

.editor-photo-add {
    cursor: pointer;
}

.editor-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.editor-vk-attach {
    display: flex;
    gap: 8px;
    margin: 0 0 8px;
    align-items: center;
}

.editor-vk-attach .form-input {
    flex: 1;
    min-width: 0;
}

.editor-vk-attach-hint {
    font-size: 12px;
    margin: 0 0 10px;
    line-height: 1.4;
}

.editor-photo-item {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
}

.editor-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.editor-photo-item__vk {
    position: absolute;
    left: 6px;
    bottom: 6px;
    z-index: 1;
    background: rgba(20, 20, 20, 0.72);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}
    display: block;
}

.editor-photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.editor-ai-label {
    font-size: 13px;
    margin-bottom: 8px;
}

.editor-ai {
    margin: 4px 0 16px;
}

.editor-ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-platforms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}

.editor-platform {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    cursor: pointer;
}

.editor-platform input:disabled + span {
    opacity: 0.45;
}

.editor-templates {
    margin: 4px 0 4px;
}

.editor-templates .choice-tiles {
    padding: 0;
}

.editor-templates .choice-tile.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.editor-publish-mobile {
    display: none;
}

.editor-publish-row {
    padding-top: 8px;
}

.editor-publish-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
}

.editor-results {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-status {
    font-size: 14px;
}

.morning-checkboxes {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

@media (min-width: 640px) {
    .morning-checkboxes {
        grid-template-columns: 1fr 1fr;
    }
}

.morning-history-preview {
    font-size: 13px;
    margin: 6px 0 0;
    line-height: 1.45;
    white-space: pre-wrap;
}

.editor-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.editor-modal[hidden] {
    display: none;
}

.editor-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.editor-modal__box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.editor-modal__box p {
    margin: 0 0 16px;
    line-height: 1.5;
}

.editor-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.editor-day-summary-modal .editor-modal__box {
    max-width: 480px;
    max-height: min(92vh, 720px);
    overflow-y: auto;
}

.editor-day-summary-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 600;
}

.editor-day-summary-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.editor-day-summary-field {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.editor-day-summary-field .form-label,
.editor-day-summary-field legend.form-label {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 600;
}

.editor-day-summary-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.editor-day-summary-sources {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border, #e5e5e5);
    border-radius: var(--radius-sm, 8px);
    background: var(--bg-muted, #f7f7f8);
}

.editor-day-summary-source-note {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}

.editor-day-summary-source-link {
    margin-left: 6px;
    font-size: 12px;
}

.editor-day-summary-source-missing {
    margin: 0;
    font-size: 13px;
}

.editor-day-summary-source {
    margin: 0;
}

.editor-template-busy {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.editor-template-busy[hidden] {
    display: none !important;
}

.editor-template-busy__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.editor-template-busy__box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 320px;
    padding: 28px 24px;
    text-align: center;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.editor-template-busy__spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 16px;
    border: 3px solid var(--border, #e5e5e5);
    border-top-color: var(--vk-blue, #5181b8);
    border-radius: 50%;
    animation: editor-template-busy-spin 0.75s linear infinite;
}

@keyframes editor-template-busy-spin {
    to {
        transform: rotate(360deg);
    }
}

.editor-template-busy__title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}

.editor-template-busy__hint {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-muted, #818c99);
}

.feed-collect-busy {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    background: rgba(237, 238, 240, 0.82);
    backdrop-filter: blur(2px);
}

.feed-collect-busy[hidden] {
    display: none !important;
}

.feed-collect-busy__box {
    width: 100%;
    max-width: 320px;
    padding: 28px 24px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.feed-collect-busy__spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--vk-blue-light);
    border-top-color: var(--vk-blue);
    border-radius: 50%;
    animation: feed-collect-spin 0.75s linear infinite;
}

@keyframes feed-collect-spin {
    to {
        transform: rotate(360deg);
    }
}

.feed-collect-busy__title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 600;
}

.feed-collect-busy__hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}

#collect-btn.is-loading {
    position: relative;
    color: transparent;
}

#collect-btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: feed-collect-spin 0.75s linear infinite;
}

.editor-day-summary-modal.is-loading .editor-modal__box {
    pointer-events: none;
}

.editor-day-summary-modal.is-loading #editor-day-summary-submit {
    position: relative;
    min-width: 7.5rem;
    color: transparent;
}

.editor-day-summary-modal.is-loading #editor-day-summary-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: editor-template-busy-spin 0.75s linear infinite;
}

.editor-desktop-actions {
    display: none;
}

.editor-undo-ai {
    margin: 0 0 16px;
}

.more-sheet__section {
    padding: 4px 20px 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* --- Сегменты / плитки выбора --- */

.choice-segment {
    display: flex;
    gap: 6px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.choice-segment--wrap {
    flex-wrap: wrap;
}

.choice-segment__btn {
    position: relative;
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 14px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.choice-segment--wrap .choice-segment__btn {
    flex: 1 1 calc(33.333% - 6px);
    min-width: 96px;
}

.choice-segment__btn input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.choice-segment__icon {
    display: inline-flex;
    color: currentColor;
    flex-shrink: 0;
}

.choice-segment__btn:hover {
    color: var(--text-primary);
}

.choice-segment__btn.is-active,
.choice-segment__btn:has(input:checked) {
    background: var(--bg-card);
    color: var(--vk-blue);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 119, 255, 0.12);
}

.choice-segment__btn:focus-visible {
    outline: 2px solid var(--vk-blue);
    outline-offset: 2px;
}

.choice-tiles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 16px 16px;
}

.choice-tiles--row {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
}

.choice-tile {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.choice-tiles--row .choice-tile {
    flex: 1 1 220px;
}

.choice-tile:hover,
.choice-tile:focus-visible {
    border-color: rgba(0, 119, 255, 0.35);
    background: var(--vk-blue-light);
    text-decoration: none;
    outline: none;
}

.choice-tile:active {
    background: #dcecfc;
}

.choice-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--vk-blue-light);
    color: var(--vk-blue);
    flex-shrink: 0;
}

.choice-tile__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding-top: 2px;
}

.choice-tile__title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.choice-tile__hint {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.35;
}

.choice-tile--link {
    color: inherit;
}

#feed-filter-sheet .app-sheet__body {
    padding: 8px 16px 20px;
}

.editor-day-summary-field .choice-segment {
    margin-top: 4px;
}

.editor-ai--sheet {
    padding: 0 16px 16px;
}

.editor-ai--sheet .editor-ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-ai--sheet .editor-ai-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 40px;
    justify-content: center;
}

@media (min-width: 769px) {
    .editor-templates {
        margin: 0 0 8px;
    }

    .editor-page #editor-more-sheet:not([hidden]) {
        display: flex !important;
        position: fixed;
        inset: 0;
        z-index: 1000;
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    .editor-page #editor-more-sheet .app-sheet__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
    }

    .editor-page #editor-more-sheet .app-sheet__panel {
        position: relative;
        z-index: 1;
        width: min(420px, calc(100vw - 32px));
        max-height: calc(100vh - 32px);
        border-radius: var(--radius);
        background: var(--bg-card);
        box-shadow: var(--shadow);
        overflow: auto;
    }

    .editor-page #editor-more-sheet .app-sheet__handle {
        display: none;
    }

    .editor-page #editor-more-sheet .choice-tiles {
        padding: 8px 16px 20px;
    }
}

/* Toast-уведомления */
.app-toast-host {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    pointer-events: none;
}

.app-toast-host[hidden] {
    display: none !important;
}

.app-toast {
    position: relative;
    flex: 0 1 auto;
    max-width: 100%;
    padding: 14px 20px;
    background: #2c2d2e;
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.app-toast--error {
    background: #5c1f1f;
}
