/* Quick-filter shared styling: consistent chip wrap, disclosures, coverage badges, mobile constraints */

.panel .chip, .subrow .chip {
  max-width: min(390px, 100%);
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  overflow: hidden;
  box-sizing: border-box;
}

.panel .chip .chip-text, .subrow .chip .chip-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
  flex: 1 1 auto;
}

.panel .chip b, .subrow .chip b {
  flex-shrink: 0;
  margin-left: 4px;
}

.coverage-badge {
  display: inline-block;
  font-size: 12px;
  color: #8A7A68;
  background: #FDF5EA;
  border: 1px solid #EBD8C2;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: 550;
  vertical-align: middle;
  line-height: 1.4;
  white-space: nowrap;
}

.row-clear {
  margin-left: auto;
  font-size: 11.5px;
  color: #A08A6C;
  background: #FFFBF6;
  border: 1px dashed #D6B58C;
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all .15s;
}

.row-clear:hover {
  color: #9A4A08;
  border-color: #E8762B;
  background: #FCEEDD;
}

.filter-more {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0;
}

.filter-more summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: #8A7A68;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px dashed #D6B58C;
  background: #FFF;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  transition: all .15s;
}

.filter-more summary::-webkit-details-marker {
  display: none;
}

.filter-more summary::after {
  content: "▾";
  font-size: 10px;
  color: #B08A5C;
  transition: transform .18s;
}

.filter-more[open] summary::after {
  transform: rotate(180deg);
}

