.page-wrapper {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 0;
  overflow-x: clip;
  /* flex:1 на прямом потомке body: заполняем высоту окна минус подвал (подвал снаружи обёртки из-за overflow-x) */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
/* Переключатель "компактный/широкий" применяется только на десктопе:
   мобильную геометрию оставляем без изменений, чтобы не ломать адаптив.
   none не интерполируется — для анимации используем 100% (как dynamics: max-height). */
@media (min-width: 921px) {
  .page-wrapper {
    transition: max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  html[data-layout-width="wide"] .page-wrapper {
    max-width: 100%;
  }
}
@media (min-width: 921px) and (prefers-reduced-motion: reduce) {
  .page-wrapper {
    transition: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .layout-width-trigger svg {
    transition: none;
  }
}

/* HEADER */
.header {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px;
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: block;
}
.logo-text .logo-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.2; letter-spacing: 0;
}
.logo-text .logo-subtitle { font-size: 11px; color: var(--text-secondary); }
.header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.layout-width-trigger svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  display: block;
  margin: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.layout-icon--collapse { opacity: 0; }
.layout-icon--expand { opacity: 1; }
html[data-layout-width="wide"] .layout-icon--expand { opacity: 0; }
html[data-layout-width="wide"] .layout-icon--collapse { opacity: 1; }
/* На телефонах и планшетах кнопку ширины не показываем */
@media (max-width: 920px) {
  .layout-width-trigger {
    display: none !important;
  }
}
/* Theme pill: circle trigger + drop-down slider */
.theme-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Кнопка-триггер темы: база под Square; Circle / Glass переопределяют в themes.css и glass.css */
.theme-trigger {
  position: relative;
  width: 30px;
  height: 30px;
  display: block;
  line-height: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--header-icon);
  padding: 0;
  transition: background 0.18s, color 0.18s, border-radius 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.theme-trigger::-moz-focus-inner {
  border: 0;
  padding: 0;
}
.theme-trigger:hover { background: rgba(128,128,128,0.12); color: var(--header-icon-active); }
/* Триггер темы: геометрический центр; слайдер — .theme-panel (--header-icon-optical) */
.theme-trigger svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  display: block;
  margin: 0;
  pointer-events: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
/* Раскрывающаяся панель: внешняя рамка; внутри только смена цвета иконки при hover (без подложки) */
.theme-panel {
  position: absolute;
  top: 50%;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--dropdown-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  box-shadow: var(--dropdown-shadow);
  /* Только ячейки слайдера — лёгкая подгонка визуального центра штриха */
  --header-icon-optical: 0.5px;
  --theme-panel-pad: 2px;
  --theme-panel-slot: 30px;
  --theme-panel-inner-gap: 2px;
  padding: 0;
  z-index: 300;
  width: 30px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  box-sizing: border-box;
  transition:
    width 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.22s ease,
    box-shadow 0.22s ease;
}
.theme-panel.open {
  overflow: visible;
  padding: var(--theme-panel-pad);
  justify-content: center;
  /* border-box: +2px под левую и правую обводку (1px), иначе ряд кнопок сжимается */
  width: calc(
    2 * var(--theme-panel-pad) + 3 * var(--theme-panel-slot) + 2 * var(--theme-panel-inner-gap) + 2px
  );
  opacity: 1;
  pointer-events: auto;
}
/* Фиксированный порядок: светлая | тёмная | авто — ряд по центру капсулы */
.theme-panel__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--theme-panel-inner-gap);
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  flex-shrink: 0;
}
.theme-panel__btn {
  box-sizing: border-box;
  width: var(--theme-panel-slot);
  height: var(--theme-panel-slot);
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: block;
  line-height: 0;
  cursor: pointer;
  border-radius: 4px;
  background: none;
  color: var(--header-icon);
  position: relative;
  transition: color 0.18s ease, border-radius 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.theme-panel__btn::-moz-focus-inner {
  border: 0;
  padding: 0;
}
.theme-panel__btn svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translate(
    calc(-50% + var(--header-icon-optical)),
    calc(-50% + var(--header-icon-optical))
  );
  display: block;
  margin: 0;
  pointer-events: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  overflow: visible;
}
.theme-panel__btn:hover:not(.active) {
  background: none;
  color: var(--header-icon-active);
}
.theme-panel__btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px var(--card-border);
  z-index: 1;
}
.theme-panel__btn.active:hover {
  background: var(--accent-hover, var(--accent));
  color: #fff;
  box-shadow: 0 0 0 1px var(--card-border);
}

/* MAIN — заполняет высоту между шапкой и низом page-wrapper, чтобы пунктир разделителя тянулся до подвала */
.page-main {
  flex: 1 1 auto;
  /* min-content: при длинной левой колонке блок растёт вместе с контентом (иначе min-height:0 + 1fr режут пунктир по высоте вьюпорта) */
  min-height: min-content;
  display: flex;
  flex-direction: column;
  /* Как зазор у нижнего конца пунктирного разделителя (.sidebar-divider::before) — до подвала */
  padding-bottom: var(--sidebar-dash-bottom-gap, 14px);
  box-sizing: border-box;
}

/* MAIN GRID */
.main-grid {
  display: grid;
  grid-template-columns: 320px 20px minmax(0, 1fr);
  gap: 0;
  align-items: start;
}
/* На десктопе строка грида не короче контента левой колонки и тянется на всю .page-main при коротком контенте */
@media (min-width: 921px) {
  .main-grid {
    align-items: stretch;
    grid-template-rows: minmax(min-content, 1fr);
    flex: 1;
    min-height: min-content;
  }
}
.left-col { display: flex; flex-direction: column; gap: 16px; }

/* CARD */
