/* Phone layout for the homepage and the customer console. Built into an overlay by
   tools/build-mobile-layout.mjs and linked after every captured stylesheet. Everything sits inside the
   console's existing 720px compact breakpoint, so desktop and tablet widths keep the captured UI. Table
   cells read their labels from data-label, which mobile-layout.mjs copies from the table header (and so
   follows the language); mobile-layout.mjs also marks which edges of a scrolling link strip hide links. */
@media (max-width: 720px) {
  /* ---------- Link strips (console tabs, homepage news links): edge fades while the strip can scroll ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-navlinks {
    scrollbar-width: none;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-navlinks::-webkit-scrollbar {
    display: none;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-navlinks button {
    min-height: 36px !important;
  }
  :is(.app-shell.agy-console-shell.agy-board-shell .agy-board-navlinks, .home-board-agy-nav .cn-home-navlinks):not(#cn-mobile)[data-mobile-more="end"] {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
  }
  :is(.app-shell.agy-console-shell.agy-board-shell .agy-board-navlinks, .home-board-agy-nav .cn-home-navlinks):not(#cn-mobile)[data-mobile-more="start"] {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
  }
  :is(.app-shell.agy-console-shell.agy-board-shell .agy-board-navlinks, .home-board-agy-nav .cn-home-navlinks):not(#cn-mobile)[data-mobile-more="both"] {
    -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent);
  }

  /* ---------- Homepage. Below 820px the captured homepage stacks into one column; these rules fit that
     column to a phone: logo and language on one row with the news links under them, the globe in view,
     both price signals side by side, a headline that breaks only between words, and a full-width login. ---------- */
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) {
    gap: 6px 12px;
    min-height: 0;
    padding: 12px 0 0;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) > button:first-child {
    grid-area: 1 / 1;
    align-self: center;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) > .conpera-language-toggle {
    grid-area: 1 / 2;
  }
  /* The strip runs to the screen edges so links scroll out under the fade instead of being cut at the margin. */
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) > .cn-home-navlinks {
    grid-area: 2 / 1 / auto / -1;
    justify-content: flex-start;
    gap: 20px;
    width: auto;
    margin: 0 -14px;
    padding: 2px 14px;
    scroll-padding-inline: 14px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) .cn-home-navlink {
    padding: 11px 0;
    font-size: 11px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-nav:not(#cn-mobile) .cn-home-navlink.is-featured {
    width: 66px;
    height: 32px;
    padding: 0;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-hero:not(#cn-mobile) {
    gap: 30px;
    padding: 14px 0 64px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-panel:not(#cn-mobile) {
    min-height: 0;
    height: clamp(260px, 74vw, 340px);
    margin: 0 -14px;
  }
  /* Phones get the static globe frame. Scale it to the panel and anchor it right, so most of the globe shows. */
  .home-board-agy-page:not(#cn-mobile) .home-earth-visual[data-earth-presentation]:not(#cn-mobile)::before {
    inset: 0;
    width: auto;
    height: auto;
    background-size: auto 118%;
    background-position: right center;
  }
  /* Fade the globe in under the links instead of cutting it at the panel's top edge. */
  .home-board-agy-page:not(#cn-mobile) .home-earth-visual:not(#cn-mobile) {
    -webkit-mask-image: linear-gradient(transparent, #000 26%);
    mask-image: linear-gradient(transparent, #000 26%);
  }
  /* Darken the panel's foot so the price signals read on the page background rather than on the globe. */
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-shade:not(#cn-mobile) {
    inset: 0;
    background: linear-gradient(rgba(2, 4, 7, 0.1), rgba(2, 4, 7, 0) 34%, rgba(2, 4, 7, 0.78) 74%, rgb(3, 5, 9)), linear-gradient(90deg, rgba(2, 4, 7, 0.6), transparent 55%);
  }
  /* Price signals: the stacked glass card had a fixed 2 x 86px height for about 110px of content per row, so its
     text spilled onto the borders. On phones they become two open columns under a hairline, each reading
     "label" then "低至 0.14 折" on one line, in the same quiet style as the proof stats below. */
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) {
    top: auto;
    right: 14px;
    bottom: 4px;
    left: 14px;
    flex-direction: row;
    align-items: stretch;
    background: none;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.16);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile)::before,
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile)::after {
    display: none;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) > div {
    width: auto;
    min-height: 0;
    justify-content: flex-start;
    gap: 8px;
    padding: 14px 0 12px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) > div + div {
    padding-left: 18px;
    box-shadow: inset 1px 0 rgba(255, 255, 255, 0.12);
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) span {
    color: rgba(241, 247, 255, 0.7);
    font-size: 12px;
  }
  /* One wrapping line, so a longer translation moves to the next line instead of running into the other column. */
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) strong {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 6px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) small {
    font-size: 12px;
  }
  /* English reads "As low as" / "1.4 % of list price": keep the phrase on its own line above the number. */
  html:lang(en) .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) small {
    flex-basis: 100%;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) b {
    font-size: clamp(30px, 9.2vw, 36px);
    font-weight: 400;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-earth-metrics:not(#cn-mobile) i {
    margin-bottom: 0;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-copy:not(#cn-mobile) h1 {
    margin-top: 0;
    font-size: clamp(40px, 12.6vw, 52px);
    word-break: keep-all;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-copy:not(#cn-mobile) > p {
    margin-top: 20px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-login-block:not(#cn-mobile) {
    justify-self: stretch;
    margin-top: 28px;
  }
  .home-board-agy-page:not(#cn-mobile) .home-board-agy-login-block:not(#cn-mobile) > .home-board-agy-login-button {
    justify-self: stretch;
    width: 100%;
    min-height: 52px;
  }
  /* Service cards keep the desktop's 218px height for two lines of text; let them fit their content. */
  .cn-commercial--light:not(#cn-mobile) .cn-commercial__capabilities .cn-commercial__card--glass {
    min-height: 0;
  }

  /* ---------- Overview: the drawer button duplicates the top navigation and covered the title ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) > .dashboard-card-wall-page > .dashboard-sidebar-toggle {
    display: none !important;
  }

  /* ---------- Wallet: the custom amount gets the full row ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .pricing-page .recharge-option-grid > .recharge-custom-card {
    grid-column: 1 / -1;
  }

  /* ---------- Shared: tables become stacked cards ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > thead {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody {
    display: block;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody > tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    height: auto;
    border-bottom: 1px solid rgba(17, 17, 17, 0.08);
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody > tr > td {
    display: block;
    width: auto !important;
    height: auto;
    min-width: 0 !important;
    max-width: none;
    overflow: visible;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0.56;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody > tr > td[colspan] {
    grid-column: 1 / -1;
    text-align: center;
  }
  html[data-console-theme="dark"] .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) :is(.keys-console-page .keys-table, .usage-explorer-page .gateway-usage-table) > tbody > tr {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }

  /* ---------- API keys: name on top, details in two columns, actions on their own row ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table-scroll {
    max-height: none;
    overflow: visible;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr {
    grid-auto-flow: row dense;
    padding: 18px 8px;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td {
    font-size: 14px;
  }
  /* Selectors with :has() stay in their own rules so older browsers still apply the rest. */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:first-child:not([colspan]) {
    grid-column: 1 / -1;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:first-child:not([colspan])::before {
    display: none !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:has(.keys-daily-summary),
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:has(> .keys-action-icons) {
    grid-column: 1 / -1;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:has(> .keys-action-icons)::before {
    display: none !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td:first-child > strong {
    margin-bottom: 0;
    overflow: visible;
    font-size: 16px;
    white-space: normal;
    text-overflow: clip;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table > tbody > tr > td > small {
    max-width: none;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table .keys-action-icons {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .keys-console-page .keys-table .keys-action-icons button {
    width: 44px;
    height: 44px;
  }

  /* ---------- Usage: request cards, a chart that fits, no sideways scroll buttons ---------- */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .usage-details-scroll-controls {
    display: none !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table-wrap {
    overflow: visible !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr {
    padding: 16px 2px;
  }
  /* Card header: time on the left, status on the right. */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr > td:first-child {
    order: -2;
    font-weight: 550;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr > td:has(> .status-pill) {
    order: -1;
    justify-self: end;
    text-align: right;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr > td:first-child::before {
    display: none !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr > td:has(> .status-pill)::before {
    display: none !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table > tbody > tr > td:is(:has(.usage-endpoint-cell), :has(.usage-response-cell)) {
    grid-column: 1 / -1;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .gateway-usage-table :is(.usage-user-agent-cell, .usage-response-cell, .usage-ip-cell code) {
    display: block;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .usage-chart {
    grid-template-columns: none !important;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    gap: 3px !important;
    overflow-x: visible !important;
  }
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .usage-chart > .usage-bar > small {
    overflow: visible;
    white-space: nowrap;
  }
  /* Many bars: label every sixth so the axis stays readable. */
  .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) .usage-explorer-page .usage-chart:has(> .usage-bar:nth-child(9)) > .usage-bar:not(:nth-child(6n + 1)) > small {
    visibility: hidden;
  }

  /* ---------- Model prices: dock the Claude notice, cap it at a third of the screen, keep prices reachable ---------- */
  .model-claude-notice-float:not(#cn-mobile) {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
  }
  .model-claude-notice-float:not(#cn-mobile) .model-claude-notice-panel {
    max-height: min(360px, 34vh);
    max-height: min(360px, 34dvh);
  }
  .model-claude-notice-float:not(#cn-mobile).is-open .model-claude-notice-content-inner {
    max-height: calc(min(360px, 34vh) - 64px);
    max-height: calc(min(360px, 34dvh) - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Let the last prices scroll above the docked notice. */
  body:has(> .model-claude-notice-float.is-open) .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) > .model-pricing-page {
    padding-bottom: calc(min(360px, 34vh) + 24px) !important;
  }
  body:has(> .model-claude-notice-float.is-collapsed) .app-shell.agy-console-shell.agy-board-shell:not(#cn-mobile) .agy-board-main:not(#cn-mobile) > .model-pricing-page {
    padding-bottom: 96px !important;
  }
}
