/* Saved combinations share the ranking panel; mobile keeps the natural flow. */
.rank-filter-side { display: contents; }
.rank-refined .table-head .rank-filter-presets { order: 4; min-width: 0; max-width: 100%; padding: 0; }
.rank-filter-presets-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.rank-filter-presets-head button { min-height: 28px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text); box-shadow: none; font-size: 11px; }
.rank-filter-presets-head button[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.rank-filter-preset-list { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; min-width: 0; }
.rank-filter-preset-chip { position: relative; display: inline-flex; min-width: 0; max-width: 100%; }
.rank-filter-preset-list [data-rank-filter-preset], #rankPresetPreview { min-height: 34px; max-width: 100%; padding: 6px 12px; border: 1px solid var(--preset-color); border-radius: 8px; background: var(--preset-color); color: var(--preset-ink); font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; white-space: normal; box-shadow: none; user-select: none; -webkit-user-select: none; }
.rank-filter-preset-list [data-rank-filter-preset][aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
.rank-filter-preset-list button:focus-visible, .rank-filter-presets-head button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.rank-filter-preset-list.is-editing .rank-filter-preset-chip { touch-action: none; }
.rank-filter-preset-list.is-editing [data-rank-filter-preset] { padding-right: 29px; cursor: grab; }
.rank-filter-preset-chip.is-dragging { opacity: .6; outline: 2px dashed var(--primary); border-radius: 8px; }
.rank-filter-preset-chip.is-drop-target { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 8px; }
.rank-filter-preset-list [data-remove-filter-preset] { position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; min-height: 20px; padding: 0; display: inline-grid; place-items: center; border: 1px solid color-mix(in srgb, var(--preset-ink) 35%, transparent); border-radius: 50%; color: var(--preset-ink); background: color-mix(in srgb, var(--preset-color) 72%, #000 28%); box-shadow: 0 1px 2px #0003; line-height: 1; }
.rank-filter-preset-list [data-remove-filter-preset] svg { display: block; width: 10px; height: 10px; }
.rank-filter-preset-list [data-remove-filter-preset]:hover, .rank-filter-preset-list [data-remove-filter-preset]:focus-visible { color: var(--danger-text, #ef4444); background: color-mix(in srgb, var(--preset-color) 56%, #fff 44%); }
.rank-preset-search-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rank-preset-search-row input { flex: 1 1 auto; min-width: 0; }
.search-regex-toggle { flex: 0 0 auto; width: 40px; height: 36px; min-height: 36px; padding: 0; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; box-shadow: none; }
.search-regex-toggle:hover { color: var(--primary); }
.search-regex-toggle[aria-pressed="true"] { border-color: var(--primary); background: rgba(var(--primary-rgb), .14); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), .22); }
.market-search-field > .search-regex-status { position: absolute; left: 12px; top: calc(100% + 3px); z-index: 3; max-width: calc(100% - 24px); margin: 0; pointer-events: none; }
.rank-preset-search-label { position: relative; }
.search-regex-status { display: block; min-height: 0; margin-top: 4px; color: var(--danger-text); font-size: 11px; line-height: 1.4; }
.search-regex-status:empty { display: none; }
#addRankFilterPresetBtn { display: inline-grid; place-items: center; width: 34px; height: 34px; min-height: 34px; padding: 0; border: 1px dashed var(--primary); border-radius: 8px; background: transparent; color: var(--primary); font-size: 23px; line-height: 1; box-shadow: none; }
.rank-filter-preset-hint { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.rank-filter-preset-hint:empty { display: none; }
#rankFilterPresetModal { z-index: 190; }
.rank-filter-preset-panel { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); }
.rank-filter-preset-panel .window-close { width: 30px; height: 30px; min-height: 30px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); }
.rank-filter-preset-panel .window-close:hover, .rank-filter-preset-panel .window-close:focus-visible { border-color: rgba(var(--danger-rgb), .45); background: rgba(var(--danger-rgb), .1); color: var(--danger); }
.rank-preset-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rank-preset-fields > label { display: grid; gap: 6px; min-width: 0; color: var(--text-soft); font-size: 12px; }
.rank-preset-fields :is(input, select) { width: 100%; min-width: 0; }
.rank-preset-color-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-preset-color-row input[type="color"] { flex: 0 0 48px; width: 48px; height: 40px; padding: 3px; cursor: pointer; }
#rankPresetPreview { display: inline-block; min-width: 0; }
.rank-preset-conditions { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 10px 16px; }
.rank-preset-conditions legend { color: var(--muted); font-size: 12px; padding: 0 5px; }
.rank-preset-conditions label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.rank-preset-conditions input { width: 16px; height: 16px; margin: 0; }
.rank-preset-notes { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 10px 0; }
#rankPresetFormError { color: var(--danger-text); font-size: 12px; line-height: 1.6; }
#rankPresetFormError:empty { display: none; }
.rank-preset-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
#rankPresetUseCurrentBtn { margin-right: auto; }
@media (min-width: 1100px) {
  .rank-refined .table-head:has(#rankFilterPresets:not(.hidden)) { grid-template-areas: "models side" "platforms side" "presets side" "active side" "quick quick"; grid-template-rows: min-content min-content min-content 1fr auto; }
  .rank-refined .table-head:has(#rankFilterPresets:not(.hidden)):has(.advanced-filters:not(.hidden)) { grid-template-areas: "models side" "platforms side" "presets side" "active side" "advanced advanced" "quick quick"; grid-template-rows: min-content min-content min-content 1fr auto auto; }
  .rank-refined .table-head:has(#rankFilterPresets:not(.hidden)) .active-filter-row { align-self: start; }
  .rank-refined .table-head .rank-filter-side:has(#rankFilterPresets:not(.hidden)) { grid-area: side; display: flex; flex-direction: column; gap: 12px; align-self: start; min-width: 0; }
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) > * { width: 100%; min-width: 0; }
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) .primary-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) .market-search-field { grid-column: auto; width: 100%; }
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) .primary-filters .model-filter-control { width: 100%; justify-self: stretch; }
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) .primary-filter-actions { grid-column: auto; }
}
@media (min-width: 1600px) {
  .rank-refined .rank-filter-side:has(#rankFilterPresets:not(.hidden)) .primary-filters { grid-template-columns: minmax(0, 1fr) 180px 128px 162px; justify-content: stretch; }
}
@media (max-width: 640px) {
  .rank-refined .table-head .rank-filter-presets { width: 100%; }
  .rank-filter-preset-list { gap: 8px; }
  .rank-filter-preset-panel { padding: 16px; }
  .rank-preset-fields { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .rank-preset-actions button { min-width: 0; padding-inline: 10px; }
}
