:root {
    --container: 1400px;

    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono";

    --fs: 14px;
    --lh: 1.35;

    --control-h: 40px;
    --control-px: 12px;

    --radius: 16px;
    --radius-sm: 12px;
}

/* Default theme: Dark */
:root,
:root[data-theme="dark"] {
    --bg: #0c0f14;
    --surface: rgba(18, 24, 38, 0.72);
    --panel: rgba(18, 24, 38, 0.62);
    --border: rgba(255, 255, 255, 0.10);
    --divider: rgba(255, 255, 255, 0.08);
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.70);
    --muted2: rgba(255, 255, 255, 0.55);
    --primary: #6366f1;
    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.25);
    --control-bg: rgba(255, 255, 255, 0.06);
    --control-bg-hover: rgba(255, 255, 255, 0.09);
    --control-border: rgba(255, 255, 255, 0.14);
    --chip-bg: rgba(255, 255, 255, 0.06);
    --chip-border: rgba(255, 255, 255, 0.12);
    --row-hover: rgba(255, 255, 255, 0.06);
    --code-bg: rgba(0, 0, 0, 0.18);
}

/* Light theme */
:root[data-theme="light"] {
    --bg: #eef1f6;
    --surface: #ffffff;
    --panel: #ffffff;
    --border: rgba(15, 23, 42, 0.14);
    --divider: rgba(15, 23, 42, 0.10);
    --text: rgba(15, 23, 42, 0.92);
    --muted: rgba(15, 23, 42, 0.72);
    --muted2: rgba(15, 23, 42, 0.55);
    --primary: #4f46e5;
    --shadow-soft: 0 10px 30px rgba(2, 6, 23, 0.12);
    --control-bg: rgba(15, 23, 42, 0.04);
    --control-bg-hover: rgba(15, 23, 42, 0.07);
    --control-border: rgba(15, 23, 42, 0.18);
    --chip-bg: rgba(15, 23, 42, 0.04);
    --chip-border: rgba(15, 23, 42, 0.16);
    --row-hover: rgba(15, 23, 42, 0.06);
    --code-bg: rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font), sans-serif;
    font-size: var(--fs);
    line-height: var(--lh);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- Layout --- */

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px 18px 26px 18px;
}

.page { margin-top: 14px; }

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
}

@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .controls__row--grid {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .controls__right {
        height: auto;
        padding-top: 0;
        justify-content: flex-start;
    }
}

/* --- Topbar & Controls --- */

.topbar {
    position: static;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

:root[data-theme="light"] .topbar,
:root[data-theme="light"] .panel {
    box-shadow: 0 10px 30px rgba(2, 6, 23, 0.10), 0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}

.topbar__inner {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 16px;
    align-items: center;
    border-bottom: 1px solid var(--divider);
}

.app-title__name {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.app-title__desc {
    color: var(--muted2);
    font-size: 13px;
    margin-top: 2px;
}

.topbar__right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.controls { padding: 14px 22px 18px 22px; }

.controls__row--grid {
    display: grid;
    grid-template-columns: 360px 1fr auto;
    gap: 12px;
    align-items: end;
    padding: 6px 10px 10px 10px;
}

.controls__right {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: calc(var(--control-h) + 18px);
    padding-top: 18px;
}

/* --- Fields & Inputs --- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

.field--grow {
    flex: 1 1 420px;
    min-width: 260px;
}

.field__label {
    color: var(--muted2);
    font-size: 12px;
}

.input {
    height: var(--control-h);
    padding: 0 var(--control-px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    color: var(--text);
    font: inherit;
    line-height: 1;
    outline: none;
}

.input::placeholder { color: color-mix(in srgb, var(--muted2) 70%, transparent); }

.input:focus {
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.search-row {
    position: relative;
    width: 100%;
}

.search-row > .input {
    width: 100%;
    display: block;
    padding-right: 90px;
}

.exclude-row {
    position: relative;
    width: 100%;
}

.exclude-row > .input {
    width: 100%;
    display: block;
    padding-right: 120px;
}

/* --- Buttons --- */

.btn {
    height: var(--control-h);
    padding: 0 var(--control-px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    border-color: var(--control-border);
    background: var(--control-bg-hover);
}

.btn:active {
    transform: none;
    filter: brightness(1.05);
}

.btn--primary {
    background: rgb(117 119 203 / 18%);
    border-color: rgb(75 77 167 / 35%);
}

.btn--accent {
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.35);
}

.btn--small {
    height: 34px;
    padding: 0 10px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 600;
}

.btn--ghost {
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    color: var(--text);
}

.btn--ghost:hover {
    background: var(--control-bg-hover);
    border-color: var(--control-border);
}

.btn--fixed {
    min-width: 132px;
    justify-content: center;
}

.btn--fixed--copy {
    min-width: 120px;
    justify-content: center;
}

.btn--success,
.btn--success:hover,
.btn--success:active,
.btn--success:focus {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.40);
}

:root[data-theme="light"] .btn--success,
:root[data-theme="light"] .btn--success:hover,
:root[data-theme="light"] .btn--success:active,
:root[data-theme="light"] .btn--success:focus {
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(22, 163, 74, 0.35);
}

/* Icon Button (Top Right) */
.icon-top {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--text);
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.icon-top:hover { background: var(--control-bg-hover); }
.icon-top:active { transform: none; filter: brightness(1.05); }
.icon-top:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}
.icon-top__svg { transition: transform 180ms ease; }

