/* Settings modal. A roomy two-column panel: a rail of large section tabs, and
   a scrolling column where each setting gets a heading, a line of explanation,
   and its control underneath. */

.settings,
.settings *,
.settings *::before,
.settings *::after {
    box-sizing: border-box;
}

.settings {
    position: fixed;
    inset: 0;
    z-index: 324897;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.66);
    backdrop-filter: blur(8px);
}

.settings[hidden] {
    display: none;
}

body.settings-open {
    overflow: hidden;
}

.settings-panel {
    display: flex;
    width: min(100%, 780px);
    height: min(560px, calc(100vh - 48px));
    padding: 12px;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--bg-1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

/* ---- rail ---- */

.settings-rail {
    display: flex;
    width: 196px;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 0 6px;
}

.settings-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-tab {
    display: flex;
    height: 46px;
    align-items: center;
    gap: 13px;
    padding: 0 14px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--accent-2);
    font-family: inherit;
    font-size: 0.98rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.settings-tab i {
    width: 18px;
    font-size: 0.95rem;
    text-align: center;
}

.settings-tab:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

.settings-tab.is-active {
    background: var(--bg-4);
    color: var(--text-bright);
    box-shadow: inset 0 0 0 1px var(--border);
}

.settings-footer {
    margin: 0;
    padding: 0 14px;
    color: var(--accent-muted);
    font-size: 0.82rem;
}

/* ---- body ---- */

.settings-body {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    padding: 14px 22px 12px 8px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.settings-body::-webkit-scrollbar {
    width: 6px;
}

.settings-body::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: var(--border-2);
}

/* z-index is required: the active section animates in, and an animated
   element stacks above earlier positioned siblings, swallowing clicks on the
   close button. */
.settings-close {
    position: absolute;
    z-index: 2;
    top: 8px;
    right: 8px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--accent-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.settings-close:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

.settings-section {
    display: none;
    flex-direction: column;
    gap: 26px;
}

.settings-section.is-active {
    display: flex;
}

.settings-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.settings-item-title {
    color: var(--text-bright);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.settings-item-desc {
    max-width: 460px;
    margin: 0 0 4px;
    color: var(--accent-2);
    font-size: 0.86rem;
    line-height: 1.5;
}

/* ---- controls ----
   No borders anywhere: controls are filled surfaces that lift a shade on
   hover and focus. Keyboard focus gets a soft ring instead of an outline. */

.settings-input {
    width: min(100%, 320px);
    height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 12px;
    outline: 0;
    background: var(--bg-3);
    color: var(--text-bright);
    font-family: inherit;
    font-size: 0.95rem;
    transition: background-color 150ms ease, box-shadow 150ms ease;
}

.settings-input::placeholder {
    color: var(--accent-muted);
}

.settings-input:hover {
    background: var(--bg-4);
}

.settings-input:focus {
    background: var(--bg-4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* Pill toggle whose knob shows an × when off and a ✓ when on. */
.settings-switch {
    position: relative;
    width: 60px;
    height: 32px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--bg-4);
    cursor: pointer;
    transition: background-color 180ms ease, box-shadow 150ms ease;
}

.settings-switch:hover {
    background: var(--border);
}

.settings-switch:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.settings-switch-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    background: var(--text-bright);
    color: var(--text-accent);
    font-size: 0.66rem;
    transition: transform 220ms cubic-bezier(0.3, 1.4, 0.5, 1);
}

.settings-switch-knob i {
    grid-area: 1 / 1;
    transition: opacity 150ms ease;
}

.settings-switch-on {
    opacity: 0;
}

.settings-switch[aria-checked="true"] {
    background: var(--accent-2);
}

.settings-switch[aria-checked="true"] .settings-switch-knob {
    background: var(--text-accent);
    color: var(--text-bright);
    transform: translateX(28px);
}

.settings-switch[aria-checked="true"] .settings-switch-off {
    opacity: 0;
}

.settings-switch[aria-checked="true"] .settings-switch-on {
    opacity: 1;
}

.settings-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-keycap {
    min-width: 170px;
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--bg-3);
    color: var(--text-bright);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.05);
    transition: background-color 150ms ease;
}

.settings-keycap:hover {
    background: var(--bg-4);
}

.settings-keycap.is-empty {
    color: var(--accent-muted);
    font-weight: 400;
}

.settings-keycap.is-recording {
    background: var(--bg-4);
    color: var(--accent-2);
    animation: settings-recording 1.1s ease-in-out infinite;
}

@keyframes settings-recording {
    50% { background: var(--bg-2); }
}

.settings-ghost {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--accent-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.settings-ghost:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

/* ---- theme grid ---- */

.settings-themes {
    display: grid;
    width: 100%;
    max-width: 480px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.settings-theme {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 0;
    border-radius: 14px;
    background: var(--bg-3);
    color: var(--accent-2);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.settings-theme:hover {
    background: var(--bg-4);
    color: var(--text-bright);
}

.settings-theme.is-active {
    background: var(--bg-4);
    color: var(--text-bright);
    box-shadow: 0 0 0 2px var(--accent-2);
}

/* A little window mock in the theme's own colors. */
.settings-theme-swatch {
    position: relative;
    display: block;
    height: 46px;
    border-radius: 9px;
    background: var(--swatch-surface);
    overflow: hidden;
}

.settings-theme-swatch::before,
.settings-theme-swatch::after {
    content: "";
    position: absolute;
    left: 9px;
    height: 6px;
    border-radius: 999px;
    background: var(--swatch-accent);
}

.settings-theme-swatch::before {
    top: 13px;
    width: 46%;
}

.settings-theme-swatch::after {
    top: 25px;
    width: 28%;
    opacity: 0.45;
}

.settings-theme-label {
    padding: 0 3px 1px;
}

/* ---- status ---- */

.settings-status {
    min-height: 20px;
    margin: auto 0 0;
    padding-top: 16px;
    color: var(--accent-muted);
    font-size: 0.82rem;
}

.settings-status.is-error {
    color: #ff8a8a;
}

@media (max-width: 640px) {
    .settings {
        padding: 10px;
    }

    .settings-panel {
        height: calc(100vh - 20px);
        flex-direction: column;
    }

    .settings-rail {
        width: auto;
        padding: 0;
    }

    .settings-tabs {
        flex-direction: row;
        overflow-x: auto;
    }

    .settings-tab {
        flex: 0 0 auto;
    }

    .settings-footer {
        display: none;
    }

    .settings-body {
        padding: 6px 6px 10px;
    }
}
