/* Custom Scanner — desktop 3-column workbench + mobile tabs */

.cs-custom-scanner .cs-builder {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Mobile step tabs ───────────────────────────────────────────────────── */
.cs-mobile-tabs {
  display: none;
  gap: 0.35rem;
  padding: 0.25rem;
  background: #f1f5f9;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.cs-mobile-tabs__btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0.55rem 0.5rem;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.cs-mobile-tabs__btn.active {
  background: #fff;
  color: var(--primary-deep);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.cs-mobile-bar {
  display: none;
  position: sticky;
  bottom: 0.5rem;
  z-index: 20;
  gap: 0.5rem;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(8px);
}
.cs-mobile-bar .cs-btn { flex: 1; justify-content: center; }

/* ── Workbench ──────────────────────────────────────────────────────────── */
.cs-workbench {
  display: grid;
  gap: 0;
  align-items: stretch;
  grid-template-columns: minmax(11.5rem, 16%) minmax(0, 1fr) minmax(13rem, 24%);
  grid-template-rows: minmax(0, 1fr);
  height: clamp(16rem, 40vh, 22rem);
  padding: 0;
  overflow: hidden;
}
.cs-workbench > .cs-panel {
  min-height: 0;
  max-height: 100%;
}

.cs-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  padding: 0.85rem 0.9rem;
  overflow: hidden;
  border-right: 1px solid #eef2f7;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.cs-panel:last-child { border-right: none; }

.cs-panel__head {
  flex: 0 0 auto;
  margin-bottom: 0.5rem;
}
.cs-panel__body {
  flex: 1 1 0;
  height: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.25rem;
  margin-right: -0.1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #f1f5f9;
}
.cs-panel__body::-webkit-scrollbar { width: 6px; }
.cs-panel__body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}
.cs-panel__body::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
}
.cs-panel__foot {
  flex: 0 0 auto;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
}

.cs-section__title {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #334155;
  margin: 0;
}
.cs-section__hint {
  font-size: 0.72rem;
  color: #64748b;
  margin: 0.25rem 0 0;
  line-height: 1.4;
}
.cs-subsection__title {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 0.35rem;
}
.cs-filters-block + .cs-filters-block {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid #f1f5f9;
}
.cs-filters-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.35rem;
}
.cs-filters-head .cs-subsection__title { margin: 0; }
.cs-filters-head .cs-search { width: min(100%, 12rem); }

/* ── Universe ───────────────────────────────────────────────────────────── */
.cs-universe-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.cs-universe-card {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cs-universe-card:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft-bg);
}
.cs-universe-card--active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #eef2ff, #f8f7ff);
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.2);
}
.cs-universe-card__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: #0f172a;
}
.cs-universe-card__desc {
  display: block;
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 0.08rem;
  line-height: 1.35;
}

/* ── Presets & filter chips ─────────────────────────────────────────────── */
.cs-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.cs-preset-chip {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--primary-border);
  background: #fff;
  color: var(--primary-deep);
  cursor: pointer;
}
.cs-preset-chip:hover { background: var(--primary-soft-bg); }

.cs-search {
  width: 100%;
  padding: 0.42rem 0.6rem;
  border-radius: 9px;
  border: 1px solid #e2e8f0;
  font-size: 0.78rem;
  background: #fff;
}
.cs-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.cs-field-group {
  border: none;
  margin-bottom: 0.35rem;
  background: #f8fafc;
  border-radius: 10px;
  padding: 0.3rem 0.55rem 0.45rem;
}
.cs-field-group__title {
  font-size: 0.68rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
}
.cs-field-group__title::-webkit-details-marker { display: none; }
.cs-field-group__count {
  font-size: 0.6rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #64748b;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
}
.cs-field-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.25rem 0 0.15rem;
}
.cs-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.28rem 0.5rem;
  border-radius: 7px;
  border: 1px dashed #c7d2fe;
  background: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--primary-deep);
  cursor: grab;
}
.cs-field-chip:hover {
  background: #eef2ff;
  border-style: solid;
}
.cs-field-chip--dragging { opacity: 0.5; }
.cs-field-chip__unit {
  font-size: 0.56rem;
  font-weight: 600;
  color: #94a3b8;
}

