/* ===== ФОРМА СОЗДАНИЯ ПОСТА ===== */
.post-form {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 16px;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-card);
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    contain: layout style;
    container-type: inline-size;
    container-name: post-form;
    overflow-x: clip;
    overflow-wrap: anywhere;
    word-break: break-word;
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
.post-form form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 0;
    box-sizing: border-box;
    overflow-x: clip;
    overflow-wrap: anywhere;
}
@supports not (overflow: clip) {
    .post-form {
        overflow-x: hidden;
    }
    .post-form form {
        overflow-x: hidden;
    }
    .post-form .photo-preview {
        overflow-x: hidden;
    }
}

.post-form textarea {
    box-sizing: border-box;
    display: block;
    flex: 0 0 auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    max-height: 200px;
    max-height: min(200px, 40vh);
    max-height: min(200px, 40svh);
    overflow: auto;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-break: anywhere;
    white-space: pre-wrap;
    field-sizing: fixed;
    overscroll-behavior: contain;
    overflow-anchor: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    line-height: 1.35;
    padding: 10px 12px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: 12px;
    color: var(--text-input);
    caret-color: var(--accent-primary);
    font-size: 15px;
    resize: none;
    outline: none;
    font-family: inherit;
    unicode-bidi: plaintext;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    contain: inline-size;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, min-height 0.28s ease, height 0.28s ease;
}
.post-form textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.85;
    overflow-wrap: anywhere;
}
.post-form textarea:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 1px;
}
.post-form textarea:focus:not(:focus-visible) {
    outline: none;
}
.post-form.is-open textarea {
    min-height: 96px;
    height: 120px;
    max-height: 200px;
    max-height: min(200px, 40vh);
    max-height: min(200px, 40svh);
    overflow: auto;
    resize: none;
}
.composer-extra {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    content-visibility: hidden;
    contain-intrinsic-size: 0 0;
    transition: grid-template-rows 0.28s ease, opacity 0.2s ease, visibility 0.2s ease;
}
.post-form.is-open .composer-extra {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    content-visibility: visible;
    contain-intrinsic-size: auto;
}
.composer-extra,
.composer-extra-inner,
.composer-meta,
.composer-toolbar,
.poll-box,
.emoji-box,
.schedule-box,
.post-form .photo-preview,
.post-files,
.post-form .form-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}
.composer-extra-inner {
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    max-width: 100%;
}
.composer-meta:empty,
.composer-community-chip:empty,
.post-form .photo-count:empty,
.post-files:empty,
.post-form .photo-upload-area:empty {
    display: none;
    margin: 0;
    padding: 0;
    gap: 0;
    min-height: 0;
}
.post-form [hidden] { display: none !important; }
.schedule-box[hidden] { display: none !important; }
.schedule-box:not([hidden]) {
    display: block;
    margin: 8px 0;
}
.post-form [data-role="expires-box"]:not([hidden]) .schedule-label {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
}
.schedule-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 100%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.schedule-label:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 8px;
}
.schedule-label:focus:not(:focus-visible) {
    outline: none;
}
.schedule-label > span {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-height: 44px;
    min-width: 0;
    overflow-wrap: anywhere;
}
.schedule-label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    padding: 10px 4px;
}
.schedule-label input {
    width: 100%;
    max-width: min(240px, 100%);
    box-sizing: border-box;
    height: 44px;
    min-width: 0;
    min-height: 44px;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    color: var(--text-input);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color-scheme: dark;
}
.schedule-label input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
[data-theme="light"] .schedule-label input {
    color-scheme: light;
    background: var(--bg-card);
    border-color: var(--border-card);
    color: #0f172a;
}

.post-form textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 30px var(--accent-glow);
}

.post-form .photo-upload-area {
    margin: 8px 0 6px;
}

