@media (max-width: 820px) {
  .sidebar-stream-attention:not([hidden]) {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
    padding: 0 18px;
    color: var(--amber);
    background: color-mix(in srgb, var(--amber) 10%, var(--bg));
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line-soft));
    font-size: calc(11px * var(--font-scale));
    font-weight: 700;
    text-align: left;
    cursor: pointer;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    /* The shell already follows the visible Host/keyboard rectangle. A fixed
     * sidebar would size its scrollport to the larger iframe and be clipped. */
    position: absolute;
    z-index: 31;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    padding-top: var(--safe-top);
    border-inline-end: 0;
    box-shadow: none;
    transform: translateX(-105%);
    transition: transform 160ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .thread-list {
    padding-inline: max(7px, var(--safe-left)) max(7px, var(--safe-right));
  }

  .sidebar.edge-dragging {
    transform: translateX(calc(-100% + var(--sidebar-edge-x, 0px)));
    transition: none;
  }

  .mobile-thread-list-control {
    display: inline-grid;
  }

  .thread-detail {
    height: 100%;
  }

  .app-shell,
  .sidebar,
  .thread-detail,
  .action-center,
  .detail-sheet {
    overscroll-behavior-x: none;
  }

  .thread-topbar-controls {
    min-height: calc(54px + var(--safe-top));
    padding: calc(5px + var(--safe-top)) max(6px, var(--safe-right)) 5px max(4px, var(--safe-left));
  }

  .thread-context-row {
    padding-inline: calc(12px + var(--column-content-left, 0px)) calc(12px + var(--column-content-right, 0px));
  }

  .message-stream {
    padding: 20px max(12px, var(--safe-right)) 32px max(12px, var(--safe-left));
  }

  .message-agent:not(.native-receipt) {
    grid-template-columns: 27px minmax(0, 1fr);
    gap: 8px;
  }

  .agent-avatar {
    width: 27px;
    height: 27px;
    border-radius: 8px;
  }

  .message-bubble {
    max-width: 91%;
  }

  .native-card-summary {
    padding: 12px;
  }

  .native-card-summary-head {
    gap: 8px;
  }

  .execution-header {
    padding: 14px 13px;
  }

  .execution-surface h2 {
    font-size: calc(14px * var(--font-scale));
  }

  .technical-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .technical-grid > span,
  .technical-grid > span:nth-child(even),
  .technical-grid > span:nth-last-child(-n + 2) {
    border-inline-end: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .technical-grid > span:last-child {
    border-bottom: 0;
  }

  .event-line {
    grid-template-columns: 39px 8px minmax(0, 1fr);
  }

  .event-line code {
    display: none;
  }

  .live-strip {
    width: calc(100% - max(20px, var(--safe-left) + var(--safe-right)));
  }

  /* The quota dialog covers the visible app rectangle and owns its safe edges. */
  .profile-menu {
    inset: var(--app-top, 0px) 0 auto;
    width: 100%;
    height: var(--app-height, 100dvh);
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .quota-detail-title {
    min-height: calc(52px + var(--safe-top));
    padding: calc(4px + var(--safe-top)) max(6px, var(--safe-right)) 4px max(14px, var(--safe-left));
  }

  .quota-panel-body {
    padding: 2px max(8px, var(--safe-right)) calc(12px + var(--safe-bottom)) max(8px, var(--safe-left));
  }

  .composer-shell {
    padding: 3px max(10px, var(--safe-right)) calc(7px + var(--safe-bottom)) max(10px, var(--safe-left));
  }

  html.keyboard-open .composer-shell,
  html.embed-hermes.keyboard-open .composer-shell {
    padding-bottom: max(7px, var(--host-bottom-safe-area));
  }

  .action-center-body {
    padding: 10px max(12px, var(--safe-right)) calc(25px + var(--safe-bottom)) max(12px, var(--safe-left));
  }

  .action-center-header {
    padding-inline: max(6px, var(--safe-left)) max(9px, var(--safe-right));
  }

  .action-card {
    padding: 11px 12px 9px;
  }

  .detail-sheet {
    width: 100%;
    max-width: none;
    max-height: 82dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
  }
}

@media (max-width: 380px) {
  html:not(.embed-hermes) .thread-context #detail-meta {
    max-width: 190px;
  }

  .message-stream {
    padding-inline: max(12px, var(--safe-left)) max(12px, var(--safe-right));
  }

  .execution-header {
    display: grid;
  }

  .status-pill {
    justify-self: start;
  }

  .summary-stat span {
    display: none;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
