:root{
  --gx-radius: 24px;
  --gx-shadow: 0 18px 50px rgba(0,0,0,.18);
  --gx-border: rgba(0,0,0,.08);
  --gx-overlay: rgba(0,0,0,.42);
}

/* If author CSS sets display/grid, it can override the native `[hidden]` behavior.
   Force-hide just our sheet elements when `[hidden]` is present. */
.gx-sheet[hidden],
.gx-sheet-overlay[hidden]{
  display: none !important;
}

.gx-sheet-overlay{
  position: fixed;
  inset: 0;
  background: var(--gx-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9998;
}

.gx-sheet{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  /* 70% height, 30% visible space above */
  top: 30vh;

  background: #fff;

  border-top-left-radius: var(--gx-radius);
  border-top-right-radius: var(--gx-radius);

  box-shadow: var(--gx-shadow);
  border-top: 1px solid var(--gx-border);

  z-index: 9999;

  display: grid;
  /* handle + header + scrollable content + footer */
  grid-template-rows: auto auto 1fr auto;

  transform: translateY(110%);
  opacity: 0;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1), opacity 160ms ease;
  will-change: transform;
}

.gx-sheet.is-open{
  transform: translateY(0);
  opacity: 1;
}

.gx-sheet__handle{
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  justify-self: center;
  margin: 10px 0 0;
}

.gx-sheet__header{
  position: sticky;
  top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding: 10px 16px 10px;
  border-bottom: 1px solid var(--gx-border);
}

.gx-sheet__title h3{
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.gx-sheet__subtitle{
  margin: 4px 0 0;
  font-size: 12px;
  opacity: .75;
}

.gx-sheet__close{
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--gx-border);
  background: rgba(255,255,255,.8);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  text-decoration: none;
  filter: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gx-sheet__close svg{
  width: 22px;
  height: 22px;
  display: block;
  filter: none;
}

.gx-sheet__close svg path{
  /* Some themes apply `stroke` to all SVGs via CSS (sometimes with !important). Force ours. */
  stroke: #111111 !important;
}

.gx-sheet__close,
.gx-sheet__close:hover,
.gx-sheet__close:focus,
.gx-sheet__close:active,
.gx-sheet__close:visited{
  color: inherit;
}

.gx-sheet__close:active{
  transform: scale(.98);
}

.gx-sheet__close:hover{
  background: rgba(255,255,255,.92);
  border-color: var(--gx-border);
}

.gx-sheet__close:focus,
.gx-sheet__close:active{
  background: rgba(255,255,255,.92);
  border-color: var(--gx-border);
}

.gx-sheet__close:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 2px;
}

.gx-sheet__content{
  overflow: auto;
  padding: 14px 16px 18px;
  -webkit-overflow-scrolling: touch;
}

