:root {
    --color-bg-dark: radial-gradient(ellipse at 80% 0%, #23243a 0%, #181926 100%);
    --color-card-dark: rgba(36,37,54,0.95);
    --color-sidebar-dark: rgba(24,25,38,0.98);
    --color-topbar-dark: rgba(24,25,38,1);
    --color-text-dark: #fff;
    --color-link-dark: #a29bfe;
    --color-border-dark: rgba(255,255,255,0.04);
    --color-shadow-dark: 0 2px 16px 0 rgba(0,0,0,0.13);
    --color-gold: #ffd86b;
    --article-bg: #23243a;
    --article-footer-bg: #181926;
    --wiki-title: #fff;
    --wiki-text: #fff;
    --wiki-meta: #bfc7d5;
    --wiki-btn-text: #fff;
    --wiki-btn-bg: transparent;
}

body {
    background: var(--color-bg-dark);
    color: var(--color-text-dark);
}
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    background: var(--color-sidebar-dark);
    border-right: 1px solid var(--color-border-dark);
    z-index: 1000;
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: none;
    transition: width 0.25s cubic-bezier(.4,0,.2,1), min-width 0.25s cubic-bezier(.4,0,.2,1), max-width 0.25s cubic-bezier(.4,0,.2,1), transform 0.25s cubic-bezier(.4,0,.2,1);
}
.sidebar .nav-link {
    color: #bfc7d5;
    font-size: 1.1rem;
    border-radius: 12px;
    padding: 0.75rem 1.2rem;
    margin: 0.2rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: background 0.2s, color 0.2s;
}
.sidebar .nav-link.active, .sidebar .nav-link:hover {
    background: rgba(108,92,231,0.12);
    color: #fff;
}
.sidebar .nav-link i {
    font-size: 1.3rem;
}
.sidebar .logo {
    font-size: 1.7rem;
    font-weight: bold;
    color: var(--color-text-dark);
    letter-spacing: 2px;
    margin-bottom: 2rem;
    text-align: center;
}
.main-content {
    margin-left: 220px;
    padding: 0;
    background: none;
    padding-top: 70px;
    transition: margin-left 0.25s cubic-bezier(.4,0,.2,1);
}
.topbar {
    position: fixed;
    left: 220px;
    top: 0;
    width: calc(100vw - 220px);
    height: 70px;
    display: flex;
    align-items: center;
    background: var(--color-topbar-dark);
    border-bottom: 1px solid var(--color-border-dark);
    padding: 0 2.5rem;
    z-index: 900;
    gap: 0;
    justify-content: space-between;
}
.searchbar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    min-width: 320px;
    max-width: 600px;
    width: 420px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.searchbar input {
    width: 420px;
    background: var(--color-card-dark);
    border: none;
    border-radius: 18px;
    padding: 0.7rem 1.2rem;
    color: var(--color-text-dark);
    font-size: 1.1rem;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.08);
    outline: none;
}
.searchbar input:focus {
    background: #23243a;
}
.content-area {
    padding: 2.5rem 2.5rem 2.5rem 2.5rem;
    max-width: 1100px;
    margin: 0 auto;
}
.card-result {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border-radius: 18px;
    box-shadow: var(--color-shadow-dark);
    border: 1px solid var(--color-border-dark);
    margin-bottom: 1.2rem;
    padding: 1.2rem 1.5rem;
    transition: box-shadow 0.2s;
}
.card-result:hover {
    box-shadow: 0 4px 32px 0 rgba(108,92,231,0.13);
}
.card-result .icon {
    font-size: 2rem;
    color: var(--color-gold);
    margin-top: 0.2rem;
}
.card-result .result-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: inherit;
}
.card-result .result-link {
    color: var(--color-link-dark);
    text-decoration: none;
    font-size: 1.05rem;
}
.card-result .result-link:hover {
    text-decoration: underline;
}
@media (max-width: 900px) {
    .sidebar { width: 60px; }
    .main-content { margin-left: 60px; }
    .sidebar .logo { font-size: 1.1rem; }
    .sidebar .nav-link span { display: none; }
    .sidebar-toggle-btn {
        left: 60px;
    }
    body.sidebar-collapsed .sidebar-toggle-btn {
        left: 0;
    }
    .topbar {
        left: 0;
        width: 100vw;
    }
    .searchbar {
        position: static;
        left: unset;
        transform: unset;
        min-width: 0;
        max-width: 100%;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}
@media (max-width: 600px) {
    .main-content {
        margin-left: 0 !important;
        padding-top: 70px;
        transition: none;
    }
    .sidebar {
        display: block;
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 220px;
        min-width: 220px;
        max-width: 80vw;
        height: 100vh;
        z-index: 2000;
        background: rgba(24,25,38,0.97);
        box-shadow: none;
        border: none;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    }
    body.sidebar-mobile-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
    }
    body.sidebar-mobile-open .sidebar-overlay {
        display: block;
        position: fixed;
        left: 0; top: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.25);
        z-index: 1999;
    }
    .sidebar-toggle-btn {
        margin-left: 0;
        margin-right: 0.25rem;
        position: static;
        display: inline-flex;
    }
    .theme-toggle {
        margin-right: 0;
        margin-left: 0.25rem;
    }
    .searchbar {
        margin: 0 0.5rem;
    }
    .searchbar input {
        max-width: 90%;
        width: 100%;
        min-width: 0;
    }
    .sidebar .nav-link span { display: inline !important; }
    .topbar {
        padding: 0 1rem;
    }
}
.theme-toggle {
    margin-left: 0;
    margin-right: 0;
    background: none;
    border: none;
    color: inherit;
    font-size: 1.6rem;
    cursor: pointer;
    transition: color 0.2s;
}
.theme-toggle:focus {
    outline: none;
}

