/* Shared phone layout. Desktop compositions stay in their page stylesheets. */
@media (max-width: 740px) {
  html { -webkit-text-size-adjust: 100%; }
  button, a, summary, input, select, textarea { touch-action: manipulation; }
  input, select, textarea { font-size: 16px; }
  .site-header, .studio-header {
    --header-height: 72px;
    --header-inset: 16px;
    height: calc(72px + env(safe-area-inset-top));
    min-height: calc(72px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }
  .site-header .menu-button, .studio-header .menu-button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 10px;
    border-radius: 12px;
  }
  .studio-header .studio-logo { top: calc(16px + env(safe-area-inset-top)); }
  .studio-header .menu-button.menu-follows-scroll {
    top: calc(14px + env(safe-area-inset-top));
    transform: none;
  }
  .studio-header .menu-button.is-floating {
    background: #f2eedff2;
    box-shadow: 0 3px 14px #253e3512;
  }
  .wordmark, .studio-logo { font-size: 26px; }

  /* A full-width caption and a clear action above the destination selector. */
  .home-art:after {
    background: linear-gradient(180deg, #071e3040 0%, transparent 25%, #07241d80 48%, #051f1cf2 100%);
  }
  .home-description {
    display: block;
    left: max(24px, env(safe-area-inset-left));
    right: max(24px, env(safe-area-inset-right));
    top: auto;
    bottom: calc(112px + env(safe-area-inset-bottom));
    width: auto;
  }
  .home-description > span { font-size: 10px; opacity: .85; letter-spacing: 2px; }
  .home-description h2 {
    max-width: 440px;
    font-size: clamp(30px, 8.8vw, 44px);
    line-height: 1.12;
    letter-spacing: -.8px;
    margin: 14px 0;
    text-wrap: balance;
  }
  .home-description p { display: block; font-size: 14px; line-height: 1.65; opacity: .9; max-width: 400px; }
  .home-description > button {
    width: 100%;
    min-height: 50px;
    justify-content: space-between;
    margin: 22px 0 0;
    padding: 8px 12px 8px 18px;
    border: 1px solid #ffffff70;
    border-radius: 14px;
    background: #ffffff14;
    font-size: 14px;
    gap: 12px;
  }
  .home-description > button span { flex-shrink: 0; width: 32px; height: 32px; font-size: 23px; border: 0; }
  .home-bottom { left: 24px; right: 24px; bottom: calc(35px + env(safe-area-inset-bottom)); }
  .home-dots > button { min-width: 44px; min-height: 44px; }
  .home-dots span { font-size: 11px; }

  /* Keep navigation comfortably tappable, including the close control. */
  #journey-menu.immersive-menu { overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
  #journey-menu .menu-top { padding: calc(78px + env(safe-area-inset-top)) 24px 24px; min-height: 0; }
  #journey-menu .menu-brand { font-size: 32px; }
  #journey-menu .menu-links { width: 100%; margin-top: 26px; }
  #journey-menu .menu-links :is(a, button) { min-height: 56px; font-size: clamp(21px, 6vw, 28px); padding-block: 12px; }
  #journey-menu .menu-links small { margin-right: 12px; }
  #journey-menu .menu-dismiss { top: calc(14px + env(safe-area-inset-top)); right: 16px; width: 44px; height: 44px; }
  #journey-menu .menu-gallery-heading { padding-inline: 24px; line-height: 1.7; }
  #journey-menu .menu-destination { min-width: 0; width: 62vw; height: 180px; min-height: 0; }
  #journey-menu .menu-foot { padding: 20px 24px; font-size: 12px; line-height: 1.6; }

  /* Forms and itinerary cards use the available width instead of tiny columns. */
  .studio-main { padding: 22px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .studio-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .studio-grid > *, .chat-layout > *, .field, .field-row, .panel { min-width: 0; }
  .page-intro { flex-wrap: wrap; gap: 14px; }
  .page-intro > div { min-width: 0; }
  .page-intro h1 { font-size: 29px; letter-spacing: -.8px; }
  .page-intro p { max-width: none; font-size: 14px; line-height: 1.65; }
  .overline { font-size: 9px; line-height: 1.6; }
  .button, .new-trip { min-height: 46px; font-size: 14px; padding: 11px 16px; }
  .new-trip > span { font-size: 20px; }
  .request-panel form { display: block; padding: 20px 16px; }
  .request-panel summary { min-height: 72px; padding: 16px; font-size: 15px; }
  .request-panel summary small { font-size: 11px; }
  .request-panel .form-footnote { text-align: left; font-size: 12px; line-height: 1.65; margin-bottom: 18px; }
  .field { font-size: 13px; margin-bottom: 18px; }
  .field input, .field select, .field textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 48px; font-size: 16px; border-radius: 10px; padding: 12px; }
  .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .add-destination { min-height: 46px; font-size: 13px; margin-top: -4px; }
  .destination-chip { padding: 4px 6px 4px 12px; font-size: 12px; }
  .destination-chip button { min-width: 36px; min-height: 36px; font-size: 22px; }
  .request-panel legend { font-size: 13px; }
  .interest-grid label { min-height: 44px; }
  .interest-grid span { min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; }
  .generate { width: 100%; min-height: 52px; font-size: 14px; }
  .destination-cover { height: 230px; }
  .cover-content { left: 18px; right: 18px; bottom: 20px; }
  .cover-content h2 { font-size: 32px; overflow-wrap: anywhere; }
  .cover-content p { font-size: 12px; line-height: 1.6; }
  .itinerary-toolbar { flex-wrap: wrap; gap: 4px 16px; }
  .view-tabs { gap: 20px; }
  .view-tabs button { min-height: 48px; font-size: 13px; }
  .draft-label { font-size: 11px; padding-bottom: 10px; }
  .day-tabs { max-width: 100%; gap: 8px; overscroll-behavior-x: contain; }
  .day-tabs button { flex-shrink: 0; min-height: 44px; font-size: 13px; }
  .day-topline { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .day-topline h3 { font-size: 18px; overflow-wrap: anywhere; }
  .day-topline button { min-height: 44px; font-size: 13px; }
  .activity-card { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 16px 12px; }
  .activity-icon { width: 30px; height: 30px; font-size: 17px; }
  .activity-card h4 { font-size: 15px; }
  .activity-time, .activity-tag { font-size: 12px; }
  .activity-cost, .day-tip { font-size: 13px; line-height: 1.7; }
  .itinerary-bottom { gap: 12px; font-size: 12px; }
  .itinerary-bottom button { min-width: 44px; min-height: 44px; flex-shrink: 0; }
  .saving-button, .saved-actions button { min-height: 44px; font-size: 13px; }
  .budget-status, .budget-brief > div, .cost-row, .data-note { font-size: 12px; line-height: 1.7; }
  .saved-actions { flex-wrap: wrap; }
  .saved-body h3 { font-size: 20px; overflow-wrap: anywhere; }
  .saved-body > p { font-size: 13px; }
  .studio-footer { padding-block: 24px; font-size: 11px; line-height: 1.7; }
  .toast { max-width: calc(100vw - 32px); white-space: normal; text-align: center; bottom: calc(20px + env(safe-area-inset-bottom)); }

  /* The composer stays in the initial viewport; only messages scroll. */
  body[data-screen="chat"] .studio-main { padding: 12px 12px 24px; }
  body[data-screen="chat"] .page-intro { margin: 0 4px 16px; }
  body[data-screen="chat"] .page-intro .overline,
  body[data-screen="chat"] .page-intro p { display: none; }
  body[data-screen="chat"] .page-intro h1 { font-size: 25px; line-height: 1.3; }
  body[data-screen="chat"] .chat-layout { gap: 24px; }
  body[data-screen="chat"] .assistant-panel {
    height: calc(100dvh - 152px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 360px;
    max-height: none;
  }
  body[data-screen="chat"] .assistant-top { padding: 12px; gap: 8px; }
  body[data-screen="chat"] .assistant-top h2 { font-size: 14px; }
  body[data-screen="chat"] .assistant-top p { font-size: 11px; }
  body[data-screen="chat"] .chat-reset { min-width: 44px; min-height: 44px; padding: 8px; }
  body[data-screen="chat"] .chat-plan-picker { padding: 10px 12px; }
  body[data-screen="chat"] .chat-plan-picker select { font-size: 16px; min-height: 44px; margin-top: 5px; }
  body[data-screen="chat"] .studio-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; }
  body[data-screen="chat"] .chat-bubble { font-size: 14px; max-width: 100%; }
  body[data-screen="chat"] .quick-questions { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 10px 12px; gap: 8px; scrollbar-width: none; }
  body[data-screen="chat"] .quick-questions button { flex: 0 0 auto; min-height: 44px; white-space: nowrap; font-size: 12px; }
  body[data-screen="chat"] #studio-chat-form { margin: 0 12px 12px; padding: 6px; gap: 6px; }
  body[data-screen="chat"] #studio-chat-input { font-size: 16px; min-height: 44px; max-height: 88px; }
  body[data-screen="chat"] #studio-chat-form button { width: 44px; height: 44px; }
  body[data-screen="chat"] .chat-input-hint { display: none; }

  /* Explore reads as a vertical photo list on a phone. */
  html:has(body.is-explore), body.is-explore { height: auto; min-height: 100%; overflow: visible; }
  body.is-explore .site-header { background: #f2eedff5; border-bottom: 1px solid #294b4015; }
  #journey { height: auto; min-height: 100dvh; overflow: visible; touch-action: pan-y; cursor: auto; padding: calc(96px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); }
  #journey .journey-track { display: block; width: 100%; height: auto; min-height: 0; }
  #journey .intro { display: block; width: 100%; min-width: 0; height: auto; padding: 12px 8px 32px; }
  #journey .tripBlock__introWrapper { margin: 0; padding: 0; }
  #journey .tripBlock__title { font-size: clamp(42px, 12vw, 64px); line-height: 1.08; letter-spacing: -1.5px; }
  #journey .back-button { margin: 18px 0 0; min-height: 44px; padding: 8px 0; font-size: 14px; }
  .explore-caption { font-size: 14px; margin: 16px 0; max-width: none; }
  .explore-quick { max-width: none; gap: 8px; }
  .explore-quick button { min-height: 44px; padding: 10px 14px; font-size: 13px; }
  #journey .journey-group { display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; height: auto; margin-bottom: 24px; scroll-margin-top: 92px; }
  #journey .tripBlock__item { margin: 0; }
  #journey .tripImageItem { width: 100%; min-width: 0; max-width: none; height: auto; aspect-ratio: 4 / 3; min-height: 0; max-height: none; border-radius: 18px 18px 0 0; }
  #journey .tripTextItem { width: 100%; max-width: none; }
  #journey .tripTextItem__wrapper { border-radius: 0 0 18px 18px; padding: 22px; min-height: 0; max-height: none; overflow: visible; }
  #journey .tripTextItem__title { font-size: 30px; }
  #journey .tripTextItem__desc { margin-top: 12px; font-size: 15px; line-height: 1.65; }
  #journey .tripTextItem__wrapper > button { min-height: 44px; font-size: 14px; }
  .explore-category { margin-bottom: 12px; font-size: 11px; }
  .explore-actions { gap: 12px; margin-top: 16px; }
  .explore-plan, .explore-more { min-height: 44px; font-size: 13px; align-items: center; }
  body.is-explore .journey-footer { display: none; }
  .explore-detail { max-height: calc(100dvh - 32px); padding: 54px 22px 24px; }
  .explore-close { width: 44px; height: 44px; top: 8px; right: 8px; }
  #chat-dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 18px; }
  #chat-dialog .chat-card { padding: 62px 16px 18px; }
  #chat-dialog .chat-heading { padding-right: 0; gap: 8px; }
  #chat-dialog .chat-heading h2 { font-size: 16px; }
  #chat-dialog .chat-heading p { font-size: 11px; }
  #chat-dialog .chat-messages { min-height: 120px; max-height: 32dvh; }
  #chat-dialog .chat-form { position: sticky; bottom: 0; background: #fffef9; }
  #chat-dialog .chat-form input { font-size: 16px; }
  #chat-dialog .chat-form button, #chat-dialog .close-chat, #chat-dialog .reset-chat { min-width: 44px; min-height: 44px; }
  #chat-dialog .suggestions button { min-height: 44px; font-size: 13px; }

  /* A single timeline leaves room for long place names and directions. */
  .route-back { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; margin-bottom: 12px; }
  .route-hero { padding: 60px 20px 24px; min-height: 260px; }
  .hero-copy h1 { font-size: 32px; overflow-wrap: anywhere; }
  .route-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .route-summary { padding: 22px; }
  .route-summary p, .route-caption { font-size: 13px; }
  .route-days a { min-height: 44px; display: inline-flex; align-items: center; font-size: 13px; }
  .route-day { scroll-margin-top: 88px; }
  .route-day > header { gap: 12px; }
  .route-day > header:after { display: none; }
  .day-marker { flex-shrink: 0; }
  .route-day h2 { font-size: 22px; }
  .route-day li, .route-day li:nth-of-type(even) { width: 100%; margin-left: 0; padding: 0 0 26px 30px; }
  .route-day li:nth-of-type(even) .stop-marker { left: 0; right: auto; }
  .route-day article { padding: 16px; }
  .stop-meta { flex-wrap: wrap; font-size: 12px; }
  .route-day article p { font-size: 13px; line-height: 1.7; }
  .route-day .stop-photo { height: auto; aspect-ratio: 16 / 10; }
}

/* The menu's slide is controlled by menu.js; avoid a second reveal animation. */
@media (max-width: 740px) {
  .journey-menu:not([hidden]) { animation: none; }
}

@media (max-width: 740px) and (max-height: 650px) {
  .home-description { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .home-description h2 { font-size: 30px; margin-block: 10px; }
  .home-description p { font-size: 13px; line-height: 1.5; }
  .home-description > button { min-height: 46px; margin-top: 14px; }
  .home-bottom { bottom: calc(23px + env(safe-area-inset-bottom)); }
}

@media (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {
  .home-description { left: 24px; bottom: 86px; top: 85px; width: min(70%, 520px); display: block; overflow-y: auto; }
  .home-description h2 { max-width: none; font-size: 30px; margin-block: 8px; }
  .home-description p { display: none; }
  .home-description > button { width: fit-content; margin-top: 12px; min-height: 44px; }
  .home-bottom { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #journey-menu .menu-film { animation: none; transform: translateX(0); }
}
