:root {
  --blue: #2f76e8;
  --blue-bg: #eaf2ff;
  --blue-mid: #dceaff;
  --text: #1f2329;
  --body: #4e5969;
  --muted: #86909c;
  --line: #e5e6eb;
  --page: #f5f7fa;
  --weak: #f2f3f5;
  --orange: #ff6a12;
  --green: #28a16a;
  --red: #d54941;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #eef1f5;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.builder-layout {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: start;
  padding: 16px;
}

.import-panel {
  position: fixed;
  top: 16px;
  right: calc(50% + 239px);
  z-index: 20;
  width: 286px;
  padding: 24px;
  border: 1px solid rgba(229, 230, 235, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 36px rgba(31, 35, 41, 0.07);
  transition: width 0.2s ease, padding 0.2s ease, border-color 0.16s, background 0.16s;
}

.import-panel.dragging {
  border-color: var(--blue);
  background: #f7faff;
}

.import-panel__content {
  opacity: 1;
  transition: opacity 0.12s ease;
}

.panel-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--weak);
  color: var(--body);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.panel-toggle__label {
  display: none;
  font-size: 13px;
  font-weight: 650;
}

.panel-toggle:hover {
  background: var(--blue-bg);
  color: var(--blue);
}

.import-panel.collapsed {
  width: 82px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
}

.import-panel.collapsed .import-panel__content {
  display: none;
  opacity: 0;
}

.import-panel.collapsed .panel-toggle {
  inset: 0;
  width: 100%;
  height: 100%;
  gap: 5px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 22px rgba(47, 118, 232, 0.24);
}

.import-panel.collapsed .panel-toggle:hover {
  background: #276bd7;
  color: #fff;
}

.import-panel.collapsed .panel-toggle__label {
  display: inline;
}

.import-panel__heading {
  margin-bottom: 22px;
  padding-right: 30px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.import-panel h1 {
  margin: 0 0 10px;
  font-size: 21px;
  line-height: 1.35;
}

.import-panel__heading p,
.drop-hint,
.file-name,
.privacy-note,
.import-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.upload-button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 11px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.upload-button:hover {
  background: #276bd7;
}

.upload-button:active {
  transform: translateY(1px);
}

.upload-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.upload-button__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 4px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  line-height: 1;
}

.drop-hint {
  margin-top: 9px;
  text-align: center;
}

.file-name {
  min-height: 21px;
  margin-top: 8px;
  overflow-wrap: anywhere;
  text-align: center;
}

.import-status {
  display: grid;
  grid-template-columns: 9px 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 20px;
  padding: 13px 14px;
  border-radius: 11px;
  background: var(--page);
}

.import-status strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--muted);
}

.status--loading .status-dot {
  background: var(--blue);
  animation: pulse 0.9s ease-in-out infinite alternate;
}

.status--success .status-dot {
  background: var(--green);
}

.status--warning .status-dot {
  background: var(--orange);
}

.status--error .status-dot {
  background: var(--red);
}

@keyframes pulse {
  to { opacity: 0.35; }
}

.config-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.config-summary[hidden] {
  display: none;
}

.config-summary div {
  padding: 10px;
  border-radius: 10px;
  background: #f7f8fa;
}

.config-summary strong,
.config-summary span {
  display: block;
}

.config-summary strong {
  margin-bottom: 2px;
  font-size: 17px;
}

.config-summary span {
  color: var(--muted);
  font-size: 12px;
}

.warning-panel {
  margin-top: 12px;
  border: 1px solid #ffd9c4;
  border-radius: 10px;
  background: #fff9f5;
  color: var(--body);
  font-size: 12px;
}

.warning-panel summary {
  padding: 10px 12px;
  cursor: pointer;
  color: #b8480c;
  font-weight: 650;
}

.warning-panel ul {
  max-height: 180px;
  margin: 0;
  padding: 0 12px 12px 29px;
  overflow: auto;
  line-height: 1.55;
}

.warning-panel li + li {
  margin-top: 6px;
}

.privacy-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.preview-stage {
  position: relative;
  width: min(100%, 430px);
}

.preview-zoom {
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid rgba(229, 230, 235, 0.95);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(31, 35, 41, 0.09);
  white-space: nowrap;
}

.preview-zoom__button,
.preview-zoom__reset {
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--body);
  cursor: pointer;
}

