body.is-mobile {
  --mobile-topbar-height: 44px;
  --mobile-tabbar-height: calc(70px + env(safe-area-inset-bottom, 0px));
  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 6px;
}

.mobile-topbar-brand,
.login-landing__mobile-brand {
  display: none;
}

body.is-mobile .sidebar {
  display: none;
}

body.is-mobile .main {
  width: 100%;
}

body.is-mobile .content {
  padding: 14px 14px calc(18px + var(--mobile-tabbar-height));
}

body.is-mobile .topbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  height: var(--mobile-topbar-height);
  padding: 0 8px;
  position: sticky;
  top: 0;
  z-index: 1305;
  border-bottom: 1px solid var(--border);
  background: rgba(42, 40, 37, 0.94);
  backdrop-filter: blur(14px);
}

body[data-theme='light'].is-mobile .topbar {
  background: rgba(252, 249, 245, 0.96);
}

body.is-mobile .topbar > :not(.page-title):not(.mobile-topbar-btn):not(.mobile-topbar-actions) {
  display: none !important;
}

body.is-mobile .mobile-topbar-brand {
  display: none;
}

body.is-mobile .page-title {
  grid-column: 2;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: center;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-topbar-btn {
  display: none;
}

body.is-mobile .mobile-topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 18px;
}

body.is-mobile .mobile-topbar-btn:hover,
body.is-mobile .mobile-topbar-btn:focus-visible {
  border-color: var(--border);
  background: var(--bg3);
  color: var(--text);
  outline: none;
}

body.is-mobile .mobile-topbar-btn--lead {
  grid-column: 1;
}

body.is-mobile .mobile-topbar-btn--trail {
  grid-column: 3;
}

.mobile-topbar-actions {
  position: absolute;
  top: calc(100% + 8px);
  right: 12px;
  width: min(240px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg2);
  box-shadow: var(--overlay-panel-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1308;
}

.mobile-topbar-actions.hidden {
  display: none;
}

.mobile-topbar-theme-group {
  display: grid;
  gap: 6px;
}

.mobile-topbar-theme-label {
  color: var(--text2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.mobile-topbar-theme-group .theme-dropdown {
  width: 100%;
}

.mobile-topbar-theme-group .theme-dropdown-trigger {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-color: var(--border);
  border-radius: 12px;
  background: var(--bg3);
  font-size: 13px;
}

.mobile-topbar-theme-group .theme-dropdown-menu {
  left: 0;
  right: 0;
  min-width: 0;
}

.mobile-topbar-theme-group .theme-dropdown-option {
  padding: 10px 12px;
}

.mobile-topbar-theme-group .theme-dropdown-option-title {
  font-size: 13px;
}

.mobile-topbar-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.mobile-topbar-action span {
  font-size: 12px;
  font-weight: 500;
}

.mobile-topbar-action:hover,
.mobile-topbar-action:focus-visible {
  border-color: var(--brand-border);
  background: var(--bg4);
  outline: none;
}

.mobile-tab-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1304;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: rgba(42, 40, 37, 0.94);
  backdrop-filter: blur(14px);
  transition: opacity .18s ease, transform .18s ease;
}

body[data-theme='light'].is-mobile .mobile-tab-bar {
  background: rgba(255, 255, 255, 0.96);
}

.mobile-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 56px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font: inherit;
}

.mobile-tab-btn.is-active {
  color: var(--text);
  background: var(--brand-soft);
}

.mobile-tab-icon {
  font-size: 20px;
}

.mobile-tab-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: currentColor;
}

.mobile-more-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1310;
  background: rgba(30, 30, 30, 0.24);
  backdrop-filter: blur(5px);
}

.mobile-more-backdrop.hidden {
  display: none;
}

.mobile-more-drawer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1311;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(78vh, 720px);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  background: var(--bg2);
  box-shadow: 0 -10px 32px rgba(30, 30, 30, 0.12);
  overflow-y: auto;
}

.mobile-more-drawer.hidden {
  display: none;
}

.mobile-more-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mobile-more-drawer__eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
}

