.model-row { display: flex; align-items: stretch; gap: 10px; }
.model-row select { flex: 1; min-width: 0; }
.model-row .btn { flex: 0 0 auto; white-space: nowrap; }
.model-status { display: block; min-height: 20px; margin-top: 7px; font-size: 13px; }
.settings-card { max-width: 920px; }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.settings-card-head h2 { margin: 0; }
.settings-provider-note { margin: 8px 0 20px; }
.settings-provider-note code { overflow-wrap: anywhere; }

.create-post-shell { padding: 0; overflow: hidden; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.section-title-with-icon { display: flex; align-items: center; gap: 11px; }
.ai-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, var(--blue), #6ba7ff); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .04em; box-shadow: 0 5px 12px rgba(24, 119, 242, .2); }
.compact-btn { min-height: 40px; padding: 8px 13px; font-size: 13px; }

.ai-composer { padding: 22px 24px 24px; border-bottom: 1px solid #d9e7fb; background: linear-gradient(180deg, #f7fbff 0%, #f2f7ff 100%); }
.ai-composer-grid { display: grid; grid-template-columns: minmax(220px, 1.55fr) minmax(140px, .72fr) minmax(180px, 1fr) auto; gap: 14px; align-items: end; margin-top: 18px; }
.ai-composer-grid .field { min-width: 0; margin: 0; }
.ai-composer-grid label { font-size: 13px; }
.ai-composer-grid input, .ai-composer-grid select { background: rgba(255, 255, 255, .95); }
.ai-generate-wrap { display: flex; align-items: flex-end; }
.ai-generate-btn { width: 100%; min-width: 152px; white-space: nowrap; }
.ai-status { display: block; min-height: 20px; margin-top: 10px; font-size: 13px; }

.post-editor-grid { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(300px, .72fr); gap: 24px; padding: 24px; align-items: start; }
.post-editor-column { display: grid; gap: 18px; min-width: 0; }
.editor-section { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.editor-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.editor-section h2, .pages-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.editor-section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.editor-section .field:last-child { margin-bottom: 0; }
.message-field textarea { min-height: 230px; padding: 14px; line-height: 1.6; }
.optional-label, .timezone-label { display: inline-flex; margin-left: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
.media-field { margin-top: 17px; }
.media-field input[type=file] { min-height: 52px; border-color: #b9c9df; background: #f8faff; }

.pages-heading { align-items: flex-start; margin-bottom: 14px; }
.pages-heading > div:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.pages-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.text-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 10px; border: 1px solid #d7e5f8; border-radius: 8px; background: #f4f8ff; color: var(--blue-dark); font: inherit; font-size: 12px; font-weight: 750; text-decoration: none; cursor: pointer; }
.text-button:hover, .text-button:focus-visible { border-color: #a9c9f5; background: #eaf3ff; }
.text-button:disabled { opacity: .5; cursor: not-allowed; }
.page-choice-list { max-height: 310px; padding: 2px 5px 2px 2px; overflow-y: auto; scrollbar-gutter: stable; }
.page-choice { min-width: 0; padding: 0; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.page-choice:has(input:checked) { border-color: #91baf1; background: #f3f8ff; box-shadow: inset 0 0 0 1px #d9e9ff; }
.page-choice input { flex: 0 0 auto; margin-left: 13px; }
.page-choice label { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; min-height: 58px; padding: 9px 12px 9px 0; }
.page-choice-avatar { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; background: #e8f1ff; color: var(--blue-dark); font-size: 13px; font-weight: 800; }
img.page-choice-avatar { display: block; border: 1px solid #dce7f5; object-fit: cover; }
.page-choice-copy { min-width: 0; }
.page-choice-copy strong, .page-choice-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-choice-copy strong { color: var(--ink); font-size: 13px; }
.page-choice-copy small { margin-top: 2px; font-size: 11px; font-weight: 500; }
.empty-page-state { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px dashed #b9c9df; border-radius: 10px; background: var(--surface-soft); }
.empty-page-state p { margin: 0; color: var(--muted); }

.publish-section { background: #fbfcfe; }
.publish-controls { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); gap: 18px; align-items: end; }
.schedule-field { margin: 0; }
.schedule-field input { min-width: 0; }
.post-submit-actions { justify-content: flex-end; flex-wrap: nowrap; }
.post-submit-actions .btn { white-space: nowrap; }
.ghost-btn { border-color: transparent; background: transparent; color: var(--muted); }
.ghost-btn:hover { border-color: var(--line); background: var(--surface); color: var(--ink); box-shadow: none; }

.post-preview { position: sticky; top: 92px; overflow: hidden; border: 1px solid #dce2ea; border-radius: 14px; background: #fff; box-shadow: 0 14px 34px rgba(20, 35, 60, .09); }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.preview-heading strong, .preview-heading span { display: block; }
.preview-heading strong { font-size: 14px; }
.preview-heading div > span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.preview-badge { padding: 4px 8px; border-radius: 999px; background: #e9f2ff; color: var(--blue-dark); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.preview-page { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.preview-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, var(--blue), #65a6fb); color: #fff; font-weight: 800; box-shadow: 0 3px 9px rgba(24, 119, 242, .2); }
.preview-page strong, .preview-page small { display: block; }
.preview-page strong { max-width: 210px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.preview-page small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.preview-message { min-height: 88px; padding: 2px 16px 16px; overflow-wrap: anywhere; color: #273144; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.preview-image-wrap { overflow: hidden; border-top: 1px solid var(--line); background: #eef1f5; }
.preview-image-wrap img { display: block; width: 100%; max-height: 420px; object-fit: cover; }
.preview-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.preview-actions span { padding: 7px 4px; border-radius: 7px; }

@media (max-width: 1080px) {
    .ai-composer-grid { grid-template-columns: minmax(220px, 1.5fr) minmax(140px, .75fr) minmax(180px, 1fr); }
    .ai-generate-wrap { grid-column: 1 / -1; }
    .ai-generate-btn { width: auto; }
    .post-editor-grid { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .72fr); }
    .publish-controls { grid-template-columns: 1fr; }
    .post-submit-actions { justify-content: flex-start; }
}

@media (max-width: 820px) {
    .post-editor-grid { grid-template-columns: 1fr; }
    .post-preview { position: static; }
    .page-choice-list { max-height: 360px; }
}

@media (max-width: 640px) {
    .model-row { flex-direction: column; }
    .model-row .btn { width: 100%; }
    .settings-card-head { align-items: flex-start; }
    .settings-provider-note { margin-bottom: 16px; font-size: 13px; }
    .settings-card textarea { min-height: 140px; }
    .settings-card form > .btn { width: 100%; }
    .create-post-shell { margin-inline: -2px; }
    .ai-composer, .post-editor-grid { padding: 18px; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .section-heading .compact-btn { width: 100%; }
    .ai-composer-grid { grid-template-columns: 1fr; gap: 13px; }
    .ai-generate-wrap { grid-column: auto; }
    .ai-generate-btn { width: 100%; }
    .editor-section { padding: 16px; }
    .message-field textarea { min-height: 210px; }
    .pages-heading { display: grid; gap: 12px; }
    .pages-heading > div:first-child { justify-content: space-between; }
    .pages-toolbar { justify-content: flex-start; }
    .checkbox-list.page-choice-list { grid-template-columns: 1fr; }
    .empty-page-state { align-items: stretch; flex-direction: column; }
    .post-submit-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
    .post-submit-actions .btn { width: 100%; }
    .post-submit-actions .ghost-btn { grid-column: auto; }
}
