/**
 * Shell sidebar + site header (theme-aware, dashboard tokens).
 */

:root {
	--shell-transition: 0.3s;
	--shell-bg: #f2f4fa;
	--shell-surface: #ffffff;
	--shell-text: #1a1d26;
	--shell-muted: #5c6578;
	--shell-border: #e0e4ee;
	--shell-accent: #041046;
	--shell-accent-soft: rgba(4, 16, 70, 0.12);
	--shell-font: Gilroy, "Segoe UI", system-ui, -apple-system, sans-serif;
	--shell-header-height: 56px; /* фиксировано: не синхронизировать с #masthead (петля ResizeObserver) */
	--shell-toggle-size: 32px;
	--shell-toggle-inset: 16px;
	--shell-panel-width: min(300px, 86vw);
	--shell-panel-radius: 8px;
	--shell-panel-gap: 0;
	--shell-sidebar-push: 0px;
}

html[data-theme="dark"] {
	--shell-bg: #050a18;
	--shell-surface: #0c1428;
	--shell-text: #e8eaef;
	--shell-muted: #9aa3b5;
	--shell-border: rgba(255, 255, 255, 0.1);
	--shell-accent: #8eb4ff;
	--shell-accent-soft: rgba(142, 180, 255, 0.16);
}

/* ------------------------------------------------------------------ header */

#masthead.site-header {
	background: var(--shell-bg);
	border-bottom: 1px solid var(--shell-border);
	margin: 0;
	padding: 0;
	position: sticky;
	top: 0;
	z-index: 10005;
}

.shell-header {
	box-sizing: border-box;
	font-family: var(--shell-font);
	width: 100%;
}

.shell-header__inner {
	align-items: center;
	box-sizing: border-box;
	display: flex;
	gap: 12px;
	height: var(--shell-header-height);
	padding: 0 var(--shell-toggle-inset);
}

/* Слева: тоггл у левого края хедера, бренд справа. Справа: бренд слева, тоггл справа. */
.shell-header__inner--left,
.shell-sidebar__head--left {
	flex-direction: row;
	justify-content: flex-start;
}

.shell-header__inner--left .shell-header__toggle,
.shell-sidebar__head--left .shell-sidebar__toggle {
	order: -1;
}

.shell-header__inner--left .shell-header__brand,
.shell-sidebar__head--left .shell-sidebar__brand {
	margin-left: auto;
}

.shell-header__inner--right,
.shell-sidebar__head--right {
	flex-direction: row;
	justify-content: flex-start;
}

.shell-header__inner--right .shell-header__toggle,
.shell-sidebar__head--right .shell-sidebar__toggle {
	margin-left: auto;
}

