@media (max-width: 1100px) {
  :root { --sidebar-width: 218px; }
  .topbar { padding: 0 20px; }
  .page-content { padding: 24px 20px 32px; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-2 { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 760px) {
  /* Drawer: tinggi mengikuti viewport dinamis (dvh) agar tidak terpotong saat bilah alamat browser
     HP menyembunyikan/menampilkan diri. 100vh = cadangan untuk browser lama. */
  .sidebar {
    inset: 0 auto auto 0;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    width: min(290px,86vw);
    box-shadow: var(--shadow);
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.open { transform: translateX(0); }
  /* Saat menu terbuka, halaman di belakangnya dikunci agar tidak ikut ter-scroll. */
  html.nav-open, html.nav-open body { overflow: hidden; }
  .main-area { margin-left: 0; }
  .mobile-only { display: inline-grid !important; }
  .topbar { height: 68px; padding: 0 14px; gap: 10px; }
  .topbar-title .eyebrow { display: none; }
  .topbar-title strong { font-size: .92rem; }
  .topbar-actions { gap: 6px; }
  .search-trigger { width: 40px; justify-content: center; padding: 0; }
  .search-label, .search-trigger kbd { display: none; }
  .connection-pill { font-size: .58rem; padding: 7px 8px; }
  .page-content { padding: 22px 14px 30px; }
  .welcome-row, .page-heading { display: block; }
  .welcome-row .heading-actions, .page-heading .heading-actions { margin-top: 14px; }
  .stat-grid { gap: 9px; }
  .stat-card { padding: 13px; }
  .stat-value { font-size: 1.25rem; }
  .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .app-footer { padding: 15px; flex-wrap: wrap; gap: 7px 14px; }
  .footer-warning { width: 100%; }
  .mobile-scrim { display: none; position: fixed; inset: 0 0 auto 0; height: 100vh; height: 100dvh; background: rgba(0,0,0,.55); z-index: 25; touch-action: none; overscroll-behavior: contain; }
  .mobile-scrim.visible { display: block; }
}
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-label { font-size: .68rem; }
  .stat-value { font-size: 1.12rem; }
  .card { padding: 14px; }
  .connection-pill { max-width: 84px; overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* LONEWOLF_MARKETS_VIEWPORT_FIX */
@media screen and (max-width: 760px) {
  #market-cards {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .market-table-wrap {
    display: none !important;
  }

  .market-asset-card {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}

@media screen and (min-width: 761px) {
  #market-cards {
    display: none !important;
  }

  .market-table-wrap {
    display: block !important;
  }
}

/* LONEWOLF AI CHAT MOBILE */
@media (max-width: 760px) {
  .ai-chat-top {
    padding: 14px;
  }
  .ai-chat-notice {
    margin: 12px 14px 0;
  }
  .ai-chat-messages {
    min-height: 260px;
    max-height: 48vh;
    padding: 16px 12px;
  }
  .ai-chat-message {
    max-width: 94%;
    padding: 11px 12px;
  }
  .ai-chat-form {
    padding: 14px;
  }
  .ai-chat-form-bottom {
    align-items: flex-start;
  }
  .ai-chat-form-bottom small {
    max-width: 65%;
    line-height: 1.5;
  }
}
@media (max-width: 380px) {
  .ai-chat-messages {
    min-height: 220px;
    padding-inline: 8px;
  }
  .ai-chat-message {
    max-width: 97%;
  }
  .ai-chat-form {
    padding: 12px;
  }
  .ai-chat-top .btn {
    padding-inline: 9px;
  }
}

/* LONEWOLF AI CHAT — MOBILE REFINEMENT */
@media screen and (max-width: 760px) {
  .ai-chat-panel {
    border-radius: 13px;
  }

  .ai-chat-top {
    padding: 14px;
    gap: 8px;
  }

  .ai-chat-top strong {
    font-size: .88rem;
  }

  .ai-chat-top small {
    font-size: .68rem;
  }

  .ai-chat-notice {
    margin: 12px 12px 0;
    padding: 10px 11px;
    font-size: .74rem;
  }

  .ai-chat-messages {
    min-height: 240px;
    max-height: 48vh;
    padding: 16px 12px;
    gap: 12px;
  }

  .ai-chat-welcome {
    padding: 24px 8px;
  }

  .ai-chat-message {
    max-width: 94%;
    padding: 11px 12px;
    border-radius: 12px;
  }

  .ai-chat-message-body {
    font-size: .86rem;
    line-height: 1.65;
  }

  .ai-chat-form {
    padding: 14px 12px 15px;
    gap: 10px;
  }

  .ai-chat-form textarea {
    min-height: 82px;
    padding: 12px;
    font-size: 16px;
  }

  .ai-chat-form-bottom {
    align-items: center;
    gap: 10px;
  }

  .ai-chat-form-bottom small {
    flex: 1 1 140px;
    max-width: none;
    font-size: .66rem;
  }

  .ai-chat-form .btn-primary {
    min-height: 44px;
    min-width: 88px;
    padding-inline: 14px;
  }
}

@media screen and (max-width: 380px) {
  .ai-chat-top {
    padding: 12px 10px;
  }

  .ai-chat-top .btn {
    padding-inline: 9px;
    font-size: .76rem;
  }

  .ai-chat-notice {
    margin-inline: 10px;
  }

  .ai-chat-messages {
    min-height: 220px;
    padding-inline: 9px;
  }

  .ai-chat-form {
    padding-inline: 10px;
  }

  .ai-chat-form-bottom small {
    flex-basis: 120px;
  }
}

/* LONEWOLF AI CHAT — MESSAGE ACTIONS MOBILE */
@media screen and (max-width: 760px) {

}

/* LONEWOLF AI CHAT — COMPACT MENU MOBILE */
@media screen and (max-width: 760px) {
  .ai-chat-menu-trigger {
    width: 38px;
    height: 38px;
  }
  .ai-chat-menu {
    min-width: 172px;
  }
  .ai-chat-menu-item {
    min-height: 44px;
    font-size: .84rem;
  }
  .ai-chat-form-actions {
    gap: 6px;
  }
  .ai-chat-form-actions .btn {
    min-height: 44px;
    padding-inline: 12px;
  }
}

/* LONEWOLF AI CHAT — MOBILE COMPOSER POLISH */
@media screen and (max-width: 760px) {
  .ai-chat-panel {
    border-radius: 14px;
  }

  .ai-chat-top {
    padding: 14px;
  }

  .ai-chat-messages {
    min-height: 250px;
    max-height: 52vh;
    padding: 18px 12px;
    gap: 15px;
  }

  .ai-chat-welcome {
    padding: 28px 8px;
  }

  .ai-chat-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }

  .ai-chat-message {
    max-width: 95%;
    padding: 12px 13px;
    border-radius: 13px;
  }

  .ai-chat-message-body {
    font-size: .92rem;
    line-height: 1.72;
  }

  .ai-chat-form {
    padding: 15px 12px 16px;
    gap: 10px;
  }

  .ai-chat-form textarea {
    min-height: 88px;
    max-height: 32vh;
    padding: 13px;
    border-radius: 13px;
  }

  .ai-chat-form-bottom {
    align-items: center;
  }

  .ai-chat-form-bottom small {
    flex: 1 1 145px;
    font-size: .68rem;
  }

  .ai-chat-form-actions .btn {
    min-height: 44px;
    border-radius: 11px;
  }
}

@media screen and (max-width: 380px) {
  .ai-chat-messages {
    padding-inline: 9px;
  }

  .ai-chat-message {
    max-width: 97%;
    padding: 11px;
  }

  .ai-chat-form-bottom {
    align-items: flex-start;
  }

  .ai-chat-form-bottom small {
    flex-basis: 100%;
  }

  .ai-chat-form-actions {
    width: 100%;
  }

  .ai-chat-form-actions .btn-primary {
    flex: 1;
  }
}

/* LONEWOLF AI CHAT — CHATGPT-STYLE V2 MOBILE */
@media screen and (max-width: 760px) {
  .ai-chat-panel {
    border-radius: 0;
  }
  .ai-chat-top {
    padding: 10px 0 14px;
    gap: 10px;
  }
  .ai-chat-top strong {
    font-size: .95rem;
  }
  .ai-chat-notice {
    margin-top: 12px;
    padding: 10px 12px;
    font-size: .76rem;
  }
  .ai-chat-messages {
    min-height: 250px;
    max-height: 52vh;
    gap: 21px;
    padding: 22px 0 26px;
  }
  .ai-chat-welcome {
    padding: 30px 8px;
  }
  .ai-chat-mark {
    width: 54px;
    height: 54px;
    border-radius: 17px;
  }
  .ai-chat-message {
    max-width: 94%;
    padding: 12px 14px;
    border-radius: 16px;
  }
  .ai-chat-message.assistant {
    max-width: 100%;
    padding: 1px 0;
  }
  .ai-chat-message-body {
    font-size: .93rem;
    line-height: 1.82;
  }
  .ai-chat-form {
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px 11px 11px;
    border-radius: 17px;
  }
  .ai-chat-form textarea {
    min-height: 70px;
    max-height: 30vh;
    padding: 8px 2px;
    font-size: 16px;
  }
  .ai-chat-form-bottom {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  .ai-chat-form-bottom small {
    flex: 1 1 135px;
    max-width: none;
    font-size: .67rem;
  }
  .ai-chat-form-actions {
    gap: 6px;
  }
  .ai-chat-form-actions .btn,
  .ai-chat-form .btn-primary {
    min-height: 44px;
    min-width: 0;
    padding-inline: 12px;
    border-radius: 12px;
  }
}
@media screen and (max-width: 380px) {
  .ai-chat-top .btn {
    padding-inline: 8px;
    font-size: .74rem;
  }
  .ai-chat-messages {
    padding-top: 18px;
  }
  .ai-chat-message.user {
    max-width: 97%;
  }
  .ai-chat-form-bottom {
    align-items: flex-start;
  }
  .ai-chat-form-bottom small {
    flex-basis: 100%;
  }
  .ai-chat-form-actions {
    width: 100%;
  }
  .ai-chat-form-actions .btn-primary {
    flex: 1;
  }
}

/* LONEWOLF GUIDE + AI CHAT MOBILE FINAL FIX 20261019 */
@media screen and (max-width: 760px) {
  .guide-index { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .guide-index-item { padding: 13px; }
  .guide-feature-details { grid-template-columns: minmax(0, 1fr); }
  .guide-detail { padding-top: 15px; }
  .guide-feature-heading { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
  .guide-feature-heading > span { width: 32px; height: 32px; border-radius: 10px; }
  .guide-quick-links { display: grid; grid-template-columns: minmax(0, 1fr); }
  body.is-ai-chat #ai-chat-top { min-width: 0; }
  body.is-ai-chat .ai-chat-top { gap: 8px; padding-inline: 0; }
  body.is-ai-chat #ai-chat-clear { min-width: 82px; min-height: 40px; padding-inline: 10px; }
  body.is-ai-chat #ai-chat-messages {
    min-height: 220px;
    max-height: 55vh;
    max-height: 55dvh;
    padding-inline: 0;
  }
}
@media screen and (max-width: 380px) {
  body.is-ai-chat #ai-chat-clear { min-width: 74px; padding-inline: 8px; font-size: .76rem; }
  .guide-feature { padding: 14px; }
  .guide-index-item { grid-template-columns: 27px minmax(0, 1fr) 14px; gap: 8px; }
}
