/* PsyAI app-specific styles on top of shared-ui (loaded after /shared/style.css) */

/* ── Page header ─────────────────────────────────────────────── */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-base);
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}
.page-head .page-title { margin-bottom: 0; }
.page-head .page-subtitle {
  margin: var(--space-xs) 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ── Links that behave as blocks ────────────────────────────── */
a.stat-card {
  color: inherit;
  text-decoration: none;
  display: block;
}
a.stat-card:hover { text-decoration: none; }
.stat-sub { margin-top: var(--space-xs); font-size: 12.5px; color: var(--text-secondary); }

/* ── Sidebar icons ──────────────────────────────────────────── */
.sidebar-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-right: var(--space-md);
  stroke-width: 1.5;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-footer { padding: var(--space-sm); }

/* ── Panels ─────────────────────────────────────────────────── */
.section-title {
  font-size: 15px;
  letter-spacing: 0.08em;
}
.panel--flush { padding: 0; }
.panel--flush .panel-head { margin: 0 18px; }
#clientDetails p { overflow-wrap: anywhere; margin-top: var(--space-md); }
.panel--client-events .panel-head { padding-top: var(--space-md); margin-bottom: var(--space-base); }
.panel-body code { overflow-wrap: anywhere; word-break: break-word; }
.admin-users-panel .panel-head { margin: var(--space-2xl) 18px var(--space-xl); }
.panel-body { padding: 0; }

.file-cell {
  display: grid;
}
.file-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: var(--space-xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  transition: border-color var(--transition-fast);
}
.file-card:hover { border-color: var(--border-strong); }
.file-card p { margin: 0; font-size: 12.5px; color: var(--text); }
.icon-lg {
  width: 24px;
  height: 24px;
  stroke: var(--text-faint);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-base);
}
.flex-inline { display: flex; align-items: center; }
.session-rec-btn-wrap {
  display: flex;
  justify-content: center;
  margin-top: var(--space-md);
}

/* ── Inline helpers (bootstrap replacements) ────────────────── */
/* spread-вариант: shared-ui .row-inline = flex-start без wrap */
.row-inline--spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.btn-group-wrap { gap: var(--space-sm); }
.mb-4 { margin-bottom: var(--space-xl); }
.text-faint-12 { font-size: 11.5px; }
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 var(--space-md);
}
@media (max-width: 768px) {
  .form-grid-3 { grid-template-columns: 1fr; }
}
.form-text {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: var(--space-xs);
}
.icon-sm {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -3px;
}
.layout-content svg:not([width]) {
  width: 18px;
  height: 18px;
  flex: none;
}
.layout-content svg.icon-lg:not([width]) { width: 24px; height: 24px; }
.empty-icon svg:not([width]) { width: 44px; height: 44px; color: var(--text-faint); }
.icon-file {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  vertical-align: -3px;
  flex: none;
}
.icon-inline {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  margin-right: var(--space-xs);
  vertical-align: -2px;
}

/* ── Grids (bootstrap row/col replacement) ──────────────────── */
.grid-sidebar {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-base);
  align-items: start;
}
.grid-sidebar > * { min-width: 0; }
.grid-sidebar > .full { grid-column: 1 / -1; }
.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-base);
}
.grid-12 > .col-4 { grid-column: span 4; }
.grid-12 > .col-8 { grid-column: span 8; }
.grid-12 > .col-12 { grid-column: span 12; }
.file-cell { grid-column: span 3; }
@media (max-width: 900px) {
  .file-cell { grid-column: span 6; }
}
@media (max-width: 900px) {
  .grid-sidebar { grid-template-columns: 1fr; }
  .grid-12 > .col-4,
  .grid-12 > .col-8 { grid-column: span 12; }
}

