.mobile-menu,
.scrim {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1500px) {
  .welcome {
    margin-top: 8px;
  }
  h1 {
    font-size: 72.8px;
  }
  .chat-scroll {
    max-height: calc(100dvh - 350px);
  }
}
@media (max-width: 1100px) {
  .sidebar {
    width: 222px;
    padding: 28px 17px 16px;
  }
  main {
    margin-left: 222px;
  }
  .chat-toolbar,
  header {
    padding-left: 25px;
    padding-right: 25px;
  }
  h1 {
    font-size: 53.76px;
  }
  .welcome {
    margin-top: 8px;
  }
  .suggestion {
    padding: 15px;
  }
  .suggestion b {
    font-size: 13px;
  }
  .other-view {
    padding: 45px 30px;
  }
  .stats > div {
    padding: 18px;
  }
  .prompt-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 760px), (max-height: 500px) and (max-width: 1000px) {
  .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 0.25s,
      visibility 0s 0.25s;
    width: 252px;
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s;
  }
  .scrim.open {
    display: block;
    position: fixed;
    inset: 0;
    background: #00000050;
    z-index: 9;
  }
  main {
    margin-left: 0;
  }
  header {
    height: 64px;
    padding: 0 20px;
  }
  .mobile-menu {
    display: block;
    font-size: 20.16px;
    padding: 0 3px;
  }
  .workspace-label,
  .header-divider {
    display: none;
  }
  .header-left {
    gap: 12px;
  }
  .chat-toolbar {
    padding: 15px 20px;
  }
  .chat-scroll {
    padding: 0 20px;
    min-height: 330px;
    max-height: none;
    flex: 1;
  }
  .chat-view {
    min-height: calc(100dvh - 98px);
  }
  .welcome {
    margin: 8px auto 12px;
  }
  .eyebrow {
    font-size: 11px;
    letter-spacing: 0.3px;
  }
  h1 {
    font-size: 45.92px;
    letter-spacing: -1.6px;
  }
  .intro {
    font-size: 12.32px;
  }
  .suggestions {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 27px;
  }
  .suggestion {
    padding: 13px 10px;
  }
  .suggestion-icon {
    width: 25px;
    height: 25px;
    font-size: 17.92px;
  }
  .suggestion b {
    font-size: 11.2px;
    line-height: 1.5;
  }
  .suggestion > span:not(.suggestion-icon) {
    font-size: 12px;
  }
  .suggestion em {
    display: none;
  }
  .welcome-foot {
    font-size: 11px;
  }
  .composer-area {
    width: calc(100% - 32px);
    margin-top: 20px;
  }
  .composer-footer {
    font-size: 11px;
    line-height: 1.5;
  }
  .composer-footer > span {
    max-width: 55%;
  }
  .composer-hint {
    display: none;
  }
  .main-footer {
    padding: 10px 20px;
    font-size: 11px;
  }
  .other-view {
    padding: 35px 20px;
  }
  /* iOS Safari zooms the page when a focused field is smaller than 16px. */
  #prompt,
  .auth-form input,
  .conversation-search input {
    font-size: 16px;
  }
  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stats > div {
    padding: 17px;
  }
  .stats b {
    margin: 10px 0;
  }
  .prompt-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .prompt-card {
    padding: 17px;
  }
  .toast {
    left: 50%;
  }
  .toolbar-note {
    font-size: 10.08px;
  }
  .transactions-heading span {
    max-width: 95px;
    text-align: right;
  }
  .message {
    font-size: 15px;
    line-height: 1.65;
  }
  h2 {
    font-size: 39.2px;
  }
}
@media (min-width: 761px) and (max-height: 900px) {
  main:has(.chat-view:not([hidden]) .welcome:not([hidden])) header {
    height: 64px;
  }
  .chat-view:has(.welcome:not([hidden])) .chat-toolbar {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .welcome h1 {
    margin: 12px 0 10px;
  }
  .welcome .intro {
    margin: 8px 0;
  }
  .welcome .suggestions {
    margin-top: 16px;
  }
  .welcome .suggestion-icon {
    margin-bottom: 10px;
  }
  .welcome .welcome-foot {
    margin: 8px auto;
  }
  .chat-view:has(.welcome:not([hidden])) .composer-area {
    margin-top: auto;
    padding-top: 8px;
    margin-bottom: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* Phones: selectors share one row, and menus open as a bottom sheet inside the
   screen instead of below a button near the right edge. */
@media (max-width: 760px), (max-height: 500px) and (max-width: 1000px) {
  .chat-toolbar .toolbar-note {
    display: none;
  }
  /* Dialogs fit the screen: tighter padding and line spacing. */
  dialog {
    padding: 24px 20px;
  }
  dialog h2 {
    font-size: 28px;
    margin-top: 10px;
  }
  dialog p {
    line-height: 1.55;
  }
  /* The start screen keeps only the hint cards: the title and intro take the room they need. */
  .welcome .eyebrow,
  .welcome h1,
  .welcome .intro {
    display: none;
  }
  .welcome .suggestions {
    margin-top: 8px;
    gap: 6px;
  }
  /* Compact card: the icon on the left, the title and text on the right. */
  .welcome .suggestion {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 12px;
    align-items: start;
    padding: 12px;
  }
  .welcome .suggestion .suggestion-icon {
    grid-row: 1 / span 2;
    margin-bottom: 0;
  }
  /* Random ideas have texts of different length: the card height stays the same, extra text ends with "…". */
  .welcome .suggestion b {
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .welcome .suggestion > span:not(.suggestion-icon) {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  .chat-toolbar {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .chat-toolbar {
    padding-left: 16px;
    padding-right: 16px;
  }
  /* Selectors share the row in equal fixed columns (two in text mode, three in
     photo mode), so they never overlap or wrap; a long label ends with "…". */
  .toolbar-selectors {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }
  .toolbar-selectors > *,
  .toolbar-selectors .choice-wrap {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .toolbar-selectors .model-button,
  .toolbar-selectors .type-choice-button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    margin-left: 0;
    padding: 8px 10px;
    font-size: 13px;
    gap: 6px;
    white-space: nowrap;
  }
  .toolbar-selectors .model-symbol {
    flex: none;
    font-size: 18px;
    line-height: 1;
  }
  .toolbar-selectors .model-button > .chevron {
    flex: none;
    margin-left: auto;
  }
  .model-brand {
    display: none;
  }
  .toolbar-selectors .model-button > span:not(.chevron):not(.model-symbol) {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .model-menu {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto;
    max-height: min(70dvh, 560px);
    overflow-y: auto;
    z-index: 40;
    box-shadow: 0 -8px 40px #00000033;
  }
  #image-size-menu {
    max-height: min(70dvh, 560px);
  }
}

/* Mobile usability: tap targets, visible composer and room for messages. */
@media (max-width: 760px), (max-height: 500px) and (max-width: 1000px) {
  /* Larger hit areas without changing how the icons look. */
  .site-home-btn span {
    display: none;
  }
  .site-home-btn svg {
    width: 19px;
    height: 19px;
  }
  .mobile-menu,
  .site-home-btn,
  .help-btn {
    position: relative;
  }
  .mobile-menu::after,
  .site-home-btn::after,
  .help-btn::after {
    content: "";
    position: absolute;
    inset: -10px;
  }
  /* A new chat scrolls as a page: keep the composer pinned to the screen. */
  .chat-view:has(.welcome:not([hidden])) .composer-area {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-bottom: 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, transparent, var(--bg) 16px);
  }
  /* Inside a conversation the footer only takes space from the messages. */
  main:has(.chat-view:not([hidden]) #welcome[hidden]) .main-footer {
    display: none;
  }
  .conversation-row {
    gap: 6px;
  }
  .conversation-delete {
    align-self: center;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
  }
  /* Notifications drop from under the header instead of covering the composer. */
  .toast {
    top: calc(72px + env(safe-area-inset-top));
    bottom: auto;
    max-width: calc(100% - 32px);
    transform: translateX(-50%) translateY(-24px);
  }
  .toast.show {
    transform: translateX(-50%) translateY(0);
  }
  /* Long drafts must leave room for the chat and the on-screen keyboard. */
  #prompt {
    max-height: min(200px, 30dvh);
  }
  /* Bottom-sheet menus dim the page behind them. */
  .model-menu {
    box-shadow: 0 0 0 100vmax #00000033, 0 -8px 40px #00000033;
  }
  /* Only the recent-chats list scrolls; the logo, menu, balance and account stay in place. */
  .sidebar {
    height: 100dvh;
    overflow: hidden;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .sidebar > :not(.history) {
    flex: none;
  }
  .history {
    flex: 1 1 0;
    min-height: 96px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
/* A very short screen (phone on its side) cannot fit everything: the drawer scrolls as a whole. */
@media (max-width: 760px) and (max-height: 560px), (max-height: 500px) and (max-width: 1000px) {
  .sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .history {
    flex: none;
    max-height: 45dvh;
  }
}
@media (max-width: 760px), (max-height: 500px) and (max-width: 1000px) {
  /* Expenses: three compact figures in one row. */
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .stats > div {
    padding: 12px;
  }
  .stats b {
    font-size: 20px;
    margin: 6px 0;
  }
  .stats small {
    display: none;
  }
  .stats button {
    text-align: left;
    font-size: 11px;
  }
}
