/* ---- Календарь v3: сетка на весь экран, масштаб колесом (js/calendar.js, жесты — js/calendar-drag.js, модель — js/calendar-model.js). Цвета — переменные темы, кроме палитры каналов ---- */
.calendar-panel { max-width: none; }
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; }
.cal-nav, .cal-zoom { display: flex; align-items: center; gap: 8px; }
.cal-zoom { flex-wrap: nowrap; }
.cal-wheel-hint { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cal-nav button, .cal-zoom button { min-width: 36px; }
.cal-title { margin: 0 6px; font-family: var(--font-ui); font-size: 22px; font-weight: 600; white-space: nowrap; }
.cal-zoom-label { min-width: 84px; text-align: center; font-family: var(--font-ui); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin: 6px 0; }
.cal-tools { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.cal-tools button { padding: 5px 12px; border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font-size: 14px; font-weight: 500; }
.cal-tools button:hover { background: var(--surface-3); }
.cal-tools button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-tools .cal-help { min-width: 34px; padding: 5px 0; font-weight: 700; }
.cal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: var(--border) solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 14px; }
.cal-chip[aria-pressed="false"] { opacity: 0.45; }
.cal-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-count { display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px; border: var(--border) solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 14px; font-variant-numeric: tabular-nums; }
.cal-count b { font-family: var(--font-ui); font-size: 16px; font-weight: 600; }
.cal-count.is-full { background: var(--ok); color: var(--on-bright); font-weight: 600; }
.cal-dot { display: inline-block; flex: none; width: 10px; height: 10px; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--faint); }
.cal-status { position: fixed; left: 50%; bottom: 24px; z-index: 80; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: max-content; max-width: min(560px, calc(100vw - 32px)); margin: 0; padding: 10px 14px; box-sizing: border-box; transform: translateX(-50%); border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ok); font-size: 14px; box-shadow: var(--shadow-btn); }   /* плавает над сеткой: в поток не встаёт, высоту сетки не меняет */
.cal-status[hidden] { display: none; }
.cal-status.is-error { border-color: var(--danger); background: var(--warn-bg); color: var(--danger); }
.cal-status-close { padding: 0 6px; border: 0; background: transparent; color: inherit; font-weight: 700; cursor: pointer; }
.cal-muted { color: var(--muted); font-size: 14px; }

