:root {
  --wm-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --wm-mobile-safe-top: env(safe-area-inset-top, 0px);
}

.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid #1f2937;
  background: #0b1120;
  color: #e5e7eb;
  cursor: pointer;
}

.mobile-nav-toggle .bars {
  width: 18px;
  height: 12px;
  display: inline-flex;
  flex-direction: column;
  justify-content: space-between;
}

.mobile-nav-toggle .bars span {
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 999px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 55;
}

body.wm-nav-open {
  overflow: hidden;
}

body.wm-nav-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 980px) {
  .mobile-nav-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(82vw, 320px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 60;
  }

  body.wm-nav-open .sidebar {
    transform: translateX(0);
  }

  .main {
    width: 100%;
  }

  .topbar {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 12px !important;
  }

  .topbar-sub {
    white-space: normal !important;
    max-width: none !important;
  }

  .provider-select {
    width: 100% !important;
    margin-left: 0 !important;
    justify-content: space-between !important;
  }

  .provider-select select {
    width: 100% !important;
  }

  #wm-tabs {
    flex-wrap: wrap;
    gap: 6px;
  }

  #wm-tabs > div:last-child {
    display: none;
  }

  .chat {
    padding: 8px 10px;
  }

  .messages {
    padding-bottom: 140px;
  }

  .input-row {
    position: sticky;
    bottom: 0;
    background: #05060a;
    padding-bottom: calc(8px + var(--wm-mobile-safe-bottom));
    margin-top: 0;
    z-index: 20;
  }

  .input-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .send-btn {
    width: 100%;
    justify-content: center;
  }

  .composer-footer {
    flex-wrap: wrap;
  }

  .sidebar-footer {
    padding-bottom: calc(12px + var(--wm-mobile-safe-bottom));
  }

  #wm-research-view {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow: auto !important;
  }

  #wm-research-view > div {
    width: 100% !important;
  }
}

@media (max-width: 680px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* WM Mobile Sidebar Bind v2 */
@media (max-width: 768px){
  [data-wm-sidebar="1"]{
    position:fixed !important;
    inset:0 auto 0 0;
    width:280px !important;
    height:100dvh !important;
    transform:translateX(-105%);
    transition:transform 180ms ease;
    z-index:1200;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
  }
  body.wm-sidebar-open [data-wm-sidebar="1"]{ transform:translateX(0); }
}

/* Source cards — mobile v2 */
@media (max-width: 680px) {
  .message-sources {
    padding: 8px 10px 10px;
  }
  .source-card {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    min-height: 44px;
  }
  .source-badge {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }
  .source-body {
    width: calc(100% - 38px);
  }
  .source-title {
    font-size: 13px;
    white-space: normal;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .source-meta-row {
    flex-wrap: wrap;
    gap: 4px;
  }
  .source-snippet {
    -webkit-line-clamp: 2;
    font-size: 11px;
  }
  .source-out {
    position: absolute;
    top: 8px;
    right: 8px;
  }
  .source-card {
    position: relative;
  }
}

/* Council pills — mobile v2.9.19 */
@media (max-width: 680px) {
  .council-row {
    gap: 4px;
  }
  .council-pill,
  .winner-pill,
  .contrib-pill,
  .transcript-btn {
    font-size: 9px;
    padding: 2px 5px;
  }
  .contrib-pill {
    display: none;
  }
}

/* WM Hamburger Force-Visible v1 */
@media (max-width:768px){
  [data-wm-hamburger="1"], .wm-nav-toggle{
    display:inline-flex !important;
    opacity:1 !important;
    visibility:visible !important;
    pointer-events:auto !important;
    position:fixed !important;
    top:10px !important;
    left:10px !important;
    width:44px !important;
    height:44px !important;
    z-index:2147483647 !important;
  }
}