/* ── Rules ──────────────────────────────────────────────────────────────── */
.cs-rules-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.cs-rules-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-shrink: 0;
}
.cs-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.42rem 0.85rem;
  border-radius: 10px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  white-space: nowrap;
}
.cs-btn--primary {
  background: var(--primary-gradient-fill);
  color: #fff;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.3);
}
.cs-btn--primary:disabled { opacity: 0.6; cursor: wait; }
.cs-btn--ghost {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #475569;
}
.cs-save-status {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  font-weight: 700;
  color: #059669;
}
.cs-save-status--error { color: #dc2626; }

.cs-dropzone {
  min-height: 4.5rem;
  border: 1.5px dashed #cbd5e1;
  border-radius: 12px;
  padding: 0.55rem;
  background: #fafbfc;
}
.cs-dropzone--active {
  border-color: var(--primary);
  background: #eef2ff;
}
.cs-dropzone[data-empty="true"] .cs-rules-list:empty + .cs-dropzone__placeholder,
.cs-dropzone[data-empty="true"] .cs-dropzone__placeholder:not(.cs-is-hidden) { display: block; }
.cs-dropzone__placeholder {
  text-align: center;
  padding: 0.65rem 0.4rem;
  color: #64748b;
  font-size: 0.78rem;
}
.cs-dropzone__placeholder.cs-is-hidden { display: none; }
.cs-dropzone__sub { font-size: 0.68rem; margin-top: 0.25rem; color: #94a3b8; }
.cs-dropzone__cta { margin-top: 0.65rem; width: 100%; justify-content: center; }

.cs-only-mobile { display: none; }
.cs-only-desktop { display: block; }

.cs-rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.cs-rule-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: start;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: grab;
}
.cs-rule-card--dragging { opacity: 0.55; }
.cs-rule-card__drag {
  color: #cbd5e1;
  font-size: 0.9rem;
  padding-top: 0.1rem;
  cursor: grab;
}
.cs-rule-card__field {
  font-size: 0.76rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.3rem;
}
.cs-rule-card__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.cs-rule-op, .cs-rule-input, .cs-select {
  font-size: 0.74rem;
  padding: 0.32rem 0.45rem;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
  background: #fff;
  max-width: 100%;
}
.cs-rule-input--num { width: 4rem; }
.cs-rule-and { font-size: 0.68rem; color: #94a3b8; font-weight: 600; }
.cs-rule-card__hint { font-size: 0.62rem; color: #94a3b8; margin-top: 0.2rem; }
.cs-rule-remove {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  font-weight: 700;
}
.cs-enum-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
}
.cs-enum-check {
  font-size: 0.68rem;
  font-weight: 600;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.cs-sort-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.cs-sort-label { font-size: 0.68rem; font-weight: 700; color: #64748b; }
.cs-select--narrow { width: auto; }

/* ── Results ────────────────────────────────────────────────────────────── */
.cs-results { padding: 1rem 1.1rem; }
.cs-results-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.cs-results-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary-deep);
  background: var(--primary-soft-bg);
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
}
.cs-results-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: #64748b;
  font-size: 0.88rem;
}
.cs-results-empty__sub { font-size: 0.76rem; margin-top: 0.3rem; color: #94a3b8; }
.cs-results-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.75rem;
  color: #64748b;
  font-size: 0.84rem;
  font-weight: 600;
}
.cs-results-loading.cs-is-hidden { display: none; }
.cs-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: cs-spin 0.7s linear infinite;
}
@keyframes cs-spin { to { transform: rotate(360deg); } }

