:root {
    color-scheme: light;
    --shell-bg: #eef3f1;
    --shell-surface: #ffffff;
    --shell-surface-muted: #f4f7f6;
    --shell-text: #17201f;
    --shell-muted: #6c7774;
    --shell-border: #dce3e1;
    --shell-primary: #0f766e;
    --shell-primary-soft: #e7f4f1;
    --shell-shadow: 0 12px 34px rgba(20, 36, 33, .1);
}

[data-theme="dark"] {
    color-scheme: dark;
    --shell-bg: #0f1413;
    --shell-surface: #19201e;
    --shell-surface-muted: #202926;
    --shell-text: #eef4f2;
    --shell-muted: #9ba8a5;
    --shell-border: #303c39;
    --shell-primary: #48b8ad;
    --shell-primary-soft: #183b37;
    --shell-shadow: 0 14px 38px rgba(0, 0, 0, .32);
}

html,
body {
    background: var(--shell-bg) !important;
    color: var(--shell-text) !important;
}

body {
    font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif !important;
}

.sidebar {
    width: 272px !important;
    min-width: 272px !important;
    padding: 14px 12px 12px;
    background: var(--shell-surface) !important;
    border-right: 1px solid var(--shell-border) !important;
    box-shadow: 4px 0 20px rgba(20, 36, 33, .035) !important;
}

.sidebar.collapsed {
    width: 84px !important;
    min-width: 84px !important;
}

.sidebar-header {
    min-height: auto;
    padding: 10px 8px 18px !important;
    border-bottom: 0 !important;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.title-icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: var(--shell-primary);
    color: #fff;
    font-family: Consolas, monospace;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
}

.sidebar-header h1 {
    min-width: 0;
    margin: 0 !important;
    color: var(--shell-text) !important;
    font-size: 17px !important;
    font-weight: 720 !important;
    letter-spacing: 0 !important;
}

.sidebar-header p {
    margin: 8px 0 0 49px !important;
    color: var(--shell-muted) !important;
    font-size: 11px !important;
}

.sidebar-controls {
    position: static !important;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 0;
    padding: 10px 0 4px;
    border-top: 1px solid var(--shell-border);
}

.theme-toggle,
.sidebar-collapse-toggle,
.menu-toggle {
    width: 34px !important;
    height: 34px !important;
    border: 1px solid var(--shell-border) !important;
    border-radius: 6px !important;
    background: var(--shell-surface) !important;
    color: var(--shell-muted) !important;
    box-shadow: none !important;
    font-size: 16px !important;
}

.sidebar-controls .theme-toggle,
.sidebar-controls .sidebar-collapse-toggle {
    width: auto !important;
    min-width: 0;
    height: 38px !important;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    font-size: 13px !important;
    font-weight: 600;
}

.control-icon {
    width: 17px;
    min-width: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--shell-primary);
    font-size: 16px;
    line-height: 1;
}

.control-label {
    min-width: 0;
    overflow: hidden;
    color: var(--shell-text);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.theme-toggle:hover,
.sidebar-collapse-toggle:hover,
.menu-toggle:hover {
    background: var(--shell-surface-muted) !important;
    color: var(--shell-primary) !important;
    border-color: var(--shell-primary) !important;
    transform: none !important;
}

.menu {
    padding: 4px 0 10px !important;
    scrollbar-width: thin;
}

.menu-group-label {
    padding: 14px 12px 7px;
    color: var(--shell-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.menu-item {
    width: 100%;
    min-height: 44px;
    margin: 2px 0;
    padding: 8px 10px !important;
    gap: 11px;
    border: 0 !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: var(--shell-text) !important;
    font-family: inherit;
    text-align: left;
}

.menu-item:hover {
    background: var(--shell-surface-muted) !important;
}

.menu-item.active {
    background: var(--shell-primary-soft) !important;
    color: var(--shell-primary) !important;
    font-weight: 650 !important;
}

.menu-icon {
    width: 34px !important;
    min-width: 34px;
    height: 28px;
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--shell-border);
    border-radius: 5px;
    background: var(--shell-surface);
    color: var(--shell-muted);
    font-family: Consolas, monospace;
    font-size: 10px !important;
    font-weight: 700;
    letter-spacing: 0;
}

.menu-item.active .menu-icon {
    border-color: color-mix(in srgb, var(--shell-primary) 35%, var(--shell-border));
    background: var(--shell-surface);
    color: var(--shell-primary);
}

.menu-text {
    min-width: 0;
    overflow: hidden;
    color: inherit;
    font-size: 13px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.footer {
    margin-top: 2px;
    padding: 8px 10px 4px !important;
    border-top: 0 !important;
    color: var(--shell-muted) !important;
    text-align: left !important;
}

.status-dot {
    width: 7px;
    height: 7px;
    margin-right: 7px;
    display: inline-block;
    border-radius: 50%;
    background: #22a06b;
    box-shadow: 0 0 0 3px rgba(34, 160, 107, .12);
}

.main-frame,
.main-frame iframe {
    background: var(--shell-bg) !important;
}

.sidebar.collapsed .sidebar-header {
    padding: 10px 11px 18px !important;
}

.sidebar.collapsed .brand-mark {
    justify-content: center;
}

.sidebar.collapsed .sidebar-controls {
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 0;
    padding: 10px 11px 4px;
    justify-items: center;
}

.sidebar.collapsed .sidebar-controls .theme-toggle,
.sidebar.collapsed .sidebar-controls .sidebar-collapse-toggle {
    width: 38px !important;
    padding: 0 !important;
    justify-content: center;
}

.sidebar.collapsed .control-label {
    display: none;
}

.sidebar.collapsed .menu-group-label {
    height: 12px;
    padding: 6px 0 0;
    overflow: hidden;
    color: transparent;
}

.sidebar.collapsed .menu-item {
    padding: 8px 11px !important;
}

.sidebar.collapsed .footer {
    display: none;
}

.sidebar.collapsed .sidebar-collapse-toggle {
    transform: none !important;
}

@media (max-width: 768px) {
    .main-frame {
        height: 100vh !important;
        padding-top: 56px;
    }

    .main-frame iframe {
        height: 100% !important;
    }

    .sidebar {
        width: min(286px, 84vw) !important;
        min-width: min(286px, 84vw) !important;
        box-shadow: var(--shell-shadow) !important;
    }

    .sidebar-header {
        padding-top: 56px !important;
    }

    .menu-toggle {
        top: 14px !important;
        left: 14px !important;
        display: flex !important;
    }

    .sidebar-collapse-toggle {
        display: none !important;
    }

    .sidebar-controls {
        grid-template-columns: 1fr;
    }

    .sidebar-controls .theme-toggle {
        width: 100% !important;
        justify-content: flex-start;
    }

    .overlay.show {
        background: rgba(8, 17, 15, .48) !important;
        backdrop-filter: blur(2px);
    }
}
