/* Final visual authority. Loaded last on purpose. */
body[data-theme="dim"] {
  color-scheme: dark;
  --bg: #071014;
  --bg-2: #0b171c;
  --surface: #101b21;
  --surface-rgb: 16, 27, 33;
  --surface-2: #15232b;
  --surface-3: #1d3039;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #f4f8fb;
  --muted: #a8bac8;
  --muted-2: #718492;
  --green: #29d391;
  --cyan: #38bdf8;
  --brand-grad: linear-gradient(135deg, #29d391, #38bdf8);
  --topbar-bg: rgba(10, 18, 23, 0.94);
  background: radial-gradient(circle at 90% 0%, rgba(56, 189, 248, 0.08), transparent 30vw), #071014 !important;
  color: var(--text) !important;
}

body:not([data-theme="dim"]) {
  color-scheme: light;
  --bg: #f3f6f8;
  --bg-2: #e8eef2;
  --surface: #ffffff;
  --surface-rgb: 255, 255, 255;
  --surface-2: #f7fafb;
  --surface-3: #eef3f6;
  --line: rgba(39, 56, 72, 0.12);
  --line-strong: rgba(39, 56, 72, 0.22);
  --text: #111827;
  --muted: #607080;
  --green: #10b981;
  --cyan: #0ea5e9;
  --brand-grad: linear-gradient(135deg, #16c784, #0ea5e9);
  background: radial-gradient(circle at 92% 0%, rgba(16, 185, 129, 0.1), transparent 32vw), var(--bg) !important;
}

body[data-theme="dim"] .topbar,
body[data-theme="dim"] .bottom-dock {
  background: var(--topbar-bg) !important;
  border-color: var(--line) !important;
}

body[data-theme="dim"] .brand strong {
  color: #f4f8fb !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
}

body[data-theme="dim"] .market-header {
  background: radial-gradient(circle at 14% 14%, rgba(56, 189, 248, 0.16), transparent 260px),
    radial-gradient(circle at 84% 22%, rgba(41, 211, 145, 0.16), transparent 300px),
    linear-gradient(135deg, #0b151b 0%, #12242b 52%, #081116 100%) !important;
  border-color: rgba(148, 163, 184, 0.2) !important;
}

body:not([data-theme="dim"]) .market-header {
  background: radial-gradient(circle at 14% 16%, rgba(14, 165, 233, 0.16), transparent 270px),
    radial-gradient(circle at 86% 22%, rgba(16, 185, 129, 0.18), transparent 270px),
    linear-gradient(135deg, #ffffff 0%, #f4faf9 58%, #eef5f9 100%) !important;
}

body[data-theme="dim"] .market-header h1 span,
body[data-theme="dim"] .market-header .desktop-title,
body[data-theme="dim"] .market-header .mobile-title {
  color: #f8fbff !important;
  -webkit-text-fill-color: #f8fbff !important;
}

body[data-theme="dim"] .market-header .subline {
  color: #a8bac8 !important;
}

.bg-icon-item {
  opacity: 0.78 !important;
  filter: none !important;
}

body[data-theme="dim"] .bg-icon-item {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

.service-choice img,
.mobile-service-tile img,
.product-category-row img,
.popular-chip img,
.market-category img {
  filter: none !important;
  background: #ffffff !important;
}

.topbar {
  min-height: 66px !important;
}

.icon-button,
.top-action-icon,
#themeToggle,
.profile-pill {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  border-radius: 13px !important;
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  box-shadow: none !important;
  transform: none !important;
}

.guest-register-btn {
  min-width: 120px !important;
  white-space: nowrap !important;
  background: var(--brand-grad) !important;
}

@media (min-width: 901px) {
  body[data-active-view="support"] main {
    width: 100% !important;
    max-width: none !important;
    min-height: calc(100dvh - 66px) !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body[data-active-view="support"] .dx-chat-layout {
    width: 100% !important;
    max-width: none !important;
    height: calc(100dvh - 66px) !important;
    min-height: calc(100dvh - 66px) !important;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    margin: 0 !important;
  }
}

body[data-theme="dim"][data-active-view="support"] .dx-chat-layout,
body[data-theme="dim"][data-active-view="support"] .dx-chat-sidebar,
body[data-theme="dim"][data-active-view="support"] .dx-chat-head,
body[data-theme="dim"][data-active-view="support"] .dx-chat-input-area,
body[data-theme="dim"][data-active-view="support"] .dx-message-top-tabs,
body[data-theme="dim"][data-active-view="support"] .dx-message-subtabs {
  background: #101b21 !important;
}

body[data-theme="dim"][data-active-view="support"] .dx-chat-main,
body[data-theme="dim"][data-active-view="support"] .dx-chat-messages,
body[data-theme="dim"][data-active-view="support"] .dx-message-list {
  background: radial-gradient(circle at 82% 0%, rgba(56, 189, 248, 0.08), transparent 360px), #15232b !important;
}

body[data-active-view="support"] .dx-message-top-tabs {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 6px !important;
  padding: 10px !important;
}

body[data-active-view="support"] .dx-message-top-tabs button {
  height: 36px !important;
  min-width: 0 !important;
  padding: 0 10px !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  border-radius: 10px !important;
}

body[data-theme="dim"][data-active-view="support"] .dx-message-top-tabs button,
body[data-theme="dim"][data-active-view="support"] .dx-message-subtabs button {
  background: #15232b !important;
  border-color: rgba(148, 163, 184, 0.18) !important;
  color: #a8bac8 !important;
}

body[data-theme="dim"][data-active-view="support"] .dx-message-top-tabs button.active,
body[data-theme="dim"][data-active-view="support"] .dx-message-subtabs button.active,
body[data-theme="dim"][data-active-view="support"] .dx-message-row.active {
  background: rgba(41, 211, 145, 0.16) !important;
  border-color: rgba(41, 211, 145, 0.46) !important;
  color: #29d391 !important;
}

@media (max-width: 900px) {
  .topbar {
    min-height: 62px !important;
  }

  .guest-register-btn {
    min-width: 0 !important;
  }

  body[data-active-view="support"] main {
    width: 100% !important;
    padding: 0 0 calc(76px + env(safe-area-inset-bottom)) !important;
  }

  body[data-active-view="support"] .dx-chat-layout {
    height: calc(100dvh - 62px - 76px - env(safe-area-inset-bottom)) !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
  }
}
