.settings-menu-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    box-sizing: border-box;
}

.settings-sidebar-title {
    color: var(--text-dim);
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1.5px;
    margin: 10px 10px 20px 10px;
    text-align: center;
}

.settings-menu-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 16px;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
}

.settings-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 13px 20px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 0.5px;
}

.settings-menu-btn svg { width: 20px; height: 20px; opacity: 0.85; flex-shrink: 0; }
@media (hover: hover) { .settings-menu-btn:hover { background: var(--border-lighter); color: var(--text-pure); } }
.settings-menu-btn.active { background: rgba(var(--primary-rgb), 0.12); border-color: rgba(var(--primary-rgb), 0.35); color: var(--primary); }
.settings-menu-btn.active svg { opacity: 1; color: var(--primary); }

.settings-center-box {
    height: calc(100vh - var(--header-height, 70px) - 90px);
    width: calc(100vh - var(--header-height, 70px) - 90px);
    max-height: 740px;
    max-width: 740px;
    flex-shrink: 0;

    box-sizing: border-box;
    background: var(--bg-panel);
    border: 1px solid var(--border-lighter);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);

    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.settings-section { display: none; flex-direction: column; gap: 25px; animation: fadeIn 0.2s ease-out forwards; }
.settings-section.active { display: flex; }
.settings-header { border-bottom: 1px solid var(--border-lighter); padding-bottom: 15px; margin-bottom: 5px; text-align: center; }
.settings-header h2 { margin: 0; color: var(--text-pure); font-size: clamp(1.2rem, 4vw, 1.4rem); text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }
.settings-block { background: var(--bg-input); border: 1px solid var(--border-lighter); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.settings-label { display: block; color: var(--text-main); font-size: 0.85rem; font-weight: 700; text-transform: uppercase; margin-bottom: 12px; }

.switch, .toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input, .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch .slider, .toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-lighter);
    border: 1px solid var(--border-color);
    transition: 0.25s ease;
    border-radius: 24px;
}

.switch .slider:before, .toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: 0.25s ease;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.switch input:checked + .slider, .toggle-switch input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.switch input:checked + .slider:before, .toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

.settings-btn-logout { background: rgba(var(--danger-rgb), 0.1); color: var(--danger); border: 1px solid rgba(var(--danger-rgb), 0.3); display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px; border-radius: 8px; font-weight: bold; font-size: 1rem; cursor: pointer; transition: all 0.2s; }
@media (hover: hover) { .settings-btn-logout:hover { background: var(--danger); color: var(--text-pure); } }
.settings-status-text { font-size: 0.85rem; font-weight: 600; color: var(--text-dim); text-align: center; margin-top: 10px; min-height: 20px; }

.settings-preview-wrapper { padding: 20px; display: flex; flex-direction: column; height: 100%; box-sizing: border-box; }
.preview-title { color: var(--text-dim); font-size: 0.85rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; margin: 10px 10px 30px 10px; text-align: center; }
.preview-section { display: none; width: 100%; flex-direction: column; align-items: center; justify-content: center; animation: fadeIn 0.3s ease-out forwards; flex: 1; }
.preview-section.active { display: flex; }

.preview-board-demo { width: 220px; height: 220px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); border: 4px solid var(--border-color); border-radius: 6px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); overflow: hidden; }
.preview-icon-large { width: 100px; height: 100px; color: var(--success); filter: drop-shadow(0 10px 20px rgba(var(--success-rgb), 0.2)); margin-bottom: 20px; }

#preview-general .profile-panel-title, #preview-appearance .profile-panel-title { display: none; }
#preview-general .profile-content-wrapper > .profile-content-wrapper, #preview-appearance .profile-content-wrapper > .profile-content-wrapper { display: none !important; }
#preview-general .profile-panel-container, #preview-appearance .profile-panel-container { padding: 0; }

#preview-general .profile-header-card, #preview-appearance .profile-header-card {
    background: var(--bg-input); padding: 40px 30px; border-radius: 16px; border: 1px solid var(--border-lighter); text-align: center; width: 100%; max-width: 450px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); margin: 0 auto; border-bottom: none; display: flex; flex-direction: column; align-items: center; box-sizing: border-box;
}

#preview-general .profile-username, #preview-appearance .profile-username { margin-bottom: 5px; font-size: 1.5rem; }
#preview-general .profile-tag, #preview-appearance .profile-tag { margin-bottom: 25px; font-size: 0.9rem; color: var(--text-dim); }
#preview-general .profile-status-badge, #preview-appearance .profile-status-badge { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; background: rgba(var(--success-rgb), 0.1); border-radius: 50px; border: 1px solid rgba(var(--success-rgb), 0.2); margin-top: 0; }
#preview-general .status-dot, #preview-appearance .status-dot { width: 10px; height: 10px; background: var(--success) !important; }
#preview-general .pip-status-text, #preview-appearance .pip-status-text { color: var(--success) !important; font-weight: 600; }