body[data-theme="light"] .btn-primary {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px 0 rgba(220,200,120,0.10);
}
body[data-theme="light"] .btn-primary:hover, 
body[data-theme="light"] .btn-primary:focus {
    background-color: #1746a2;
    border-color: #1746a2;
    color: #fff;
    box-shadow: 0 4px 16px 0 #ffe9b3;
}
body[data-theme="light"] .btn-secondary {
    background-color: #ede6d6;
    color: #23243a;
    border-color: #e0d9b8;
}
body[data-theme="light"] .form-control, 
body[data-theme="light"] .form-control-lg {
    background: #fff;
    color: #23243a;
    border: 1.5px solid #e0d9b8;
    box-shadow: 0 2px 8px 0 rgba(220,200,120,0.04);
}
body[data-theme="light"] .form-control:focus {
    background: #fffefb;
    color: #23243a;
    border-color: #b48a2c;
    box-shadow: 0 2px 12px 0 #ffe9b3;
}
body[data-theme="light"] .alert-danger {
    background: #fff0f0;
    color: #a94442;
    border-color: #f5c6cb;
}
body[data-theme="light"] .alert {
    border-radius: 12px;
    box-shadow: 0 2px 8px 0 #ffe9b3;
}
body[data-theme="light"] .badge.bg-secondary {
    background: #ffe9b3 !important;
    color: #23243a !important;
}
body[data-theme="light"] ::-webkit-scrollbar {
    width: 10px;
    background: #ede6d6;
}
body[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #e0d9b8;
    border-radius: 8px;
}
body[data-theme="light"] ::selection {
    background: #ffe9b3;
    color: #23243a;
}


.text-secondary, .text-muted {
    color: #bfc7d5 !important;
}
body[data-theme="light"] .text-secondary, 
body[data-theme="light"] .text-muted {
    color: #8a8a8a !important;
}


body[data-theme="light"] .card-result:hover {
    box-shadow: 0 4px 24px 0 rgba(255, 216, 107, 0.13), 0 0 4px 1px #ffe9b3;
    border-color: #ffe9b3;
}
body[data-theme="light"] .card-result .icon {
    color: #b48a2c;
}