.post-form .photo-upload-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    padding: 0 16px;
    background: var(--bg-input);
    border: 1px dashed var(--border-card);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.post-form .photo-upload-label:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.post-form .photo-upload-label:focus:not(:focus-visible) {
    outline: none;
}

.post-form .photo-upload-label:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.post-form .photo-upload-label input[type="file"] {
    display: none;
}

.post-form .photo-preview {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0;
    box-sizing: border-box;
    max-height: calc(80px * 2 + 8px);
    overflow-x: clip;
    overflow-y: auto;
    overflow-wrap: anywhere;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;
    scrollbar-width: thin;
}
.post-form .photo-preview:empty {
    display: none;
    margin: 0;
    gap: 0;
    max-height: 0;
}
.post-form .photo-preview .preview-item img:not([src]),
.post-form .photo-preview .preview-item img[src=""],
.post-form .photo-preview .preview-item img[src="null"],
.post-form .photo-preview .preview-item img[src="undefined"],
.post-form .photo-preview .preview-item img[src="about:blank"] {
    display: none;
}
.post-form .photo-preview .preview-item:has(img:not([src])),
.post-form .photo-preview .preview-item:has(img[src=""]),
.post-form .photo-preview .preview-item:has(img[src="null"]),
.post-form .photo-preview .preview-item:has(img[src="undefined"]),
.post-form .photo-preview .preview-item:has(img[src="about:blank"]) {
    display: none;
}

.post-form .photo-preview .preview-item {
    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    flex: 0 1 auto;
    min-width: 44px;
    min-height: 44px;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
    overflow-wrap: anywhere;
    background: var(--bg-input);
    border: 1px solid var(--border-card);
    contain: layout paint;
}
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) {
    width: 80px;
    height: 80px;
    aspect-ratio: 1 / 1;
}

.composer-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 8px 0 4px;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    /* 44px tools + padding-block so focus ring fits under border-box + overflow-y:hidden */
    min-height: 52px;
    padding-block: 4px;
    padding-inline: 2px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x manipulation;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}
.composer-toolbar::after {
    content: "";
    flex: 0 0 8px;
    width: 8px;
    height: 1px;
    pointer-events: none;
}
.composer-toolbar .tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border-card);
    background: var(--bg-input);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}
