:root {
    --ui-panel-bg: rgba(255, 255, 255, 0.88);
    --ui-panel-text: #0f172a;
    --ui-panel-border: rgba(148, 163, 184, 0.35);
    --ui-pill-bg: #ffffff;
    --ui-pill-hover: #eef2ff;
    --ui-pill-border: #dbe4f0;
    --ui-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
}

html[data-theme="dark"] {
    --ui-panel-bg: rgba(30, 41, 59, 0.88);
    --ui-panel-text: #e2e8f0;
    --ui-panel-border: rgba(100, 116, 139, 0.45);
    --ui-pill-bg: #0f172a;
    --ui-pill-hover: #1e293b;
    --ui-pill-border: #334155;
    --ui-shadow: 0 14px 38px rgba(2, 6, 23, 0.5);
}

#site-global-ui {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4000;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ui-panel-bg);
    color: var(--ui-panel-text);
    border: 1px solid var(--ui-panel-border);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    padding: 8px;
    box-shadow: var(--ui-shadow);
}

#site-global-ui .ui-pill {
    border: 1px solid var(--ui-pill-border);
    background: var(--ui-pill-bg);
    color: inherit;
    border-radius: 999px;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    line-height: 34px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

#site-global-ui .ui-pill:hover {
    background: var(--ui-pill-hover);
}

#site-global-ui .ui-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

body.site-global-ui-enabled {
    padding-top: 62px !important;
}

#site-theme-toggle {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 4100;
    border: 1px solid var(--ui-pill-border);
    background: var(--ui-pill-bg);
    color: var(--ui-panel-text);
    border-radius: 999px;
    padding: 6px 10px;
    box-shadow: var(--ui-shadow);
}

.site-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.site-theme-switch-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.site-theme-switch-track {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #d1d5db;
    border: 1px solid #94a3b8;
    position: relative;
    transition: background 0.2s ease;
}

.site-theme-switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.3);
    transition: transform 0.2s ease;
}

.site-theme-switch-input:checked + .site-theme-switch-track {
    background: #111827;
    border-color: #374151;
}

.site-theme-switch-input:checked + .site-theme-switch-track::after {
    transform: translateX(20px);
}

.site-theme-switch-text {
    font-size: 13px;
    color: var(--ui-panel-text);
}

.site-theme-switch.in-user-nav {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe4f0;
    border-radius: 999px;
    padding: 4px 8px;
    flex-shrink: 0;
}

html[data-theme="dark"] .site-theme-switch.in-user-nav {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(100, 116, 139, 0.5);
}

.site-home-lang {
    position: relative;
    flex-shrink: 0;
}

#site-home-left-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
    flex-shrink: 0;
}

.site-theme-switch.in-home-left {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid #dbe4f0;
    border-radius: 999px;
    padding: 4px 8px;
    flex-shrink: 0;
}

.site-home-lang-trigger {
    border: 1px solid #dbe4f0;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    border-radius: 999px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 17px;
    line-height: 34px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.1);
}

.site-home-lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 136px;
    display: none;
    flex-direction: column;
    border: 1px solid #dbe4f0;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}

.site-home-lang.open .site-home-lang-menu {
    display: flex;
}

.site-home-lang-item {
    padding: 8px 10px;
    text-decoration: none;
    color: #0f172a;
    font-size: 13px;
    transition: background 0.2s ease;
    display: block;
}

.site-home-lang-item:hover {
    background: #eef2ff;
}

.site-home-lang-item.active {
    background: #dbeafe;
}

html[data-theme="dark"] .site-home-lang-trigger {
    background: rgba(15, 23, 42, 0.88);
    color: #e5e7eb;
    border-color: rgba(100, 116, 139, 0.5);
}

html[data-theme="dark"] .site-home-lang-menu {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(100, 116, 139, 0.5);
}

html[data-theme="dark"] .site-theme-switch.in-home-left {
    background: rgba(15, 23, 42, 0.88);
    border-color: rgba(100, 116, 139, 0.5);
}

html[data-theme="dark"] .site-home-lang-item {
    color: #e5e7eb;
}

html[data-theme="dark"] .site-home-lang-item:hover {
    background: #1e293b;
}

html[data-theme="dark"] .site-home-lang-item.active {
    background: #334155;
}

html[data-theme="dark"] body {
    background: linear-gradient(180deg, #0b1220 0%, #111827 100%) !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] .box,
html[data-theme="dark"] .page-card,
html[data-theme="dark"] .dialog,
html[data-theme="dark"] .wrap,
html[data-theme="dark"] .feature-card,
html[data-theme="dark"] .account-notice,
html[data-theme="dark"] .inline-login-tip,
html[data-theme="dark"] .message-board,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .container,
html[data-theme="dark"] .wall-item,
html[data-theme="dark"] .comment-item,
html[data-theme="dark"] .author-dropdown,
html[data-theme="dark"] .avatar-dropdown,
html[data-theme="dark"] .tag-input-wrapper,
html[data-theme="dark"] .tag-link,
html[data-theme="dark"] .tag-pill,
html[data-theme="dark"] .preview-note,
html[data-theme="dark"] .ghost-btn,
html[data-theme="dark"] .btn-muted {
    background: rgba(15, 23, 42, 0.82) !important;
    color: #e5e7eb !important;
    border-color: rgba(100, 116, 139, 0.45) !important;
}

html[data-theme="dark"] .wall-item.important {
    background: rgba(30, 41, 59, 0.9) !important;
    border-color: rgba(251, 146, 60, 0.65) !important;
}

html[data-theme="dark"] .wall-preview.is-clamped::after {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0), rgba(15, 23, 42, 0.98)) !important;
}

html[data-theme="dark"] .wall-item.important .wall-preview.is-clamped::after {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0), rgba(30, 41, 59, 0.98)) !important;
}

html[data-theme="dark"] .wall-title,
html[data-theme="dark"] .expand-link,
html[data-theme="dark"] .comment-chip,
html[data-theme="dark"] .meta,
html[data-theme="dark"] .subtle,
html[data-theme="dark"] .subtle-link,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .empty-comments,
html[data-theme="dark"] .page-info,
html[data-theme="dark"] .comment-author,
html[data-theme="dark"] .comment-time,
html[data-theme="dark"] .author-dropdown-note,
html[data-theme="dark"] .avatar-dropdown-note {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] body.blog-detail-page,
html[data-theme="dark"] body.wall-detail-page {
    color: #ffffff !important;
}

html[data-theme="dark"] body.blog-detail-page *,
html[data-theme="dark"] body.wall-detail-page * {
    color: #ffffff !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #0f172a !important;
    color: #e5e7eb !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] table tr,
html[data-theme="dark"] th,
html[data-theme="dark"] td {
    background: rgba(15, 23, 42, 0.65) !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] a {
    color: #93c5fd !important;
}

@media (max-width: 700px) {
    #site-global-ui {
        max-width: calc(100vw - 16px);
        overflow-x: auto;
        left: 8px;
        transform: none;
        right: 8px;
        justify-content: flex-start;
    }

    #site-theme-toggle {
        top: 56px;
        right: 8px;
    }

    .site-theme-switch-text {
        display: none;
    }
}