/* ── Modal sizing variants ──────────────────────────────────── */
.modal-box--form {
  width: min(560px, 94vw);
  height: auto;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box--wide {
  width: min(880px, 94vw);
  height: auto;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box--narrow {
  width: min(440px, 94vw);
  height: auto;
  max-height: 90vh;
  overflow-y: auto;
}
@media (max-width: 768px) {
  .modal-box--form { width: min(560px, 98vw); }
  .modal-box--wide { width: min(880px, 98vw); }
  .modal-box--narrow { width: min(440px, 98vw); }
}
.modal-box .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  flex-wrap: wrap;
}
.modal-box .modal-actions .btn-danger:first-child { margin-right: auto; }

/* OnlyOffice editor modal */
.modal-box--office {
  width: 98vw;
  max-width: 98vw;
  height: 98vh;
  max-height: 98vh;
  padding: 0;
  overflow: hidden;
}
.modal:has(.modal-box--office) { padding: 1vh 1vw; }
.office-modal-top {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.office-modal-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.office-modal-status {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  padding-inline: var(--space-sm);
}
.office-editor-host {
  flex: 1 1 auto;
  min-height: 0;
}
.office-editor-host iframe { width: 100% !important; height: 100% !important; border: 0; display: block; }
/* DocsAPI moves the editor iframe into modal-box after the header with a fixed pixel
   height (overflow in Firefox) — force it to fill remaining flex space instead. */
.modal-box--office > iframe {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0;
  border: 0;
  display: block;
}
@media (max-width: 768px) {
  .modal:has(.modal-box--office) { padding: 1vh 1vw; }
  .modal-box--office { width: 98vw; max-width: 98vw; height: 98vh; max-height: 98dvh; }
}

/* ── Clients in event form / picker ─────────────────────────── */
.client-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}
.client-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-elevated);
}
.client-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex: none;
}
.client-remove-btn .icon-inline { margin-right: 0; }
.client-remove-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.client-picker-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 50vh;
  overflow-y: auto;
}
.client-multi__item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
}
.client-multi__item:hover { border-color: var(--accent); }

/* ── Guest invite dropdown menu ─────────────────────────────── */
.guest-invite-menu {
  position: fixed;
  z-index: 2100;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 16px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 0 6px 20px rgba(23, 31, 43, 0.18);
  padding: var(--space-xs);
}
.guest-invite-menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.guest-invite-menu__item:hover { background: var(--accent-soft); }
.guest-invite-menu__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.guest-invite-menu__icon { display: inline-flex; flex: none; color: var(--text-secondary); }
.guest-invite-menu__icon .icon-inline { margin-right: 0; }
.guest-invite-menu__item.is-copied { color: var(--accent); }
.guest-invite-menu__item.is-copied .guest-invite-menu__icon { color: var(--accent); }
.guest-invite-menu__item--all { color: var(--text-secondary); font-size: 12.5px; }
.guest-invite-menu__sep { height: 1px; background: var(--border); margin: var(--space-xs) 0; }
.guest-invite-menu__hint {
  padding: var(--space-xs) var(--space-sm) 2px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Error pages ─────────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}
.error-code {
  font-family: var(--font-display);
  font-size: 72px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* ── Reveal animations ──────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.05s; }
.reveal-delay-2 { transition-delay: 0.12s; }
.reveal-delay-3 { transition-delay: 0.19s; }

/* ── Transcript / markdown ───────────────────────────────────── */
.transcript-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-height: 420px;
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--bg);
  border: 1px solid var(--border);
}

#fileViewerModal .transcript-text {
  max-height: none;
  min-height: 100%;
  box-sizing: border-box;
  margin: 0;
}