/* --- History List & Inline Actions --- */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.history-item:hover { background: var(--row-hover); }

.history-item__value {
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.history-item__actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.history-item__btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.history-item__btn:hover {
    color: var(--text);
    background: var(--control-bg-hover);
}

/* Inline Actions (inside inputs) */
.inline-action {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted2);
    cursor: pointer;
    user-select: none;
}

.inline-action:hover {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.inline-action:active { transform: translateY(calc(-50% + 0.5px)); }

.inline-action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
    border-radius: 8px;
}

#excludeHistoryBtn.inline-action { right: 8px; }

#excludeClearBtn.inline-action,
#searchClearBtn.inline-action {
    right: 72px;
    font-size: 16px;
    font-weight: 600;
    color: var(--muted2);
}

#searchClearBtn.inline-action {
    right: 62px;
    font-size: 14px;
}

.inline-action--multisearch {
    right: 8px;
    font-size: 12px;
    color: var(--muted2);
}

#excludeClearBtn.inline-action:hover,
#searchClearBtn.inline-action:hover {
    color: var(--muted);
    text-decoration: none;
}

/* --- Segmented Control --- */

.segmented {
    display: inline-flex;
    align-items: stretch;
    border-radius: 12px;
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    overflow: hidden;
}

.segmented__btn {
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.segmented__btn + .segmented__btn { border-left: 1px solid var(--divider); }
.segmented__btn:hover { background: var(--control-bg-hover); }
.segmented__btn:active { filter: brightness(1.05); }

.segmented--tight .segmented__btn {
    height: 28px;
    padding: 0 6px;
    font-size: 11.5px;
    border-radius: 0;
}

.segmented--equal { width: 156px; }
.segmented--equal .segmented__btn { flex: 1 1 0; justify-content: center; }

.segmented--equal-actions { width: 148px; }
.segmented--equal-actions .segmented__btn { flex: 1 1 0; justify-content: center; }

/* Segment Tints */
.segmented__btn--ok { background: rgba(99, 102, 241, 0.08); }
.segmented__btn--danger, .segmented__btn--warn { background: rgb(237 237 255 / 8%); }
.segmented__btn--info { background: rgba(99, 102, 241, 0.08); }
.segmented__btn--neutral { background: rgba(255, 255, 255, 0.04); }

:root[data-theme="light"] .segmented__btn--neutral { background: rgba(15, 23, 42, 0.03); }

.segmented__btn--ok:hover { background: rgb(35 40 255 / 8%); }
.segmented__btn--danger:hover, .segmented__btn--warn:hover { background: rgb(136 136 157 / 8%); }
.segmented__btn--info:hover { background: rgb(35 40 255 / 8%); }
.segmented__btn--neutral:hover { background: var(--control-bg-hover); }

/* --- Panels --- */

.panel {
    border: 1px solid var(--border);
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px;
    border-bottom: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
    min-width: 0;
    z-index: 10;
    position: relative;
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
}

.panel__title {
    margin: 0;
    font-size: 14px;
    color: var(--text);
    letter-spacing: 0.2px;
}

.panel__actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.panel__meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.v-sep {
    width: 1px;
    height: 22px;
    background: var(--divider);
    display: inline-block;
    border-radius: 1px;
    margin: 0 2px;
}

.pill {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    color: var(--text);
    font-size: 12px;
}

.pill--muted { color: var(--muted); }

.pill--copyable {
    cursor: pointer;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    font: inherit;
    font-size: 12px;
    color: var(--text);
    transition: background 120ms ease, border-color 120ms ease;
    min-width: max-content;
    text-align: center;
    justify-content: center;
}

.pill--copyable:hover {
    background: var(--control-bg-hover);
    border-color: var(--control-border);
}

.pill--copyable:active {
    filter: brightness(1.05);
}

.pill--copyable.btn--success {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.40);
    min-width: max-content;
}

.filter-info {
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap;
    padding: 0 10px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    cursor: pointer;
    user-select: none;
}

.filter-info:hover {
    color: var(--text);
    background: var(--control-bg-hover);
    border-color: var(--control-border);
}

.filter-info:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