.cs-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cs-table-wrap.cs-is-hidden { display: none; }
.cs-table {
  width: 100%;
  min-width: 32rem;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cs-table th {
  text-align: left;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}
.cs-table td {
  padding: 0.55rem;
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}
.cs-row { cursor: pointer; }
.cs-row:hover { background: #f8fafc; }
.cs-row__rank { font-weight: 800; color: #94a3b8; width: 1.75rem; }
.cs-row__sym { min-width: 7rem; }
.cs-row__ticker { display: block; font-weight: 900; color: #0f172a; }
.cs-row__name {
  display: block;
  font-size: 0.65rem;
  color: #94a3b8;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-row__link {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.cs-pill {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
}
.cs-pill--score { background: #eef2ff; color: var(--primary-deep); }
.cs-pill--signal { background: #f0fdf4; color: #15803d; }

.cs-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
}
.cs-page-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cs-page-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.cs-page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.cs-page-info {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  text-align: center;
}

.cs-custom-scanner .cs-is-hidden { display: none !important; }

/* ── SEO content (below builder) ─────────────────────────────────────────── */
.cs-seo-section { margin-top: 0.25rem; }
.cs-seo-grid {
  display: grid;
  gap: 1rem;
  margin-top: 0.75rem;
}
@media (min-width: 768px) {
  .cs-seo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cs-seo-grid__title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.35rem;
}
.cs-seo-grid__text {
  font-size: 0.78rem;
  line-height: 1.55;
  color: #64748b;
  margin: 0;
}
.cs-seo-faq {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.cs-seo-faq__item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  background: #fff;
}
.cs-seo-faq__q {
  font-size: 0.8rem;
  font-weight: 800;
  color: #0f172a;
  cursor: pointer;
}
.cs-seo-faq__a {
  font-size: 0.78rem;
  line-height: 1.55;
  color: #64748b;
  margin: 0.5rem 0 0;
}
.cs-seo-related {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}
@media (min-width: 640px) {
  .cs-seo-related { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .cs-seo-related { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.cs-seo-related__card {
  display: block;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.cs-seo-related__card:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft-bg);
}
.cs-seo-related__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  color: #0f172a;
}
.cs-seo-related__desc {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.2rem;
  line-height: 1.45;
}
.cs-seo-noscript {
  font-size: 0.8rem;
  line-height: 1.55;
  color: #64748b;
  margin: 0.5rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  .cs-mobile-tabs { display: flex; }
  .cs-mobile-bar { display: flex; }

  .cs-workbench {
    display: block;
    height: auto;
    overflow: visible;
    padding: 0;
    background: #fff;
  }

  .cs-panel {
    display: none;
    height: clamp(14rem, 42vh, 20rem);
    max-height: clamp(14rem, 42vh, 20rem);
    border-right: none;
    padding: 0.85rem;
  }
  .cs-panel.is-active { display: flex; }

  .cs-panel__body {
    flex: 1 1 0;
    height: 0;
    min-height: 0;
    overflow-y: auto;
  }

  .cs-rules-actions--desktop { display: none; }

  .cs-only-desktop { display: none !important; }
  .cs-only-mobile { display: block; }
  .cs-filters-head .cs-only-mobile.cs-subsection__title { display: block; }

  .cs-field-chip {
    cursor: pointer;
    border-style: solid;
    border-color: #a5b4fc;
    padding-right: 0.65rem;
  }
  .cs-field-chip::after {
    content: '+';
    font-size: 0.72rem;
    font-weight: 900;
    color: var(--primary);
    margin-left: 0.15rem;
  }
  .cs-rule-card { cursor: default; grid-template-columns: 1fr auto; }
  .cs-rule-card__drag { display: none; }
  .cs-dropzone {
    border-style: solid;
    border-color: #e2e8f0;
    background: #f8fafc;
  }

  .cs-page .page-hero__sub { font-size: 0.82rem; }
  .cs-builder { padding-bottom: 0.25rem; }
}

@media (max-width: 639px) {
  .cs-hide-sm { display: none; }
  .cs-panel {
    height: clamp(13rem, 40vh, 18rem);
    max-height: clamp(13rem, 40vh, 18rem);
  }
  .cs-rule-card__controls { flex-direction: column; align-items: stretch; }
  .cs-rule-op, .cs-rule-input, .cs-select { width: 100%; }
}

/* ── Desktop polish ─────────────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .cs-mobile-tabs,
  .cs-mobile-bar { display: none !important; }

  .cs-panel--rules { border-left: 1px solid #eef2f7; border-right: 1px solid #eef2f7; }
}
