:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18212b;
  background: #f4f6f8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { max-width: 1420px; margin: 0 auto; padding: 24px 16px 48px; }
header, .section-heading, .connection, .actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1, h2 { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; }
h2 { font-size: 20px; margin-bottom: 16px; }
p { line-height: 1.45; }
.muted { color: #66717d; font-size: 14px; }
.card { background: #fff; border: 1px solid #dce2e8; border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.narrow { max-width: 420px; margin: 48px auto; }
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.admin-content { min-width: 0; }
.side-menu { position: sticky; top: 16px; display: grid; gap: 8px; padding: 10px; border: 1px solid #dce2e8; border-radius: 10px; background: #fff; }
.side-menu .nav-button { width: 100%; min-height: 48px; text-align: left; background: transparent; color: #293743; }
.side-menu .nav-button:hover { background: #eef4f8; }
.side-menu .nav-button.active { background: #168acd; color: #fff; }
.constructor-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 18px; align-items: start; }
.preview-card { position: sticky; top: 16px; }
label { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #bac4ce; border-radius: 6px; padding: 9px 10px; font: inherit; background: #fff; }
button { min-height: 40px; border: 0; border-radius: 6px; padding: 9px 14px; background: #168acd; color: white; font: inherit; font-weight: 650; cursor: pointer; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: #e9eef2; color: #24323e; }
button.danger-link { background: transparent; color: #b23535; padding: 4px 6px; min-height: 34px; }
fieldset { border: 1px solid #dce2e8; border-radius: 8px; padding: 14px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 700; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.toolbar button { min-height: 34px; padding: 6px 10px; background: #eef2f5; color: #263440; }
.text-editor { min-height: 180px; border: 1px solid #bac4ce; border-radius: 6px; padding: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.text-editor:empty::before { content: attr(data-placeholder); color: #89939e; }
.text-editor blockquote { border-left: 3px solid #6fb4dc; margin: 8px 0; padding-left: 10px; color: #42505d; }
.radio { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.radio input { width: auto; min-height: 0; }
.button-row-config { display: grid; grid-template-columns: 1.2fr 1.1fr 1.5fr 1fr 70px auto; gap: 8px; align-items: end; border-bottom: 1px solid #e5e9ed; padding-bottom: 10px; margin-bottom: 10px; }
.button-row-config label { margin: 0; }
.repeat-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 8px; }
.telegram-preview { background: #dfe9ef; border-radius: 10px; padding: 14px; min-height: 220px; }
.preview-text { background: #fff; border-radius: 10px 10px 4px 10px; padding: 12px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.preview-text blockquote { border-left: 3px solid #168acd; margin: 8px 0; padding-left: 9px; }
.preview-media { margin-bottom: 4px; overflow: hidden; border-radius: 10px 10px 0 0; background: #c4d1d8; }
.preview-media img, .preview-media video { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.preview-media + .preview-text { border-radius: 0 0 4px 10px; }
.preview-buttons { display: grid; gap: 4px; margin-top: 4px; }
.preview-button-row { display: flex; gap: 4px; }
.preview-button { flex: 1; text-align: center; background: #fff; color: #168acd; border-radius: 5px; padding: 9px 5px; font-weight: 700; font-size: 14px; }
.preview-button.primary { background: #2f88c9; color: #fff; }
.preview-button.success { background: #45a36b; color: #fff; }
.preview-button.danger { background: #d55555; color: #fff; }
.publications-card { min-height: 560px; }
.post-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 22px; border-top: 1px solid #dce2e8; padding-top: 14px; }
.post-filter { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; text-align: left; background: #f1f4f6; color: #263440; border: 2px solid transparent; }
.post-filter span { font-size: 16px; }
.post-filter strong { font-size: 30px; line-height: 1; }
.post-filter.active { background: #e5f3fb; color: #116fa4; border-color: #168acd; }
.post-list { display: grid; gap: 14px; }
.post-item { border: 1px solid #e0e5e9; border-radius: 9px; padding: 18px; }
.post-item > .publish-existing { min-height: 44px; padding-left: 18px; padding-right: 18px; }
.post-item .meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: #66717d; font-size: 13px; }
.job-list { display: grid; gap: 6px; margin: 10px 0; }
.job-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.job-row span { flex: 1; min-width: 230px; }
.job-row button { min-height: 30px; padding: 4px 8px; font-size: 12px; }
.status { display: inline-block; border-radius: 12px; padding: 3px 8px; background: #edf1f4; font-size: 12px; font-weight: 700; }
.status.published { background: #dff3e7; color: #1b6a39; }
.status.error { background: #fde4e4; color: #952c2c; }
#message { min-height: 24px; padding: 0 2px; }
#message.error { color: #a92f2f; }
#message.success { color: #176d3a; }

@media (max-width: 850px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side-menu { position: static; grid-template-columns: 1fr 1fr; }
  .side-menu .nav-button { text-align: center; }
  .constructor-layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .post-filters { grid-template-columns: 1fr; }
  .post-filter { min-height: 70px; }
  .button-row-config { grid-template-columns: 1fr 1fr; }
  .url-field { grid-column: 1 / -1; }
  header, .connection { align-items: flex-start; flex-direction: column; }
}
