.dm-header {
	position: sticky;
	top: 0;
	z-index: 80;
	flex-shrink: 0;
	width: 100%;
	height: var(--dm-header-height);
	isolation: isolate;
	background: var(--dm-glass);
	background: color-mix(in srgb, var(--dm-bg-secondary) 86%, transparent);
	border-bottom: 1px solid var(--dm-border);
}

.dm-header::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
}

body.admin-bar .dm-header {
	top: var(--wp-admin--admin-bar--height, 32px);
}

.dm-header__inner {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--dm-space-4);
	height: var(--dm-header-height);
}

.dm-logo {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-width: 0;
	line-height: 1;
}

.dm-logo .custom-logo-link {
	display: flex;
	align-items: center;
}

.custom-logo,
.dm-logo__img {
	height: 32px;
	width: auto;
	display: block;
}

.dm-logo__img--dark {
	display: none;
}

html[data-theme="light"] .dm-logo__img--light {
	display: none;
}

html[data-theme="light"] .dm-logo__img--dark {
	display: block;
}

.dm-logo__wordmark {
	font-weight: 800;
	font-size: 1.25rem;
	letter-spacing: -0.04em;
	line-height: 1.05;
	color: var(--dm-brand);
	background-image: linear-gradient(90deg, var(--dm-brand), var(--dm-cyan));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.dm-logo__wordmark:hover {
	color: var(--dm-brand-hover);
}

.dm-logo__tagline {
	margin: 3px 0 0;
	font-size: 11px;
	line-height: 1.2;
	color: var(--dm-text-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 220px;
}

.dm-nav__list {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 2px;
}

.dm-nav__list > li {
	position: relative;
}

.dm-nav__list a {
	display: inline-flex;
	align-items: center;
	padding: 10px 12px;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--dm-text-secondary);
	border-radius: var(--dm-radius-sm);
}

.dm-nav__list a:hover {
	color: var(--dm-text);
}

.dm-nav__list .current-menu-item > a,
.dm-nav__list .current_page_item > a {
	color: var(--dm-text);
	box-shadow: inset 0 -2px 0 var(--dm-brand), 0 6px 12px rgba(139, 61, 255, 0.18);
}

.dm-nav__list .menu-item-has-children > a::after {
	content: "";
	width: 6px;
	height: 6px;
	margin-left: 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg) translateY(-2px);
}

.dm-nav__list .sub-menu {
	display: none;
	position: absolute;
	top: calc(100% - 2px);
	left: 0;
	z-index: 90;
	min-width: 220px;
	padding: var(--dm-space-2);
	background: var(--dm-surface-2);
	border: 1px solid var(--dm-border);
	border-radius: var(--dm-radius-md);
	box-shadow: var(--dm-panel-shadow);
}

.dm-nav__list .sub-menu a {
	display: block;
	width: 100%;
	border-radius: var(--dm-radius-sm);
}

.dm-nav__list .menu-item-has-children:hover > .sub-menu,
.dm-nav__list .menu-item-has-children:focus-within > .sub-menu,
.dm-nav__list .menu-item-has-children.is-open > .sub-menu {
	display: block;
}

.dm-header__actions {
	display: flex;
	align-items: center;
	gap: var(--dm-space-2);
}

.dm-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--dm-border);
	border-radius: var(--dm-radius-md);
	background: var(--dm-surface);
	color: var(--dm-text-secondary);
	cursor: pointer;
}

.dm-icon-btn--round {
	border-radius: var(--dm-radius-full);
}

.dm-icon-btn:hover,
.dm-icon-btn[aria-expanded="true"] {
	color: var(--dm-text);
	border-color: var(--dm-border-strong);
	background: var(--dm-surface-2);
}

.dm-header__telegram {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 0 14px;
	border: 1px solid var(--dm-border);
	border-radius: var(--dm-radius-full);
	background: var(--dm-surface-2);
	color: var(--dm-text);
	font-size: 0.875rem;
	font-weight: 600;
}