.gx-sheet__footer{
  position: sticky;
  bottom: 0;

  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;

  padding: 12px 16px 16px;
  border-top: 1px solid var(--gx-border);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Buttons */
.gx-btn{
  height: 44px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gx-btn:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 2px;
}

/* Trigger */
.gx-filter-adult-note{
  width: 100%;
  margin: 0 0 10px 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(185, 33, 48, .22);
  background:
    radial-gradient(130% 120% at 0% 0%, rgba(185, 33, 48, .08), rgba(185, 33, 48, 0) 64%),
    linear-gradient(180deg, rgba(255, 250, 251, .98), rgba(255, 247, 248, .98));
  box-shadow: 0 4px 14px rgba(185, 33, 48, .08);
  text-align: center;
}

.gx-filter-adult-note__text{
  margin: 0;
  color: #8f1d2d;
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: .005em;
}

.gx-filter-trigger{
  width: 100%;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (max-width: 575px){
  .gx-filter-adult-note{
    padding: 9px 10px;
    margin-bottom: 9px;
  }

  .gx-filter-adult-note__text{
    font-size: 12px;
    line-height: 1.4;
  }
}

.gx-filter-trigger__icon{
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.gx-filter-trigger__icon svg{
  width: 18px;
  height: 18px;
  display: block;
}

.gx-filter-trigger:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 2px;
}

/* Optional: basic section styling (Phase 1 placeholders) */
.gx-sheet__section-title{
  margin: 0 0 6px 0;
  font-size: 13px;
  font-weight: 700;
}
.gx-sheet__hint{
  margin: 0 0 14px 0;
  font-size: 13px;
  opacity: .7;
}

/* Phase 2: selector rows + subpanels (accordion, no overlap) */
.gx-selector-list{
  border: 1px solid var(--gx-border);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.gx-selector-row{
  width: 100%;
  padding: 14px 14px;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--gx-border);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: #111;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: none;
  text-decoration: none;
  filter: none;
}

.gx-selector-row:last-of-type{
  border-bottom: 0;
}

.gx-selector-row__label{
  font-weight: 700;
  font-size: 14px;
}

.gx-selector-row__summary{
  font-size: 12px;
  opacity: .72;
  white-space: nowrap;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-self: end;
}

.gx-selector-row__chev{
  display: none;
}

.gx-selector-row:hover{
  background: rgba(0,0,0,.015);
  color: #111;
}

.gx-selector-row:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: -2px;
}

.gx-subpanel{
  border-bottom: 1px solid var(--gx-border);
  background: rgba(0,0,0,.01);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 260ms cubic-bezier(.2,.8,.2,1), opacity 180ms ease;
  contain: layout paint;
}

.gx-subpanel.is-open{
  max-height: var(--gx-panel-h, 320px);
  opacity: 1;
}

.gx-subpanel__inner{
  padding: 12px 12px 14px;
}

.gx-subpanel__hint{
  margin: 10px 2px 0;
  font-size: 12px;
  opacity: .7;
}

.gx-chip-row{
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  contain: content;
}

.gx-filter-ui .gx-chip{
  flex: 0 0 auto;
  scroll-snap-align: start;
  border-radius: 999px;
  border: 1px solid var(--gx-border);
  background: #fff;
  color: #111;
  height: 32px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  line-height: 32px;
  cursor: pointer;
  display: inline-flex;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  gap: 6px;
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  filter: none;
  white-space: nowrap;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gx-filter-ui .gx-chip:hover{
  background: rgba(0,0,0,.015);
  border-color: rgba(0,0,0,.12);
}

.gx-filter-ui .gx-chip.is-selected,
.gx-filter-ui .gx-chip.is-selected:hover,
.gx-filter-ui .gx-chip.is-selected:focus,
.gx-filter-ui .gx-chip.is-selected:active{
  box-shadow: none !important;
}

.gx-filter-ui .gx-chip__text{
  display: inline-flex;
  align-items: center;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.gx-filter-ui .gx-chip::after{
  content: '';
}

.gx-filter-ui .gx-chip.is-selected::after{
  content: "\2713";
  font-size: 12px;
  line-height: 1;
  opacity: .95;
}

.gx-filter-ui .gx-chip.is-locked,
.gx-filter-ui .gx-chip:disabled{
  opacity: .55;
  cursor: not-allowed;
}

.gx-filter-ui .gx-chip:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 2px;
}

.gx-segment{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.gx-seg{
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--gx-border);
  background: #fff !important;
  color: #111 !important;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-decoration: none;
  filter: none;
  box-shadow: none !important;
}

.gx-seg:hover{
  background: rgba(0,0,0,.015) !important;
  border-color: rgba(0,0,0,.12);
  color: #111 !important;
}

.gx-seg.is-selected,
.gx-seg[aria-pressed="true"],
.gx-seg.is-selected:hover,
.gx-seg[aria-pressed="true"]:hover,
.gx-seg.is-selected:focus,
.gx-seg[aria-pressed="true"]:focus,
.gx-seg.is-selected:active,
.gx-seg[aria-pressed="true"]:active{
  box-shadow: none !important;
}

.gx-seg:focus-visible{
  outline: 2px solid rgba(0,0,0,.18);
  outline-offset: 2px;
}

/* Remove the default mobile focus ring/flash while preserving keyboard focus via :focus-visible */
.gx-sheet button:focus{
  outline: none;
  box-shadow: none;
}

.gx-sheet button{
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 781px){
  .gx-sheet-overlay{
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .gx-sheet:not(.gx-report-sheet){
    width: 100%;
    top: auto;
    height: auto;
    max-height: 72vh;
    overflow-y: auto;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-sheet__handle{
    margin: 8px 0 0;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-sheet__header{
    padding: 8px 16px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-sheet__subtitle{
    margin: 2px 0 0;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-sheet__content{
    padding: 12px 16px 14px;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-selector-row{
    padding: 12px 14px;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-subpanel__inner{
    padding: 10px 12px 12px;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-subpanel__hint{
    margin: 8px 2px 0;
  }

  .gx-sheet:not(.gx-report-sheet) .gx-sheet__footer{
    padding: 8px 16px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #fff;
  }
}

@media (prefers-reduced-motion: reduce){
  .gx-sheet{ transition: none; }
  .gx-subpanel{ transition: none; }
}

/* Hide global Search FAB while filter sheet is open (prevents it sitting above the overlay). */
html.gx-filter-sheet-open #hp-search-fab,
body.gx-filter-sheet-open #hp-search-fab{
  display: none !important;
}