.preview-zoom__button {
  width: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.preview-zoom__reset {
  padding: 0 9px;
  font-size: 13px;
}

.preview-zoom__button:hover,
.preview-zoom__reset:hover:not(:disabled) {
  background: var(--blue-bg);
  color: var(--blue);
}

.preview-zoom__button:disabled,
.preview-zoom__reset:disabled {
  color: #c9cdd4;
  cursor: default;
}

.preview-zoom__value {
  width: 48px;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.phone-viewport {
  position: relative;
  width: 100%;
  height: min(844px, calc(100dvh - 32px));
  min-height: 620px;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 0 26px rgba(0, 0, 0, 0.09);
}

.phone-shell {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 48px 50px 42px minmax(0, 1fr) auto auto;
  overflow: hidden;
  background: #fff;
  transform-origin: top left;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  font-size: 16px;
  font-weight: 650;
}

.icon-button {
  min-width: 32px;
  height: 38px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--body);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.more-button {
  font-size: 16px;
  letter-spacing: 1px;
}

.channel-tabs {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 0 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #fff;
  scrollbar-width: none;
  white-space: nowrap;
}

.channel-tabs::-webkit-scrollbar {
  display: none;
}

.channel-tab {
  position: relative;
  height: 50px;
  flex: 0 0 auto;
  padding: 16px 0 12px;
  border: 0;
  background: transparent;
  color: var(--body);
  cursor: pointer;
  font-size: 14px;
}

.channel-tab.active {
  color: var(--text);
  font-weight: 700;
}

.channel-tab.active::after {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 28px;
  height: 3px;
  border-radius: 4px;
  background: var(--blue);
  content: "";
  transform: translateX(-50%);
}

.filter-toolbar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.toolbar-tools {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 14px;
}

.filter-label {
  color: var(--blue);
  font-weight: 650;
}

.filter-dot {
  display: none;
  width: 6px;
  height: 6px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--blue);
  vertical-align: 2px;
}

.filter-dot.show {
  display: inline-block;
}

.sort-label {
  color: var(--body);
}

.sort-label i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.filter-main {
  min-height: 0;
  display: flex;
  background: #fff;
}

.category-nav {
  width: 92px;
  flex: 0 0 92px;
  padding-top: 2px;
  background: var(--page);
}

.nav-item {
  position: relative;
  width: 100%;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 0 13px;
  border: 0;
  background: transparent;
  color: var(--body);
  cursor: pointer;
  text-align: left;
  font-size: 14px;
}

.nav-item.active {
  background: #fff;
  color: var(--blue);
  font-weight: 650;
}

.nav-item.active::after {
  position: absolute;
  top: 16px;
  right: 0;
  width: 3px;
  height: 26px;
  border-radius: 3px;
  background: var(--blue);
  content: "";
}

.nav-dot {
  display: none;
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--blue);
}

.nav-item.has-selection .nav-dot {
  display: block;
}

.filter-content {
  min-width: 0;
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px 32px;
  background: #fff;
  scrollbar-color: #f2f3f5 transparent;
  scrollbar-width: thin;
}

.filter-content::-webkit-scrollbar,
.selected-area::-webkit-scrollbar {
  width: 5px;
}

.filter-content::-webkit-scrollbar-track,
.selected-area::-webkit-scrollbar-track {
  background: transparent;
}

.filter-content::-webkit-scrollbar-thumb,
.selected-area::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #f2f3f5;
}

.filter-group {
  margin-bottom: 31px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.group-heading,
.subgroup-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.group-heading {
  margin-bottom: 16px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 24px;
}

.filter-subgroup {
  margin-bottom: 24px;
}

.filter-subgroup:last-child {
  margin-bottom: 0;
}

.subgroup-title {
  margin-bottom: 12px;
  color: var(--body);
  font-size: 15px;
  font-weight: 650;
  line-height: 21px;
}

.business-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 20px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 8px;
  align-items: stretch;
}

.option-button {
  position: relative;
  min-width: 0;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 5px;
  border: 0;
  border-radius: 8px;
  background: var(--weak);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-align: center;
}

.option-button.full-row {
  grid-column: 1 / -1;
}

.option-item-tag {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  max-width: 50%;
  height: 24px;
  padding: 0 6px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #fa670d;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.option-button.has-option-tag .option-name,
.option-button.has-option-tag .option-description {
  overflow: hidden;
  text-overflow: ellipsis;
}

.option-button.has-option-tag .option-name {
  transform: translateX(var(--option-title-shift, 0));
  transition: transform 160ms ease;
}

.secondary-filter-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 8px;
}

.filter-subgroup--cascade {
  margin-top: 0;
}

.cascade-filter {
  padding: 0;
}

.cascade-level + .cascade-level {
  margin-top: 24px;
}

.cascade-level.cascade-level--required .subgroup-title {
  color: #f53f3f;
}