.filter-more summary:hover, .filter-more[open] summary {
  color: var(--accent-deep, #9A4A08);
  border-color: var(--accent, #E8762B);
  background: #FFF7EE;
}

.filter-more .filter-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 8px 10px;
  background: #FFF9F2;
  border: 1px solid #EFE0CB;
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}

.empty-group-note {
  font-size: 12px;
  color: #9E8D7B;
  font-style: italic;
  padding: 8px 12px;
  margin: 4px 0;
  background: #FAF4EB;
  border: 1px dashed #E5D6C2;
  border-radius: 10px;
  width: 100%;
}

/* Keep labels aligned while the choices use the available reading width. */
.panel .subrow.facet-row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  align-items: start;
  max-height: none;
  overflow: visible;
}
.panel .facet-label {
  padding-top: 4px;
  align-self: start;
  margin: 0;
  min-width: 0;
}
.facet-label .coverage-badge {
  display: block;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  white-space: normal;
}
.facet-choices {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.facet-choices .chip { min-height: 34px; }
.facet-choices .filter-more { flex-basis: 100%; width: 100%; }
.facet-choices .filter-more summary { padding: 5px 12px; }
.facet-choices .filter-options { max-height: none; overflow: visible; }
.filter-guide { margin-left: auto; color: #87592e; font-size: 12px; }
.filter-guide summary {
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  list-style: none;
}
.filter-guide summary::-webkit-details-marker { display: none; }
.filter-guide summary::after { content: ' ⓘ'; }
.filter-guide[open] { flex-basis: 100%; margin-left: 0; }
.filter-guide[open] summary { display: inline-block; background: #fbf4ea; }
.filter-guide-body {
  padding: 4px 12px;
  border: 1px solid #eddfcf;
  border-radius: 10px;
  background: #fffaf3;
  color: #776653;
  line-height: 1.65;
  white-space: normal;
  overflow-wrap: anywhere;
}
.filter-guide-body p { margin: 7px 0; }
.panel .chip:focus-visible, .filter-guide summary:focus-visible,
.filter-more summary:focus-visible {
  outline: 2px solid #ac5b19;
  outline-offset: 3px;
}

/* 390px Mobile Viewport Constraints (e.g. iPhone standard screens) */
@media (max-width: 480px) {
  .panel .subrow.facet-row { grid-template-columns: minmax(0, 1fr); }
  .panel .facet-label { padding-top: 0; }
  .facet-label .coverage-badge { display: inline; margin-left: 8px; }
  .facet-choices { gap: 6px; }
  .facet-choices .chip { min-height: 40px; max-width: 100%; }
  .panel .chip, .subrow .chip {
    max-width: calc(100vw - 44px);
    font-size: 14px;
    padding: 5px 10px;
  }
  .panel .subrow {
    padding: 6px 8px;
    gap: 6px;
  }
  .coverage-badge {
    display: block;
    margin: 4px 0 0 0;
    width: fit-content;
  }
  .filter-more .filter-options {
    padding: 6px;
    gap: 5px;
  }
}


/* Compact filter panels retain full labels, selected values and keyboard access. */
.panel .chiprow { padding: 8px 16px; gap: 6px; }
.panel .grpbtn { padding: 5px 11px; min-height: 32px; }
.panel .subrow { margin-top: 3px; padding: 6px 10px; gap: 6px; border-radius: 10px; }
.panel .subrow.facet-row { grid-template-columns: 146px minmax(0, 1fr); }
.panel .facet-label { padding-top: 2px; }
.facet-label .coverage-badge { margin-top: 2px; line-height: 1.3; }
.facet-choices { gap: 6px; }
.facet-choices .chip, .selected-filters .chip { min-height: 30px; padding: 4px 10px; }
.facet-choices .filter-more { flex: 0 0 auto; width: auto; }
.facet-choices .filter-more summary { padding: 4px 10px; }
.facet-choices .filter-more[open] { flex-basis: 100%; width: 100%; }
.facet-choices .filter-options { max-height: 180px; overflow-y: auto; padding: 6px 8px; }
.panel .selected-filters { padding: 6px 10px; align-items: center; }
.panel .row-clear { margin-left: auto; padding: 3px 9px; }
@media (max-width: 480px) {
  .panel .chiprow { padding: 7px 10px; }
  .panel .subrow.facet-row { grid-template-columns: minmax(0, 1fr); }
  .facet-choices .chip, .selected-filters .chip { min-height: 38px; padding: 5px 10px; }
  .facet-choices .filter-options { max-height: 190px; }
  .panel .grpbtn { min-height: 38px; }
}

/* A single reset sits beside the guide; selected chips toggle themselves off. */
.panel .chiprow,.panel .chips { gap: 7px; align-items: center; }
.panel .grpbtn { min-height: 34px; padding: 6px 12px; border-radius: 9px; font-family: inherit; font-size: 12px; }
.panel .subrow { padding: 9px 11px; border: 1px solid #ece1d3; background: #fbf8f3; border-radius: 10px; }
.panel .subrow.facet-row { grid-template-columns: 132px minmax(0,1fr); gap: 12px; }
.panel .facet-label { padding-top: 4px; color: #88745c; font-size: 11.5px; }
.panel .facet-choices { gap: 6px; }
.panel .chip { min-height: 34px; padding: 5px 11px; border: 1px solid #e5d8c7; border-radius: 8px; background: #fffefa; font-family: inherit; font-size: 12px; font-weight: 600; }
.panel .chip b { margin-left: 3px; font-size: 11px; font-weight: 550; color: #ad8358; font-variant-numeric: tabular-nums; }
.panel .chip.active,.panel .grpbtn.open { color: #fff; background: #8b480f; border-color: #8b480f; box-shadow: none; }
.panel .chip.active b { color: #f8e7d5; }
.panel .filter-more summary { min-height: 34px; display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 8px; font-size: 11.5px; }
.panel .filter-reset { margin-left: auto; min-height: 32px; padding: 4px 9px; border: 0; border-radius: 7px; background: transparent; color: #996a40; font-family: inherit; font-size: 11.5px; font-weight: 550; cursor: pointer; white-space: nowrap; }
.panel .filter-reset:hover { background: #f5ebdf; color: #793d10; }
.panel .filter-reset:focus-visible { outline: 2px solid #ac5b19; outline-offset: 2px; }
.panel .filter-reset + .filter-guide { margin-left: 0; }
.panel .selected-filters,.panel .gclear,.panel .row-clear,.panel [data-clear-all] { display: none; }
@media(max-width:480px){
  .panel .chiprow,.panel .chips { gap: 6px; }
  .panel .subrow.facet-row { grid-template-columns: minmax(0,1fr); gap: 7px; padding: 8px; }
  .panel .facet-label { padding-top: 0; }
  .panel .chip,.panel .grpbtn,.panel .filter-reset,.panel .filter-guide summary,.panel .filter-more summary { min-height: 38px; }
  .panel .chip { max-width: 100%; padding: 6px 10px; font-size: 12px; }
  .panel .grpbtn { padding: 6px 9px; font-size: 11.5px; }
  .panel .filter-reset { min-width: 38px; padding: 4px; }
  .panel .filter-guide summary { padding: 5px 4px; font-size: 11px; }
}

/* One-line choices with an anchored overflow menu. */
.panel:has(.facet-choices) { overflow: visible; }
.panel .coverage-badge { display: block; margin: 2px 0 0; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 10.5px; line-height: 1.2; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.panel .subrow.facet-row { grid-template-columns: 140px minmax(0,1fr); align-items: center; }
.panel .facet-label { padding-top: 0; align-self: center; white-space: normal; line-height: 1.25; word-break: break-word; font-size: 11.5px; }
.panel .facet-choices { position: relative; flex-wrap: nowrap; min-width: 0; }
.panel .facet-choices > .chip { flex: 0 0 auto; white-space: nowrap; max-width: min(390px, 100%); }
.panel .facet-choices > .chip .chip-text { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .facet-choices > .filter-more,
.panel .facet-choices > .filter-more[open] { position: static; flex: 0 0 auto; width: auto; }
.panel .facet-choices > .filter-more[hidden] { display: none; }
.panel .facet-choices .filter-more summary { white-space: nowrap; }
.panel .facet-choices .filter-options { position: absolute; right: 0; top: calc(100% + 5px); width: min(820px,calc(100vw - 44px)); max-height: 220px; overflow-y: auto; margin: 0; z-index: 50; box-shadow: 0 8px 24px #55351b22; }
.panel .review-filterbar { position: relative; flex-wrap: nowrap; }
.panel .review-filterbar > .facet-choices { flex: 1 1 0; }
.panel .review-filterbar > .chiplab,
.panel .review-filterbar > .filter-guide,
.panel .review-filterbar > .filter-reset { flex: 0 0 auto; margin-left: 0; white-space: nowrap; }
.panel .review-filterbar > .filter-guide[open] { flex-basis: auto; }
.review-filterbar .filter-guide-body { position: absolute; right: 10px; top: calc(100% - 2px); width: min(650px,calc(100vw - 44px)); z-index: 60; box-sizing: border-box; }
@media(max-width:480px){
  .panel .subrow.facet-row { grid-template-columns: 72px minmax(0,1fr); gap: 6px; }
  .panel .review-filterbar { gap: 5px; }
}

.panel .facet-choices .filter-more:has(.chip.active) > summary { color: #8b480f; border-color: #bd7b45; background: #fff0df; }

.panel .subrow.facet-row { position: relative; }
.panel .facet-choices { position: static; }
.panel .facet-choices .filter-options { width: min(820px,100%); }