.composer-toolbar .tool:hover {
    border-color: var(--accent-primary);
}
.composer-toolbar .tool:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.composer-toolbar .tool:focus:not(:focus-visible) {
    outline: none;
}
.composer-toolbar .tool input { display: none; }
.composer-toolbar .tool svg { display: block; pointer-events: none; }
.composer-toolbar .tool.is-on {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--btn-theme-hover);
}
.composer-toolbar .tool.tool-ttl {
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.schedule-label input[type="checkbox"] {
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent-primary);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.schedule-label input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 3px;
}
.composer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px 8px;
    min-width: 0;
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.composer-meta [data-role="char-count"] {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-width: 0;
    min-height: 44px;
    touch-action: manipulation;
}
.composer-community-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-sizing: border-box;
    flex: 0 1 auto;
    margin-right: auto;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    max-width: 100%;
    padding: 0 10px;
    overflow: hidden;
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.composer-community-chip svg {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
}
.composer-community-chip > span {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.composer-community-chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 8px;
}
.composer-community-chip:focus:not(:focus-visible) {
    outline: none;
}
.poll-box[hidden],
.emoji-box[hidden],
.poll-box:empty,
.emoji-box:empty,
.schedule-box:empty,
.composer-extra:empty,
.composer-extra-inner:empty {
    display: none !important;
}
.emoji-box:not([hidden]),
.post-form .emoji-box:not([hidden]) {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    align-items: flex-start;
    gap: 6px;
    margin: 8px 0;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: 120px;
    max-height: min(120px, 40vh);
    max-height: min(120px, 40svh);
    /* room for edge .emoji :focus-visible outline-offset inside overflow-x:hidden */
    padding: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;
    scrollbar-width: thin;
}
.poll-box:not([hidden]) {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 8px 0;
    box-sizing: border-box;
    /* room for full-width input :focus-visible outline-offset inside overflow-x:hidden */
    padding-inline: 4px;
}
.poll-box input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-input);
    background: var(--bg-input);
    color: var(--text-input);
    color-scheme: dark;
    outline: none;
    font: inherit;
    font-size: 14px;
    overflow-x: auto;
    overflow-wrap: anywhere;
    text-overflow: ellipsis;
    field-sizing: fixed;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.poll-box input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.poll-box input:focus:not(:focus-visible) {
    outline: none;
}
.emoji-box .emoji {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}
.emoji-box .emoji:hover {
    background: var(--btn-theme-hover, rgba(124, 92, 252, 0.12));
}
.emoji-box .emoji:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 8px;
}
.emoji-box .emoji:focus:not(:focus-visible) {
    outline: none;
}
.feed-sentinel {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    text-align: center;
    color: var(--text-muted);
    padding: 12px;
    font-size: 13px;
    touch-action: manipulation;
}
.post-form .photo-count {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    max-width: 100%;
    flex: 1 1 0;
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 0;
    overflow-wrap: anywhere;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.post-form .preview-item.file,
.post-form .preview-item.photo.is-broken,
.post-form .photo-preview .preview-item.file,
.post-form .photo-preview .preview-item.photo.is-broken,
.post-form form .photo-preview .preview-item.file,
.post-form form .photo-preview .preview-item.photo.is-broken {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    min-height: 44px;
    max-height: none;
    padding: 0 4px 0 10px;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    aspect-ratio: auto;
}
.post-form .photo-preview .preview-item.file .preview-kind,
.post-form .photo-preview .preview-item.photo.is-broken .preview-kind,
.post-form form .photo-preview .preview-item.file .preview-kind,
.post-form form .photo-preview .preview-item.photo.is-broken .preview-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
}
.post-form .photo-preview .preview-item.file .preview-name,
.post-form .photo-preview .preview-item.photo.is-broken .preview-name,
.post-form form .photo-preview .preview-item.file .preview-name,
.post-form form .photo-preview .preview-item.photo.is-broken .preview-name {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.3;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.post-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.post-file {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    flex: 0 1 auto;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    height: 44px;
    max-width: 100%;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border-card);
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.post-file:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.post-file:focus:not(:focus-visible) {
    outline: none;
}
.post-form .photo-preview .preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-form .photo-preview .preview-item .remove-file,
.post-form .photo-preview .preview-item .preview-remove {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    text-align: center;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.2s ease;
}
/* 44×44 X covers ~half an 80px thumb — shrink remove, keep file-row X at 44px */
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    max-width: 24px;
    max-height: 24px;
    font-size: 12px;
    top: 2px;
    right: 2px;
}
.post-form .photo-preview .preview-item.file .remove-file,
.post-form .photo-preview .preview-item.file .preview-remove,
.post-form .photo-preview .preview-item.photo.is-broken .remove-file,
.post-form .photo-preview .preview-item.photo.is-broken .preview-remove,
.post-form form .photo-preview .preview-item.file .remove-file,
.post-form form .photo-preview .preview-item.file .preview-remove,
.post-form form .photo-preview .preview-item.photo.is-broken .remove-file,
.post-form form .photo-preview .preview-item.photo.is-broken .preview-remove {
    position: static;
    top: auto;
    right: auto;
    flex: 0 0 auto;
    align-self: center;
    margin-left: auto;
    z-index: auto;
}
.post-form .photo-preview .preview-item .remove-file:focus-visible,
.post-form .photo-preview .preview-item .preview-remove:focus-visible {
    /* inset ring — outline outside is clipped by .preview-item overflow:hidden */
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}
.post-form .photo-preview .preview-item .remove-file:focus:not(:focus-visible),
.post-form .photo-preview .preview-item .preview-remove:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

