:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --accent: #495057;
    --icon-filter: brightness(0) saturate(100%) invert(0%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(0%) contrast(100%);
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    --accent: #6c757d;
    --icon-filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.3s ease;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 0;
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.subtitle {
    font-size: 1.44rem;
    font-weight: 400;
    color: var(--text-secondary);
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.theme-btn {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.theme-btn:hover {
    transform: translateY(-2px);
}

.theme-icon {
    width: 16px;
    height: 16px;
    transition: all 0.3s ease;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.toggle-switch {
    width: 50px;
    height: 25px;
    appearance: none;
    background: var(--border-color);
    border-radius: 25px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-switch:checked {
    background: var(--accent);
}

.toggle-switch::before {
    content: '';
    position: absolute;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch:checked::before {
    transform: translateX(25px);
}

.size-slider {
    width: 120px;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    appearance: none;
}

.size-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

#sizeValue {
    font-weight: 500;
    color: var(--accent);
    min-width: 40px;
}

.libraries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 60px;
}

.library-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.library-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.library-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.library-name-link {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.library-name-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.icons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-primary);
    transition: all 0.2s ease;
    margin-bottom: 6px;
}

.icon-box:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.icon-name {
    font-size: 9px;
    font-weight: 400;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
    max-width: 60px;
}

footer {
    text-align: center;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

footer a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 1.12rem;
    }

    .controls {
        flex-direction: column;
        gap: 20px;
        justify-content: center;
    }

    .libraries-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .icons-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .icon-box {
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    .icon-wrapper {
        width: 20px;
        height: 20px;
    }

    .icon-name {
        font-size: 8px;
        max-width: 50px;
    }
}