.tree-cleanup {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* --- Tree & Code Scroll Areas --- */

.scroll-area {
    overflow-x: auto;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
}

:root[data-theme="light"] .scroll-area {
    scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
}

.scroll-area::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
    background-color: rgba(255, 255, 255, 0.22);
}
.scroll-area::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.38); }

:root[data-theme="light"] .scroll-area::-webkit-scrollbar-thumb { background-color: rgba(15, 23, 42, 0.22); }
:root[data-theme="light"] .scroll-area::-webkit-scrollbar-thumb:hover { background-color: rgba(15, 23, 42, 0.34); }

.tree-wrap {
    padding: 10px 10px 14px 10px;
    min-height: 220px;
    max-height: min(920px, calc(100vh - 260px));
    flex: 1 1 auto;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.code {
    margin: 0;
    padding: 12px;
    min-height: 220px;
    max-height: min(920px, calc(100vh - 260px));
    flex: 1 1 auto;
    color: var(--text);
    background: var(--code-bg);
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    line-height: 1.55;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.selected-list {
    min-height: 220px;
    max-height: min(920px, calc(100vh - 260px));
    flex: 1 1 auto;
    padding: 6px;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.selected-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    line-height: 1.55;
    padding: 3px 8px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-item:hover {
    background: var(--row-hover);
}

.selected-item--highlight {
    animation: selected-highlight 1500ms ease forwards;
}

@keyframes selected-highlight {
    0%   { background: rgba(99, 102, 241, 0.32); }
    60%  { background: rgba(99, 102, 241, 0.18); }
    100% { background: transparent; }
}

.tree {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tree li { margin: 0; padding: 0; }

.tree ul {
    list-style: none;
    padding-left: 18px;
    margin: 0;
    position: relative;
}

.tree ul::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: color-mix(in srgb, var(--muted) 28%, transparent);
    opacity: 0.55;
}

.tree li > .node { position: relative; }

.tree li > .node::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 50%;
    width: 10px;
    height: 1px;
    background: color-mix(in srgb, var(--muted) 28%, transparent);
    opacity: 0.55;
}

.tree > li > ul::before,
.tree > li > .node::before { display: none; }

.node--highlight {
    animation: node-highlight 2500ms ease forwards;
    border-radius: 12px;
}

@keyframes node-highlight {
    0%   { background: rgba(99, 102, 241, 0.38); }
    60%  { background: rgba(99, 102, 241, 0.18); }
    100% { background: transparent; }
}

.node {
    display: grid;
    grid-template-columns: 18px 18px 18px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 4px 6px;
    border-radius: 12px;
}

.node:hover { background: var(--row-hover); }

.toggle {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.toggle:disabled { opacity: 0.25; cursor: default; }

.checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    line-height: 1;
    opacity: 0.9;
}

.icon--folder-action { cursor: pointer; }
.icon--folder-action:hover { transform: translateY(-0.5px); }

.label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.meta {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.meta__link {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    pointer-events: auto;
}

.meta__link:hover { opacity: 0.9; }

/* --- Modals --- */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1000;
}

.modal.is-open { display: block; }

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

:root[data-theme="light"] .modal__backdrop { background: rgba(2, 6, 23, 0.65); }

.modal__dialog {
    position: relative;
    width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    margin: 16px auto;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px;
    border-bottom: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.modal__title {
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal__head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal__meta {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--divider);
}

.modal__body { padding: 12px; }

.modal__code {
    margin: 0;
    padding: 12px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    color: var(--text);
    background: var(--code-bg);
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    line-height: 1.6;
    white-space: pre;
}

/* --- Empty State --- */

.empty { margin-bottom: 14px; }

.empty__card {
    border: 1px solid var(--border);
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 22px;
    text-align: center;
}

.empty__title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
}

.empty__text {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.5;
}

.kbd {
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--chip-border);
    background: var(--chip-bg);
    color: var(--text);
}

/* --- Filters Modal UI --- */

.filters-ui__section + .filters-ui__section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--divider);
}

.filters-ui__title {
    font-weight: 700;
    margin-bottom: 6px;
}

.filters-ui__desc {
    color: var(--muted2);
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 10px;
}

.filters-ui__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
}

/* Switch */
.switch {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px 10px;
    border-radius: 12px;
    border: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.switch:hover { background: var(--row-hover); }

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch__ui {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    position: relative;
}

.switch__ui::after {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: var(--text);
    opacity: 0.9;
    position: absolute;
    top: 50%;
    left: 3px;
    transform: translateY(-50%);
    transition: left 160ms ease, background 160ms ease;
}

.switch input:checked + .switch__ui {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.40);
}

.switch input:checked + .switch__ui::after { left: 21px; }

.switch__text {
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.35;
}

.switch-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Group: switch + nested editor visually attached */
.switch-group {
    border-radius: 12px;
    border: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
    overflow: hidden;
}