.cascade-range {
  margin-top: 18px;
  padding: 16px 12px 12px;
  border-radius: 8px;
  background: var(--weak);
}

.cascade-range__track {
  position: relative;
  height: 24px;
}

.cascade-range__track::before,
.cascade-range__fill {
  position: absolute;
  top: 10px;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 999px;
  content: "";
}

.cascade-range__track::before {
  background: #dfe3ea;
}

.cascade-range__fill {
  right: calc(100% - var(--range-end));
  left: var(--range-start);
  background: var(--blue);
}

.cascade-range__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  pointer-events: none;
}

.cascade-range__input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.cascade-range__input::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 3px solid #d9dee8;
  border-radius: 50%;
  appearance: none;
  background:
    linear-gradient(#c5cbd5, #c5cbd5) center 7px / 8px 2px no-repeat,
    linear-gradient(#c5cbd5, #c5cbd5) center 11px / 8px 2px no-repeat,
    #fff;
  box-shadow: 0 1px 3px rgb(38 50 71 / 18%);
  pointer-events: auto;
}

.cascade-range__input::-moz-range-track {
  height: 4px;
  background: transparent;
}

.cascade-range__input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid #d9dee8;
  border-radius: 50%;
  background:
    linear-gradient(#c5cbd5, #c5cbd5) center 5px / 8px 2px no-repeat,
    linear-gradient(#c5cbd5, #c5cbd5) center 9px / 8px 2px no-repeat,
    #fff;
  box-shadow: 0 1px 3px rgb(38 50 71 / 18%);
  pointer-events: auto;
}

.cascade-range__input--min {
  z-index: 2;
}

.cascade-range__input--max {
  z-index: 3;
}

.cascade-range__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}

.option-button:active {
  transform: scale(0.985);
}

.option-button.selected {
  background: var(--blue-mid);
}

.option-name,
.option-description {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  text-align: center;
}

.option-name {
  color: var(--text);
  font-size: 15px;
  line-height: 20px;
}

.option-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: -0.08px;
}

.option-button.selected .option-name {
  color: var(--blue);
  font-weight: 650;
}

.search-box {
  grid-column: 1 / -1;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: var(--weak);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.search-icon {
  position: relative;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  border: 1.8px solid var(--muted);
  border-radius: 50%;
}

.search-icon::after {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 6px;
  height: 1.8px;
  border-radius: 2px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
  transform-origin: center;
}

.search-placeholder {
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  padding: 46px 12px 20px;
  text-align: center;
}

.empty-state__title,
.empty-state__text {
  display: block;
}

.empty-state__title {
  color: var(--body);
  font-size: 14px;
  font-weight: 600;
}

.empty-state__text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.selected-area {
  display: none;
  max-height: 118px;
  overflow: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
  scrollbar-color: #f2f3f5 transparent;
  scrollbar-width: thin;
}

.selected-area.show {
  display: block;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-tag {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 10px;
  border-radius: 7px;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 13px;
}

.tag-remove {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.bottom-actions {
  min-height: 72px;
  display: flex;
  gap: 12px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}

.reset-button,
.confirm-button {
  height: 48px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
}

.reset-button {
  width: 82px;
  flex: 0 0 82px;
  background: var(--weak);
  color: var(--text);
}

.confirm-button {
  min-width: 0;
  flex: 1;
  padding: 0 8px;
  background: var(--blue);
  color: #fff;
}

.toast {
  position: absolute;
  top: 58px;
  left: 50%;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(31, 35, 41, 0.88);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: 0.18s;
  font-size: 13px;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

@media (max-width: 1080px) {
  .import-panel {
    right: auto;
    left: 16px;
  }
}

@media (max-width: 780px) {
  body {
    background: #fff;
  }

  .builder-layout {
    padding: 0;
  }

  .import-panel {
    top: 12px;
    right: auto;
    left: 12px;
    width: min(286px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .import-panel.collapsed {
    width: 82px;
    overflow: hidden;
  }

  .preview-stage {
    width: min(100%, 430px);
  }

  .preview-zoom {
    position: fixed;
    top: 12px;
    right: 12px;
    left: auto;
    z-index: 15;
  }

  .phone-viewport {
    height: 100dvh;
    min-height: 620px;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 380px) {
  .category-nav {
    width: 88px;
    flex-basis: 88px;
  }

  .filter-content {
    padding-right: 10px;
    padding-left: 10px;
  }

  .option-button {
    padding-right: 3px;
    padding-left: 3px;
  }

  .option-name {
    font-size: 14px;
  }

  .option-description {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
