/* Round 308: blur + dim behind pop-ups, sheets and modals (Day, Night, T3, DP).
   backdrop-filter with -webkit- prefix and a dim color fallback. --sheet-drag (0–1)
   fades the blur and dim in step with SheetSwipe. Loaded after theme CSS so it wins. */

:is(dialog.asheet, dialog.wsheet, dialog.psheet, dialog.gcx, dialog.dsheet, dialog.adlg, dialog.fsheet)::backdrop{
  background:rgba(8,12,24,.48);
  -webkit-backdrop-filter:blur(12px);
  backdrop-filter:blur(12px);
}

:is(dialog.asheet, dialog.wsheet, dialog.psheet, dialog.gcx, dialog.dsheet, dialog.adlg, dialog.fsheet)::backdrop{
  background:rgba(8,12,24,calc(.48 * (1 - var(--sheet-drag, 0))));
  -webkit-backdrop-filter:blur(calc(12px * (1 - var(--sheet-drag, 0)))) saturate(1.1);
  backdrop-filter:blur(calc(12px * (1 - var(--sheet-drag, 0)))) saturate(1.1);
}

html[data-theme=light]:not([data-skin]) :is(dialog.asheet, dialog.wsheet, dialog.psheet, dialog.gcx, dialog.dsheet, dialog.adlg, dialog.fsheet)::backdrop{
  background:rgba(15,23,42,.32);
  background:rgba(15,23,42,calc(.32 * (1 - var(--sheet-drag, 0))));
}

:is(html[data-skin=night], html[data-skin=t3], html[data-skin=dp], html[data-skin=heritage]) :is(dialog.asheet, dialog.wsheet, dialog.psheet, dialog.gcx, dialog.dsheet, dialog.adlg, dialog.fsheet)::backdrop{
  background:rgba(0,0,0,.52);
  background:rgba(0,0,0,calc(.52 * (1 - var(--sheet-drag, 0))));
}

/* Overlays that are themselves the shade (not a dialog backdrop). */
.ocx-modal::before{
  -webkit-backdrop-filter:blur(calc(12px * (1 - var(--ocx-drag, 0)))) saturate(1.1);
  backdrop-filter:blur(calc(12px * (1 - var(--ocx-drag, 0)))) saturate(1.1);
}
.sp-ov{
  -webkit-backdrop-filter:blur(12px) saturate(1.1);
  backdrop-filter:blur(12px) saturate(1.1);
}
.tm-sched-shade{
  -webkit-backdrop-filter:blur(12px) saturate(1.2);
  backdrop-filter:blur(12px) saturate(1.2);
}

@media (prefers-reduced-motion:reduce){
  :is(dialog.asheet, dialog.wsheet, dialog.psheet, dialog.gcx, dialog.dsheet, dialog.adlg, dialog.fsheet)::backdrop{
    transition:none;
  }
}

/* Custom filter / sort sheet (replaces the native <select> popover). */
dialog.fsheet{
  border:0;padding:0;border-radius:18px;width:min(340px,calc(100vw - 40px));
  max-height:min(72vh,560px);background:var(--card,#fff);color:var(--ink);
  box-shadow:0 18px 50px rgba(0,0,0,.35);overflow:hidden;
}
.fsheet-in{display:flex;flex-direction:column;max-height:min(72vh,560px)}
.fsheet-grab{width:36px;height:5px;border-radius:99px;background:rgba(127,127,127,.4);margin:8px auto 2px;flex:none}
.fsheet h2{font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted,#6b7280);
  margin:0;padding:6px 18px 8px}
.fsheet-list{overflow:auto;-webkit-overflow-scrolling:touch;padding:0 0 8px;overscroll-behavior:contain}
.fsheet-opt{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  width:100%;background:none;border:0;border-top:1px solid var(--line,rgba(127,127,127,.22));
  padding:14px 18px;font:inherit;font-size:16px;color:inherit;text-align:left;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.fsheet-opt:focus,.fsheet-opt:focus-visible{outline:none}
.fsheet-opt[aria-selected=true]{font-weight:650}
.fsheet-radio{width:20px;height:20px;border-radius:50%;border:2px solid var(--muted,#8b93a0);flex:none;position:relative;box-sizing:border-box}
.fsheet-opt[aria-selected=true] .fsheet-radio{border-color:var(--brand-d,#1b2a4a);background:var(--brand-d,#1b2a4a)}
.fsheet-opt[aria-selected=true] .fsheet-radio::after{content:"";position:absolute;inset:4px;border-radius:50%;background:#fff}

html[data-theme=light]:not([data-skin]) dialog.fsheet{background:#fff;color:#0f141c;box-shadow:0 18px 50px rgba(15,23,42,.28)}
:is(html[data-skin=night], html[data-skin=t3]) dialog.fsheet{background:#1c1c1e;color:#f1f5f9;box-shadow:0 18px 50px rgba(0,0,0,.6)}
:is(html[data-skin=night], html[data-skin=t3]) .fsheet-opt{border-color:#2c2c2e}
:is(html[data-skin=night], html[data-skin=t3]) .fsheet h2{color:#8b93a0}
html[data-skin=night] .fsheet-opt[aria-selected=true] .fsheet-radio{border-color:#1f6bff;background:#1f6bff}
html[data-skin=t3] .fsheet-opt[aria-selected=true] .fsheet-radio{border-color:#773141;background:#773141}
html[data-skin=dp] dialog.fsheet{background:#0f1a18;color:#e8f0ee;box-shadow:0 18px 50px rgba(0,0,0,.6)}
html[data-skin=dp] .fsheet-opt{border-color:#1c2e2a}
html[data-skin=dp] .fsheet-opt[aria-selected=true] .fsheet-radio{border-color:#3dffc8;background:#3dffc8}
html[data-skin=dp] .fsheet-opt[aria-selected=true] .fsheet-radio::after{background:#0f1a18}
html[data-skin=heritage] dialog.fsheet{background:#17140f;color:#f3ecd8;box-shadow:0 18px 50px rgba(0,0,0,.6)}
html[data-skin=heritage] .fsheet-opt{border-color:#3a3428}
html[data-skin=heritage] .fsheet h2{color:#b5aa90}
html[data-skin=heritage] .fsheet-opt[aria-selected=true] .fsheet-radio{border-color:#d4b45a;background:#d4b45a}
html[data-skin=heritage] .fsheet-opt[aria-selected=true] .fsheet-radio::after{background:#17140f}