.post-form .photo-preview .preview-item .remove-file:hover,
.post-form .photo-preview .preview-item .preview-remove:hover {
    background: #ff4444;
}

.post-form .form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    touch-action: manipulation;
}

.post-form .form-actions button {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 20px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}
.post-form .form-actions button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-primary);
}
.post-form .form-actions button:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}
.post-form .form-actions button:disabled:focus-visible,
.post-form .form-actions button[aria-disabled="true"]:focus-visible {
    outline: none;
    box-shadow: none;
}

.post-form .form-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px var(--accent-glow);
}
.post-form .form-actions button:disabled,
.post-form .form-actions button[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    pointer-events: none;
    filter: grayscale(0.2);
}
.composer-toolbar {
    scroll-snap-type: x proximity;
    scroll-padding-inline: 8px;
    touch-action: pan-x pinch-zoom;
}
.composer-toolbar .tool {
    scroll-snap-align: start;
}
.composer-toolbar .tool:active,
.emoji-box .emoji:active {
    filter: brightness(1.08);
}
.composer-toolbar .tool.tool-ttl {
    white-space: nowrap;
    max-width: 100%;
}
.composer-meta {
    min-height: 44px;
    touch-action: manipulation;
}
.composer-meta [data-role="char-count"] {
    min-width: 44px;
    font-variant-numeric: tabular-nums;
}
.composer-meta [data-role="char-count"]:focus-visible,
.post-form .photo-count:focus-visible,
.feed-sentinel:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: 8px;
}
.post-form .photo-count,
.poll-box:not([hidden]),
.emoji-box:not([hidden]),
.post-form .photo-preview,
.post-files {
    touch-action: manipulation;
}
.post-form .form-actions button:active:not(:disabled):not([aria-disabled="true"]) {
    transform: translateY(0);
    filter: brightness(0.96);
}
.schedule-label input:focus:not(:focus-visible),
.schedule-label input[type="checkbox"]:focus:not(:focus-visible) {
    outline: none;
}

/* ===== СВЕТЛАЯ ТЕМА ===== */
[data-theme="light"] .post-form {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: #0f172a;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
    color-scheme: light;
}
[data-theme="light"] .post-form textarea {
    background: #ffffff;
    border-color: #c5ced8;
    color: #0f172a;
}
[data-theme="light"] .post-form textarea::placeholder {
    color: #64748b;
    opacity: 1;
}
[data-theme="light"] .post-form textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.18);
}
[data-theme="light"] .post-form textarea:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 1px;
}
[data-theme="light"] .composer-toolbar .tool:focus-visible,
[data-theme="light"] .post-form .photo-upload-label:focus-visible,
[data-theme="light"] .poll-box input:focus-visible,
[data-theme="light"] .schedule-label:focus-visible,
[data-theme="light"] .schedule-label input:focus-visible,
[data-theme="light"] .schedule-label input[type="checkbox"]:focus-visible,
[data-theme="light"] .emoji-box .emoji:focus-visible,
[data-theme="light"] .post-file:focus-visible,
[data-theme="light"] .composer-community-chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
[data-theme="light"] .post-form .photo-preview .preview-item .remove-file:focus-visible,
[data-theme="light"] .post-form .photo-preview .preview-item .preview-remove:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}
[data-theme="light"] .post-form .form-actions button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-primary);
}
[data-theme="light"] .post-form .photo-upload-label,
[data-theme="light"] .composer-toolbar .tool,
[data-theme="light"] .poll-box input,
[data-theme="light"] .post-form .photo-preview .preview-item {
    background: var(--bg-card);
    border-color: var(--border-card);
    color: #0f172a;
}
[data-theme="light"] .post-form .photo-upload-label {
    color: #475569;
}
[data-theme="light"] .composer-toolbar .tool.is-on {
    background: rgba(124, 92, 252, 0.10);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
[data-theme="light"] .composer-meta,
[data-theme="light"] .composer-community-chip,
[data-theme="light"] .post-form .photo-count,
[data-theme="light"] .post-form .preview-item.file,
[data-theme="light"] .post-form .preview-item.photo.is-broken,
[data-theme="light"] .feed-sentinel {
    color: #475569;
}
[data-theme="light"] .poll-box input::placeholder {
    color: #64748b;
    opacity: 1;
}
[data-theme="light"] .poll-box input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.18);
}
[data-theme="light"] .schedule-label {
    color: #475569;
}
[data-theme="light"] .schedule-label input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.18);
}
[data-theme="light"] .schedule-label input::-webkit-calendar-picker-indicator {
    opacity: 0.65;
    cursor: pointer;
}
[data-theme="light"] .post-file {
    background: var(--bg-card);
    border-color: var(--border-card);
}
[data-theme="light"] .emoji-box .emoji:hover {
    background: #f3f4f6;
}
[data-theme="light"] .post-form .form-actions button {
    color: #fff;
}

