/* Stable settings navigation: one fixed row geometry, no bright right edge. */
#settingsView .settings-window {
    grid-template-columns: 250px minmax(0, 1fr) !important;
    transition: none !important;
}

#settingsView .settings-tabs {
    width: 250px !important;
    min-width: 250px !important;
    max-width: 250px !important;
    flex: 0 0 250px !important;
    scrollbar-gutter: auto !important;
}

#settingsView .settings-tabs {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
}

#settingsView .settings-tabs-pills {
    width: 100% !important;
    padding: 0 !important;
    gap: 4px !important;
    overflow: visible !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn,
#settingsView .settings-tabs-pills .settings-tab-btn:hover,
#settingsView .settings-tabs-pills .settings-tab-btn:focus,
#settingsView .settings-tabs-pills .settings-tab-btn:focus-visible,
#settingsView .settings-tabs-pills .settings-tab-btn.active {
    width: calc(100% - 24px) !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 0 12px !important;
    box-sizing: border-box !important;
    position: relative !important;
    flex: 0 0 calc(100% - 24px) !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    outline: none !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    transform: none !important;
    transition: background-color 120ms ease, color 120ms ease !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn {
    justify-content: flex-start !important;
    color: var(--text-secondary) !important;
    background: transparent !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn:hover,
#settingsView .settings-tabs-pills .settings-tab-btn:focus-visible {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.055) !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn.active {
    color: var(--text-primary) !important;
    background: rgba(255, 255, 255, 0.075) !important;
    border-left: 0 !important;
}

body.light-mode #settingsView .settings-tabs-pills .settings-tab-btn:hover,
body.light-mode #settingsView .settings-tabs-pills .settings-tab-btn:focus-visible {
    background: rgba(15, 23, 42, 0.045) !important;
}

body.light-mode #settingsView .settings-tabs-pills .settings-tab-btn.active {
    background: rgba(15, 23, 42, 0.06) !important;
    border-left: 0 !important;
}

/* The active marker is painted independently, so it cannot change row width. */
#settingsView .settings-tabs-pills .settings-tab-btn.active::before {
    content: "" !important;
    position: absolute !important;
    top: 9px !important;
    bottom: 9px !important;
    left: 0 !important;
    width: 2px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.66) !important;
    pointer-events: none !important;
}

/* Compact settings navigation: keep the sidebar readable without oversized rows. */
#settingsView .settings-tabs-pills .settings-tab-btn,
#settingsView .settings-tabs-pills .settings-tab-btn:hover,
#settingsView .settings-tabs-pills .settings-tab-btn:focus,
#settingsView .settings-tabs-pills .settings-tab-btn:focus-visible,
#settingsView .settings-tabs-pills .settings-tab-btn.active {
    height: 34px !important;
    min-height: 34px !important;
    flex-basis: calc(100% - 24px) !important;
    padding: 0 8px !important;
    font-size: 13px !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn .tab-icon,
#settingsView .settings-tabs-pills .settings-tab-btn svg {
    width: 15px !important;
    height: 15px !important;
    flex-basis: 15px !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn.active::before {
    top: 8px !important;
    bottom: 8px !important;
}

body.light-mode #settingsView .settings-tabs-pills .settings-tab-btn.active::before {
    background: rgba(15, 23, 42, 0.54) !important;
}

/* AI actions stay controls, never full-width bars. */
#settingsView #settings-tab-ai .ai-settings-row-btn {
    flex: 0 0 108px !important;
    width: 108px !important;
    min-width: 108px !important;
    max-width: 108px !important;
}

#settingsView #settings-tab-ai .ai-settings-selector {
    flex: 0 0 150px !important;
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
}

/* The AI panel starts cleanly; there is no content above its first row. */
#settingsView #settings-tab-ai .ai-settings-row:first-child {
    border-top: 0 !important;
}

/* Changing settings sections must not resize or animate the shell. */
#settingsView .settings-window,
#settingsView .settings-panels,
#settingsView .settings-tab-content,
#settingsView .settings-tab-content.active {
    transition: none !important;
    animation: none !important;
}

/* Final compact geometry: settings navigation must never grow on hover. */
#settingsView .settings-tabs-pills .settings-tab-btn,
#settingsView .settings-tabs-pills .settings-tab-btn:hover,
#settingsView .settings-tabs-pills .settings-tab-btn:focus,
#settingsView .settings-tabs-pills .settings-tab-btn:focus-visible,
#settingsView .settings-tabs-pills .settings-tab-btn.active {
    width: calc(100% - 32px) !important;
    height: 32px !important;
    min-height: 32px !important;
    margin: 0 16px !important;
    flex-basis: calc(100% - 32px) !important;
    padding: 0 8px !important;
    gap: 8px !important;
    font-size: 12.5px !important;
    line-height: 1 !important;
    transform: none !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn .tab-icon,
#settingsView .settings-tabs-pills .settings-tab-btn svg {
    width: 14px !important;
    height: 14px !important;
    flex-basis: 14px !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn.active::before {
    top: 7px !important;
    bottom: 7px !important;
    width: 2px !important;
}

/* Keep each tab as wide as its icon and label, not as wide as the panel. */
#settingsView .settings-tabs-pills {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: max-content !important;
    max-width: 100% !important;
}

#settingsView .settings-tabs-pills .settings-tab-btn,
#settingsView .settings-tabs-pills .settings-tab-btn:hover,
#settingsView .settings-tabs-pills .settings-tab-btn:focus,
#settingsView .settings-tabs-pills .settings-tab-btn:focus-visible,
#settingsView .settings-tabs-pills .settings-tab-btn.active {
    width: 100% !important;
    max-width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    flex: 0 0 36px !important;
    align-self: stretch !important;
    font-size: 14px !important;
    line-height: 1 !important;
}
