: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; gap: 20px; 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 0 0 auto; }
header > a.muted:hover { color: var(--accent); }
.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 { min-height: 120px; 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 { background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.history li.owner { border-left-color: var(--accent); }
.history li.coder { border-left-color: #8a6fd1; }
.history li.system { border-left-color: #2e9e5b; }
.history li.fail { border-left-color: #d64545; }
.history .h-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.history .h-what { color: var(--muted, #888); }
.history .h-rev { font-size: .85em; padding: 0 6px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.history .h-at { margin-left: auto; font-size: .85em; color: var(--muted, #888); white-space: nowrap; }
.history p { margin: 6px 0 0; white-space: pre-line; }
.history-panel { margin-top: 16px; }

.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(--accent); }
.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 var(--line); }
table.plan .checks label { display: inline-block; margin: 0 10px 4px 0; white-space: nowrap; font-weight: normal; }
.badge.urgent { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.badge.waiting { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.slot.waiting { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }

/* Превью 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-nav { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 12px 0; }
.ig-count { color: #737373; font-size: 12px; min-width: 32px; text-align: center; }
.ig-prev, .ig-next { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 1px solid #dbdbdb;
    background: #fff; color: #262626; font-size: 18px; line-height: 22px; cursor: pointer; }
.ig-nav [hidden] { display: inline-block; visibility: hidden; }
.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 { aspect-ratio: 9 / 16; background: #000; }
.ig-reel video { width: 100%; height: 100%; object-fit: cover; display: block; border: 0; border-radius: 0; cursor: pointer; }
.ig-reel-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 13px; color: #737373; }
.ig-reel-bar button { background: none; border: 0; padding: 2px 4px; color: #262626; font-size: 15px; cursor: pointer; }
.ig-reel-bar .ig-download { padding: 2px 4px; color: #262626; font-size: 17px; text-decoration: none; }
.ig-reel-bar input { flex: 1; min-width: 0; margin: 0; }
.ig-reel-info { padding: 0 12px 4px; }
.ig-follow { border: 1px solid #dbdbdb; 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; cursor: pointer; padding: 0 0 4px; }
.ig-reel-cap.open { -webkit-line-clamp: 8; }
.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; }

/* Выпадающий список (js/select.js) */
select { font: inherit; width: 100%; padding: 8px 10px; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.sel { position: relative; margin-top: 4px; }
.sel select { position: absolute; inset: 0; opacity: 0; pointer-events: none; margin: 0; }
.sel-btn { display: block; width: 100%; text-align: left; padding: 8px 32px 8px 10px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--bg); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 38px; position: relative; }
.sel-btn::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
    border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s, margin .15s; }
.sel.open .sel-btn::after { transform: rotate(-135deg); margin-top: -2px; }
.sel-btn:hover { border-color: var(--muted); }
.sel-btn:focus-visible, .sel.open .sel-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.sel-btn:disabled { opacity: .6; cursor: default; }
.sel-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
    max-height: 240px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.sel.up .sel-list { top: auto; bottom: calc(100% + 4px); }
.sel-list li { padding: 7px 10px 7px 28px; border-radius: 5px; cursor: pointer; position: relative; font-size: 14px; }
.sel-list li.active { background: var(--bg); }
.sel-list li[aria-selected="true"] { color: var(--accent); font-weight: 600; }
.sel-list li[aria-selected="true"]::before { content: ""; position: absolute; left: 11px; top: 50%; width: 4px; height: 8px; margin-top: -6px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.sel-list li[aria-disabled="true"] { opacity: .45; cursor: default; }

.tabs.days { border-bottom: 0; margin-top: -8px; }
.tabs.days a { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.tabs.days a.active { border-color: var(--accent); }
.tabs.days a.drop, .post.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.post.dragging { opacity: .4; }
.now-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); align-items: center; }

.ig-link { color: var(--accent, #0a66c2); text-decoration: underline; cursor: pointer; }

/* Пользователи и права */
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; padding: 0; accent-color: var(--accent); }
label.inline { display: flex; align-items: center; gap: 8px; }
.small { font-size: 13px; }
.users-head { margin-bottom: 16px; }
.users { display: grid; gap: 10px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.add-user { max-width: 640px; margin-bottom: 20px; }
.add-user:not([open]) { display: none; }
.add-user form { display: grid; gap: 12px; margin-top: 12px; }
.add-user form > button { justify-self: start; }
.add-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .add-grid { grid-template-columns: 1fr; } }

.user-card { padding: 0; }
.user-card > summary { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.user-card > summary:hover .edit { color: var(--accent); }
.user-card[open] > summary { border-bottom: 1px solid var(--line); }
.avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff;
    background: linear-gradient(135deg, #fa7e1e, #d62976 55%, #4f5bd5); }
.who { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.who .summary { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); }
.chip.admin { color: var(--accent); border-color: currentColor; }
.chip.err { color: var(--err); border-color: currentColor; }
.edit { font-size: 14px; color: var(--muted); white-space: nowrap; }
.edit::after { content: " ▾"; }
.user-card[open] .edit::after { content: " ▴"; }
.user-card form { display: grid; gap: 16px; padding: 16px 18px 18px; }

.role { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.opt:has(input:disabled) { cursor: default; }
.opt input { margin-top: 4px; }
.opt span, .right span { display: grid; }
.opt small, .right small { color: var(--muted); font-size: 12px; line-height: 1.35; }
form.user > p.small { margin: -8px 0 0; }

.projects { display: grid; gap: 12px; }
form.user.admin .projects { display: none; }
.project { margin: 0; padding: 4px 14px 14px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.project legend { padding: 0 6px; margin-left: -6px; }
.project.off { border-style: dashed; }
.project.off .presets, .project.off .rgroups, .project.off .view-note { display: none; }
.view-note { margin: 8px 0 0; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i { flex: none; width: 36px; height: 20px; border-radius: 10px; background: var(--line); position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 18px; }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 12px; }
.chip-btn { font-size: 13px; padding: 3px 12px; border-radius: 14px; background: transparent; color: var(--text); border: 1px solid var(--line); }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.rgroups { display: grid; gap: 8px 24px; grid-template-columns: 2fr 1fr; }
@media (max-width: 700px) { .rgroups { grid-template-columns: 1fr; } }
.rgroups h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.rgroups > div:first-child { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-content: start; }
.rgroups > div:first-child h3 { grid-column: 1 / -1; }
@media (max-width: 500px) { .rgroups > div:first-child { grid-template-columns: 1fr; } }
.right { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.right input { margin-top: 4px; }

.pwd summary { color: var(--accent); font-size: 14px; }
.pwd label { max-width: 320px; margin-top: 8px; }
.user-actions { display: flex; align-items: center; gap: 14px; }
.user-actions .danger { margin-left: auto; color: var(--err); }
.users > *, .user-card > *, .user-card form > * { min-width: 0; }
.project.off::after { content: "Нет доступа"; display: block; font-size: 13px; color: var(--muted); }
@media (max-width: 600px) {
    header { flex-wrap: wrap; gap: 8px 16px; }
    .users-head button { padding: 6px 12px; }
    .user-card > summary { padding: 12px; gap: 10px; }
    .user-card form { padding: 12px; }
    .edit { display: none; }
    .rgroups > div:first-child { grid-template-columns: 1fr; }
}

/* ===== Общий вид: шапка, крошки, кнопки-ссылки ===== */
header { position: sticky; top: 0; z-index: 30; padding: 0 16px; height: 52px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo img { width: 24px; height: 24px; }
.main-nav { display: flex; gap: 2px; height: 100%; }
.main-nav a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.main-nav a:hover { color: var(--text); }
.main-nav a.active { color: var(--text); border-color: var(--accent); }
.user-chip { font-size: 13px; padding: 3px 10px; border-radius: 12px; background: var(--bg); color: var(--muted); }
@media (max-width: 600px) { header { height: auto; padding: 8px 12px; } .main-nav a { padding: 6px 8px; } }

.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs span { margin: 0 4px; opacity: .6; }
a.btn { display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 14px; }
a.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
a.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
button { transition: filter .15s; }
button:hover { filter: brightness(1.08); }
button.secondary.warn { color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, transparent); }
.flash { position: sticky; top: 60px; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,.08); }

/* ===== Проекты ===== */
.brand-ava { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px #d62976; }
.project-card { display: grid; gap: 14px; transition: border-color .15s, box-shadow .15s; }
.project-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.07); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 10px; display: grid; }
.stat b { font-size: 22px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.attn { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.stat.attn b { color: var(--accent); }
.alert { margin: 0; font-size: 13px; padding: 6px 10px; border-radius: 6px; background: color-mix(in srgb, var(--err) 9%, transparent); }
.project-card dl { margin: 0; }

/* ===== Проект ===== */
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; line-height: 1.2; }
.page-head .muted { font-size: 14px; }
.head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pills a { padding: 5px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.pills a small { color: var(--muted); margin-left: 2px; }
.pills a.zero { color: var(--muted); }
.pills a.attn small { color: #fff; background: var(--accent); border-radius: 8px; padding: 0 6px; }
.pills a:hover { border-color: var(--accent); }
.pills a.active { background: var(--text); color: var(--panel); border-color: var(--text); }
.pills a.active small { color: inherit; opacity: .75; }

.post { display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.post:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.07); }
a.post-link { display: block; color: var(--text); flex: 1; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px 12px; margin: 0; }
.card-actions button { flex: 1; padding: 6px 10px; font-size: 13px; white-space: nowrap; }

/* ===== Пост ===== */
.panel.decision { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.panel h2 { margin-bottom: 2px; }

/* ===== План: дни и виды как переключатели ===== */
table.plan .checks label { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px 6px 0; padding: 3px 10px; border: 1px solid var(--line);
    border-radius: 14px; cursor: pointer; font-size: 13px; user-select: none; }
table.plan .checks label input { position: absolute; opacity: 0; pointer-events: none; }
table.plan .checks label:has(input:checked) { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); color: var(--accent); }
table.plan th, table.plan td { border-bottom-color: var(--line); }
table.plan input[type="time"] { width: 110px; }

/* ===== Календарь ===== */
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.legend .slot { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid currentColor; border-radius: 999px; background: color-mix(in srgb, currentColor 12%, transparent); }
.legend .slot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.legend .slot.waiting { border-style: dashed; }
.day { min-height: 110px; }
.slot { display: flex; align-items: center; gap: 6px; }
.slot img { width: 22px; height: 28px; object-fit: cover; border-radius: 3px; flex: none; }
.slot span { overflow: hidden; text-overflow: ellipsis; }
.head .buttons a.btn { padding: 5px 12px; }
@media (max-width: 600px) { .slot img { display: none; } }

/* ===== Вход ===== */
.login-logo { width: 48px; height: 48px; }
.login h1 { margin: 0; }
.login .small { margin-top: -10px; }
.project-card > *, .stats > * { min-width: 0; }
.stat span { overflow-wrap: anywhere; line-height: 1.3; }
.head h1::first-letter { text-transform: uppercase; }
input[name="horizon"] { max-width: 120px; }

/* Заявки и AI-рутина */
.badge.idea { color: var(--muted); }
.badge.images { color: var(--accent); }
.badge.build { color: var(--accent); background: var(--panel); }
.badge.attn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.ai-state { font-size: 12px; color: var(--muted); }
.ai-state.busy { color: var(--accent); }
.ai-state.busy::before { content: "● "; animation: ai-blink 1.2s infinite; }
.ai-state.wait::before { content: "◷ "; }
.ai-state.fail { color: var(--err); }
@keyframes ai-blink { 50% { opacity: .2; } }
.new-post { max-width: 720px; }
.new-post .magic-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.new-post .voices { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.new-post .voice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.new-post .voice-row select { flex: 1 1 240px; min-width: 0; }
.magic-state { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; border: 1px solid currentColor; }
.magic-state:empty { display: none; }
.magic-state.busy { color: var(--accent); }
.magic-state.done { color: var(--ok); }
.magic-state.fail { color: var(--err); border-radius: 8px; }
.magic-state.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.magic-state.done::before { content: "✓"; }
.magic-state.fail::before { content: "!"; }
@keyframes spin { to { transform: rotate(360deg); } }
.new-post .hint { font-size: 13px; color: var(--muted); margin: 0; }
.drop-zone { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.drop-zone.over { border-color: var(--accent); color: var(--accent); }
.drop-zone input { display: none; }
.picked { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.picked li { display: flex; justify-content: space-between; gap: 8px; }
.picked button { padding: 0 6px; background: none; color: var(--err); border: none; }
.req-files { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.req-files a, .req-files label { display: grid; gap: 4px; font-size: 12px; color: var(--text); overflow-wrap: anywhere; }
.req-files img, .req-files video { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: var(--line); }
.req-files .doc { aspect-ratio: 4 / 5; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; }
.prelim-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); width: 100%; }
.prelim-grid label { position: relative; display: block; cursor: pointer; }
.prelim-grid img { width: 100%; border-radius: 8px; border: 3px solid transparent; display: block; }
.prelim-grid input { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; }
.prelim-grid input:checked + img, .prelim-grid input:checked + video, .prelim-grid .picked-one img, .prelim-grid .picked-one video { border: 3px solid var(--ok); border-radius: 8px; }
.prelim-grid video { width: 100%; display: block; border: 3px solid transparent; border-radius: 8px; background: #000; }
.prelims h3 { margin: 12px 0 4px; }
.script { white-space: pre-line; margin: 0; }
.prelim-form { display: grid; gap: 12px; }
.prelim-item { display: grid; gap: 6px; align-content: start; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); transition: opacity .15s; }
.prelim-item.off { opacity: .45; }
.prelim-item.picked-one { border: 2px solid var(--ok); }
.prelim-item img, .prelim-item video { width: 100%; border-radius: 6px; display: block; background: #000; }
.prelim-item .use { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.prelim-item textarea { font-size: 13px; }
.prelim-item .doc { padding: 24px 8px; text-align: center; border-radius: 6px; background: var(--panel); }
.prelim-bar { position: sticky; bottom: 0; padding: 10px 0; background: var(--panel); align-items: center; }
.live-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; display: flex; gap: 12px; align-items: center;
    padding: 8px 10px 8px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 6px 24px rgba(0,0,0,.2); font-size: 14px; }

/* Диктовка голосом (js/voice.js) */
.mic-wrap { position: relative; display: block; }
.mic-wrap > input, .mic-wrap > textarea { width: 100%; padding-right: 36px; box-sizing: border-box; }
.mic-wrap .mic { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); padding: 2px 6px; background: none; border: none; font-size: 16px; opacity: .55; cursor: pointer; }
.mic-wrap.area .mic { top: 6px; transform: none; }
.mic-wrap.two > input, .mic-wrap.two > textarea { padding-right: 64px; }
.mic-wrap .mic.edit { right: 32px; }
.mic-wrap.busy > input, .mic-wrap.busy > textarea { opacity: .5; }
.mic-wrap .mic:hover { opacity: 1; }
.mic-wrap .mic.on { opacity: 1; animation: ai-blink 1.2s infinite; }
.delete-zone { margin-top: 24px; justify-content: flex-end; }
.delete-zone .danger { color: var(--err); }
.random-posts { display: flex; gap: 4px; margin: 0; }
.random-posts input { width: 56px; }

/* ===== Удобство: фокус, состояния, мобильная вёрстка ===== */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
button:disabled, button[aria-busy=true] { opacity: .6; cursor: default; filter: none; }
a.btn:hover { filter: brightness(1.08); }
a.btn.ghost { background: none; color: var(--muted); padding: 7px 10px; }
a.btn.ghost:hover { color: var(--accent); filter: none; }
.head-actions .sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 2px; }
.flash { display: flex; align-items: flex-start; gap: 10px; }
.flash.err { border-left-color: var(--err); }
.flash .flash-x { margin-left: auto; padding: 0 4px; background: none; color: var(--muted); font-size: 18px; line-height: 1; }
.flash.gone { display: none; }
.empty { padding: 32px 16px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.kbd-hint { font-size: 12px; color: var(--muted); }
dialog.ask { border: 1px solid var(--line); border-radius: 12px; padding: 18px; width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--text);
    box-shadow: 0 16px 48px rgba(0,0,0,.25); }
dialog.ask::backdrop { background: rgba(0,0,0,.45); }
dialog.ask form { display: grid; gap: 12px; margin: 0; }
dialog.ask h2 { font-size: 17px; }
dialog.ask .buttons { justify-content: flex-end; }
@media (max-width: 600px) {
    main { padding: 16px 12px; }
    h1 { font-size: 21px; }
    .main-nav { width: 100%; overflow-x: auto; scrollbar-width: none; order: 3; }
    .main-nav::-webkit-scrollbar, .pills::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
    header .logo { order: 1; } header form { order: 2; }
    .main-nav a { white-space: nowrap; }
    .pills, .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 0 12px; }
    .pills a, .tabs a { white-space: nowrap; flex: none; }
    .head-actions { margin-left: 0; width: 100%; }
    .head-actions .sep { display: none; }
    .posts { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
    .card-actions button { padding: 8px 10px; }
    table.plan, table.plan tbody, table.plan tr, table.plan td { display: block; width: 100%; }
    table.plan thead { display: none; }
    table.plan tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
    table.plan td { border: 0; padding: 4px 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