@media (hover: none) {
    .post-form .form-actions button:hover {
        transform: none;
        box-shadow: none;
    }
    .composer-toolbar .tool:hover {
        border-color: var(--border-card);
    }
    .emoji-box .emoji:hover {
        background: transparent;
    }
}

@media (max-width: 720px) {
    .post-form {
        padding: 8px max(10px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
        margin-bottom: 10px;
        border-radius: 12px;
    }
    .post-form textarea {
        padding: 10px 12px;
        font-size: 16px;
    }
    .composer-toolbar {
        gap: 4px;
        margin: 4px 0 2px;
        padding-inline: 2px 10px;
    }
    .post-form .photo-preview {
        gap: 6px;
        margin: 6px 0;
        max-height: calc(64px * 2 + 6px);
    }
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) {
        width: 64px;
        height: 64px;
    }
    /* 44×44 X covers a 64px thumb — shrink remove, keep file-row X at 44px */
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 12px;
        top: 2px;
        right: 2px;
    }
    .post-form .form-actions {
        gap: 6px;
        margin-top: 6px;
    }
    .composer-community-chip {
        padding: 0 8px;
    }
    .emoji-box:not([hidden]),
    .post-form .emoji-box:not([hidden]) {
        max-height: 120px;
        max-height: min(120px, 36vh);
        max-height: min(120px, 36svh);
    }
}

@container post-form (max-width: 520px) {
    .post-form textarea {
        padding: 8px 10px;
        font-size: 16px;
        line-height: 1.3;
        max-height: 160px;
        max-height: min(160px, 36vh);
        max-height: min(160px, 36svh);
    }
    .post-form.is-open textarea {
        min-height: 72px;
        height: 104px;
        max-height: 160px;
        max-height: min(160px, 36vh);
        max-height: min(160px, 36svh);
        overflow: auto;
        resize: none;
    }
    .composer-toolbar {
        gap: 4px;
        margin: 4px 0 2px;
        padding-inline: 2px 10px;
    }
    .composer-meta {
        margin-top: 2px;
        gap: 4px 6px;
    }
    .post-form .photo-preview {
        gap: 4px;
        margin: 4px 0;
        max-height: calc(64px * 2 + 4px);
    }
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) {
        width: 64px;
        height: 64px;
    }
    /* 44×44 X covers a 64px thumb — shrink remove, keep file-row X at 44px */
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 12px;
        top: 2px;
        right: 2px;
    }
    .post-form .form-actions {
        flex-wrap: nowrap;
        gap: 6px;
        margin-top: 6px;
    }
    .post-form .form-actions button {
        padding: 0 16px;
        flex: 0 0 auto;
    }
    .post-form .photo-count {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .composer-community-chip {
        padding: 0 8px;
    }
    .schedule-label input {
        max-width: 100%;
    }
    .poll-box:not([hidden]),
    .emoji-box:not([hidden]),
    .schedule-box:not([hidden]) {
        margin: 6px 0;
        gap: 4px;
    }
    .emoji-box:not([hidden]),
    .post-form .emoji-box:not([hidden]) {
        max-height: 104px;
        max-height: min(104px, 36vh);
        max-height: min(104px, 36svh);
    }
}