.dm-header__telegram:hover {
	color: var(--dm-text);
	border-color: rgba(139, 61, 255, 0.45);
	box-shadow: var(--dm-glow-brand);
}

.dm-header__saved {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 1px solid var(--dm-border);
	border-radius: var(--dm-radius-full);
	background: var(--dm-surface);
	color: var(--dm-text-secondary);
}

.dm-header__saved:hover {
	color: var(--dm-text);
	border-color: var(--dm-border-strong);
	background: var(--dm-surface-2);
}

.dm-header__saved:not(.is-empty) {
	color: var(--dm-brand);
}

.dm-header__saved [data-dm-bookmarks-count] {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	border-radius: var(--dm-radius-full);
	background: var(--dm-brand);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
}

.dm-header__saved.is-empty [data-dm-bookmarks-count] {
	display: none;
}

.dm-theme-icon--sun {
	display: none;
}

html[data-theme="light"] .dm-theme-icon--moon {
	display: none;
}

html[data-theme="light"] .dm-theme-icon--sun {
	display: block;
}

.dm-avatar {
	display: inline-flex;
	width: 36px;
	height: 36px;
	padding: 2px;
	border-radius: var(--dm-radius-full);
	background: linear-gradient(135deg, var(--dm-brand), var(--dm-cyan));
}

.dm-avatar__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border-radius: inherit;
	background: var(--dm-surface-2);
	color: var(--dm-text-secondary);
}

.dm-avatar__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dm-nav-toggle {
	display: none;
}

.dm-nav-toggle__close {
	display: none;
}

.dm-nav-toggle[aria-expanded="true"] .dm-nav-toggle__open {
	display: none;
}

.dm-nav-toggle[aria-expanded="true"] .dm-nav-toggle__close {
	display: block;
}

.dm-nav-backdrop {
	display: none;
}

@media (max-width: 1023px) {
	.dm-header__inner {
		grid-template-columns: minmax(0, 1fr) auto;
	}

	.dm-nav {
		display: none;
		position: fixed;
		top: var(--dm-header-height);
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 85;
		padding: var(--dm-space-4);
		overflow: auto;
		background: var(--dm-bg-secondary);
		border-bottom: 1px solid var(--dm-border);
	}

	body.admin-bar .dm-nav {
		top: calc(var(--dm-header-height) + 46px);
	}

	.dm-nav.is-open {
		display: block;
	}

	.dm-nav-backdrop {
		display: none;
		position: fixed;
		inset: 0;
		z-index: 70;
		background: rgba(5, 7, 13, 0.45);
	}

	.dm-nav-backdrop:not([hidden]) {
		display: block;
	}

	.dm-nav__list {
		flex-direction: column;
		align-items: stretch;
	}

	.dm-nav__list .sub-menu {
		position: static;
		display: none;
		min-width: 0;
		margin-top: var(--dm-space-2);
		box-shadow: none;
	}

	.dm-nav__list .menu-item-has-children:hover > .sub-menu {
		display: none;
	}

	.dm-nav__list .menu-item-has-children:focus-within > .sub-menu,
	.dm-nav__list .menu-item-has-children.is-open > .sub-menu {
		display: block;
	}

	.dm-nav-toggle {
		display: inline-flex;
	}
}

@media (max-width: 782px) {
	body.admin-bar .dm-header {
		top: var(--wp-admin--admin-bar--height, 46px);
	}
}

@media (max-width: 480px) {
	.custom-logo,
	.dm-logo__img {
		height: 26px;
	}
}

@media (max-width: 639px) {
	.dm-header__telegram-label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
	}

	.dm-header__telegram {
		width: 40px;
		padding: 0;
		justify-content: center;
	}
}

@media (min-width: 783px) {
	body.admin-bar .dm-nav {
		top: calc(var(--dm-header-height) + 32px);
	}
}