.shell-header__brand {
	color: var(--shell-text);
	flex: 0 1 auto;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.2;
	min-width: 0;
	overflow: hidden;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.shell-header__brand:hover,
.shell-header__brand:focus-visible {
	color: var(--shell-accent);
}

/* Горизонтальное меню в шапке — только desktop (см. shell-sidebar.js BP 1024) */
.shell-header__nav {
	display: none;
	margin: 0;
	max-width: 100%;
	min-width: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
}

@media (min-width: 1025px) {
	.shell-header--has-nav .shell-header__nav {
		display: block;
	}
}

.shell-header__menu,
.shell-header__nav .menu {
	display: flex;
	flex-wrap: nowrap;
	gap: 4px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.shell-header__menu li,
.shell-header__nav .menu li {
	margin: 0;
}

.shell-header__menu a,
.shell-header__nav .menu a {
	border-radius: var(--shell-panel-radius);
	color: var(--shell-muted);
	display: block;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	padding: 6px 12px;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
	white-space: nowrap;
}

.shell-header__menu a:hover,
.shell-header__menu a:focus-visible,
.shell-header__nav .menu a:hover,
.shell-header__nav .menu a:focus-visible {
	color: var(--shell-text);
}

.shell-header__menu .current-menu-item > a,
.shell-header__menu .current-menu-ancestor > a,
.shell-header__nav .menu .current-menu-item > a,
.shell-header__nav .menu .current-menu-ancestor > a {
	background: var(--shell-accent-soft);
	color: var(--shell-accent);
	font-weight: 600;
}

/* Шапка с меню: меню по центру; бренд и тоггл — по стороне сайдбара */
.shell-header--has-nav .shell-header__inner {
	display: grid;
	gap: 12px;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.shell-header--has-nav .shell-header__nav {
	grid-column: 2;
	grid-row: 1;
	justify-self: center;
}

.shell-header--has-nav .shell-header__menu,
.shell-header--has-nav .shell-header__nav .menu {
	justify-content: center;
}

/* Сайдбар слева: тоггл слева, бренд справа */
.shell-header--has-nav[data-shell-position="left"] .shell-header__toggle {
	grid-column: 1;
	grid-row: 1;
	justify-self: start;
	margin-left: 0;
	order: 0;
}

.shell-header--has-nav[data-shell-position="left"] .shell-header__brand {
	grid-column: 3;
	grid-row: 1;
	justify-self: end;
	margin-left: 0;
}

/* Сайдбар справа: бренд слева, тоггл справа */
.shell-header--has-nav[data-shell-position="right"] .shell-header__brand {
	grid-column: 1;
	grid-row: 1;
	justify-self: start;
	margin-left: 0;
}

.shell-header--has-nav[data-shell-position="right"] .shell-header__toggle {
	grid-column: 3;
	grid-row: 1;
	justify-self: end;
	margin-left: 0;
	order: 0;
}

.shell-header__toggle,
.shell-sidebar__toggle {
	align-items: center;
	background: var(--shell-surface);
	border: 1px solid var(--shell-border);
	border-radius: var(--shell-panel-radius);
	box-sizing: border-box;
	color: var(--shell-text);
	cursor: pointer;
	display: inline-flex;
	flex: 0 0 auto;
	font-family: inherit;
	font-size: 1.15rem;
	height: var(--shell-toggle-size);
	justify-content: center;
	line-height: 1;
	padding: 0;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	width: var(--shell-toggle-size);
}

.shell-header__toggle:hover,
.shell-header__toggle:focus-visible,
.shell-sidebar__toggle:hover,
.shell-sidebar__toggle:focus-visible {
	background: var(--shell-accent-soft);
	border-color: var(--shell-accent);
	color: var(--shell-accent);
}

.shell-header__toggle-glyph,
.shell-sidebar__toggle-glyph {
	direction: ltr;
	display: inline-block;
	font-weight: 400;
	line-height: 1;
	unicode-bidi: isolate;
}

html.shell-sidebar-closed .shell-sidebar__toggle {
	pointer-events: none;
	visibility: hidden;
}

html.shell-sidebar-closed .shell-header__toggle {
	position: relative;
	visibility: visible;
	z-index: 10012;
}

html.shell-sidebar-open .shell-header__toggle {
	pointer-events: none;
	visibility: hidden;
}

html.shell-sidebar-open .shell-sidebar__toggle {
	pointer-events: auto;
	visibility: visible;
}

/* ------------------------------------------------------------------ panels */

#shell-panels-root {
	inset: 0;
	pointer-events: none;
	position: fixed;
	z-index: 10010;
}

.shell-panels-overlay {
	background: transparent;
	inset: 0;
	opacity: 0;
	pointer-events: none;
	position: fixed;
	visibility: hidden;
	z-index: 1001;
}

.shell-panel {
	bottom: var(--shell-panel-gap);
	box-sizing: border-box;
	height: auto;
	max-width: min(100vw, 90vw);
	overflow: hidden;
	pointer-events: auto;
	position: fixed;
	top: var(--shell-panel-gap);
	transition: transform var(--shell-transition) ease-in-out;
	width: var(--shell-panel-width);
	z-index: 10011;
}

.shell-panel__inner {
	height: 100%;
}

.shell-panel--left {
	border-radius: var(--shell-panel-radius);
	left: var(--shell-panel-gap);
	transform: translateX(calc(-100% - var(--shell-panel-gap)));
}

.shell-panel--right {
	border-radius: var(--shell-panel-radius);
	right: var(--shell-panel-gap);
	transform: translateX(calc(100% + var(--shell-panel-gap)));
}

html.shell-sidebar-open .shell-panel--left,
body.shell-sidebar-open .shell-panel--left {
	transform: translateX(0);
}

html.shell-sidebar-open .shell-panel--right,
body.shell-sidebar-open .shell-panel--right {
	transform: translateX(0);
}

html.shell-sidebar-closed .shell-panel,
body.shell-sidebar-closed .shell-panel {
	pointer-events: none;
	visibility: hidden;
}

html.shell-sidebar-open .shell-panel,
body.shell-sidebar-open .shell-panel {
	pointer-events: auto;
	visibility: visible;
}

html.shell-sidebar-closed .shell-panel--left,
body.shell-sidebar-closed .shell-panel--left {
	transform: translate3d(calc(-100% - var(--shell-panel-gap)), 0, 0);
}

html.shell-sidebar-closed .shell-panel--right,
body.shell-sidebar-closed .shell-panel--right {
	transform: translate3d(calc(100% + var(--shell-panel-gap)), 0, 0);
}

/* Push #page (или #primary): контент сдвигается, панель не перекрывает рабочую область */
[data-shell-push="1"] {
	box-sizing: border-box;
	max-width: 100%;
	transition: margin-left var(--shell-transition) ease-in-out,
		margin-right var(--shell-transition) ease-in-out;
}

html.shell-sidebar-closed [data-shell-push="1"],
body.shell-sidebar-closed [data-shell-push="1"] {
	margin-left: 0 !important;
	margin-right: 0 !important;
}

html.shell-sidebar-open.shell-sidebar-position-left [data-shell-push="1"] {
	margin-left: var(--shell-sidebar-push, 0) !important;
	margin-right: 0 !important;
}

html.shell-sidebar-open.shell-sidebar-position-right [data-shell-push="1"] {
	margin-left: 0 !important;
	margin-right: var(--shell-sidebar-push, 0) !important;
}

@media (max-width: 1024px) {
	html.shell-sidebar-open [data-shell-push="1"],
	html.shell-sidebar-closed [data-shell-push="1"] {
		margin-left: 0 !important;
		margin-right: 0 !important;
	}
}

html.shell-panels-pre * {
	transition: none !important;
}

/* ------------------------------------------------------------------ sidebar */

.shell-sidebar {
	background: var(--shell-bg);
	border: 1px solid var(--shell-border);
	border-radius: var(--shell-panel-radius);
	box-sizing: border-box;
	color: var(--shell-text);
	display: flex;
	flex-direction: column;
	font-family: var(--shell-font);
	height: 100%;
	min-height: 100%;
	overflow: hidden;
	padding: 0 16px 16px;
}

.shell-sidebar__head {
	align-items: center;
	box-sizing: border-box;
	display: flex;
	flex-shrink: 0;
	gap: 10px;
	height: var(--shell-header-height);
	overflow: hidden;
}


.shell-sidebar__brand {
	color: var(--shell-text);
	flex: 1 1 auto;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	line-height: 1.2;
	min-width: 0;
	overflow: hidden;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.shell-sidebar__brand:hover,
.shell-sidebar__brand:focus-visible {
	color: var(--shell-accent);
}

.shell-sidebar__divider {
	border-top: 1px solid var(--shell-border);
	flex-shrink: 0;
	margin: 0 0 12px;
}

.shell-sidebar__divider--bottom {
	margin-top: auto;
}

.shell-sidebar__nav {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
}

.shell-sidebar__menu,
.shell-sidebar__nav .menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.shell-sidebar__menu li,
.shell-sidebar__nav .menu li {
	margin: 0;
}

.shell-sidebar__menu a,
.shell-sidebar__nav .menu a {
	color: var(--shell-text);
	display: block;
	font-size: 0.9375rem;
	font-weight: 500;
	padding: 8px 4px;
	text-decoration: none;
}

.shell-sidebar__menu a:hover,
.shell-sidebar__menu a:focus-visible,
.shell-sidebar__nav .menu a:hover,
.shell-sidebar__nav .menu a:focus-visible {
	color: var(--shell-text);
}

.shell-sidebar__menu .current-menu-item > a,
.shell-sidebar__menu .current-menu-ancestor > a,
.shell-sidebar__nav .menu .current-menu-item > a,
.shell-sidebar__nav .menu .current-menu-ancestor > a {
	background: var(--shell-accent-soft);
	border-radius: var(--shell-panel-radius);
	color: var(--shell-accent);
	font-weight: 600;
}

.shell-sidebar__settings {
	flex-shrink: 0;
	padding-top: 4px;
}

.shell-sidebar__settings-title {
	color: var(--shell-muted);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	margin-bottom: 10px;
	text-transform: uppercase;
}

.shell-sidebar__theme {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 12px;
}

.shell-sidebar__theme-btn {
	background: var(--shell-surface);
	border: 1px solid var(--shell-border);
	border-radius: var(--shell-panel-radius);
	color: var(--shell-text);
	cursor: pointer;
	font-family: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	padding: 8px 14px;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.shell-sidebar__theme-btn:hover,
.shell-sidebar__theme-btn:focus-visible {
	background: var(--shell-accent-soft);
	border-color: var(--shell-accent);
	color: var(--shell-accent);
}

.shell-sidebar__theme-btn.is-active {
	background: var(--shell-accent-soft);
	border-color: var(--shell-accent);
	color: var(--shell-accent);
	font-weight: 600;
}

.shell-sidebar__account-name {
	color: var(--shell-text);
	display: block;
	font-size: 0.9375rem;
	font-weight: 600;
}

.shell-sidebar__account-login {
	color: var(--shell-accent);
	display: inline-block;
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: none;
}

.shell-sidebar__account-login:hover,
.shell-sidebar__account-login:focus-visible {
	text-decoration: underline;
}

/* Page background follows shell theme */
body.shell-has-sidebar {
	background: var(--shell-bg);
	color: var(--shell-text);
}
