/* Calendar, integrations, media, settings and drawer. Colors come from tokens.css. */

.state-pending { --st: var(--st-pending); --st-fg: #ffffff; }
.state-running { --st: var(--st-running); --st-fg: #0b0e13; }
.state-publishing { --st: var(--st-publishing); --st-fg: #0b0e13; }
.state-posted { --st: var(--st-posted); --st-fg: #0b0e13; }
.state-failed { --st: var(--st-failed); --st-fg: #ffffff; }
.state-draft { --st: var(--st-draft); --st-fg: #0b0e13; }
.state-cancelled { --st: var(--st-cancelled); --st-fg: #ffffff; }
.state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st, var(--muted)); display: inline-block; flex: none; }

/* ——— Page frame ——— */
.cal-page, .pz-page { display: grid; gap: 20px; }
.cal-page .page-header, .pz-page .page-header { margin-bottom: 0; }
.pz-link { font-size: 13px; }
.pz-kicker { font: 700 11px/1 var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ——— Account filter bar ——— */
.channel-bar { display: flex; flex-direction: column; gap: 10px; }
.channel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.channel-group-label {
  font: 700 11px/1 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 78px;
}
.channel {
  --acct: var(--primary);
  display: inline-grid;
  grid-template-columns: 28px auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.16s ease;
}
.channel:hover { background: var(--surface-2); border-color: var(--line-strong); transform: translateY(-1px); }
.channel:active { transform: scale(0.98); }
.channel.is-active { background: color-mix(in srgb, var(--acct) 14%, var(--surface)); border-color: color-mix(in srgb, var(--acct) 60%, transparent); }
.channel.is-warn .channel-avatar { box-shadow: 0 0 0 2px var(--st-failed); }
.channel-avatar {
  width: 28px; height: 28px; border-radius: 50%; overflow: visible;
  display: grid; place-items: center; background: var(--surface-3); color: var(--acct); font-weight: 700; font-size: 13px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--acct) 70%, transparent);
}
.channel-avatar img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.channel-text { display: grid; min-width: 0; max-width: 220px; line-height: 1.25; }
.channel-text strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-count:not(:empty) {
  min-width: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center;
  background: color-mix(in srgb, var(--acct) 22%, transparent); color: var(--ink);
}
.channel-manage { margin-left: auto; }

/* ——— Toolbar ——— */
.pz-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.pz-nav { display: flex; align-items: center; gap: 8px; }
.pz-nav .btn-sm, .pz-views .pz-view { min-height: 38px; }
.pz-title { margin: 0 0 0 12px; font: 600 20px/1.2 var(--display); color: var(--ink); }
.pz-views { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.pz-view {
  padding: 0 16px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-soft);
  font: 600 14px/1 var(--font); cursor: pointer;
}
.pz-view:hover { color: var(--ink); }
.pz-view.is-active { background: var(--primary-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 45%, transparent); }
.pz-controls { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pz-modes { gap: 2px; }
.pz-mode { display: inline-grid; place-items: center; padding: 0 11px; }

/* ——— Multi-account filter popover ——— */
.cal-filter { position: relative; }
.cal-filter-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 46px; height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.cal-filter-btn:hover,
.cal-filter-btn[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--ink);
}
.cal-filter-btn.has-filter { color: var(--accent-text); border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); }
.cal-filter-dot {
  position: absolute; top: 8px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
}
.cal-filter-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 40;
  min-width: 260px; max-width: min(320px, 85vw);
  padding: 8px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: menu-pop 0.16s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.cal-filter-menu[hidden] { display: none; }
.cal-filter-list { display: grid; gap: 2px; max-height: 280px; overflow-y: auto; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.cal-filter-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
  font: 500 13.5px/1.25 var(--font);
  transition: background 0.12s ease;
}
.cal-filter-item:hover { background: var(--surface-3); }
.cal-filter-item.is-all { font-weight: 600; }
.cal-filter-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.cal-filter-check {
  flex: none;
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  display: grid; place-items: center;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.cal-filter-item input:checked + .cal-filter-check {
  background: var(--primary);
  border-color: var(--primary);
}
.cal-filter-item input:checked + .cal-filter-check::after {
  content: "";
  width: 9px; height: 5px;
  border-left: 2px solid var(--on-accent);
  border-bottom: 2px solid var(--on-accent);
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.cal-filter-item input:indeterminate + .cal-filter-check {
  background: color-mix(in srgb, var(--primary) 55%, var(--surface));
  border-color: var(--primary);
}
.cal-filter-item input:indeterminate + .cal-filter-check::after {
  content: "";
  width: 8px; height: 2px;
  background: var(--on-accent);
  border-radius: 2px;
}
.cal-filter-avatar { flex: none; display: inline-flex; }
.cal-filter-avatar img,
.cal-filter-avatar .user-initial { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; font-size: 11px; }
.cal-filter-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pz-summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-right: auto; }
.pz-total { color: var(--ink-soft); font-weight: 600; margin-right: 6px; font-size: 14px; }
.summary-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
}
.summary-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st); }
.pz-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--muted); }
.pz-legend span { display: inline-flex; align-items: center; gap: 8px; }