@container post-form (max-width: 360px) {
    .post-form textarea {
        padding: 8px 10px;
        font-size: 16px;
        line-height: 1.25;
        max-height: 140px;
        max-height: min(140px, 32vh);
        max-height: min(140px, 32svh);
    }
    .post-form.is-open textarea {
        min-height: 64px;
        height: 96px;
        max-height: 140px;
        max-height: min(140px, 32vh);
        max-height: min(140px, 32svh);
        overflow: auto;
        resize: none;
    }
    .composer-toolbar {
        gap: 2px;
        margin: 2px 0 0;
        padding-inline: 2px 10px;
    }
    .composer-meta {
        margin-top: 0;
        gap: 2px 4px;
    }
    .post-form .photo-preview {
        gap: 4px;
        margin: 4px 0;
        max-height: calc(56px * 2 + 4px);
    }
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) {
        width: 56px;
        height: 56px;
        min-width: 44px;
        min-height: 44px;
    }
    /* 44×44 X covers a 56px thumb — shrink remove, keep file-row X at 44px */
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 12px;
        top: 2px;
        right: 2px;
    }
    .post-form .form-actions {
        flex-wrap: nowrap;
        gap: 4px;
        margin-top: 4px;
    }
    .post-form .form-actions button {
        padding: 0 12px;
        flex: 0 0 auto;
    }
    .post-form .photo-count {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
    .emoji-box:not([hidden]),
    .poll-box:not([hidden]),
    .schedule-box:not([hidden]) {
        margin: 4px 0;
        gap: 2px;
    }
    .emoji-box:not([hidden]),
    .post-form .emoji-box:not([hidden]) {
        max-height: 96px;
        max-height: min(96px, 32vh);
        max-height: min(96px, 32svh);
    }
}