body[data-theme="white"] {
    --color-bg-dark: radial-gradient(ellipse at 80% 0%, #f4f4fc 0%, #c7d4f7 100%);
    --color-card-dark: #d6def0;
    --color-sidebar-dark: #bbc8e2;
    --color-topbar-dark: #bbc8e2;
    --color-text-dark: #181a1b;
    --color-link-dark: #2563eb;
    --color-border-dark: rgba(30,60,120,0.07);
    --color-shadow-dark: 0 2px 16px 0 rgba(60,100,180,0.07);
    --color-gold: #5b7be8;
    --article-bg: #fff;
    --article-footer-bg: #f6f6f6;
    --wiki-title: #000;
    --wiki-text: #000;
    --wiki-meta: #444;
    --wiki-btn-text: #fff;
    --wiki-btn-bg: transparent;
}
body[data-theme="white"] {
    background: var(--color-bg-dark);
    color: var(--color-text-dark);
}
body[data-theme="white"] .sidebar {
    background: var(--color-sidebar-dark);
    border-right: 1px solid var(--color-border-dark);
}
body[data-theme="white"] .sidebar .nav-link {
    color: #181a1b;
}
body[data-theme="white"] .sidebar .nav-link.active, 
body[data-theme="white"] .sidebar .nav-link:hover {
    background: #2563eb22;
    color: #000;
}
body[data-theme="white"] .sidebar .logo {
    color: var(--color-text-dark);
}
body[data-theme="white"] .main-content {
    background: none;
}
body[data-theme="white"] .topbar {
    background: var(--color-topbar-dark);
    border-bottom: 1px solid var(--color-border-dark);
}
body[data-theme="white"] .searchbar input {
    background: #e3e6f3;
    color: var(--color-text-dark);
}
body[data-theme="white"] .searchbar input:focus {
    background: #f4f4fc;
}
body[data-theme="white"] .content-area {
  
}
body[data-theme="white"] .card-result {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    box-shadow: var(--color-shadow-dark);
    border: 1px solid var(--color-border-dark);
}
body[data-theme="white"] .card-result:hover {
    box-shadow: 0 4px 32px 0 rgba(60,100,180,0.13);
    border-color: #2563eb33;
}
body[data-theme="white"] .card-result .icon {
    color: var(--color-gold) !important;
}
body[data-theme="white"] .card-result .result-title {
    color: inherit;
}
body[data-theme="white"] .card-result .result-link {
    color: var(--color-link-dark);
}
body[data-theme="white"] .card-result .result-link:hover {
    text-decoration: underline;
}
body[data-theme="white"] .theme-toggle {
    color: inherit;
}
body[data-theme="white"] .btn-primary {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 2px 8px 0 rgba(60,100,180,0.10);
}
body[data-theme="white"] .btn-primary:hover, 
body[data-theme="white"] .btn-primary:focus {
    background-color: #1746a2;
    border-color: #1746a2;
    color: #fff;
    box-shadow: 0 4px 16px 0 #c7d4f7;
}
body[data-theme="white"] .btn-secondary {
    background-color: #e3e6f3;
    color: #181a1b;
    border-color: #bbc8e2;
}
body[data-theme="white"] .form-control, 
body[data-theme="white"] .form-control-lg {
    background: #fff;
    color: #181a1b;
    border: 1.5px solid #bbc8e2;
    box-shadow: 0 2px 8px 0 rgba(60,100,180,0.04);
}
body[data-theme="white"] .form-control:focus {
    background: #f4f4fc;
    color: #181a1b;
    border-color: #2563eb;
    box-shadow: 0 2px 12px 0 #c7d4f7;
}
body[data-theme="white"] .alert-danger {
    background: #e3e6f3;
    color: #181a1b;
    border-color: #bbc8e2;
}
body[data-theme="white"] .alert {
    border-radius: 12px;
    box-shadow: 0 2px 8px 0 #c7d4f7;
}
body[data-theme="white"] .badge.bg-secondary {
    background: #c7d4f7 !important;
    color: #181a1b !important;
}
body[data-theme="white"] ::-webkit-scrollbar {
    width: 10px;
    background: #f4f4fc;
}
body[data-theme="white"] ::-webkit-scrollbar-thumb {
    background: #bbc8e2;
    border-radius: 8px;
}
body[data-theme="white"] ::selection {
    background: #c7d4f7;
    color: #181a1b;
}
body[data-theme="white"] .text-secondary, 
body[data-theme="white"] .text-muted,
body[data-theme="white"] .sidebar,
body[data-theme="white"] .main-content,
body[data-theme="white"] .content-area,
body[data-theme="white"] .card-result,
body[data-theme="white"] .result-title,
body[data-theme="white"] .result-link,
body[data-theme="white"] .topbar,
body[data-theme="white"] .sidebar .logo {
    color: #181a1b !important;
}

body[data-theme="dark"] .icon {
    color: var(--color-gold) !important;
}
body[data-theme="dark"] .card-result .icon {
    color: var(--color-gold) !important;
}


img.emoji {
    width: 20px;
    height: 20px;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.1em;
}


.wiki-categories {
    background: var(--color-card-dark);
    border-radius: 1.2rem;
    border: 1.5px solid var(--color-border-dark);
    box-shadow: var(--color-shadow-dark);
    color: var(--color-text-dark);
}
.wiki-categories .card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border-dark);
    color: var(--color-text-dark);
    font-weight: 600;
}
.wiki-categories .list-group-item {
    background: transparent;
    color: var(--color-text-dark);
    border: none;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: background 0.2s, color 0.2s;
}
.wiki-categories .list-group-item.active,
.wiki-categories .list-group-item:active {
    background: rgba(108,92,231,0.12) !important;
    color: #fff !important;
    font-weight: 600;
    border-radius: 12px;
    transition: background 0.2s, color 0.2s;
}

.wiki-filter-card {
    background: var(--color-card-dark);
    border-radius: 1.2rem;
    border: 1.5px solid var(--color-border-dark);
    box-shadow: var(--color-shadow-dark);
    color: var(--color-text-dark);
}
.wiki-search-form .form-select,
.wiki-search-form .form-control {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border-dark);
}
.wiki-search-form .form-select:focus,
.wiki-search-form .form-control:focus {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border-color: var(--accent-color);
    box-shadow: 0 2px 12px 0 var(--color-shadow-dark);
}
.wiki-search-form .btn-outline-secondary {
    border-color: var(--color-border-dark);
    color: var(--color-text-dark);
}
.wiki-search-form .btn-outline-secondary:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

