/* Filter drawer: right-side on desktop, bottom-sheet on mobile */

.drawer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    justify-content: flex-end;
}
.drawer[hidden] { display: none; }

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity .22s ease;
}
.drawer.open .drawer-backdrop { opacity: 1; }
html[data-theme="dark"] .drawer-backdrop { background: rgba(0, 0, 0, 0.6); }

.drawer-panel {
    position: relative;
    width: 420px;
    max-width: 94vw;
    height: 100%;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(0.2, 0.8, 0.25, 1);
    box-shadow: -4px 0 28px rgba(0, 0, 0, 0.12);
}
.drawer.open .drawer-panel { transform: translateX(0); }

/* Left-side drawer (scope selector) — mirror of the right filters drawer */
.drawer-left { justify-content: flex-start; }
.drawer-left .drawer-panel {
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.12);
}
.drawer-left.open .drawer-panel { transform: translateX(0); }
#scope-drawer .drawer-head { justify-content: flex-start; gap: 10px; }
#scope-drawer .drawer-close { margin-left: auto; }

.scope-section { display: flex; flex-direction: column; gap: 8px; }
.scope-divider { height: 1px; background: var(--border); margin: 2px 0; }
.scope-hint { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--text-subtle); }

/* Project picker (top of the scope drawer) */
.scope-projects { max-height: 24vh; }
.scope-proj-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color .12s ease;
}
.scope-proj-row:last-child { border-bottom: none; }
.scope-proj-row:hover { background: var(--bg-subtle); }
.scope-proj-row.is-current { color: var(--accent); font-weight: 600; }
.scope-proj-check { flex-shrink: 0; width: 16px; display: inline-flex; align-items: center; color: var(--accent); }
.scope-proj-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Темы / Рубрики — full-width mode toggle */
.scope-mode { display: flex; width: 100%; }
.scope-mode button { flex: 1; padding: 7px 10px; font-size: 12px; }

.scope-list { max-height: 34vh; }
.scope-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: var(--bg-elevated);
}
.scope-list .rubric-row-name { flex: 1; }
.scope-row-count {
    flex-shrink: 0;
    margin-left: auto;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10.5px;
    color: var(--text-subtle);
    background: var(--bg-subtle);
    padding: 1px 7px;
    border-radius: 8px;
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-head h2 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}
.drawer-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
    padding: 0;
}
.drawer-close:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-subtle); }
.drawer-close:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

.drawer-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.fgroup { display: flex; flex-direction: column; gap: 8px; }
.fgroup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
/* Tag AND/OR (any/all) segmented toggle */
.fmatch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
/* Keep the slot reserved when hidden so appearing doesn't shift the layout.
   !important beats the global reset `[hidden] { display: none !important }`
   (tokens.css) — otherwise the toggle is removed from flow and the group jumps. */
.fmatch[hidden] { display: inline-flex !important; visibility: hidden; pointer-events: none; }
.fmatch button {
    padding: 3px 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color .12s ease, color .12s ease;
}
.fmatch button + button { border-left: 1px solid var(--border); }
.fmatch button:hover { color: var(--text); }
.fmatch button.is-active { background: var(--accent); color: var(--accent-fg); }
/* Rubric-count hint: "Все" when nothing selected, otherwise the number */
.fcount {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--text-subtle);
}
.fcount.is-count { color: var(--accent); font-weight: 600; }
.fgroup-label {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.fchips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.fchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 15px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all .12s ease;
}
.fchip:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.fchip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.fchip.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-fg);
}

.fdaterange {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.fdaterange[hidden] { display: none; }
.fdate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 140px;
    min-width: 0;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.fdate:focus-within {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--focus-ring);
    color: var(--text);
}
/* Required field highlighted when empty */
.fdate.is-error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
    color: var(--text);
}
.fdate.is-error .fdate-label { color: #ef4444; }
.fdate-label {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-subtle);
    flex-shrink: 0;
}
.fdate-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    padding: 0;
    font-family: inherit;
}
.fdate-input::placeholder {
    color: var(--text-subtle);
    opacity: 0.8;
}

.finput {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.finput:focus-within {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px var(--focus-ring);
    color: var(--text);
}
.finput input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    font: inherit;
    font-size: 13px;
    color: var(--text);
}
/* Native cancel button replaced by the custom .input-clear (see feed.css). */
.finput input::-webkit-search-cancel-button,
.finput input::-webkit-search-decoration { display: none; -webkit-appearance: none; }

/* Rubric filter — a scrollable checkbox list (like the theme picker) */
.rubric-picker {
    max-height: 220px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-subtle);
    margin-top: 2px;
}
.rubric-picker:empty { display: none; }
.rubric-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    transition: background-color .12s ease;
}
.rubric-row:last-child { border-bottom: none; }
.rubric-row:hover { background: var(--bg-subtle); }
.rubric-row[hidden] { display: none; }
.rubric-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent);
}
.rubric-row-name {
    min-width: 0;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dynamic chip lists (tags): scrollable, filterable */
.fchips-list {
    max-height: 168px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-top: 2px;
}
.fchips-list:empty { display: none; }
.fchip[hidden] { display: none; }
.fchip-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}
.fchip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--bg-subtle);
    color: var(--text-subtle);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
}
.fchip.is-active .fchip-count {
    background: rgba(255, 255, 255, 0.22);
    color: var(--accent-fg);
}
/* Grows a cut chip list — the last chip of the list. Dashed and muted so it
   reads as an action closing the row rather than one more filter to pick. */
.fchips-more {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border: 1px dashed var(--border);
    border-radius: 15px;
    background: transparent;
    color: var(--text-subtle);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: all .12s ease;
}
.fchips-more:hover {
    border-color: var(--border-strong);
    background: var(--bg-subtle);
    color: var(--text);
}
.fchips-more:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.fgroup-empty {
    font-size: 12px;
    color: var(--text-subtle);
    margin: 0;
}
.fgroup-empty[hidden] { display: none; }

.drawer-foot {
    padding: 14px 18px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.drawer-foot .btn-secondary,
.drawer-foot .btn-primary {
    margin-top: 0;
    flex: 1;
    min-height: 40px;
    min-width: auto;
}
