/* Search shares the toolbar; filters sit above the image list. */
#gallery-section .explore-toolbar {
  display: grid;
  grid-template-columns: auto minmax(250px, 1fr) auto;
  align-items: center;
  gap: 16px 22px;
  padding: 8px 0 14px;
  min-height: 66px;
}
.explore-toolbar > .sort-tabs { gap: 22px; align-self: stretch; }
.explore-toolbar > .sort-tabs button { align-items: center; padding: 0; font-size: 11px; white-space: nowrap; }
.explore-toolbar > .sort-tabs button.active::after { bottom: -15px; }
.explore-toolbar > .view-controls { padding: 0; gap: 8px; }
.explore-toolbar > .view-controls > span { margin: 0 2px 0 0; }
.explore-search-form { min-width: 0; margin: 0; }
.explore-search-main { display: flex; align-items: center; gap: 9px; }
.explore-search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 7px;
  padding: 4px;
  border: 1px solid var(--site-edge, var(--line));
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--ink) 3%, transparent);
  transition: border-color .18s, box-shadow .18s;
}
.explore-search-field:focus-within { border-color: var(--site-accent, var(--green)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 11%, transparent); }
.explore-search-input { display: flex; align-items: center; flex: 1; min-width: 0; gap: 9px; padding-left: 8px; color: var(--muted); }
.explore-search-input svg { width: 16px; height: 16px; }
.explore-search-input input { flex: 1; min-width: 0; width: 100%; height: 34px; padding: 7px 0; border: 0; background: transparent; color: var(--ink); font-size: 12px; }
.explore-search-input input::placeholder { color: var(--muted); opacity: .85; }
#explore-search-input:focus { box-shadow: none; }
.explore-search-field > .explore-search-submit { flex: 0 0 auto; height: 34px; padding: 8px 13px; border-radius: 7px; font-size: 11px; }
.explore-search-options { position: static; flex: 0 0 auto; align-self: stretch; }
.explore-search-options > summary { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 30px; height: 100%; min-height: 34px; padding: 7px; border: 1px solid transparent; border-radius: 7px; color: var(--green); background: color-mix(in srgb, var(--green) 8%, var(--surface)); list-style: none; cursor: pointer; font-size: 11px; }
.explore-search-options > summary::-webkit-details-marker { display: none; }
.explore-search-options > summary svg { width: 13px; height: 13px; flex: none; }
.explore-search-options[open] > summary { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
.explore-search-options[open] > summary > [data-icon="chevron-down"] { transform: rotate(180deg); }
.explore-search-popup { position: absolute; top: calc(100% + 10px); right: 0; z-index: 35; display: grid; gap: 15px; width: 248px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 17px; border: 1px solid var(--site-edge, var(--line)); border-radius: 11px; background: var(--surface); color: var(--ink); box-shadow: 0 12px 32px color-mix(in srgb, var(--ink) 14%, transparent); }
.explore-search-options:not([open]) > .explore-search-popup { display: none; }
.explore-search-popup fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; margin: 0; padding: 0; gap: 8px; border: 0; }
.explore-search-popup legend { margin-bottom: 9px; padding: 0; color: var(--muted); font-size: 10px; }
.explore-search-popup label { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: 36px; padding: 8px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 11px; cursor: pointer; }
.explore-search-popup label:has(input:checked) { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); color: var(--green); background: var(--green-pale); }
.explore-search-popup input[type="radio"] { width: 13px; height: 13px; flex: none; margin: 0; accent-color: var(--green); }
.explore-search-popup p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.explore-search-popup > .button { width: 100%; min-height: 36px; font-size: 11px; }
.explore-search-options > summary:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.explore-search-main > .filter-button { flex: 0 0 auto; gap: 6px; justify-content: center; height: 44px; padding: 10px 12px; border: 1px solid var(--site-edge, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--surface) 70%, var(--bg)); color: var(--muted); font-size: 11px; white-space: nowrap; transition: background .18s, border-color .18s, color .18s; }
.explore-search-main > .filter-button:hover,
.explore-search-main > .filter-button[aria-expanded="true"] { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); color: var(--green); background: color-mix(in srgb, var(--green) 7%, var(--surface)); }
.explore-search-main > .filter-button svg { width: 15px; height: 15px; }
#filter-toggle #filter-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
#gallery-section #filter-panel { position: absolute; top: calc(100% - 8px); right: 0; z-index: 31; width: min(100%, 540px); margin: 0; padding: 22px; grid-template-columns: repeat(2, minmax(0, 1fr)); border-color: var(--site-edge, var(--line)); background: var(--surface); box-shadow: 0 14px 38px color-mix(in srgb, var(--ink) 15%, transparent); max-height: min(560px, calc(100dvh - 120px)); overflow-y: auto; overscroll-behavior: contain; }
#filter-panel > .filter-tag-input { grid-column: 1 / -1; }
#filter-panel .metadata-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); border-color: var(--line); }
#filter-panel .filter-color-field { grid-column: 1 / -1; grid-row: auto; }
#filter-panel input, #filter-panel select { border-color: var(--site-edge, var(--line)); background: var(--surface); color: var(--ink); }
#gallery-section #filter-panel > [data-action="apply-filter"] { grid-column: 2; grid-row: 3; }
#gallery-section #filter-panel > [data-action="reset-filter"] { grid-column: 1; grid-row: 3; }
.advanced-filter-heading { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.advanced-filter-heading h2 { margin: 0; color: var(--ink); font-size: 13px; font-weight: 550; }
.advanced-filter-heading p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.explore-filter-wrap { position: relative; }
#gallery-section #tag-bar { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-items: center; gap: 8px; padding: 15px 0 18px; overflow: visible; }
#tag-bar .explore-inline-filter { position: relative; display: flex; align-items: center; min-width: 0; width: 100%; margin: 0; font-size: 0; color: var(--muted); }
#tag-bar .explore-inline-filter select { appearance: none; width: 100%; min-width: 0; max-width: none; height: 34px; padding: 0 28px 0 11px; border: 1px solid var(--site-edge, var(--line)); border-radius: 7px; background: var(--surface); color: var(--muted); font: inherit; font-size: 11px; text-overflow: ellipsis; cursor: pointer; }
#tag-bar .explore-inline-filter::after { content: ''; position: absolute; right: 12px; top: calc(50% - 4px); width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); pointer-events: none; }
#tag-bar .explore-inline-filter:has(.explore-filter-edit:not(.hidden)) select { padding-right: 70px; }
#tag-bar .explore-inline-filter.active select { border-color: color-mix(in srgb, var(--green) 40%, var(--line)); background: var(--green-pale); color: var(--green); }
#tag-bar .explore-filter-edit { position: absolute; right: 27px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 24px; min-height: 24px; padding: 2px 5px; border: 0; border-radius: 4px; color: var(--green); background: var(--green-pale); font-size: 10px; }
#tag-bar .explore-filter-edit[hidden] { display: none; }
#tag-bar > .tag-chip { width: 100%; min-width: 0; height: 34px; padding: 0 13px; font-size: 11px; }
#tag-bar > #filter-toggle { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-width: 0; min-height: 34px; height: 34px; padding: 0 11px; border: 1px solid var(--site-edge, var(--line)); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: 11px; white-space: nowrap; cursor: pointer; list-style: none; }
#tag-bar > #filter-toggle[aria-expanded="true"],
#tag-bar > #filter-toggle.active { background: var(--green-pale); color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
#tag-bar > #filter-toggle svg { width: 14px; height: 14px; }
#tag-bar .explore-inline-filter select:focus-visible,
#tag-bar > #filter-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
/* Custom ranges use compact, theme-aware dialogs with room for both bounds. */
dialog.explore-filter-dialog { width: 480px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 26px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--site-edge, var(--line)); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 70px color-mix(in srgb, var(--ink) 22%, transparent); }
dialog.explore-filter-dialog::backdrop { background: color-mix(in srgb, var(--ink) 35%, transparent); backdrop-filter: blur(4px); }
.dialog-body.explore-filter-dialog { padding: 28px; }
.explore-filter-dialog h2 { margin: 0 0 9px; color: var(--ink); font-size: 18px; font-weight: 550; }
.explore-filter-dialog > p, .explore-filter-dialog form > p { margin: 0 0 20px; color: var(--muted); font-size: 11px; line-height: 1.8; }
.explore-filter-dialog-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 13px; }
.explore-filter-dialog-fields > label { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; color: var(--muted); font-size: 11px; }
.explore-filter-dialog-fields input, .explore-filter-dialog-fields select { width: 100%; min-width: 0; height: 42px; padding: 9px 10px; border: 1px solid var(--site-edge, var(--line)); border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px; }
.explore-filter-dialog-fields input:focus, .explore-filter-dialog-fields select:focus { border-color: var(--green); outline-color: var(--green); }
.explore-filter-dialog-fields .explore-filter-wide, .explore-filter-dialog-fields > p, .explore-filter-dialog-fields > small { grid-column: 1 / -1; }
.explore-filter-dialog-fields > p, .explore-filter-dialog-fields > small { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.explore-filter-dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 19px; margin-top: 22px; border-top: 1px solid var(--line); }
.explore-filter-dialog-actions .button { min-height: 38px; padding: 9px 15px; font-size: 11px; }
.explore-filter-dialog-actions .text-button { margin-right: auto; font-size: 11px; }
.explore-filter-dialog [role="alert"]:empty { display: none; }
@media (max-width: 1350px) {
  .explore-toolbar > .view-controls > span { display: none; }
  #gallery-section #tag-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  #gallery-section .explore-toolbar { grid-template-columns: minmax(0, 1fr) auto; gap: 15px; padding-top: 0; }
  .explore-toolbar > .explore-search-form { grid-column: 1 / -1; grid-row: 1; }
  .explore-toolbar > .sort-tabs { min-height: 29px; }
  .explore-toolbar > .view-controls { justify-self: end; }
}
@media (max-width: 767px) {
  #gallery-section #tag-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  #gallery-section .explore-toolbar { gap: 12px 8px; padding-bottom: 12px; }
  .explore-toolbar > .sort-tabs { gap: 16px; }
  .explore-toolbar > .sort-tabs button { font-size: 10px; }
  .explore-toolbar > .sort-tabs button.active::after { bottom: -13px; }
  .explore-search-input { padding-left: 6px; gap: 7px; }
  .explore-search-input input { font-size: 12px; }
  .explore-search-field > .explore-search-submit { padding-inline: 10px; }
  .explore-search-main { gap: 7px; }
  .explore-search-main > .filter-button { padding-inline: 10px; font-size: 10px; }
  #gallery-section #filter-panel { padding: 16px; }
  #gallery-section #tag-bar { gap: 7px; padding: 13px 0 16px; }
  #tag-bar .explore-inline-filter select { padding-left: 9px; padding-right: 22px; font-size: 10px; }
  #tag-bar > .tag-chip, #tag-bar > #filter-toggle { font-size: 10px; padding-inline: 10px; }
  #filter-panel > label:not(.filter-tag-input) { grid-column: auto; }
  #filter-panel .metadata-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .explore-search-field { gap: 4px; }
  .explore-search-options-label { display: none; }
  .explore-search-popup { width: 238px; padding: 15px; }
  dialog.explore-filter-dialog { padding: 22px 18px; }
  .dialog-body.explore-filter-dialog { padding: 25px 20px; }
  .explore-filter-dialog-fields { gap: 13px 10px; }
  .explore-filter-dialog-fields input, .explore-filter-dialog-fields select { padding-inline: 9px; }
}
@media (max-width: 360px) {
  .explore-toolbar > .sort-tabs { gap: 10px; }
  .explore-toolbar > .view-controls { gap: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .explore-search-field, .explore-search-main > .filter-button { transition: none; }
}
