html.fm-lock,
html.fm-lock body {
  overflow: hidden;
}

.divar-item[hidden] {
  display: none !important;
}

.divar-item.fm-last {
  border-bottom: none;
}

.filter-btn {
  position: relative;
}

.fm-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.fm-badge[hidden],
.fm-reset-inline[hidden],
.fm-empty[hidden] {
  display: none;
}

.fm-reset-inline {
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
}

.fm-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}

.fm-empty-btn {
  margin-top: 12px;
  padding: 8px 18px;
  border: 1px solid var(--primary);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.fm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0);
  transition: background 0.25s ease;
}

.fm-overlay[hidden] {
  display: none;
}

.fm-overlay.show {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.fm-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--bg-card);
  color: var(--ink);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform 0.3s var(--ease);
}

.fm-overlay.show .fm-sheet {
  transform: translateY(0);
}

.fm-grabber {
  width: 40px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.fm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.fm-title {
  font-size: 16px;
  font-weight: 800;
}

.fm-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--ink-soft);
}

.fm-clear {
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 4px;
}

.fm-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}

.fm-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-soft);
}

.fm-section:last-child {
  border-bottom: none;
}

.fm-label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
}

.fm-select select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}

.fm-dual {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fm-dual input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
  text-align: center;
}

.fm-dual input::placeholder {
  color: var(--ink-faint);
}

.fm-dual input:focus,
.fm-select select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.fm-dual-sep {
  width: 10px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.fm-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}

.fm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: start;
}

.fm-list > :last-child {
  border-bottom: none;
}

.fm-acc {
  border-bottom: 1px solid var(--border-soft);
}

.fm-acc .fm-row {
  border-bottom: none;
}

.fm-switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex-shrink: 0;
}

.fm-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.fm-switch i {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: var(--border);
  transition: background 0.2s;
}

.fm-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease);
}

.fm-switch input:checked + i {
  background: var(--primary);
}

.fm-switch input:checked + i::after {
  transform: translateX(-18px);
}

.fm-acc-right {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-faint);
}

.fm-acc-right b {
  font-size: 12px;
  font-weight: 500;
}

.fm-acc-right svg {
  transition: transform 0.2s;
}

.fm-acc.open .fm-acc-right svg {
  transform: rotate(180deg);
}

.fm-acc-body {
  display: none;
  padding: 6px 20px 16px;
}

.fm-acc.open .fm-acc-body {
  display: block;
}

.fm-range {
  position: relative;
  height: 32px;
  direction: rtl;
}

.fm-range-track {
  position: absolute;
  top: 14px;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.fm-range-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: var(--primary);
}

.fm-range input[type="range"] {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.fm-range input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 32px;
}

.fm-range input[type="range"]::-moz-range-track {
  background: transparent;
  height: 32px;
}

.fm-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: 3px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: pointer;
}

.fm-range input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  cursor: pointer;
}

.fm-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 500;
}

.fm-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft);
  background: var(--bg-card);
  flex-shrink: 0;
}

.fm-submit {
  width: 100%;
  height: 52px;
  border-radius: var(--r-md);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-primary);
  transition: transform var(--t-fast);
}

.fm-submit:active {
  transform: scale(0.97);
}

@media (min-width: 640px) {
  .fm-overlay {
    align-items: center;
    padding: 16px;
  }

  .fm-sheet {
    max-height: 86vh;
    border-radius: 22px;
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s var(--ease), opacity 0.25s ease;
  }

  .fm-overlay.show .fm-sheet {
    transform: none;
    opacity: 1;
  }

  .fm-grabber {
    display: none;
  }
}