/* ── FullCalendar overrides ─────────────────────────────────── */
.fc {
  --fc-border-color: var(--border);
  --fc-page-bg-color: var(--panel);
  --fc-today-bg-color: color-mix(in srgb, var(--accent-soft) 40%, transparent);
  --fc-event-border-color: var(--accent);
  --fc-neutral-bg-color: var(--bg-elevated);
  font-size: 12.5px;
}
.fc a { color: var(--text); text-decoration: none; }
.fc a:hover { text-decoration: none; }
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number {
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 6px 8px;
}
.fc .fc-toolbar-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}
.fc .fc-button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 0;
  box-shadow: none;
  font-size: 12px;
  padding: 5px 12px;
}
.fc .fc-button:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-strong);
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.fc .fc-button:focus,
.fc .fc-button:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 1px;
  box-shadow: none;
}
.fc .fc-event {
  border-radius: 0;
  font-size: 11px;
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent);
}
.fc .fc-event:hover { background: var(--accent); color: #fff; }
.fc .fc-v-event .fc-event-main { color: var(--accent); }
.fc .fc-event:hover .fc-event-main { color: #fff; }
.fc .fc-timegrid-event .fc-event-time { font-size: 11px; }
.fc .fc-daygrid-day.fc-day-today { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.fc .fc-popover,
.fc .fc-more-popover .fc-popover-body {
  background: var(--panel);
  border: 1px solid var(--border);
}
.calendar-body { padding: var(--space-base); }

/* ── Mobile calendar (≤768px) ───────────────────────────────── */
.cal-fab { display: none; }

@media (max-width: 768px) {
  /* Основное действие в шапке заменяет FAB */
  .page-head #new-event-btn { display: none; }

  /* Плавающая кнопка «Новое событие» */
  .cal-fab {
    position: fixed;
    right: 16px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px rgba(10, 99, 102, 0.38);
    cursor: pointer;
    z-index: 90;
  }
  .cal-fab svg { width: 24px; height: 24px; }
  .cal-fab:active { transform: scale(0.94); }

  /* Календарь на всю ширину — снимаем двойные отступы */
  .calendar-body { padding: 0; }

  /* Тулбар: три аккуратные строки по центру — заголовок, навигация, переключатель вида */
  .fc .fc-header-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    margin: 0;
  }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; width: 100%; }
  /* Порядок строк тулбара: заголовок → навигация → переключатель вида */
  .fc .fc-toolbar-chunk:nth-child(2) { order: -1; }
  .fc .fc-toolbar-title { font-size: 16px; text-align: center; }

  /* Touch-targets ≥44px */
  .fc .fc-button { min-height: 44px; min-width: 44px; padding: 8px 12px; }
  .fc .fc-button-group .fc-button { padding: 8px 10px; }
  .fc .fc-col-header-cell-cushion,
  .fc .fc-daygrid-day-number { padding: 6px; font-size: 12px; }

  /* Плотность month-вида: событие — одна строка, время скрыто */
  .fc .fc-daygrid-day-frame { min-height: 40px; }
  .fc .fc-daygrid-day-events { font-size: 10px; }
  .fc .fc-event { padding: 1px 4px; font-size: 10px; }
  .fc .fc-event-time { display: none; }

  /* timeGridDay: читаемые слоты во всю ширину */
  .fc .fc-timegrid-slot { height: 2.4em; }
  .fc .fc-timegrid-now-indicator-arrow { display: none; }

  /* Поп-овер «+N ещё» не выходит за границы вьюпорта */
  .fc .fc-popover,
  .fc .fc-more-popover { max-width: calc(100vw - 16px); box-sizing: border-box; }
}

/* ── LiveKit video ──────────────────────────────────────────── */
.livekit-video-container {
  background: #141414;
  border: 1px solid var(--border);
  min-height: var(--video-height, 480px);
  display: flex;
  flex-direction: column;
}
.livekit-video-stage {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2px;
  padding: var(--space-md);
  min-height: 360px;
}
.livekit-video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.lk-stage-wrapper {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 360px;
  background: var(--video-bg);
  overflow: hidden;
}
.lk-main-tile { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
/* Авто-сетка: 2 участника — split, 3+ — spotlight + полоса миниатюр */
.lk-stage-split {
  position: absolute; inset: 0; padding: 8px;
  display: grid; grid-template-rows: 1fr 1fr; gap: 8px;
}
@media (orientation: landscape) {
  .lk-stage-split { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
}
.lk-split-tile { position: relative; inset: auto; overflow: hidden; border-radius: 8px; }
.lk-stage-spot {
  position: absolute; inset: 0; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.lk-spot-tile { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; overflow: hidden; border-radius: 8px; }
.lk-thumb-strip {
  flex: none; display: flex; gap: 8px; height: 110px; overflow-x: auto;
  scrollbar-width: thin;
}
.lk-thumb-tile {
  position: relative; flex: 0 0 150px; height: 100%; overflow: hidden;
  border-radius: 8px; cursor: pointer; outline: 1px solid rgba(255,255,255,0.15);
}
.lk-thumb-tile:hover { outline-color: rgba(255,255,255,0.45); }
@media (max-width: 576px) {
  .lk-thumb-strip { height: 84px; }
  .lk-thumb-tile { flex-basis: 112px; }
}
.lk-tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  color: currentColor;
}
.lk-tile-placeholder svg { stroke-opacity: 0.2; }
.lk-tile-label {
  position: absolute;
  bottom: 12px;
  left: 12px;
  color: #fff;
  font-size: 0.875rem;
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  z-index: 10;
}
.lk-pip-tile {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: clamp(96px, 30vw, 200px);
  /* Пропорции окна = пропорции видео (--lk-ar ставится из метаданных трека) */
  aspect-ratio: var(--lk-ar, 4 / 3);
  overflow: hidden;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  border: 2px solid rgba(255,255,255,0.2);
  background: var(--bg-elevated);
}
.lk-pip-tile video { transform: scaleX(-1); }
.lk-pip-tile .lk-tile-placeholder svg { width: 40px; height: 40px; stroke-opacity: 0.3; }
@media (orientation: portrait) and (pointer: coarse) {
  .lk-pip-tile { aspect-ratio: 9 / 16; }
}
.lk-pip-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  color: #fff;
  font-size: 0.625rem;
  background: rgba(0,0,0,0.5);
  padding: 1px 6px;
  z-index: 10;
}
.lk-pip-btn {
  position: absolute;
  top: 4px;
  width: 26px;
  height: 26px;
  font-size: 12px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
  padding: 0;
}
.lk-pip-btn--mic { right: 4px; }
.lk-pip-btn--cam { right: 32px; }
@media (max-width: 768px), (pointer: coarse) {
  .lk-pip-btn { width: 36px; height: 36px; font-size: 15px; }
  .lk-pip-btn--cam { right: 44px; }
}
@media (max-width: 576px) {
  .lk-stage-wrapper { min-height: 240px; }
}

/* ── Mobile fullscreen video modal ─────────────────────────── */
.modal--fullscreen { padding: 0; }
.modal-box--video {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #141414;
  color: #fff;
  overflow: hidden;
}
.lk-modal-top {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  padding: calc(var(--space-sm) + env(safe-area-inset-top, 0px)) var(--space-md) var(--space-sm);
  background: rgba(20, 20, 20, 0.92);
  border-bottom: 1px solid #2a2a2a;
}
.lk-modal-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
}
.lk-modal-top-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}
/* Иконки без текста в верхней панели модалки */
.lk-modal-top-actions .btn {
  font-size: 0;
  gap: 0;
  padding: 8px 12px;
  min-height: 44px;
  min-width: 44px;
  color: #e5e5e5;
  background: transparent;
  border-color: transparent;
}
.lk-modal-top-actions .btn .icon-sm { width: 22px; height: 22px; }
.lk-modal-top-actions .btn.is-active { color: var(--accent); }
.lk-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: #e5e5e5;
  cursor: pointer;
}
.lk-modal-close:active { color: #fff; }
.lk-modal-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.lk-modal-stage .livekit-video-container {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  border: none;
}
.lk-modal-controls {
  display: flex;
  align-items: stretch;
  gap: var(--space-sm);
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-md)
    calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  background: rgba(20, 20, 20, 0.95);
  border-top: 1px solid #2a2a2a;
}
.lk-modal-controls .btn {
  flex: 1 1 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.livekit-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  color: #9a9a9a;
  font-size: 13px;
  background: #1c1c1c;
  min-height: 240px;
  border: 1px dashed #333;
}
.lk-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-top: 1px solid #2a2a2a;
}
.lk-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  height: 38px;
  padding: 0 var(--space-lg);
  border: 1px solid #3a3a3a;
  background: #222;
  color: #e5e5e5;
  font-family: var(--font-body);
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.lk-control-btn:hover { background: #2e2e2e; border-color: #4a4a4a; }
.lk-control-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.lk-control-btn--danger { border-color: rgba(169, 50, 38, 0.6); color: #e8b4ad; }
.lk-control-btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.lk-control-btn--active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lk-control-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Бренд в хедере: «AI» акцентным цветом ─────────────────── */
.layout-header .auth-word em { color: var(--accent); }

/* ── Touch: мгновенные тапы без задержки/зума по двойному тапу ── */
.menu-toggle,
#headerMenu .sidebar-link,
#headerMenu .logout-link {
  touch-action: manipulation;
}

/* ── Global media safety ────────────────────────────────────── */
img, video, iframe, embed, object { max-width: 100%; }

/* ── Mobile: сайдбар в бургер-меню (≤768px) ───────────────── */
@media (max-width: 768px) {
  body { overflow-x: clip; }
  .panel--flush .panel-head { margin: 0 var(--space-md); }
  /* panel--flush не имеет padding — negative margins full-bleed не нужны */
  .panel--flush .table-wrap { margin-left: 0; margin-right: 0; }

  /* Элементы занимают 98% ширины окна */
  .layout-content {
    width: 98%;
    max-width: 98%;
    padding-left: 0;
    padding-right: 0;
  }
  .layout-header { padding-left: 1vw; padding-right: 1vw; }

  .sidebar { display: none; }

  .layout-header #headerMenu {
    width: 260px;
    max-height: calc(100vh - 48px - var(--safe-top));
    max-height: calc(100dvh - 48px - var(--safe-top));
    overflow-y: auto;
    padding: var(--space-sm) 0 0;
  }
  #headerMenu .sidebar-nav {
    flex-direction: column;
    padding: var(--space-xs) 0;
    gap: 0;
    width: 100%;
  }
  #headerMenu .sidebar-nav + .sidebar-nav {
    border-top: 1px solid var(--border);
  }
  #headerMenu .sidebar-link {
    display: flex;
    width: 100%;
    min-height: 44px;
    padding: 10px var(--space-lg);
    white-space: normal;
    border-left: 2px solid transparent;
    border-bottom: none;
    font-size: 13px;
  }
  #headerMenu .sidebar-link.active {
    border-left-color: var(--accent);
    border-bottom-color: transparent;
  }
  #headerMenu .logout-link {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    padding: 10px var(--space-lg);
    background: none;
    border: none;
    border-left: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    color: var(--text-secondary);
  }
  #headerMenu .logout-link:hover {
    color: var(--text);
    background: var(--bg-elevated);
  }
  #headerMenu .theme-toggle {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    padding: 10px var(--space-lg);
    background: none;
    border: none;
    border-left: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    color: var(--text-secondary);
  }
  #headerMenu .theme-toggle:hover {
    color: var(--text);
    background: var(--bg-elevated);
  }
  #headerMenu .theme-toggle .theme-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    margin-right: var(--space-md);
  }
  #headerMenu .theme-toggle-label { display: inline; }
  #headerMenu .sidebar-footer {
    border-top: 1px solid var(--border);
    border-left: none;
    padding: var(--space-sm) var(--space-lg);
    display: block;
  }
  #headerMenu .topbar-email {
    order: 40;
    width: 100%;
  }
  #headerMenu .topbar-plan-badge {
    order: 41;
    align-self: flex-start;
    margin: 0 var(--space-md) var(--space-sm);
  }
  #headerMenu .sidebar-footer {
    order: 42;
  }
}

