:root {
    color-scheme: light;
}

.theme-toggle {
    position: relative;
    flex-shrink: 0;
}

.theme-toggle svg {
    width: 1.25rem;
    height: 0.875rem;
    transform: scale(1.2);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    overflow: visible;
}

.theme-toggle .theme-sun,
[data-theme="dark"] .theme-toggle .theme-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .theme-sun {
    display: block;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
}

.theme-toggle:focus-visible {
    outline: 2px solid #f2c17d;
    outline-offset: 3px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --primary-color: #8ec8dc;
    --primary-dark: #c0dce8;
    --accent-color: #eab678;
    --bg-color: #111a24;
    --surface-color: #1a2734;
    --surface-alt: #203242;
    --sidebar-bg: #172430;
    --text-main: #d5dfe7;
    --text-muted: #9aafbf;
    --border-color: #344959;
    --shadow-soft: 0 0.625rem 1.5rem rgba(3, 10, 18, 0.2);
    --shadow-hover: 0 1rem 1.875rem rgba(3, 10, 18, 0.3);
}

[data-theme="dark"] body {
    background: radial-gradient(ellipse at 75% 0, #203a48 0, transparent 45rem), var(--bg-color);
}

[data-theme="dark"] body::before {
    background: none;
}

[data-theme="dark"] .top-header,
[data-theme="dark"] .content-topbar {
    background: linear-gradient(126deg, #253d50 0%, #245066 56%, #226074 100%);
}

[data-theme="dark"] .top-header {
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(177, 221, 233, 0.12);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #1b2c39, #172430);
    border-color: var(--border-color);
}

[data-theme="dark"] #content-area,
[data-theme="dark"] .modal-dialog {
    background: linear-gradient(160deg, #1c2c3a, #192530);
}

[data-theme="dark"] .nav-item,
[data-theme="dark"] .nav-item.open,
[data-theme="dark"] .nav-submenu > ul,
[data-theme="dark"] .language-switcher-menu,
[data-theme="dark"] .nav-section-actions-menu,
[data-theme="dark"] .topic-actions-menu {
    background: var(--surface-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .nav-item:hover {
    border-color: #527789;
}

[data-theme="dark"] .nav-link {
    color: #b1c5d3;
}

[data-theme="dark"] .nav-link::before {
    background: #536d7e;
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .language-switcher-option:hover,
[data-theme="dark"] .language-switcher-option.is-active,
[data-theme="dark"] .nav-section-actions-menu button:hover,
[data-theme="dark"] .topic-actions-menu button:hover {
    background: #294252;
    color: #e2edf3;
}

[data-theme="dark"] .nav-link.active {
    background: linear-gradient(110deg, #30556b, #28667a);
    color: #fff;
}

[data-theme="dark"] .nav-link:hover::before,
[data-theme="dark"] .nav-link.active::before {
    background: var(--accent-color);
}

[data-theme="dark"] .sidebar-search-input,
[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field select,
[data-theme="dark"] .form-field textarea {
    background: #13212d;
    border-color: var(--border-color);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .sidebar-title,
[data-theme="dark"] .sidebar-search,
[data-theme="dark"] .sidebar-admin,
[data-theme="dark"] .modal-header,
[data-theme="dark"] h2 {
    border-color: var(--border-color);
}

[data-theme="dark"] .nav-section-actions-toggle,
[data-theme="dark"] .modal-close,
[data-theme="dark"] .button-secondary,
[data-theme="dark"] .sidebar-admin-link,
[data-theme="dark"] .sidebar-auth-link {
    background: var(--surface-alt);
    border-color: var(--border-color);
}

[data-theme="dark"] .doc-content a {
    color: #8ecde5;
}

[data-theme="dark"] .doc-content a:hover {
    border-bottom-color: #8ecde5;
}

[data-theme="dark"] .doc-content .quote,
[data-theme="dark"] .warning {
    color: #ead8bc;
    background: #362f28;
    border-color: #bc8d56;
}

[data-theme="dark"] .doc-content .dle-warning-block {
    background-color: #362f28 !important;
    color: #ead8bc !important;
    border-color: #bc8d56 !important;
    box-shadow: none !important;
}

[data-theme="dark"] .doc-content .dle-error-block {
    background-color: #382b2d !important;
    color: #ecd4ce !important;
    border-color: #b77965 !important;
    box-shadow: none !important;
}

[data-theme="dark"] .note:not(.warning),
[data-theme="dark"] .doc-table th,
[data-theme="dark"] .doc-table tr:hover td {
    background: var(--surface-alt);
}

[data-theme="dark"] .table-responsive,
[data-theme="dark"] .doc-table {
    background: var(--surface-color);
}

[data-theme="dark"] .docs-search-highlight {
    background: #705729;
    color: #fff0cc;
}

[data-theme="dark"] code {
    background: #253440;
    border-color: var(--border-color);
    color: #f1bd8c;
}

[data-theme="dark"] pre,
[data-theme="dark"] pre[class*="language-"],
[data-theme="dark"] :not(pre) > code[class*="language-"] {
    background: #111d28;
    border-color: var(--border-color);
    color: #d4e2ed;
    text-shadow: none;
    box-shadow: none;
}

[data-theme="dark"] pre code {
    background: transparent;
    color: #d4e2ed;
    text-shadow: none;
}

[data-theme="dark"] .token.comment,
[data-theme="dark"] .token.prolog,
[data-theme="dark"] .token.doctype,
[data-theme="dark"] .token.cdata {
    color: #91a5b4;
}

[data-theme="dark"] .token.punctuation {
    color: #b7c9d5;
}

[data-theme="dark"] .token.property,
[data-theme="dark"] .token.tag,
[data-theme="dark"] .token.boolean,
[data-theme="dark"] .token.number,
[data-theme="dark"] .token.constant,
[data-theme="dark"] .token.symbol,
[data-theme="dark"] .token.deleted {
    color: #eca6b5;
}

[data-theme="dark"] .token.selector,
[data-theme="dark"] .token.attr-name,
[data-theme="dark"] .token.string,
[data-theme="dark"] .token.char,
[data-theme="dark"] .token.builtin,
[data-theme="dark"] .token.inserted,
[data-theme="dark"] .token.regex,
[data-theme="dark"] .token.string-property.property {
    color: #b7d69c;
}

[data-theme="dark"] .token.operator,
[data-theme="dark"] .token.entity,
[data-theme="dark"] .token.url,
[data-theme="dark"] .token.variable,
[data-theme="dark"] .token.important,
[data-theme="dark"] .token.bbcode .token.tag,
[data-theme="dark"] .token.bbshortcode .token.tag {
    color: #e8c28e;
    background: transparent;
}

[data-theme="dark"] .token.atrule,
[data-theme="dark"] .token.attr-value,
[data-theme="dark"] .token.keyword {
    color: #8ccde2;
}

[data-theme="dark"] .token.function,
[data-theme="dark"] .token.class-name {
    color: #c8b0e7;
}

[data-theme="dark"] div.code-toolbar > .toolbar > .toolbar-item > button,
[data-theme="dark"] div.code-toolbar > .toolbar > .toolbar-item > a,
[data-theme="dark"] div.code-toolbar > .toolbar > .toolbar-item > span {
    color: #c0dce8;
    background: #203242;
    text-shadow: none;
}

[data-theme="dark"] .sidebar-admin-exit,
[data-theme="dark"] .topic-actions-menu .danger,
[data-theme="dark"] .nav-section-actions-menu .danger {
    color: #f0a7a7;
}

[data-theme="dark"] .modal-feedback.is-error {
    background: #442c33;
    color: #ffc0c0;
}

[data-theme="dark"] .modal-feedback.is-success {
    background: #233e35;
    color: #acdfbf;
}