.page-settings .tooltip-container { position: relative; display: flex; align-items: center; cursor: help; z-index: 50; }
.page-settings .info-icon { display: flex; justify-content: center; align-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--text-dim); color: var(--text-dim); font-size: 11px; font-weight: bold; font-family: serif; transition: all 0.2s ease; }
@media (hover: hover) { .page-settings .tooltip-container:hover .info-icon { color: var(--primary); border-color: var(--primary); background: rgba(var(--primary-rgb), 0.1); } }
.page-settings .tooltip-text { visibility: hidden; background-color: var(--bg-item); color: var(--text-main); border-radius: 8px; padding: 12px; position: absolute; bottom: 140%; left: 50%; transform: translateX(-50%) translateY(10px); opacity: 0; transition: opacity 0.2s, transform 0.2s; font-size: 0.8rem; line-height: 1.5; box-shadow: 0 10px 25px rgba(0,0,0,0.5); border: 1px solid var(--border-lighter); pointer-events: none; z-index: 100; width: max-content; max-width: 250px; }
.page-settings .tooltip-text strong { color: var(--text-pure); }
.page-settings .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -6px; border-width: 6px; border-style: solid; border-color: var(--bg-item) transparent transparent transparent; }
@media (hover: hover) { .page-settings .tooltip-container:hover .tooltip-text { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); } }
.page-settings .tooltip-container:active .tooltip-text, .page-settings .tooltip-container:focus-within .tooltip-text { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1100px) {
    .settings-center-box {
        width: 100%;
        height: auto;
        padding: 1rem;
        aspect-ratio: auto;
        max-width: none;
    }
}

.theme-selector-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.theme-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.theme-dropdown-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
}

.theme-select-input {
    width: 100%;
    padding: 11px 16px;
    background: var(--bg-panel);
    border: 1px solid var(--border-lighter);
    border-radius: 10px;
    color: var(--text-pure);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.theme-select-input:hover {
    border-color: var(--primary);
}

.theme-select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.theme-actions-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.theme-action-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--bg-panel);
    border: 1px solid var(--border-lighter);
    border-radius: 10px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.theme-action-icon-btn:hover:not(:disabled) {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-action-icon-btn.danger:hover:not(:disabled) {
    background: rgba(var(--danger-rgb), 0.15);
    color: var(--danger);
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(var(--danger-rgb), 0.25);
}

.theme-action-icon-btn.danger .theme-trash-svg {
    overflow: visible;
}

.theme-action-icon-btn.danger .theme-trash-lid {
    transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: 3px 6px;
}

.theme-action-icon-btn.danger:hover:not(:disabled) .theme-trash-lid {
    transform: rotate(-22deg) translate(-1px, -2px);
}

.theme-action-icon-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--bg-panel) !important;
    border-color: var(--border-lighter) !important;
    color: var(--text-dim) !important;
    transform: none !important;
    box-shadow: none !important;
}

.theme-action-icon-btn svg {
    width: 18px;
    height: 18px;
}

.piece-style-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.piece-style-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    background: var(--bg-panel);
    border: 2px solid var(--border-lighter);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.piece-style-card:hover {
    border-color: rgba(var(--primary-rgb), 0.5);
    transform: translateY(-2px);
}

.piece-style-card.active {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb), 0.08);
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.15);
}

.piece-style-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 50px;
    margin-bottom: 8px;
}

.piece-style-preview img {
    width: 44px;
    height: 44px;
}

.piece-style-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-pure);
}

.color-swatches-grid {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg-panel);
    padding: 18px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-lighter);
    width: 100%;
    box-sizing: border-box;
}

.color-swatch-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    flex: 1;
    min-width: 0;
}

.color-swatch-item span {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.25;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.color-swatch-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
    outline: none;
    flex-shrink: 0;
}

.color-swatch-btn:hover {
    transform: scale(1.15);
    border-color: var(--primary);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.5);
}

.custom-select-container {
    position: relative;
    width: 100%;
    user-select: none;
}

.custom-select-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-lighter);
    border-radius: 10px;
    color: var(--text-pure);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    min-height: 42px;
}

.custom-select-container:hover .custom-select-trigger {
    border-color: var(--primary);
}

.custom-select-container.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.2);
}

.custom-select-trigger-content {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.custom-select-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.custom-select-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-dim);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-select-chevron.rotated {
    transform: rotate(180deg);
    color: var(--primary);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-lighter);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: fadeIn 0.15s ease-out;
}

.custom-select-group-header {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 1px;
    padding: 6px 10px 4px 10px;
}

.custom-select-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.custom-select-option:hover {
    background: var(--border-lighter);
    color: var(--text-pure);
}

.custom-select-option.selected {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
    font-weight: 700;
}

.custom-select-option-content {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.custom-select-check {
    width: 16px;
    height: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

.appearance-subtabs-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: var(--bg-panel);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-lighter);
    margin-bottom: 5px;
}

.appearance-subtab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.appearance-subtab-btn svg {
    width: 18px;
    height: 18px;
}

.appearance-subtab-btn:hover {
    color: var(--text-pure);
}

.appearance-subtab-btn.active {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}