/* ── Mobile overrides for shared-ui ─────────────────────────── */
#toast-container,
.toast-container { max-width: calc(100vw - 16px); }

@media (max-width: 640px) {
  .stat-card { padding: 14px; }
  .stat-value { font-size: 26px; }
}

/* AI analysis block on session page */
.ai-analysis-body p, .ai-analysis-body ul, .ai-analysis-body ol, .ai-analysis-body li { font-size: 12.5px; line-height: 1.5; }

/* Prompt results on session page */
.prompt-result-output { font-family: var(--font-mono, monospace); font-size: .82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 4px 0 var(--space-sm, 12px); max-height: 420px; overflow: auto; }
.prompt-result-output--md { font-family: inherit; font-size: 12.5px; white-space: normal; word-break: normal; }
.prompt-result-output--md > :first-child { margin-top: 0; }
.prompt-result-output--md > :last-child { margin-bottom: 0; }
.prompt-result-output--md p { margin: 0 0 .6em; font-size: inherit; line-height: inherit; }
.prompt-result-output--md h1, .prompt-result-output--md h2, .prompt-result-output--md h3, .prompt-result-output--md h4, .prompt-result-output--md h5, .prompt-result-output--md h6 { margin: 1em 0 .4em; font-size: 1em; line-height: 1.3; }
.prompt-result-output--md h1 { font-size: 1.15em; }
.prompt-result-output--md h2 { font-size: 1.08em; }
.prompt-result-output--md ul, .prompt-result-output--md ol { margin: 0; padding-left: 2em; }
.prompt-result-output--md li { margin: .15em 0; }
.prompt-result-output--md code { font-family: var(--font-mono, monospace); font-size: .85em; background: var(--surface, rgba(127,127,127,.12)); border-radius: 4px; padding: .1em .35em; }
.prompt-result-output--md pre { background: var(--surface, rgba(127,127,127,.12)); border-radius: 6px; padding: 8px 10px; overflow: auto; margin: 0 0 .6em; }
.prompt-result-output--md pre code { background: none; padding: 0; }
.prompt-result-output--md blockquote { margin: 0 0 .6em; padding: .2em 0 .2em .9em; border-left: 3px solid var(--border); color: var(--text-secondary, inherit); }
.prompt-result-output--md table { border-collapse: collapse; margin: 0 0 .6em; font-size: .85em; }
.prompt-result-output--md th, .prompt-result-output--md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.prompt-result-output--md hr { border: 0; border-top: 1px solid var(--border); margin: .8em 0; }
.prompt-result-output--md a { color: var(--link, inherit); }
.prompt-result-badge { font-size: .7rem; padding: 1px 8px; border-radius: 999px; margin-left: 6px; text-transform: none; letter-spacing: 0; }
.prompt-result-actions { display: flex; gap: 8px; justify-content: flex-end; margin: 12px 0 var(--space-sm, 12px); }
.prompt-result-badge--ok { background: var(--success-soft); color: var(--success); }
.prompt-result-badge--fail { background: var(--danger-soft); color: var(--danger); }

