:root {
    --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6ec;
    --accent: #1d5fd8; --ok: #12805c; --warn: #b26b00; --err: #c0392b;
}
@media (prefers-color-scheme: dark) {
    :root { --bg: #14161b; --panel: #1d2027; --text: #e6e8ec; --muted: #9aa1ad; --line: #2e323b; --accent: #6b9cff; --ok: #3fbf8f; --warn: #e0a040; --err: #ff6b5e; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); font-weight: normal; }
header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
header form { display: flex; gap: 12px; align-items: center; margin: 0; }
.logo { font-weight: 600; color: var(--text); }
button { font: inherit; padding: 8px 16px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; }
input { font: inherit; width: 100%; padding: 8px 10px; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }

.login { max-width: 340px; margin: 12vh auto 0; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 14px; }
.error { color: var(--err); margin: 0; }
.note { font-size: 13px; color: var(--muted); margin: 0; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { display: block; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.card:hover { border-color: var(--accent); }
.card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0 0; font-size: 14px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; text-align: right; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--text); border-color: var(--accent); }

.posts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.post { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.thumb { position: relative; aspect-ratio: 4 / 5; background: var(--line); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.kind { position: absolute; left: 8px; top: 8px; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,.6); color: #fff; }
.body { padding: 10px 12px 12px; }
.body p { margin: 4px 0 0; font-size: 13px; }
.row { display: flex; justify-content: space-between; align-items: center; }
.caption { white-space: pre-line; overflow-wrap: anywhere; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 1px solid currentColor; }
.badge.published { color: var(--ok); }
.badge.queued { color: var(--warn); }
.badge.draft { color: var(--muted); }

a.post { display: block; color: var(--text); }
a.post:hover { border-color: var(--accent); }
.badge.review { color: var(--accent); }
.badge.approved { color: var(--ok); }
.badge.rework { color: var(--err); }
.head { gap: 12px; }
.head h1 { margin: 0; }
.flash { padding: 8px 12px; border-radius: 6px; background: var(--panel); border-left: 3px solid var(--ok); }
.post-page { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; margin-top: 16px; }
@media (max-width: 860px) { .post-page { grid-template-columns: 1fr; } }
.media { display: grid; gap: 16px; justify-items: center; }
.files { width: 100%; }
.files summary { cursor: pointer; color: var(--muted); }
.files[open] { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.files[open] summary { grid-column: 1 / -1; }
.files img, .files video { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #000; }
.side { display: grid; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; }
textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); resize: vertical; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
button.secondary { background: none; color: var(--accent); border: 1px solid var(--accent); }
button.ok-btn { background: var(--ok); }
button.warn-btn { background: var(--err); }
.ok { color: var(--ok); margin: 0; }
.issues { margin: 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.history li { border-left: 3px solid var(--line); padding-left: 10px; }
.history li.owner { border-color: var(--accent); }
.history p { margin: 2px 0 0; white-space: pre-line; }

.badge.failed { color: var(--err); }
label { display: grid; gap: 2px; font-size: 14px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow { font-size: 12px; color: var(--muted); padding: 0 4px; }
.day { min-height: 92px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.day.other { opacity: .45; }
.day.today { border-color: var(--accent); }
.num { font-size: 12px; color: var(--muted); }
.slot { font-size: 12px; padding: 1px 6px; border-radius: 4px; border-left: 3px solid currentColor; background: var(--bg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.queued { color: var(--warn); }
.slot.published { color: var(--ok); }
.slot.failed { color: var(--err); }
@media (max-width: 600px) { .day { min-height: 64px; } .slot { font-size: 11px; padding: 0 3px; } }
.err { color: var(--err); }

/* План публикаций */
table.plan { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.plan th, table.plan td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid #e5e5e5; }
table.plan .checks label { display: inline-block; margin: 0 10px 4px 0; white-space: nowrap; font-weight: normal; }
.badge.waiting { background: #fff3cd; color: #7a5b00; }
.slot.waiting { background: #fff3cd; }

/* Превью Instagram: экран телефона 390 px, светлая тема приложения, пропорции как после публикации */
.ig { width: 100%; max-width: 390px; }
.ig-modes { display: flex; gap: 4px; margin-bottom: 8px; }
.ig-modes button { flex: 1; padding: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.ig-modes button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.ig-phone { background: #fff; color: #000; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; padding-bottom: 10px;
    font: 14px/18px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; }
.ig-ava { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: #dbdbdb; flex: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #d62976; }
.ig-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-ava.big { width: 77px; height: 77px; box-shadow: none; }
.ig-menu { margin-left: auto; letter-spacing: 1px; }
.ig-media { position: relative; overflow: hidden; aspect-ratio: 4 / 5; background: #000; touch-action: pan-y; user-select: none; }
.ig-track { display: flex; height: 100%; transition: transform .3s ease; }
.ig-slide { flex: 0 0 100%; height: 100%; position: relative; }
.ig-slide img, .ig-slide video { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; border-radius: 0; }
.ig-count { position: absolute; top: 12px; right: 12px; background: rgba(26,26,26,.8); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 12px; }
.ig-prev, .ig-next { position: absolute; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; padding: 0; border-radius: 50%;
    background: rgba(255,255,255,.85); color: #262626; font-size: 18px; line-height: 24px; }
.ig-prev { left: 8px; } .ig-next { right: 8px; }
.ig-reel-mark { position: absolute; top: 12px; right: 12px; color: #fff; text-shadow: 0 0 4px #000; }
.ig-actions { display: flex; align-items: center; gap: 14px; padding: 8px 12px 6px; position: relative; }
.ig-actions svg { width: 24px; height: 24px; fill: none; stroke: #000; stroke-width: 1.8; stroke-linejoin: round; }
.ig-actions .ig-save { margin-left: auto; }
.ig-pager { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.ig-pager i { width: 6px; height: 6px; border-radius: 50%; background: #c7c7c7; }
.ig-pager i.on { background: #0095f6; }
.ig-caption { padding: 0 12px; white-space: pre-wrap; word-wrap: break-word; }
.ig-caption.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ig-tag { color: #00376b; }
.ig-more { background: none; color: #737373; padding: 0 12px; }
.ig-time { padding: 6px 12px 0; color: #737373; font-size: 12px; }
.ig-reel { position: relative; aspect-ratio: 9 / 16; background: #000; margin-bottom: -10px; }
.ig-reel video { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; border-radius: 0; }
.ig-reel-info { position: absolute; left: 0; right: 48px; bottom: 48px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; }
.ig-reel-info .ig-ava { box-shadow: none; }
.ig-follow { border: 1px solid rgba(255,255,255,.8); border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.ig-reel-cap { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; pointer-events: auto; cursor: pointer; }
.ig-reel-cap.open { -webkit-line-clamp: 8; }
.ig-reel-cap .ig-tag { color: #fff; font-weight: 600; }
.ig-profile { display: flex; align-items: center; gap: 16px; padding: 16px 12px; }
.ig-profile .muted { color: #737373; }
.ig-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-bottom: -10px; }
.ig-tile { position: relative; aspect-ratio: 3 / 4; background: #efefef; overflow: hidden; }
.ig-tile img { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; border-radius: 0; }
.ig-tile.this { outline: 3px solid #0095f6; outline-offset: -3px; }
.ig-badge { position: absolute; top: 6px; right: 6px; color: #fff; font-size: 14px; text-shadow: 0 0 3px rgba(0,0,0,.7); }
.ig-note { font-size: 12px; margin: 6px 0 0; }
