/* =========================================================
   SETTINGS — SIDEBAR TAB LAYOUT
   Loaded last: overrides the single-scroll look from
   style.css / liquid-glass.css. Structure is built by
   applySettingsTabs() in ui-extras.js.
   ========================================================= */

.settings-card {
    max-width: 880px !important;
    width: min(880px, 94vw);
    /* fixed height: the card must not resize as you switch tabs */
    height: min(640px, 86vh);
    max-height: 86vh;
    padding: 0 !important;
    overflow: hidden;
}

.settings-body {
    display: flex;
    /* column, so the search bar can sit as a full-width strip above the shell */
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden !important;
    min-height: 0;
}

.settings-shell {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
}

/* ---------- nav column ---------- */
.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 10px;
    overflow-y: auto;
    border-right: 1px solid color-mix(in srgb, #fff 9%, transparent);
    background: color-mix(in srgb, var(--surface) 26%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
body:is([data-theme="white"], [data-theme="nord"]) .settings-nav {
    background: rgba(255, 255, 255, .38);
    border-right-color: rgba(0, 0, 0, .07);
}

.snav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--soft);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.snav-item:hover {
    background: color-mix(in srgb, #fff 7%, transparent);
    color: var(--text);
}
.snav-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.snav-item.active {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    border-color: color-mix(in srgb, var(--accent) 42%, transparent);
    color: var(--text);
    font-weight: 600;
}
.snav-ico {
    flex: 0 0 auto;
    width: 20px;
    font-size: 15px;
    line-height: 1;
    text-align: center;
}
.snav-txt {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* version stamp sits at the bottom of the nav column */
.settings-nav .set-about {
    margin-top: auto !important;
    margin-bottom: 0 !important;
    padding: 10px 8px !important;
    background: none !important;
    border: 0 !important;
}

/* ---------- pane area ---------- */
.settings-panes {
    overflow-y: auto;
    padding: 20px 24px 24px;
    min-width: 0;
}

.settings-pane { display: none; }
.settings-pane.active {
    display: block;
    animation: setPaneIn .18s ease both;
}
@keyframes setPaneIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

.spane-title {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--text);
}

/* The section is now the pane itself — drop the tile chrome. */
.settings-body .settings-pane .set-section {
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.settings-pane .set-row {
    padding: 11px 0 !important;
}

.settings-panes::-webkit-scrollbar,
.settings-nav::-webkit-scrollbar { width: 6px; }
.settings-panes::-webkit-scrollbar-thumb,
.settings-nav::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, #fff 14%, transparent);
    border-radius: 999px;
}

/* ---------- narrow: nav becomes a chip row on top ---------- */
@media (max-width: 760px) {
    .settings-card { height: auto; max-height: 88vh; }
    .settings-shell { grid-template-columns: none; grid-template-rows: auto minmax(0, 1fr); }

    .settings-nav {
        flex-direction: row;
        gap: 6px;
        padding: 10px 12px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        border-right: 0;
        border-bottom: 1px solid color-mix(in srgb, #fff 9%, transparent);
    }
    .settings-nav::-webkit-scrollbar { display: none; }

    .snav-item {
        width: auto;
        flex: 0 0 auto;
        padding: 8px 12px;
        border-radius: 999px;
        white-space: nowrap;
    }
    .settings-nav .set-about { display: none; }

    .settings-panes { padding: 16px; }
    .spane-title { font-size: 16px; margin-bottom: 10px; }
}

/* ---------- Capacitor / mobile shell ---------- */
html.app-mobile #settingsModal .settings-card {
    max-width: none !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: none !important;
}
html.app-mobile #settingsModal .settings-body {
    display: flex !important;
    padding: 0 !important;
    overflow: hidden !important;
}
html.app-mobile .settings-shell {
    grid-template-columns: none;
    grid-template-rows: auto minmax(0, 1fr);
}
html.app-mobile .settings-nav {
    flex-direction: row;
    gap: 6px;
    padding: 10px var(--sp-4);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface) !important;
}
html.app-mobile .settings-nav::-webkit-scrollbar { display: none; }
html.app-mobile .snav-item {
    width: auto;
    flex: 0 0 auto;
    padding: 9px 14px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
html.app-mobile .snav-item.active {
    background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
    border-color: var(--accent);
}
html.app-mobile .settings-nav .set-about { display: none; }
html.app-mobile .settings-panes {
    padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: reduce) {
    .settings-pane.active { animation: none; }
}

/* =========================================================
   SETTINGS — SEARCH BAR, GROUPS, HOTKEY LIST
   ========================================================= */

.settings-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--sp-4, 16px);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex: 0 0 auto;
}
.settings-search > svg { color: var(--muted); flex: 0 0 auto; }
.settings-search input[type="search"] {
    flex: 1;
    min-width: 0;
    height: 34px;
}
.settings-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.set-search-x {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    font-size: 12px;
}
.set-search-x:hover { color: var(--text); border-color: var(--border-2); }

.set-search-empty {
    padding: 14px var(--sp-4, 16px);
    font-size: 12.5px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

/* While searching, the rail steps aside and every pane renders stacked so a
   match outside the active tab is still reachable. */
.settings-shell.searching .settings-nav { display: none; }
.settings-shell.searching { grid-template-columns: minmax(0, 1fr); }
.settings-shell.searching .settings-pane { display: block; }
.settings-shell.searching .settings-pane.set-pane-empty { display: none; }
.set-hit-hide { display: none !important; }

/* Sub-heading inside a pane */
.set-group {
    margin: 18px 0 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.set-group:first-child { margin-top: 2px; }
.spane-title + .set-section > .set-group:first-child { margin-top: 0; }

.set-hint {
    font-size: 11px;
    color: var(--muted);
}
.set-keys-note { margin-top: 10px; }

/* Read-only hotkey reference */
.set-keys {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    display: grid;
    gap: 6px;
}
.set-keys li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text);
    padding: 7px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.set-keys kbd {
    flex: 0 0 auto;
    min-width: 58px;
    text-align: center;
    padding: 3px 8px;
    font: 600 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-2, var(--border));
    border-bottom-width: 2px;
    border-radius: 6px;
}

@media (max-width: 760px) {
    .settings-search { padding: 8px 12px; }
    .set-keys kbd { min-width: 46px; }
}

/* Inline control pairs (e.g. accent colour + reset) share one row */
.set-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}
.set-inline .color-input { flex: 1; min-width: 0; }