/* Сетка: часы по вертикали (фон .cal-days), дни — колонки; высота — от верха календаря до низа окна */
.cal-main { display: flex; flex-direction: column; min-height: 360px; }
.cal-body { --cal-head: 56px; position: relative; flex: 1; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.cal-body.is-list { overflow-y: auto; }
.cal-body.is-half { --half-c: color-mix(in srgb, var(--line) 70%, transparent); }
.cal-body.is-tenth { --tenth-c: color-mix(in srgb, var(--line) 40%, transparent); }
.cal-axis { position: absolute; left: 0; top: 0; bottom: 0; z-index: 3; pointer-events: none; }
.cal-hour { position: absolute; transform: translateY(-50%); color: var(--muted); font-family: var(--font-ui); font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-now-tag { position: absolute; right: 2px; transform: translateY(-50%); padding: 0 4px; border-radius: 4px; background: var(--red); color: var(--on-bright); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-days { position: absolute; left: 74px; right: 0; top: 0; bottom: 0; overflow: hidden; touch-action: none; user-select: none;
    --hour-c: var(--line); --half-c: transparent; --tenth-c: transparent;
    background-image: linear-gradient(var(--hour-c) 1px, transparent 1px), linear-gradient(var(--half-c) 1px, transparent 1px), linear-gradient(var(--tenth-c) 1px, transparent 1px);
    background-size: 100% var(--hour-px, 60px), 100% calc(var(--hour-px, 60px) / 2), 100% calc(var(--hour-px, 60px) / 6);
    background-position: 0 var(--cal-head), 0 var(--cal-head), 0 var(--cal-head); }
.cal-day { position: absolute; top: 0; bottom: 0; min-width: 0; border-left: 1px solid var(--line); }
.cal-day.is-today { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.cal-day-head { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; gap: 6px; height: var(--cal-head); padding: 0 8px; box-sizing: border-box; overflow: hidden; white-space: nowrap; background: var(--surface); border-bottom: 1px solid var(--line); }
.cal-day.is-today .cal-day-head { background: var(--accent); color: var(--accent-text); border-bottom: 2px solid var(--line-strong); }
.cal-hole-note { color: var(--red); font-size: 11px; font-weight: 600; white-space: nowrap; }
.cal-hole-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.cal-dow { font-size: 11px; font-weight: 600; color: var(--muted); }
.cal-dnum { font-family: var(--font-ui); font-size: 22px; font-weight: 600; line-height: 1; }
.cal-mon { font-size: 12px; color: var(--muted); }
.cal-day.is-narrow .cal-day-head { flex-direction: column; justify-content: center; gap: 2px; padding: 0 2px; }
.cal-day.is-narrow .cal-mon { display: none; }
.cal-day.is-narrow .cal-dow { font-size: 11px; }
.cal-day.is-narrow .cal-dnum { font-size: 22px; }
.cal-day.is-weekend .cal-dnum,
.cal-day.is-past .cal-day-head { color: var(--muted); }
.cal-day.is-today .cal-dnum { font-size: 26px; font-weight: 600; color: var(--accent-text); }   /* число сегодня — без кружка, 26 px */
.cal-col { position: absolute; top: var(--cal-head); bottom: 0; left: 0; right: 0; overflow: hidden; }
.cal-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--red); pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: 0; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

.cal-thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.cal-ph { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cal-badge { position: relative; display: inline-grid; place-items: center; flex: none; }
.cal-badge.is-ok { background: var(--ok); }
.cal-badge.is-accent::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.cal-badge.is-accent { animation: cal-pulse 1.2s ease-in-out infinite; }
@keyframes cal-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.25); opacity: 0.7; } }

.cal-time-tick { position: absolute; z-index: 2; width: 3px; height: 8px; border-radius: 2px; background: var(--c, var(--accent)); pointer-events: none; }

/* Перетаскивание: отметки времени в колонке, траектория, плашка сдвига */
.cal-marks { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
/* Точки прилипания: 10 мин — 6 px, час — 10 px, прилипшая — 14 px с кольцом 3 px, слот расписания — 10 px с рамкой */
.cal-mark { position: absolute; left: 1px; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--faint); transition: transform 0.08s; }
.cal-mark.is-hour { left: 0; width: 10px; height: 10px; margin-top: -5px; background: var(--line-strong); }
.cal-mark.is-slot { left: 0; width: 10px; height: 10px; margin-top: -5px; border: 1.5px solid var(--line-strong); background: var(--accent); }
.cal-mark.is-on { left: -2px; width: 14px; height: 14px; margin-top: -7px; background: var(--accent); box-shadow: 0 0 0 3px var(--line-strong); }
.cal-mark.is-slot.is-on { left: -2px; width: 14px; height: 14px; margin-top: -7px; }
.cal-trail { position: fixed; inset: 0; z-index: 85; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.cal-trail-line { stroke-width: 2; stroke-dasharray: 6 6; opacity: 0.9; }
/* Место, откуда тащат: штриховка и подпись «было: 14:00» */
.cal-was { position: fixed; z-index: 84; box-sizing: border-box; border: 2px dashed #b9ae90; border-radius: 12px; background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface) 8px 16px); pointer-events: none; }
.cal-was span { position: absolute; left: 12px; top: 8px; font-size: 13px; color: var(--muted); }
/* Карточка в руке: рамка 3 px, тень 8 px, наклон −1.5° (задаёт calendar-drag.js) */
.cal-drag-card { position: fixed !important; left: 0; top: 0; z-index: 89; margin: 0; border: 1px solid var(--line-strong); box-shadow: var(--shadow-card); opacity: 1 !important; pointer-events: none; }
/* Плашка сдвига: 30 px на тёмном, тень 4 px красная */
.cal-ghost { position: fixed; left: 0; top: 0; z-index: 90; display: grid; gap: 2px; min-width: 150px; padding: 8px 12px; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--line-strong); color: var(--surface); box-shadow: 0 4px 4px 18px rgba(5, 6, 14, .45); pointer-events: none; white-space: nowrap; }
.cal-ghost.is-bad { border-color: var(--danger); }
.cal-ghost.is-bad .cal-ghost-shift { color: var(--surface); }
.cal-ghost-shift { font-family: var(--font-ui); font-size: 30px; font-weight: 600; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.cal-ghost-when { font-size: 14px; }
.cal-ghost-note { max-width: 260px; color: var(--surface-3); font-size: 12px; white-space: normal; }
.cal-ghost.is-bad .cal-ghost-note { color: var(--danger); }

/* Список (вид из v2, на телефоне удобнее) */
.cal-list { display: grid; padding: 0 16px 12px; }
.cal-list > .cal-more { padding: 14px 0; }
.cal-lday { display: grid; }
.cal-lday-head { position: sticky; top: 0; z-index: 2; margin: 0; padding: 14px 0 6px; background: var(--surface); border-bottom: 1px solid var(--line); font-family: var(--font-ui); font-size: 17px; font-weight: 600; }
.cal-row { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start; width: 100%; padding: 10px 8px 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.cal-row::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--c); }
.cal-row:hover { background: var(--surface-2); }
.cal-row.is-past { opacity: 0.6; filter: saturate(0.5); }
.cal-row-media { width: 64px; height: 64px; overflow: hidden; border-radius: 8px; background: var(--surface-2); }
.cal-row-media img { width: 64px; height: 64px; object-fit: cover; }
.cal-row-media.is-empty { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600; }
.cal-row-body { display: grid; gap: 4px; min-width: 0; }
.cal-row-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.cal-row-top > b { font-family: var(--font-ui); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-row-top .cal-badge { width: 16px; height: 16px; }
.cal-row-channel { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.cal-row-channel .cal-dot { width: 8px; height: 8px; border: 0; background: var(--c); }
.cal-row .cal-text { padding: 0; font-size: 13px; }
.cal-lfree { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 8px 8px 14px; border: 0; border-left: 2px dashed var(--c); border-bottom: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; text-align: left; white-space: nowrap; }
.cal-lfree .cal-plus { font-size: 16px; }
.cal-lfree:hover { background: var(--surface-2); color: var(--text); }
.cal-lempty { padding: 8px 0 10px; }
.cal-more { justify-self: start; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.cal-more:hover { color: var(--text); text-decoration: underline; }

/* Панель подробностей */
.cal-panel { top: 96px; right: 16px; bottom: 16px; z-index: 60; align-content: start; box-shadow: var(--shadow-card); }
.cal-panel:focus { outline: none; }
.cal-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-panel-head b { font-family: var(--font-ui); font-size: 18px; font-weight: 600; }
.cal-pop-close { width: 32px; height: 32px; padding: 0; border: var(--border) solid var(--line-strong); border-radius: 50%; background: var(--surface); }
.cal-panel p { margin: 0; }
.cal-pop-channel { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.cal-pop-when { color: var(--muted); font-size: 14px; }
.cal-pop-status { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.cal-pop-thumb { display: block; width: 100%; max-height: 260px; object-fit: cover; border: 1.5px solid var(--line); border-radius: var(--radius); }
.cal-pop-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.cal-pop-error { padding: 8px 10px; border: 1.5px solid var(--danger); border-radius: var(--radius); background: var(--warn-bg); color: var(--danger); font-size: 14px; }
.cal-panel a { color: var(--link); font-weight: 600; }
.cal-pop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.cal-act { padding: 7px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font-weight: 500; }
.cal-act:hover { background: var(--surface-3); }
.cal-act.is-danger { margin-left: auto; padding-right: 0; border-color: transparent; background: transparent; color: var(--danger); }
.cal-act.is-danger:hover { background: transparent; text-decoration: underline; }
.cal-picks { display: grid; gap: 8px; }
.cal-pick { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; padding: 6px; border: var(--border) solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); text-align: left; box-shadow: var(--shadow-btn); }
.cal-pick:hover { background: var(--surface-3); }
.cal-ph svg { width: 22px; height: 22px; }
.cal-pick-thumb, .cal-pick .cal-ph { width: 72px; height: 72px; border-radius: 6px; object-fit: cover; }
.cal-pick-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.35; }

/* Подсказка «один раз» */
.cal-hint-layer { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--shadow-ink) 55%, transparent); }
.cal-hint { display: grid; gap: 14px; width: min(440px, 100%); padding: 20px; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); }
.cal-hint-title { margin: 0; font-family: var(--font-ui); font-size: 22px; font-weight: 600; }
.cal-hint-lines { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cal-hint-lines li { display: flex; align-items: flex-start; gap: 10px; font-size: 15px; line-height: 1.4; }
.cal-hint-ico { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--accent); font-size: 14px; }
.cal-hint .primary-button { justify-self: end; }

/* Телефон (< 700 px): экран дня из calendar-phone.js вместо сетки; шапка, неделя, список, шторка */
.cal-phone { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--surface); color: var(--text); }
.cal-phone-head { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 10px; background: var(--accent); color: var(--accent-text); border-bottom: 1px solid var(--line); }
.cal-phone-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-phone-top h1 { margin: 0; font-family: var(--font-ui); font-size: 24px; font-weight: 600; }
.cal-phone-top span { font-size: 13px; font-weight: 700; }
.cal-phone-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-phone-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 56px; padding: 0; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); }
.cal-phone-day.is-today { background: var(--surface); }
.cal-phone-day.is-selected { background: var(--line-strong); color: var(--accent); }
.cal-phone-wd { font-size: 10px; }
.cal-phone-day b { font-family: var(--font-ui); font-size: 18px; font-weight: 600; }
.cal-phone-dots { display: flex; gap: 2px; }
.cal-phone-dots i { width: 5px; height: 5px; border-radius: 50%; }
.cal-phone-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 12px 16px 0; }
.cal-phone-title h2 { margin: 0; font-family: var(--font-ui); font-size: 20px; font-weight: 600; }
.cal-phone-title span { font-size: 12px; color: var(--muted); }
.cal-phone-list { flex: 1; min-height: 0; display: grid; grid-auto-rows: max-content; align-content: start; gap: 8px; overflow-y: auto; padding: 10px 16px 150px; }
.cal-phone-row { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; }
.cal-phone-time { font-family: var(--font-ui); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-phone-card { position: relative; display: flex; align-items: center; overflow: hidden; border: 1.5px solid var(--line-strong); background: var(--surface); box-shadow: inset 4px 0 0 var(--c); text-align: left; color: var(--text); }
.cal-phone-thumb { width: 50px; height: 50px; flex: none; border-radius: 8px; object-fit: cover; background: var(--surface-3); }
.cal-phone-thumb.is-text { display: grid; place-items: center; font-size: 10px; color: var(--muted); }
.cal-phone-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-phone-text { font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-phone-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-phone-slot { display: flex; align-items: center; gap: 8px; width: 100%; height: 48px; padding: 0 12px; box-sizing: border-box; border: 2px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 13px; text-align: left; }
.cal-phone-slot.is-best { background: var(--gap-bg); }
.cal-phone-plus { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; }
.cal-phone-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; align-items: center; gap: 10px; padding: 10px 16px 18px; background: var(--surface); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; }
.cal-phone-pool { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--text); font-family: var(--font-ui); font-size: 18px; font-weight: 600; text-align: left; }
.cal-phone-fill { height: 44px; padding: 0 14px; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--red); color: var(--on-bright); font-weight: 700; box-shadow: 0 3px 3px 18px rgba(5, 6, 14, .45); }

/* Телефон: масштаб до трёх дней, недели и месяца в быстром переключателе нет */
@media (max-width: 700px) {
    .calendar-panel { width: calc(100vw - 40px); max-width: calc(100vw - 40px); }
    .cal-title { font-size: 18px; }
    .cal-bar > .cal-tools, .cal-zoom, #cal-full, .cal-body .cal-zoom { display: none; }   /* на телефоне — один день, без масштаба и «Круглых суток» */
    .cal-bar .cal-chips { flex: 1 1 100%; width: 100%; min-width: 0; flex-wrap: wrap; overflow: visible; }   /* чипы каналов переносятся, а не уезжают вправо */
    .cal-bar .cal-chip { white-space: nowrap; }
    .cal-main .cal-stage { grid-template-columns: minmax(0, 1fr); }
    .cal-main .cal-pool-col { display: none; }
    .cal-main .cal-panel:not(.is-sheet) { display: none; }   /* без выбора поста на телефоне панели нет: только шторка */
    .cal-body { min-height: 520px; }
}
@media (max-width: 899px) {
    .cal-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 70vh; border-radius: 14px 14px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
    .cal-badge.is-accent { animation: none; }
}