body[data-theme="white"] .wiki-categories,
body[data-theme="white"] .wiki-filter-card {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border-dark);
    box-shadow: var(--color-shadow-dark);
}
body[data-theme="white"] .wiki-categories .card-header {
    color: var(--color-text-dark);
    background: transparent;
    border-bottom: 1px solid var(--color-border-dark);
}
body[data-theme="white"] .wiki-categories .list-group-item {
    background: transparent;
    color: var(--color-text-dark);
}
body[data-theme="white"] .wiki-categories .list-group-item.active,
body[data-theme="white"] .wiki-categories .list-group-item:active {
    background: #2563eb22 !important;
    color: #000 !important;
    font-weight: 600;
    border-radius: 12px;
    transition: background 0.2s, color 0.2s;
}
body[data-theme="white"] .wiki-search-form .form-select,
body[data-theme="white"] .wiki-search-form .form-control {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border-dark);
}
body[data-theme="white"] .wiki-search-form .form-select:focus,
body[data-theme="white"] .wiki-search-form .form-control:focus {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border-color: var(--accent-color);
    box-shadow: 0 2px 12px 0 var(--color-shadow-dark);
}
body[data-theme="white"] .wiki-search-form .btn-outline-secondary {
    border-color: var(--color-border-dark);
    color: var(--color-text-dark);
}
body[data-theme="white"] .wiki-search-form .btn-outline-secondary:hover {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}


.sidebar-toggle-btn {
    position: static;
    margin-left: 0;
    margin-right: 0;
}
body.sidebar-collapsed .sidebar-toggle-btn {
    left: 0;
}
body.sidebar-collapsed .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    border: none !important;
}
body.sidebar-collapsed .main-content {
    margin-left: 0 !important;
}

@media (min-width: 901px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
}


.table thead th {
    background: transparent;
    border-bottom: 1.5px solid var(--color-border-dark);
    color: var(--color-text-dark);
    font-weight: 600;
    text-align: left;
    padding: 0.75rem;
    vertical-align: middle;
}
.table tbody td {
    border-bottom: 1px solid var(--color-border-dark);
    border-top: none;
    background: transparent;
    color: var(--color-text-dark);
    padding: 0.75rem;
    vertical-align: middle;
}
.table tbody tr:last-child td {
    border-bottom: none;
}
.table tbody tr {
    background: transparent;
    transition: background 0.2s;
}
.table tbody tr:hover {
    background: rgba(108,92,231,0.12);
}
body[data-theme="white"] .table tbody tr:hover {
    background: rgba(37,99,235,0.12);
}


.table {
    color: var(--color-text-dark);
    border-color: var(--color-border-dark);
    margin-bottom: 1rem;
    width: 100%;
}
.table-sm td, .table-sm th {
    padding: 0.5rem;
}
.table-striped tbody tr:nth-of-type(odd) {
    background: rgba(108,92,231,0.06);
}
.table-bordered {
    border: 1px solid var(--color-border-dark);
}
.table-bordered td, .table-bordered th {
    border: 1px solid var(--color-border-dark);
}
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-hover tbody tr:hover {
    background: rgba(108,92,231,0.12);
}
.table-hover tbody tr:hover td {
    color: var(--color-text-dark);
}

body[data-theme="white"] .table tbody tr:hover {
    background: rgba(37,99,235,0.12);
}
body[data-theme="white"] .table-striped tbody tr:nth-of-type(odd) {
    background: rgba(37,99,235,0.06);
}
body[data-theme="white"] .table-hover tbody tr:hover {
    background: rgba(37,99,235,0.12);
}


.form-control, .form-select, input[type="text"], input[type="password"], input[type="file"], textarea, select {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border-dark);
    border-radius: 12px;
    padding: 0.7rem 1.1rem;
    font-size: 1.08rem;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.form-control:focus, .form-select:focus, input[type="text"]:focus, input[type="password"]:focus, input[type="file"]:focus, textarea:focus, select:focus {
    background: var(--color-bg-dark);
    color: var(--color-text-dark);
    border-color: var(--color-link-dark);
    box-shadow: 0 2px 12px 0 var(--color-link-dark);
    outline: none;
}
input[type="range"] {
    width: 100%;
    accent-color: var(--color-link-dark);
    background: transparent;
    margin-top: 0.5rem;
}
input[type="range"]:focus {
    outline: none;
}
button, .btn {
    border-radius: 12px;
    font-size: 1.08rem;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}

body[data-theme="dark"] select,
body[data-theme="dark"] .form-select {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
    border: 1.5px solid var(--color-border-dark);
}
body[data-theme="dark"] select option,
body[data-theme="dark"] .form-select option {
    background: var(--color-card-dark);
    color: var(--color-text-dark);
}