.mobile-more-drawer__title {
  margin-top: 4px;
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.mobile-more-list,
.mobile-more-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-more-section {
  padding: 6px 4px 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
}

.mobile-more-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg3);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.mobile-more-row-copy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mobile-more-row-copy span {
  font-size: 13px;
  font-weight: 600;
}

.mobile-more-row--danger {
  color: var(--red);
}

body.is-mobile .login-landing {
  padding: 0;
}

body.is-mobile .login-landing__panel {
  width: 100%;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

body.is-mobile .login-landing__brand {
  display: none;
}

body.is-mobile .login-landing__mobile-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}

body.is-mobile .login-landing__mobile-logo {
  display: block;
  width: min(240px, 72vw);
  max-width: 100%;
  height: auto;
}

body.is-mobile .login-landing__mobile-sub {
  font-family: var(--font-brand);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: .18em;
  line-height: 1;
  color: var(--text);
  text-align: center;
}

body[data-theme='light'].is-mobile .login-landing__mobile-sub {
  color: var(--text);
}

body.is-mobile .login-landing__mobile-note {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 10px;
  letter-spacing: .7px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  text-align: center;
}

body[data-theme='light'].is-mobile .login-landing__mobile-note {
  background: var(--bg3);
  color: var(--text2);
}

body.is-mobile .login-landing__card {
  min-height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
}

body[data-theme='light'].is-mobile .login-landing__card {
  background: var(--bg);
}

body.is-mobile .login-landing__card .fi,
body.is-mobile .login-landing__submit {
  min-height: 44px;
}

body.is-mobile .login-landing__card .fi,
body.is-mobile .auth-modal .fi {
  font-size: 16px;
  line-height: 1.45;
}

body.is-mobile .login-landing__actions {
  margin-top: 20px;
}

body.is-mobile .fi,
body.is-mobile .btn,
body.is-mobile .combo-toggle,
body.is-mobile .map-sector-action,
body.is-mobile .ai-chat-send {
  min-height: 44px;
}

body.is-mobile .g2,
body.is-mobile .g4 {
  grid-template-columns: minmax(0, 1fr);
}

body.is-mobile #page-progress .g4,
body.is-mobile #page-dashboard #dashHero {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.is-mobile .progress-column-stack {
  gap: 12px;
}

body.is-mobile .progress-sector-row {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 0;
}

body.is-mobile .progress-sector-breakdown {
  gap: 6px;
}

body.is-mobile .progress-sector-chip {
  max-width: 100%;
}

body.is-mobile .progress-sector-share {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

body.is-mobile .progress-sector-share-label {
  margin-top: 0;
}

body.is-mobile .progress-activity-feed-card {
  display: none;
}

body.is-mobile .scope-transformer-schedule-card {
  display: none;
}

body.is-mobile #page-dashboard #dashHero,
body.is-mobile #page-dashboard > .g2:last-child {
  display: none;
}

body.is-mobile #page-dashboard > .g2 {
  margin-bottom: 0 !important;
}

body.is-mobile .map-wrap .card,
body.is-mobile #page-dashboard .card.g-span2 {
  border-radius: 16px;
}

body.is-mobile .map-sector-picker {
  z-index: 1090;
  left: 12px;
  right: 12px;
  width: auto;
  max-width: none;
  transform: none;
  justify-content: stretch;
  align-items: stretch;
  gap: 8px;
  padding: 8px;
  border-radius: 18px;
}

body.is-mobile .map-sector-picker.map-sector-picker--collapsed {
  gap: 0;
  padding: 6px;
}

body.is-mobile .map-mobile-filter-bar {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 8px;
}

body.is-mobile .map-mobile-filter-toggle {
  flex: 1 1 auto;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg2) 84%, transparent);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

body.is-mobile .map-mobile-expand-btn {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg2) 84%, transparent);
  color: var(--text2);
  cursor: pointer;
}

body.is-mobile .map-mobile-expand-btn:hover,
body.is-mobile .map-mobile-expand-btn[aria-pressed='true'] {
  border-color: rgba(79, 195, 247, .34);
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  color: var(--text);
}

body.is-mobile .map-mobile-filter-toggle-status {
  white-space: normal;
}

