/* Phone and narrow-tablet layout. Loaded last so it can override the desktop trade desk.
   Desktop (1150px and up) is unchanged. */

@media (max-width: 1149px) {
  body.hl-site .nav {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    height: calc(52px + env(safe-area-inset-top)) !important;
    min-height: calc(52px + env(safe-area-inset-top)) !important;
    max-height: none !important;
    padding: env(safe-area-inset-top) 10px 0 !important;
    gap: 8px !important;
    position: sticky;
    top: 0;
    z-index: 40;
    overflow: visible;
  }
  body.hl-site .brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
  }
  body.hl-site .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  body.hl-site .nav-right {
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap !important;
    justify-content: flex-end;
    gap: 6px !important;
  }
  body.hl-site .nav #connectBtn {
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.hl-site #publisherLoginBtn {
    font-size: 0 !important;
    min-width: 64px;
    padding: 0 10px !important;
  }
  body.hl-site #publisherLoginBtn::after {
    content: "Login";
    font-size: 12px;
    font-weight: 600;
  }
  body.hl-site .nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: none;
    order: 3;
    width: 44px;
    height: 36px;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 4px;
    background: #273035 !important;
    color: #f6fefd !important;
    font-size: 0 !important;
  }
  body.hl-site .nav-toggle::before {
    content: "";
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
  }
  body.hl-site .nav-toggle[aria-expanded="true"] {
    background: #17453f !important;
    color: #97fce4 !important;
  }
  body.hl-site .nav-links {
    display: none !important;
  }
  body.hl-site .nav-links.open {
    display: flex !important;
    position: absolute;
    z-index: 50;
    top: calc(52px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    width: 100% !important;
    max-height: calc(100dvh - 52px - env(safe-area-inset-top));
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0;
    margin: 0;
    padding: 6px 8px calc(12px + env(safe-area-inset-bottom));
    overflow: auto;
    overscroll-behavior: contain;
    background: #0f1a1f;
    border-bottom: 1px solid #273035;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  }
  body.hl-site .nav-links.open a,
  body.hl-site .nav-links.open .more-btn {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 16px;
    line-height: 1.2;
    text-align: left;
    border-radius: 6px;
  }
  body.hl-site .nav-links.open .more { width: 100%; }
  body.hl-site .nav-links.open .more-menu {
    position: static !important;
    min-width: 0 !important;
    width: 100%;
    margin: 0;
    padding: 0 0 4px 10px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  body.hl-site .nav-links.open .more-menu a {
    min-height: 44px;
    font-size: 15px;
    color: #c5d0ce !important;
  }
}

@media (max-width: 980px) {
  html { overflow-x: clip; }
  /* Keep body overflow visible so the viewport scrolls and the header can stick.
     A scrollport on body pins sticky children to the document instead of the screen. */
  body.hl-site,
  body.hl-site.models-terminal-route {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }
  body.hl-site .main {
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 12px 12px calc(28px + env(safe-area-inset-bottom)) !important;
  }
  body.hl-site.models-terminal-route .main {
    padding: 0 0 env(safe-area-inset-bottom) !important;
    background: #0c1014 !important;
  }

  body.hl-site .page-h h1,
  body.hl-site .hl-page-head h1,
  body.hl-site .docs h1,
  body.hl-site .hero h1,
  body.hl-site .mp-self h1 {
    font-size: 22px !important;
    line-height: 1.25 !important;
  }
  body.hl-site .page-h .sub,
  body.hl-site .hl-page-head .dim,
  body.hl-site .docs p,
  body.hl-site .hero p,
  body.hl-site .note,
  body.hl-site .lead {
    font-size: 14px !important;
    line-height: 1.5 !important;
  }
  body.hl-site .docs,
  body.hl-site .hero,
  body.hl-site .markdown-body,
  body.hl-site .hl-page {
    overflow-wrap: anywhere;
  }
  body.hl-site pre,
  body.hl-site pre code,
  body.hl-site .docs pre,
  body.hl-site .hub code,
  body.hl-site .markdown-body code {
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
  }
  body.hl-site pre,
  body.hl-site .docs pre {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  body.hl-site .main .btn {
    min-height: 44px;
    padding: 8px 14px;
    font-size: 15px;
  }
  body.hl-site .main input:not([type=checkbox]):not([type=radio]):not([type=range]),
  body.hl-site .main select,
  body.hl-site .main textarea,
  body.hl-site dialog input,
  body.hl-site dialog textarea {
    font-size: 16px !important;
    min-height: 44px;
  }
  body.hl-site dialog,
  body.hl-site .publisher-auth-dialog,
  body.hl-site .wc {
    width: min(420px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px);
  }
  body.hl-site .toasts {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: none;
  }

  /* Trade desk: one scrolling column. Chart, then the order ticket, then history. */
  body.hl-site .models-trade-desk {
    display: flex !important;
    flex-direction: column;
    height: auto !important;
    min-height: 0 !important;
    gap: 6px;
    padding: 0;
    overflow: visible !important;
  }
  body.hl-site .models-trade-desk .mobile-desk-tabs { display: none !important; }
  body.hl-site .models-trade-desk .terminal-chart,
  body.hl-site .models-trade-desk .terminal-side,
  body.hl-site .models-trade-desk .terminal-bottom {
    display: flex !important;
    width: 100% !important;
    overflow: visible !important;
    min-height: 0 !important;
  }
  body.hl-site .models-trade-desk .terminal-panel { overflow: visible; }
  body.hl-site .models-trade-desk .terminal-side { flex-direction: column; }
  body.hl-site .models-trade-desk .dex-windows { order: 1; }
  body.hl-site .models-trade-desk .dex-trade { order: 2; }
  body.hl-site .models-trade-desk .dex-flow { order: 3; }
  body.hl-site .models-trade-desk .dex-pool { order: 4; }
  body.hl-site .models-trade-desk .dex-flow:empty,
  body.hl-site .models-trade-desk .dex-pool:empty,
  body.hl-site .models-trade-desk .dex-windows:empty,
  body.hl-site .models-trade-desk #acctActions:empty,
  body.hl-site .models-trade-desk #acctAnn:empty { display: none !important; }

  body.hl-site .models-trade-desk .dex-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    min-height: 0;
    padding: 12px;
  }
  body.hl-site .models-trade-desk .dex-head .pair-btn {
    display: flex;
    width: 100%;
    align-items: flex-start;
    white-space: normal;
    font-size: 16px;
    line-height: 1.25;
    text-align: left;
  }
  body.hl-site .models-trade-desk .dex-av {
    width: 36px;
    height: 36px;
  }
  body.hl-site .models-trade-desk .dex-names {
    flex: 1;
    min-width: 0;
  }
  body.hl-site .models-trade-desk .dex-pair {
    display: block;
    white-space: normal;
    font-size: 16px;
    line-height: 1.3;
  }
  body.hl-site .models-trade-desk #pairLabel {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  body.hl-site .models-trade-desk .dex-quote { font-size: 13px; }
  body.hl-site .models-trade-desk .pair-chevron {
    margin-left: auto;
    flex: none;
    padding-top: 4px;
  }
  body.hl-site .models-trade-desk .dex-meta { gap: 4px; }
  body.hl-site .models-trade-desk .dex-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 10px;
    width: 100%;
    margin: 0;
    align-items: start;
  }
  body.hl-site .models-trade-desk .dex-stat { min-width: 0; }
  body.hl-site .models-trade-desk .dex-stat span { font-size: 11px; }
  body.hl-site .models-trade-desk .dex-stat strong {
    font-size: 14px;
    overflow-wrap: anywhere;
  }
  body.hl-site .models-trade-desk .dex-price { grid-column: 1 / -1; }
  body.hl-site .models-trade-desk .dex-price strong {
    font-size: 26px;
    letter-spacing: -0.03em;
  }
  body.hl-site .models-trade-desk .dex-price em { display: none; }

  body.hl-site .models-trade-desk .chart-tools {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
  }
  body.hl-site .models-trade-desk .chart-tools .legend { display: none; }
  body.hl-site .models-trade-desk .chart-tools:not(:has(button)) { display: none; }
  body.hl-site .models-trade-desk .chart-tools .rng button {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
  }
  body.hl-site .models-trade-desk .chart-box {
    flex: none;
    height: clamp(220px, 46vh, 340px);
    min-height: 220px;
  }

  body.hl-site .models-trade-desk .dex-windows {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.hl-site .models-trade-desk .dex-win {
    min-width: 0;
    padding: 8px 6px;
    gap: 3px;
  }
  body.hl-site .models-trade-desk .dex-win span { font-size: 10px; }
  body.hl-site .models-trade-desk .dex-win strong { font-size: 12px; overflow-wrap: anywhere; }
  body.hl-site .models-trade-desk .dex-flow,
  body.hl-site .models-trade-desk .dex-pool {
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  body.hl-site .models-trade-desk .dex-pool-row {
    align-items: flex-start;
    gap: 8px;
  }
  body.hl-site .models-trade-desk .dex-pool-row strong {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  body.hl-site .models-trade-desk #entry { padding: 12px 12px 16px; }
  body.hl-site .models-trade-desk #entry .seg button {
    min-height: 46px;
    font-size: 15px;
  }
  body.hl-site .models-trade-desk #entry .inp input {
    font-size: 16px !important;
    padding: 12px 4px;
  }
  body.hl-site .models-trade-desk #entry .pcts button {
    min-height: 40px;
    font-size: 13px;
  }
  body.hl-site .models-trade-desk #entry .size-slider {
    height: 28px;
    margin: 12px 0 6px;
  }
  body.hl-site .models-trade-desk #entry .quote .r,
  body.hl-site .models-trade-desk #entry .quote .r3 {
    flex-wrap: wrap;
    align-items: baseline;
  }
  body.hl-site .models-trade-desk #entry .quote .v { overflow-wrap: anywhere; text-align: right; }
  body.hl-site .models-trade-desk #entry #sendBtn,
  body.hl-site .models-trade-desk #entry #deskConnect {
    min-height: 48px !important;
    height: 48px !important;
    font-size: 16px !important;
    font-weight: 650;
    border-radius: 6px;
  }
  body.hl-site .models-trade-desk #acctAnn {
    gap: 8px;
    padding: 4px 12px 14px;
  }
  body.hl-site .models-trade-desk #acctAnn a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 4px;
    background: #1c242e;
    text-decoration: none;
  }
  body.hl-site .models-trade-desk #acctActions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 12px 12px;
  }
  body.hl-site .models-trade-desk #acctActions a,
  body.hl-site .models-trade-desk #acctActions button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.hl-site .models-trade-desk .terminal-bottom .desk-tabs {
    position: sticky;
    top: calc(52px + env(safe-area-inset-top));
    z-index: 6;
    flex-wrap: nowrap;
    overflow-x: auto;
    background: #11161c;
    scrollbar-width: none;
  }
  body.hl-site .models-trade-desk .terminal-bottom .desk-tabs::-webkit-scrollbar { display: none; }
  body.hl-site .models-trade-desk .terminal-bottom .desk-tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 13px;
  }
  body.hl-site .models-trade-desk #bottomBody {
    flex: none;
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
    padding: 8px 10px 16px;
    -webkit-overflow-scrolling: touch;
  }
  body.hl-site .models-trade-desk #bottomBody .tbl {
    min-width: 640px;
    font-size: 13px;
  }
  body.hl-site .models-trade-desk .empty {
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  body.hl-site .models-trade-desk .pair-picker {
    position: fixed;
    inset: 0;
    z-index: 70;
  }
  body.hl-site .models-trade-desk .pair-picker-panel {
    width: 100%;
    max-height: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
  }
  body.hl-site .models-trade-desk .pair-picker-head input {
    font-size: 16px !important;
    min-height: 44px;
  }
  body.hl-site .models-trade-desk .pair-filters button { min-height: 36px; }
  body.hl-site .models-trade-desk .pair-picker-table th:nth-child(n + 4),
  body.hl-site .models-trade-desk .pair-picker-table td:nth-child(n + 4) { display: none; }
  body.hl-site .models-trade-desk .pair-picker-table th,
  body.hl-site .models-trade-desk .pair-picker-table td {
    padding: 12px 10px;
  }
  body.hl-site .models-trade-desk .pair-picker-table .pair-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  /* Explore, download, account, and the older buy page. */
  body.hl-site .toolbar { flex-wrap: wrap; }
  body.hl-site .toolbar .seg {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.hl-site .toolbar .seg button {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
    height: auto;
    padding: 8px 12px;
  }
  body.hl-site .toolbar input[type="search"] {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0 !important;
    min-height: 44px;
    font-size: 16px !important;
  }
  body.hl-site #linesBox,
  body.hl-site .tbl-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Rankings keeps every chain column on desktop. On a phone, show the model,
     how much it is used, and the membership price. The row still opens the model. */
  body.hl-site #lbBox .tbl-wrap { overflow: hidden; }
  body.hl-site #lbBox #linesTbl {
    display: table !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
  }
  body.hl-site #lbBox #linesTbl th,
  body.hl-site #lbBox #linesTbl td { display: none !important; }
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(2),
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(6),
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(7) {
    display: table-cell !important;
    overflow: hidden;
    vertical-align: middle;
    padding: 10px 6px !important;
    font-size: 13px !important;
    line-height: 1.3 !important;
    text-align: right !important;
    border-bottom: 1px solid #273035;
  }
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(2) {
    width: 54% !important;
    text-align: left !important;
    white-space: normal !important;
  }
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(6) { width: 18% !important; }
  body.hl-site #lbBox #linesTbl :is(th, td):nth-child(7) { width: 28% !important; }
  body.hl-site #lbBox #linesTbl td:nth-child(2) b,
  body.hl-site #lbBox #linesTbl td:nth-child(2) a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  body.hl-site .hub .hub-layout,
  body.hl-site .hub .hub-download-wrap .hub-layout,
  body.hl-site .product {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body.hl-site .hub .container-xl,
  body.hl-site .hub .hub-download-wrap {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  body.hl-site .hub .UnderlineNav,
  body.hl-site .hub .UnderlineNav-body,
  body.hl-site .mp-self-tabs,
  body.hl-site .mp-tabs {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  body.hl-site .hub .UnderlineNav-item,
  body.hl-site .mp-self-tab,
  body.hl-site .mp-tab {
    flex: 0 0 auto;
    min-height: 44px;
  }
  body.hl-site .mp-self {
    padding-left: 12px;
    padding-right: 12px;
  }
  body.hl-site .mp-self-tabs {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  body.hl-site .mp-self-layout,
  body.hl-site .mp-layout,
  body.hl-site .mp-profile {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body.hl-site #main:has(> .hub + .crumbs) > :is(.crumbs, .product, #torrentBox, .mine, .tech) {
    width: calc(100% - 16px) !important;
  }
  body.hl-site .crumbs {
    flex-wrap: wrap;
    gap: 6px;
  }
}