.switch--flat {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.switch-group__child {
    border-top: 1px solid var(--divider);
    padding: 10px;
    background: color-mix(in srgb, var(--panel) 94%, var(--bg));
}

/* Common Editor */
.common-editor {
    margin-top: 10px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.common-editor--compact {
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.common-editor__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.common-editor__title {
    font-weight: 700;
    font-size: 13px;
}

.common-editor__desc {
    color: var(--muted2);
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 10px;
}

.common-editor.is-disabled { opacity: 0.55; }
.common-editor.is-disabled textarea,
.common-editor.is-disabled button { pointer-events: none; }

.textarea {
    width: 100%;
    min-height: 320px;
    resize: vertical;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--control-border);
    background: var(--control-bg);
    color: var(--text);
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    line-height: 1.55;
    outline: none;
}

.textarea--compact { min-height: 220px; }

.textarea:focus {
    border-color: rgba(99, 102, 241, 0.55);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

/* --- Settings Modal Layout --- */

.settings-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 8px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-group {
    background: color-mix(in srgb, var(--panel) 96%, var(--text));
    border: 1px solid var(--divider);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 24px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    gap: 16px;
    background: var(--surface);
}

.settings-row + .settings-row { border-top: 1px solid var(--divider); }

.settings-row__info {
    flex: 1;
    min-width: 0;
}

.settings-row__label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
}

.settings-row__desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
}

.settings-row__action { flex-shrink: 0; }

.settings-row--nested {
    background: var(--surface);
    border-top: none !important;
    padding-top: 0;
    padding-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.input--compact {
    height: 36px;
    width: 220px;
    padding: 0 12px;
    font-size: 13px;
    text-align: left;
    background: var(--control-bg);
    border: 1px solid var(--control-border);
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input--compact:hover,
.input--compact:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    outline: none;
}

.settings-row .switch {
    border: 0;
    background: transparent;
    padding: 0;
    display: flex;
    width: auto;
}

/* --- Theme Switcher (Pill) --- */

.theme-switcher {
    display: inline-flex;
    background: var(--control-bg);
    padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--control-border);
    width: fit-content;
    min-width: 0;
}

.theme-switcher__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.theme-switcher__btn:hover { color: var(--text); }

.theme-switcher__btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.theme-switcher__btn--active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .theme-switcher__btn--active {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.05);
    color: #4f46e5;
}

.theme-icon { opacity: 0.8; }
.theme-switcher__btn--active .theme-icon { opacity: 1; }

/* --- Sort Dropdown --- */

.sort-dropdown {
    position: relative;
    display: inline-flex;
    margin-left: auto;
}

#sortBtn {
    border: 0;
    background: transparent;
    padding: 0 8px;
    width: 34px;
    color: var(--muted);
}

#sortBtn:hover {
    background: var(--control-bg-hover);
    color: var(--text);
}

.sort-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    margin-top: 8px;
    z-index: 1000;
    background: color-mix(in srgb, var(--panel), var(--bg));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    min-width: 220px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transform-origin: top right;
    animation: menu-pop 0.15s ease-out;
}

@keyframes menu-pop {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.sort-item {
    text-align: left;
    background: transparent;
    border: 0;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.sort-item:hover { background: var(--control-bg-hover); }

.sort-item.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.sort-item.active::after {
    content: "✓";
    font-weight: bold;
}

.sort-sep {
    height: 1px;
    background: var(--divider);
    margin: 4px 6px;
}

.context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 180px;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--panel), var(--bg));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: menu-pop 0.12s ease-out;
}

.context-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.85;
}

.context-menu__item:hover {
    background: var(--control-bg-hover);
    opacity: 1;
}

.context-menu__item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.context-menu__item:hover svg {
    opacity: 1;
}

.modal__dialog--medium {
    width: min(680px, calc(100vw - 32px));
}

.multisearch-ui {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.multisearch-ui__input-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multisearch-ui__label {
    font-size: 13px;
    color: var(--muted2);
}

.multisearch-ui__actions {
    display: flex;
    justify-content: flex-end;
}

.multisearch-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 340px;
    overflow-y: auto;
    padding: 2px;
}

.multisearch-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--divider);
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

.multisearch-result-item--notfound {
    opacity: 0.45;
}

.multisearch-result-item__cb {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.multisearch-result-item__path {
    flex: 1;
    font-family: var(--mono), monospace;
    font-size: 12.5px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multisearch-result-item__badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--divider);
    color: var(--muted2);
    background: var(--chip-bg);
    white-space: nowrap;
}

.multisearch-result-item--notfound .multisearch-result-item__badge {
    color: rgba(239, 68, 68, 0.7);
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.07);
}

.multisearch-ui__apply-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--divider);
}

.multisearch-ui__summary {
    font-size: 13px;
    color: var(--muted);
}