/* ——— Week / day grid ——— */
.pz-calendar { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.wk { --cols: 7; display: grid; }
.wk-row { display: grid; grid-template-columns: 72px repeat(var(--cols), minmax(0, 1fr)); }
.wk-header { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); }
.wk-head { display: grid; justify-items: center; gap: 4px; padding: 14px 6px 12px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.wk-head strong { font: 600 22px/1 var(--display); color: var(--ink); letter-spacing: 0; text-transform: none; }
.wk-head small { color: var(--muted); min-height: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.wk-head.is-today strong {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: var(--on-accent);
}
.wk-body { max-height: calc(100vh - 330px); min-height: 460px; overflow-y: auto; }
.wk-hour { padding: 10px 12px 0 0; text-align: right; font-size: 12px; color: var(--muted); border-right: 1px solid var(--line); }
.wk-cell {
  position: relative; min-height: 76px; padding: 10px 8px 8px; display: grid; gap: 10px; align-content: start;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.wk-cell:last-child { border-right: 0; }
.wk-cell.is-past { background: rgba(255, 255, 255, 0.012); }
.wk-cell[data-slot] { cursor: pointer; }
.wk-cell[data-slot]:hover { background: var(--primary-soft); }
.wk-add { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent-text); font-size: 20px; opacity: 0; }
.wk-cell[data-slot]:hover .wk-add { opacity: 1; }
.wk.is-day .wk-row { grid-template-columns: 72px minmax(0, 1fr); }
.wk.is-day .wk-cell { min-height: 88px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ——— Post cards (top account band, status ring + corner status badge) ——— */
.post-card {
  --acct: var(--primary);
  position: relative;
  width: 100%; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 4px 10px; align-items: start;
  padding: 18px 10px 9px; border-radius: 10px; text-align: left; cursor: pointer; font: inherit; color: var(--ink);
  border: 1.5px solid color-mix(in srgb, var(--st, var(--line-strong)) 85%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--st, transparent) 22%, transparent);
  background: var(--surface-2);
  transition: background 0.14s ease, border-color 0.16s ease, transform 0.16s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.16s ease;
}
.post-card-band {
  position: absolute; top: 0; left: 0; right: 0; height: 10px;
  border-radius: 8px 8px 0 0;
  background: color-mix(in srgb, var(--acct) 82%, #000);
  pointer-events: none;
}
.post-card-badge {
  position: absolute; top: -6px; left: -6px; z-index: 2;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--st, var(--muted));
  color: var(--st-fg, #0b0e13);
  box-shadow: 0 0 0 2px var(--surface), 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.post-card:hover {
  background: var(--surface-3);
  border-color: var(--st, var(--line-strong));
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--st, transparent) 24%, transparent), 0 6px 14px rgba(0, 0, 0, 0.22);
}
.post-card:active { transform: translateY(0) scale(0.99); }
.post-card.state-cancelled { opacity: 0.72; }
.post-card-avatar { width: 24px; height: 24px; border-radius: 50%; overflow: visible; display: grid; place-items: center; background: var(--surface-3); font-size: 11px; font-weight: 700; }
.post-card-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.post-card-body { display: grid; min-width: 0; gap: 3px; }
.post-card-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-card-meta strong { color: var(--ink); font-weight: 600; }
.post-card-text { font-size: 12.5px; line-height: 1.4; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-text.is-placeholder { color: var(--muted); font-style: italic; }
.post-card-state { grid-column: 2; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.post-card.is-compact { grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 2px 8px; padding: 15px 8px 8px; }
.post-card.is-compact .post-card-band { height: 8px; }
.post-card.is-compact .post-card-avatar { width: 20px; height: 20px; }
.post-card.is-compact .post-card-body { gap: 2px; }
.post-card.is-compact .post-card-meta { font-size: 11px; }
.post-card.is-compact .post-card-text {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.post-card.is-compact .post-card-state { display: none; }

/* ——— Month grid ——— */
.mo-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.mo-dow span { padding: 12px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; text-transform: uppercase; letter-spacing: 0.06em; }
.mo-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mo-cell {
  min-height: clamp(112px, calc((100vh - 290px) / 6), 180px); padding: 12px; display: grid; grid-template-rows: auto 1fr; gap: 10px; cursor: pointer;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.mo-cell:nth-child(7n) { border-right: 0; }
.mo-cell:hover { background: var(--surface-2); }
.mo-cell.is-out { opacity: 0.4; }
.mo-cell.is-past { background: rgba(255, 255, 255, 0.012); }
.mo-cell.is-expanded, .wk-cell.is-expanded { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.mo-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.mo-num { font: 600 15px/1 var(--display); color: var(--ink-soft); }
.mo-cell.is-today .mo-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--on-accent); }
.mo-cards { display: grid; gap: 10px; align-content: start; min-width: 0; padding-top: 4px; }
.mo-more {
  border: 0; background: none; color: var(--accent-text); font: 600 12px/1.2 var(--font); cursor: pointer;
  text-align: center; padding: 5px 6px; border-radius: var(--radius-sm); width: 100%;
  transition: background 0.12s ease, color 0.12s ease;
}
.mo-more:hover { background: var(--primary-soft); color: var(--ink); }
.mo-more.is-expanded { color: var(--muted); }
.mo-more.is-expanded:hover { color: var(--ink); }

/* ——— List view ——— */
.cal-list { display: grid; }
.cal-list-day { padding: 16px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.cal-list-day:last-child { border-bottom: 0; }
.cal-list-day.is-today { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.cal-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cal-list-title { display: flex; align-items: baseline; gap: 10px; }
.cal-list-title strong { font: 600 15px/1.2 var(--display); color: var(--ink); }
.cal-list-count { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.cal-list-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.cal-list-empty { padding: 48px 24px; text-align: center; }
.cal-list-empty strong { display: block; font: 600 16px/1.3 var(--display); color: var(--ink); margin-bottom: 6px; }
.count-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.count-badge {
  min-width: 20px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; text-align: center;
  color: var(--ink); background: color-mix(in srgb, var(--st) 22%, transparent); border: 1px solid color-mix(in srgb, var(--st) 40%, transparent);
}

/* ——— Drawer ——— */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(2px); animation: drawer-fade 0.18s ease both; }
@keyframes drawer-fade { from { opacity: 0; } to { opacity: 1; } }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  animation: drawer-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1; }
.drawer-head h2 { margin: 0; min-width: 0; font: 700 18px/1.2 var(--display); overflow-wrap: anywhere; }
.drawer-body { padding: 18px 20px 28px; display: grid; gap: 18px; }
.drawer-preview { display: grid; place-items: center; }
.phone {
  position: relative; width: 240px; aspect-ratio: 9 / 16; border-radius: 26px; overflow: hidden;
  background: #000; border: 6px solid var(--surface-3); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.drawer-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.drawer-video.is-url { display: grid; place-items: start center; align-content: start; padding-top: 32px !important; text-align: center; color: var(--muted); padding: 16px; font-size: 13px; word-break: break-all; }
.phone-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 12px 12px; color: #fff; font-size: 11.5px; line-height: 1.35;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85)); pointer-events: none; max-height: 60%; overflow: hidden; overflow-wrap: anywhere;
}
.phone-caption p { margin: 4px 0 0; }
.drawer-content-box {
  display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
}
.drawer-content-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-content-head h3 { margin: 0; font: 700 13px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.drawer-content-text {
  margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: text;
  max-height: 260px; overflow-y: auto;
}
.drawer-content-text.is-comment {
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-soft);
}
.drawer-content-empty { margin: 0; }
.drawer-content-sub { display: grid; gap: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.drawer-content-label { font: 700 11px/1 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.drawer-content-link { font-size: 13.5px; color: var(--accent-text); overflow-wrap: anywhere; text-decoration: none; }
.drawer-content-link:hover { text-decoration: underline; }
.drawer-facts { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.drawer-facts dt { color: var(--muted); }
.drawer-facts dd { margin: 0; color: var(--ink); word-break: break-word; }
.drawer-facts .err-line { color: var(--danger-ink); }
.drawer-actions { display: grid; gap: 10px; }
.drawer-actions .btn { min-height: 42px; }
#drawer-status.is-err { color: var(--danger-ink); }
.tl-title { margin: 6px 0 0; font: 700 15px/1 var(--display); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; display: grid; gap: 12px; border-left: 2px solid var(--line); }
.tl-item { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 10px; margin-left: -12px; }
.tl-dot { width: 12px; height: 12px; margin-top: 3px; border-radius: 50%; background: var(--st, var(--muted)); box-shadow: 0 0 0 3px var(--surface); }
.tl-item strong { font-size: 13px; }
.tl-item small { color: var(--muted); font-size: 12px; }
.tl-item p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); word-break: break-word; }

/* ——— Integrations ——— */
@keyframes card-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.integration-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 24px; align-items: stretch; }
.integration-card {
  --acct: var(--primary);
  min-width: 0;
  display: grid; grid-template-rows: auto auto 1fr auto; gap: 18px; padding: 24px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid color-mix(in srgb, var(--acct) 75%, transparent);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.integration-card:not(.is-skeleton) { animation: card-enter 0.26s cubic-bezier(0.22, 1, 0.36, 1) both; }
.integration-card:not(.is-skeleton):hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.integration-card.is-disabled { opacity: 0.65; }
.integration-card.is-blocked { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.integration-card.is-empty { justify-items: start; grid-template-rows: none; }
.integration-card header { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-width: 0; }
.integration-card header img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: var(--surface-3); box-shadow: 0 0 0 2px color-mix(in srgb, var(--acct) 70%, transparent); }
.integration-id { min-width: 0; }
.integration-card h2 { margin: 0; font: 700 16px/1.25 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.integration-card header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease; }
.health-ok { background: var(--ok-soft); color: var(--ok-ink); }
.health-warn { background: var(--warn-soft); color: var(--warn-ink); }
.health-error { background: var(--danger-soft); color: var(--danger-ink); }
.integration-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.integration-stats div { display: grid; justify-items: center; min-width: 0; padding: 14px 4px; border-radius: var(--radius); background: var(--surface-2); }
.integration-stats strong { font: 700 20px/1 var(--display); }
.integration-stats strong.is-err { color: var(--danger-ink); }
.integration-stats span { font-size: 11px; color: var(--muted); margin-top: 4px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.integration-card dl { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; align-content: start; }
.integration-card dt { color: var(--muted); white-space: nowrap; }
.integration-card dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.integration-card footer { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; min-width: 0; }
.integration-card footer .btn { min-height: 36px; flex: 0 1 auto; white-space: nowrap; }

/* Loading button: both labels share one grid cell so the width never changes. */
.btn-stack { display: inline-grid; }
.btn-stack > * { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-label-loading { visibility: hidden; }
.btn.is-loading { cursor: progress; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading .btn-label-loading { visibility: visible; }
.btn-spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid color-mix(in srgb, var(--accent-text) 30%, transparent); border-top-color: var(--accent-text);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts: fixed, never shift layout. */
.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 1100; display: grid; gap: 8px; justify-items: end; pointer-events: none; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--ok); animation: toast-in 0.18s ease both; transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation-duration: 2s; } .toast { animation: none; } }

@media (max-width: 1200px) {
  .mo-cell { padding: 10px; }
}
@media (max-width: 900px) {
  .channel-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .channel { flex: none; }
  .channel-manage { margin-left: 0; flex: none; }
  .pz-calendar { overflow-x: auto; }
  .wk-row { grid-template-columns: 56px repeat(var(--cols), minmax(120px, 1fr)); }
  .mo-cell { min-height: 96px; padding: 6px; }
  .mo-cell .post-card-meta { display: none; }
}
@media (max-width: 600px) {
  .mo-cell { min-height: 84px; padding: 4px; gap: 4px; }
  .mo-top .count-badges { display: none; }
  .mo-cell .post-card.is-compact { grid-template-columns: 1fr; justify-items: center; padding: 3px; border-left-width: 2px; }
  .mo-cell .post-card.is-compact .post-card-body, .mo-cell .post-card.is-compact .post-card-state { display: none; }
  .mo-more { font-size: 11px; padding: 2px 0 0; }
  .pz-title { margin-left: 4px; font-size: 18px; }
  .wk-row { grid-template-columns: 48px repeat(var(--cols), minmax(110px, 1fr)); }
  .pz-calendar { overflow-x: auto; }
}

/* ——— Media library ——— */
.media-upload { cursor: pointer; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; align-items: start; }
.media-tile {
  display: flex; flex-direction: column; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.media-tile:not(.is-skeleton) { animation: card-enter 0.24s cubic-bezier(0.22, 1, 0.36, 1) both; }
.media-tile:not(.is-skeleton):hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.media-thumb { aspect-ratio: 4 / 5; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 13px; overflow: hidden; }
.media-thumb video,
.media-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.media-tile:hover .media-thumb img { transform: scale(1.03); }
.media-meta { display: grid; gap: 4px; padding: 14px 16px 6px; min-width: 0; }
.media-meta strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta small { color: var(--muted); font-size: 12.5px; }
.media-tile footer { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 16px; }
.media-empty { padding: 48px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); text-align: center; color: var(--muted); grid-column: 1 / -1; }
.media-empty strong { color: var(--ink); font: 600 17px/1.3 var(--display); }

/* ——— Settings ——— */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 24px; align-items: start; }
.settings-card { padding: 24px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.settings-card h2 { margin: 0 0 16px; font: 600 16px/1.2 var(--display); }
.settings-card dl { display: grid; gap: 0; margin: 0; }
.settings-row { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.settings-row:first-child { border-top: 0; padding-top: 0; }
.settings-row dt { color: var(--muted); }
.settings-row dd { margin: 0; display: grid; gap: 4px; justify-items: start; }
.settings-row small { color: var(--muted); font-size: 12px; }
.settings-card code, .page-header code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: 12.5px; }
.settings-form { display: grid; gap: 16px; }
.settings-row dd input,
.settings-row dd select {
  width: 100%;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--surface-2);
  color: var(--ink);
  font: inherit;
}
.settings-row dd select {
  padding-right: 40px;
}
.settings-row dd input:focus,
.settings-row dd select:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
.settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.settings-actions .is-err { color: var(--danger-ink); }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; gap: 4px; }
}
.drawer-actions .field { display: grid; gap: 8px; }
.drawer-actions input[type="datetime-local"] {
  min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink); font: 500 14px/1 var(--font); color-scheme: dark;
}
.drawer-actions input[type="datetime-local"]:focus { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* ——— Skeleton loading states ——— */
@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
.skel-circle { border-radius: 50%; flex: none; }
.skel-pill { border-radius: 999px; }
.skel-line { height: 12px; }
.skel-line-lg { height: 16px; }
.skel-line-sm { height: 10px; }
.skel-btn { height: 34px; border-radius: var(--radius-sm); }

/* Calendar grid skeleton */
.cal-skel-head {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line); padding: 14px 12px; gap: 12px;
}
.cal-skel-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
}
.cal-skel-cell {
  min-height: 112px; padding: 12px; display: grid; align-content: start; gap: 8px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.cal-skel-cell:nth-child(7n) { border-right: 0; }
.cal-skel-card { height: 38px; border-radius: var(--radius-sm); }

/* Drawer skeleton */
.drawer-skel { display: grid; gap: 18px; }
.drawer-skel-phone { width: 220px; height: 340px; border-radius: 24px; margin: 0 auto; }
.drawer-skel-box { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.drawer-skel-facts { display: grid; grid-template-columns: 96px 1fr; gap: 10px 14px; }

/* Integration / media / schedule-item skeletons */
.integration-card.is-skeleton { pointer-events: none; }
.integration-card.is-skeleton header { grid-template-columns: 48px minmax(0, 1fr) 78px; }
.integration-card.is-skeleton .skel-stat { height: 64px; border-radius: var(--radius); }
.integration-card.is-skeleton footer { display: flex; gap: 8px; }
.media-tile.is-skeleton { pointer-events: none; }
.media-tile.is-skeleton .media-thumb { padding: 0; display: block; }
.media-tile.is-skeleton .media-thumb .skel { width: 100%; height: 100%; aspect-ratio: 4 / 5; border-radius: 0; }
.media-thumb.is-loading {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
.media-thumb.is-loading img,
.media-thumb.is-loading video { opacity: 0; }
.media-thumb img,
.media-thumb video { transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.schedule-item.is-skeleton { pointer-events: none; }

/* Soft navigation subtle dim while fetching next page */
main.app-main { transition: opacity 0.14s ease; }
main.app-main.is-nav-loading { opacity: 0.55; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--surface-2); }
  main.app-main, .app-layout, .side-nav, .side-link, .side-ctrl-btn, .post-card, .integration-card, .media-tile, .media-thumb img { transition: none !important; animation: none !important; }
}