@media (max-width: 360px) {
    .post-form {
        padding: 6px max(8px, env(safe-area-inset-right, 0px)) max(6px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
        margin-bottom: 8px;
        border-radius: 10px;
    }
    .post-form textarea {
        padding: 8px 10px;
        font-size: 16px;
        max-height: 140px;
        max-height: min(140px, 32vh);
        max-height: min(140px, 32svh);
    }
    .post-form.is-open textarea {
        min-height: 64px;
        height: 96px;
        max-height: 140px;
        max-height: min(140px, 32vh);
        max-height: min(140px, 32svh);
        overflow: auto;
        resize: none;
    }
    .composer-toolbar {
        gap: 2px;
        margin: 2px 0 0;
        padding-inline: 2px 10px;
    }
    .post-form .form-actions {
        flex-wrap: nowrap;
    }
    .post-form .form-actions button {
        flex: 0 0 auto;
        padding: 0 12px;
    }
    .post-form .photo-count {
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

@media (pointer: coarse) {
    .composer-toolbar .tool,
    .emoji-box .emoji,
    .poll-box input,
    .schedule-label,
    .schedule-label input,
    .schedule-label input[type="checkbox"],
    .post-form .photo-upload-label,
    .post-form .form-actions button,
    .post-form .photo-preview .preview-item .remove-file,
    .post-form .photo-preview .preview-item .preview-remove,
    .post-file {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    .post-form textarea,
    .poll-box input,
    .schedule-label input[type="datetime-local"] {
        font-size: 16px;
    }
}

/* after coarse 44px mins — 80/64/56px photo thumbs keep a small X; file-row stays 44px */
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    max-width: 24px;
    max-height: 24px;
    font-size: 12px;
    top: 2px;
    right: 2px;
}
@container post-form (max-width: 520px) {
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 12px;
        top: 2px;
        right: 2px;
    }
}
@container post-form (max-width: 360px) {
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .remove-file,
    .post-form .photo-preview .preview-item:not(.file):not(.is-broken) .preview-remove {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        max-width: 24px;
        max-height: 24px;
        font-size: 12px;
        top: 2px;
        right: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .post-form textarea,
    .composer-extra,
    .composer-toolbar .tool,
    .emoji-box .emoji,
    .poll-box input,
    .schedule-label input,
    .post-form .photo-upload-label,
    .post-form .photo-preview .preview-item .remove-file,
    .post-form .photo-preview .preview-item .preview-remove,
    .post-form .form-actions button {
        transition: none;
    }
    .post-form .form-actions button:hover {
        transform: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .post-form .photo-preview .preview-item .remove-file,
    .post-form .photo-preview .preview-item .preview-remove {
        background: #111111;
    }
}

@media (prefers-contrast: more) {
    .post-form,
    .post-form textarea,
    .composer-toolbar .tool,
    .poll-box input,
    .schedule-label input,
    .post-file,
    .post-form .photo-upload-label,
    .post-form .photo-preview .preview-item {
        border-width: 2px;
    }
    .post-form textarea:focus-visible,
    .composer-toolbar .tool:focus-visible,
    .emoji-box .emoji:focus-visible,
    .poll-box input:focus-visible,
    .schedule-label:focus-visible,
    .schedule-label input:focus-visible,
    .post-form .photo-upload-label:focus-visible,
    .post-form .form-actions button:focus-visible,
    .post-file:focus-visible,
    .composer-community-chip:focus-visible,
    .post-form .photo-preview .preview-item .remove-file:focus-visible,
    .post-form .photo-preview .preview-item .preview-remove:focus-visible {
        outline-width: 3px;
    }
}

@media (forced-colors: active) {
    .post-form,
    .post-form textarea,
    .composer-toolbar .tool,
    .poll-box input,
    .schedule-label input,
    .post-file,
    .composer-community-chip,
    .post-form .photo-upload-label,
    .post-form .photo-preview .preview-item,
    .post-form .photo-preview .preview-item .remove-file,
    .post-form .photo-preview .preview-item .preview-remove,
    .emoji-box .emoji,
    .post-form .form-actions button {
        border: 1px solid ButtonText;
    }
    .post-form .form-actions button {
        background: Highlight;
        color: HighlightText;
        forced-color-adjust: none;
    }
    .post-form .photo-preview .preview-item .remove-file,
    .post-form .photo-preview .preview-item .preview-remove {
        background: Canvas;
        color: CanvasText;
        forced-color-adjust: none;
    }
    .post-form .form-actions button:disabled,
    .post-form .form-actions button[aria-disabled="true"] {
        background: ButtonFace;
        color: GrayText;
        border: 1px solid GrayText;
    }
}

.post-form form {
    touch-action: manipulation;
    overscroll-behavior: contain;
}
.post-form textarea,
.composer-toolbar {
    scrollbar-color: var(--border-card) transparent;
}
.post-form .photo-preview .preview-item:not(.file):not(.is-broken) {
    aspect-ratio: 1 / 1;
}
.post-form .photo-preview:not(:has(.preview-item)) {
    display: none;
    margin: 0;
    gap: 0;
    max-height: 0;
}
.post-form [aria-busy="true"] {
    pointer-events: none;
    cursor: progress;
    opacity: 0.72;
}
.post-form textarea[aria-invalid="true"],
.poll-box input[aria-invalid="true"],
.schedule-label input[aria-invalid="true"] {
    border-color: #ff4444;
}
.post-form textarea:disabled,
.poll-box input:disabled,
.schedule-label input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.composer-extra {
    content-visibility: hidden;
    contain-intrinsic-size: 0 0;
}
.post-form.is-open .composer-extra {
    content-visibility: visible;
    contain-intrinsic-size: auto;
}
.schedule-box[data-role="expires-box"]:not([hidden]) {
    display: block;
    margin: 8px 0;
}
[data-theme="light"] .poll-box input,
[data-theme="light"] .schedule-label input {
    color-scheme: light;
}
@supports not (container-type: inline-size) {
    .post-form {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    .post-form textarea,
    .poll-box input {
        max-width: 100%;
        min-width: 0;
    }
}
@media print {
    .composer-toolbar,
    .emoji-box,
    .poll-box,
    .schedule-box,
    .photo-preview,
    .form-actions,
    .composer-extra {
        display: none !important;
    }
    .post-form {
        box-shadow: none;
        break-inside: avoid;
    }
    .post-form textarea {
        max-height: none;
        overflow: visible;
        box-shadow: none;
    }
}
@media (prefers-reduced-data: reduce) {
    .post-form textarea,
    .composer-extra,
    .composer-toolbar .tool,
    .emoji-box .emoji,
    .post-form .form-actions button {
        transition: none;
    }
}

/* Open poll, schedule, or expires-24h: extras scroll, sticky Publish stays on card */
.post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: calc(100svh - 6.5rem);
    max-height: calc(100dvh - 6.5rem - env(keyboard-inset-height, 0px) - env(keyboard-inset-bottom, 0px));
}
.post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) form {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.post-form.is-open:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) textarea {
    flex: 0 0 auto;
    min-height: 3.5rem;
    height: 4rem;
    max-height: min(5rem, 18svh);
}
.post-form.is-open:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) .composer-extra {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr);
}
.post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) .composer-extra-inner {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;
    scrollbar-width: thin;
}
.poll-box:not([hidden]) {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(12.5rem, 32svh);
    box-sizing: border-box;
    /* keep focus ring room when this rule also sets overflow-x:hidden */
    padding-inline: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    overflow-anchor: none;
    scrollbar-width: thin;
}
.poll-box input {
    scroll-margin-top: 8px;
    scroll-margin-bottom: 4.5rem;
}
.post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) .form-actions {
    position: sticky;
    bottom: max(0px, env(keyboard-inset-bottom, 0px));
    z-index: 4;
    flex: 0 0 auto;
    margin-bottom: 0;
    /* room for Publish :focus-visible outline-offset:2px + 4px accent shadow inside form overflow:hidden */
    padding-top: 8px;
    padding-inline: 6px;
    padding-bottom: max(10px, calc(6px + env(safe-area-inset-bottom, 0px)));
    /* dark --bg-card is rgba(255,255,255,0.03) — opaque fill so poll/schedule/expires don't bleed */
    background: #161b27;
    box-shadow: 0 -12px 16px 8px #161b27;
    border-top: 1px solid var(--border-card);
}
[data-theme="light"] .post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) .form-actions {
    background: var(--bg-card);
    box-shadow: 0 -12px 16px 8px var(--bg-card);
}

@media (max-width: 720px) {
    .post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) {
        max-height: calc(100svh - 5.25rem);
        max-height: calc(100dvh - 5.25rem - env(keyboard-inset-height, 0px) - env(keyboard-inset-bottom, 0px));
    }
    .poll-box:not([hidden]) {
        max-height: min(10rem, 28svh);
    }
}

@media (max-height: 560px) {
    .post-form.is-open:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) textarea {
        min-height: 3rem;
        height: 3rem;
        max-height: 3.25rem;
    }
    .poll-box:not([hidden]) {
        max-height: min(8rem, 26svh);
    }
}

@media (forced-colors: active) {
    .post-form:has(.poll-box:not([hidden]), .schedule-box:not([hidden])) .form-actions {
        background: Canvas;
        box-shadow: none;
        border-top: 1px solid ButtonText;
    }
}