body.is-mobile .map-mobile-filter-content {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

body.is-mobile .map-sector-picker.map-sector-picker--collapsed .map-mobile-filter-content {
  display: none;
}

body.is-mobile .map-sector-dropdown,
body.is-mobile .map-progress-date-picker {
  flex: 1 1 100%;
  min-width: 0;
  max-width: none;
  width: 100%;
}

body.is-mobile .map-progress-date-picker {
  gap: 6px;
  align-items: stretch;
}

body.is-mobile .map-sector-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 10px;
  min-height: 0;
  padding: 10px 12px;
  border-radius: 14px;
}

body.is-mobile .map-sector-trigger #mapSectorSummary {
  grid-column: 1;
  white-space: normal;
  line-height: 1.35;
}

body.is-mobile .map-sector-actions {
  grid-column: 1 / -1;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
}

body.is-mobile .map-sector-toggle-label {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  font-size: 12px;
  opacity: 1;
}

body.is-mobile .map-sector-toggle-label i {
  font-size: 16px;
}

body.is-mobile .map-sector-picker .map-sector-action,
body.is-mobile .map-sector-picker .map-sector-inline-status {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 10px;
}

body.is-mobile .map-progress-date-trigger {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
}

body.is-mobile .map-progress-date-trigger-wrap,
body.is-mobile .map-progress-date-copy {
  min-width: 0;
}

body.is-mobile .map-progress-date-value {
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.is-mobile .map-progress-date-clear {
  min-height: 40px;
  padding-inline: 10px;
}

body.is-mobile .map-sector-menu,
body.is-mobile .map-progress-date-menu {
  position: static;
  top: auto;
  right: auto;
  left: auto;
  z-index: auto;
  width: 100%;
  margin-top: 8px;
  border-radius: 16px;
}

body.is-mobile .map-sector-menu {
  max-height: min(52dvh, calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height) - 168px));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-bottom: max(14px, calc(var(--mobile-tabbar-height) - 48px));
  scroll-padding-bottom: max(14px, calc(var(--mobile-tabbar-height) - 48px));
}

body.is-mobile .map-sector-menu .project-zone-list,
body.is-mobile .map-sector-menu .map-sector-list,
body.is-mobile .map-sector-menu .map-sector-village-list {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

body.is-mobile .map-shell.map-fullscreen {
  top: var(--mobile-topbar-height);
  right: 0;
  bottom: var(--mobile-tabbar-height);
  left: 0;
  width: auto;
  height: auto !important;
  min-height: 0;
  max-height: none;
}

body.is-mobile .map-wrap:has(.map-shell.map-fullscreen) .map-sector-picker {
  position: fixed;
  top: calc(var(--mobile-topbar-height) + 8px);
  left: 12px;
  right: 12px;
  z-index: 1090;
  width: auto;
  max-width: none;
  transform: none;
}

body.is-mobile .map-expand-btn {
  display: none;
}

body.is-mobile .map-shell.map-fullscreen .map-sector-menu {
  height: auto;
  max-height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height) - 104px);
}

body.is-mobile .map-layer-panel {
  position: fixed;
  right: 12px;
  bottom: calc(var(--mobile-tabbar-height) + 8px);
  left: 12px;
  width: auto;
  min-width: 0;
  max-height: min(60vh, calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height) - 24px));
  padding: 16px 14px 14px;
  border-radius: 18px;
}

body.is-mobile .map-shell.map-fullscreen .map-layer-panel {
  top: auto;
  bottom: calc(var(--mobile-tabbar-height) + 8px);
  max-height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height) - 24px);
}

body.is-mobile .map-shell.map-fullscreen .map-status-stack {
  right: 8px;
  bottom: 18px;
  width: min(220px, calc(100% - 16px));
}

body.is-mobile .map-status-stack {
  transition: opacity .18s ease, transform .18s ease;
  transform-origin: right center;
}

body.is-mobile .map-status-stack.map-status-stack--collapsed {
  opacity: 0;
  transform: translateX(calc(100% + 18px));
  pointer-events: none;
}

body.is-mobile .map-status-toggle {
  position: absolute;
  right: 8px;
  bottom: 78px;
  z-index: 911;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 9px 10px 9px 12px;
  border: 1px solid rgba(59,130,246,.24);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .26);
  color: var(--text);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  transform: none;
}