/* Session report blocks (collapsible) */
.report-block { border: 1px solid var(--border); border-radius: 10px; margin-bottom: var(--space-sm, 12px); background: var(--surface, transparent); }
.report-block:last-child { margin-bottom: 0; }
.report-block__head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; user-select: none; }
.report-block__head::-webkit-details-marker { display: none; }
.report-block__head:hover { background: rgba(127, 127, 127, .06); border-radius: 10px; }
.report-block__title { font-weight: 600; font-size: .9rem; }
.report-block__head .panel-details__chevron { flex-shrink: 0; color: var(--text-secondary, #6b7280); transition: transform .2s ease; }
.report-block[open] > .report-block__head .panel-details__chevron { transform: rotate(90deg); }
.report-block__body { padding: 0 14px 12px; }
.report-block__body > :first-child { margin-top: 0; }
.report-block .prompt-result-actions { margin: 12px 0 0; }

/* Topbar user plan badge */
.topbar-plan-badge {
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #0a6366) 10%, transparent);
  color: var(--accent, #0a6366);
  border: 1px solid color-mix(in srgb, var(--accent, #0a6366) 25%, transparent);
  white-space: nowrap;
}

/* Client notification checkboxes: Telegram-style */
.notif-checks, .notif-channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (min-width: 900px) {
  .notif-checks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 24px;
  }
  .notif-channels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 24px;
  }
}
.notif-checks label, .notif-channels label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 4px 0;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  user-select: none;
}
.notif-checks input[type="checkbox"], .notif-channels input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.notif-checks .tg-check__box, .notif-channels .tg-check__box {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  transition: background-color .18s ease, border-color .18s ease;
}
.notif-checks .tg-check__box svg, .notif-channels .tg-check__box svg {
  width: 15px;
  height: 15px;
  display: block;
}
.notif-checks .tg-check__box polyline, .notif-channels .tg-check__box polyline {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset .22s ease .04s;
}
.notif-checks input[type="checkbox"]:checked + .tg-check__box, .notif-channels input[type="checkbox"]:checked + .tg-check__box {
  background: var(--accent, #0a6366);
  border-color: var(--accent, #0a6366);
}
.notif-checks input[type="checkbox"]:checked + .tg-check__box polyline, .notif-channels input[type="checkbox"]:checked + .tg-check__box polyline {
  stroke-dashoffset: 0;
}
.notif-checks input[type="checkbox"]:focus-visible + .tg-check__box, .notif-channels input[type="checkbox"]:focus-visible + .tg-check__box {
  outline: 2px solid var(--accent, #0a6366);
  outline-offset: 2px;
}
.notif-checks label:hover .tg-check__box, .notif-channels label:hover .tg-check__box {
  border-color: var(--accent, #0a6366);
}
@media (prefers-reduced-motion: reduce) {
  .notif-checks .tg-check__box, .notif-channels .tg-check__box,
  .notif-checks .tg-check__box polyline, .notif-channels .tg-check__box polyline { transition: none; }
}

/* -- Theme toggle (header) ----------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}
.theme-toggle .theme-icon {
  width: 18px;
  height: 18px;
  display: none;
}
.theme-toggle-label { display: none; }
/* По умолчанию (без явного выбора) — иконка по системной теме */
.theme-toggle .theme-icon--sun { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .theme-icon--sun { display: none; }
  html:not([data-theme="light"]) .theme-toggle .theme-icon--moon { display: block; }
}
html[data-theme="dark"] .theme-toggle .theme-icon--sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon--moon { display: block; }
html[data-theme="light"] .theme-toggle .theme-icon--sun { display: block; }
html[data-theme="light"] .theme-toggle .theme-icon--moon { display: none; }

/* -- Collapsible panels ------------------------------------------- */
.panel-details > summary.panel-head {
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin-bottom: 0;
}
.panel-details[open] > summary.panel-head {
  margin-bottom: var(--space-lg);
}
.panel-details > summary.panel-head::-webkit-details-marker {
  display: none;
}
.panel-details__chevron {
  flex-shrink: 0;
  color: var(--text-secondary, #6b7280);
  transition: transform .2s ease;
}
.panel-details[open] .panel-details__chevron {
  transform: rotate(90deg);
}

/* ── Модалка загрузки файлов (files.html / pages/files.js) ──── */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xl) var(--space-base);
  border: 1px dashed var(--border-strong);
  background: var(--bg-elevated);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.upload-dropzone--over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-dropzone--busy {
  opacity: 0.55;
  pointer-events: none;
}
/* Одиночный файл (модалка сессии) — компактнее очереди на /files */
.upload-dropzone--single {
  padding: var(--space-lg) var(--space-base);
}
.upload-dropzone--single .upload-dropzone-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-dropzone-icon {
  width: 28px;
  height: 28px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.upload-dropzone-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.upload-dropzone-hint {
  font-size: 11.5px;
  color: var(--text-faint);
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}
.upload-queue:empty { display: none; }

.upload-file-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--border);
  background: var(--panel);
}
.upload-file-item--error { border-color: var(--danger); background: var(--danger-soft); }
.upload-file-item--done { border-color: var(--accent); }
.upload-file-item--canceled { opacity: 0.6; }

.upload-file-icon { display: flex; flex: none; color: var(--text-secondary); }
.upload-file-main { flex: 1; min-width: 0; }
.upload-file-name {
  display: block;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-file-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.upload-file-bar {
  height: 4px;
  background: var(--fill);
  margin-top: var(--space-sm);
  overflow: hidden;
}
.upload-file-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width var(--transition-base);
}
.upload-file-item--error .upload-file-fill { background: var(--danger); }
.upload-file-status { flex: none; width: 44px; text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.upload-file-status--done { color: var(--accent); }
.upload-file-status--error { color: var(--danger); }
.upload-file-remove { flex: none; }

.upload-destination {
  margin: var(--space-md) 0 0;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.upload-destination:empty { display: none; }
.upload-destination strong { color: var(--text); font-weight: 500; }

/* «Очистить» прижимаем к левому краю, остальные кнопки — справа */
#uploadModal .modal-actions #uploadClearBtn { margin-right: auto; }