body.is-mobile .map-status-toggle i {
  font-size: 13px;
}

body.is-mobile .map-status-toggle.hidden {
  display: none !important;
}

body.is-mobile .map-status-toggle:hover,
body.is-mobile .map-status-toggle:focus-visible {
  border-color: rgba(59,130,246,.42);
  color: var(--white);
  outline: none;
}

body.is-mobile .ai-chat-mini {
  display: none !important;
}

body.is-mobile .ai-chat-backdrop {
  inset: 0 0 var(--mobile-tabbar-height) 0;
}

body.is-mobile .ai-chat-widget {
  right: 12px;
  bottom: calc(2px + var(--mobile-tabbar-height));
  left: 12px;
  width: auto;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached {
  top: var(--mobile-topbar-height);
  right: 0;
  bottom: auto;
  left: 0;
  width: auto;
  height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height));
  max-height: calc(100dvh - var(--mobile-topbar-height) - var(--mobile-tabbar-height));
  max-width: none;
  border-radius: 0;
  transform: none;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached:focus-within {
  height: calc(100dvh - var(--mobile-topbar-height));
  max-height: calc(100dvh - var(--mobile-topbar-height));
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached:focus-within ~ #mobileTabBar .mobile-tab-bar {
  opacity: 0;
  transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px)));
  pointer-events: none;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached .ai-chat-hd {
  padding: 10px 12px;
}

body.is-mobile .ai-chat-btns {
  gap: 6px;
}

body.is-mobile .ai-chat-ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
}

body.is-mobile .ai-chat-ctrl .ph {
  font-size: 18px;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached .ai-chat-body {
  padding: 14px;
  overscroll-behavior: contain;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached .ai-chat-foot {
  position: sticky;
  bottom: 0;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
}

body.is-mobile .ai-chat-input {
  min-height: 44px;
  padding: 11px 12px;
  font-size: 16px;
  line-height: 1.45;
  border-radius: 12px;
}

body.is-mobile .ai-chat-widget.ai-chat-widget-detached .ai-chat-input {
  min-height: 48px;
}

body.is-mobile .ai-chat-send {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

@media (max-width: 379px) {
  body.is-mobile .content {
    padding: 12px 12px calc(14px + var(--mobile-tabbar-height));
  }

  body.is-mobile .page-title {
    font-size: 12px;
  }

  body.is-mobile #page-progress .g4,
  body.is-mobile #page-dashboard #dashHero {
    grid-template-columns: minmax(0, 1fr);
  }
}

body.is-mobile .mobile-topbar-btn,
body.is-mobile .mobile-topbar-theme-group .theme-dropdown-trigger,
body.is-mobile .mobile-topbar-action,
body.is-mobile .mobile-tab-btn,
body.is-mobile .map-mobile-filter-toggle,
body.is-mobile .map-mobile-expand-btn,
body.is-mobile .map-sector-picker .map-sector-action,
body.is-mobile .map-sector-picker .map-sector-inline-status,
body.is-mobile .map-progress-date-nav,
body.is-mobile .map-progress-date-trigger,
body.is-mobile .map-progress-date-value,
body.is-mobile .map-progress-date-day,
body.is-mobile .map-progress-date-clear,
body.is-mobile .map-status-toggle,
body.is-mobile .ai-chat-ctrl,
body.is-mobile .ai-chat-send {
  border-radius: var(--radius-sm);
}

body.is-mobile .mobile-topbar-actions,
body.is-mobile .mobile-topbar-theme-group .theme-dropdown-menu,
body.is-mobile .map-wrap .card,
body.is-mobile #page-dashboard .card.g-span2,
body.is-mobile .map-sector-picker,
body.is-mobile .map-sector-menu,
body.is-mobile .map-progress-date-menu,
body.is-mobile .map-layer-panel,
body.is-mobile .ai-chat-widget {
  border-radius: var(--radius-lg);
}

body.is-mobile .mobile-more-drawer {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

body.is-mobile .mobile-more-row,
body.is-mobile .map-sector-trigger,
body.is-mobile .ai-chat-input {
  border-radius: var(--radius-md);
}

body.is-mobile .login-landing__mobile-note {
  border-radius: var(--radius-lg);
}
