/* Touch layout, visible keyboard viewport and iPhone safe areas. */
@media(max-width:760px){
  :root{--safe-bottom:env(safe-area-inset-bottom,0px);}
  :root[data-keyboard="open"]{--safe-bottom:0px;}
  html,body{overscroll-behavior:none;}
  .app-shell,.auth-screen{position:fixed;top:var(--viewport-top,0px);right:0;bottom:auto;left:0;height:var(--app-height,100dvh);}
  button,a,input,textarea,select{-webkit-tap-highlight-color:transparent;}
  button,a{touch-action:manipulation;}
  input,textarea,select,.text-field,.history-search,.preset-fields textarea{font-size:16px;}
  .workspace,.desktop-app .workspace,.main{height:100%;min-height:0;}
  .main-header{height:calc(56px + env(safe-area-inset-top,0px));min-height:calc(56px + env(safe-area-inset-top,0px));padding:env(safe-area-inset-top,0px) max(10px,env(safe-area-inset-right,0px)) 0 max(10px,env(safe-area-inset-left,0px));gap:4px;}
  .main-header .icon-button{width:44px;height:44px;flex:0 0 44px;}
  .conversation-title{display:flex;align-items:center;flex:1;gap:2px;overflow:hidden;}
  #headerMode{display:block;flex:1;max-width:none;font-size:13px;}
  .title-menu{width:26px;height:44px;flex-shrink:0;}
  .header-actions{gap:0;margin-left:0;}
  .header-usage{height:36px;padding:0 9px;font-size:12px;}
  .sidebar{top:var(--viewport-top,0px);bottom:auto;height:var(--app-height,100dvh);width:min(320px,87vw);padding:calc(14px + env(safe-area-inset-top,0px)) 14px calc(12px + var(--safe-bottom));}
  .sidebar-head{padding-bottom:22px;}
  .sidebar-close{width:44px;height:44px;}
  .new-chat{min-height:44px;font-size:14px;}
  .mode-item{height:46px;font-size:14px;}
  .history-search{height:44px;}
  .section-label{font-size:10px;}
  .history-list{grid-auto-rows:44px;}
  .history-row .history-item{height:44px;font-size:13px;}
  .history-more{width:40px;height:40px;right:0;}
  .plan-card,.profile{min-height:55px;}
  .plan-copy strong,.profile-copy strong{font-size:13px;}
  .plan-copy small,.profile-copy small{font-size:11px;}
  .welcome{padding:0 24px;}
  .welcome h1{font-size:clamp(34px,9vw,43px);line-height:1.15;}
  .welcome>p:not(.eyebrow){font-size:14px;line-height:1.65;margin-top:14px;}
  .composer-wrap{padding:12px max(12px,env(safe-area-inset-right,0px)) max(10px,var(--safe-bottom)) max(12px,env(safe-area-inset-left,0px));}
  .conversation.is-empty .composer-wrap{padding-top:24px;padding-bottom:0;}
  .composer{padding:14px 12px 10px;border-radius:20px;}
  .composer textarea{font-size:16px;line-height:1.55;min-height:42px;max-height:min(160px,calc(var(--app-height,100dvh)*.3));padding-bottom:12px;}
  .composer-toolbar{min-height:44px;}
  .tool-button,.send-button{width:44px;height:44px;}
  .model-select{height:40px;font-size:13px;padding:0 10px;}
  .model-menu{left:12px;right:12px;bottom:calc(var(--composer-space) - 24px);max-height:min(370px,calc(var(--app-height,100dvh) - 150px));overflow-y:auto;}
  .model-menu button{min-height:52px;}
  .model-menu strong{font-size:13px;}.model-menu small{font-size:11px;}
  .disclaimer{margin:8px 8px 0;font-size:10px;color:var(--muted);}
  .suggestions{margin:16px 16px auto;gap:7px;padding-bottom:max(18px,var(--safe-bottom));}
  .suggestions button{min-height:38px;padding:0 11px;font-size:11px;}
  .messages{padding:18px max(16px,env(safe-area-inset-right,0px)) var(--composer-space) max(16px,env(safe-area-inset-left,0px));}
  .message{margin-bottom:26px;}
  .message-body{font-size:16px;line-height:1.7;}
  .message-content .answer-text{line-height:1.7;}
  .message.user{max-width:92%;margin-bottom:28px;}
  .message.user .message-content{padding:10px 14px;}
  .message-body>strong,.message-meta .text-button{font-size:11px;}
  .message-meta .text-button{min-height:36px;padding:5px 0;}
  .message-content table,.code-block{display:block;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;}
  .message-content a,.message-attachment{overflow-wrap:anywhere;}
  .attachment-list.is-visible{flex-wrap:nowrap;overflow-x:auto;padding:7px 6px 14px;gap:12px;}
  .attachment-chip{flex-shrink:0;max-width:min(260px,80vw);}
  .attachment-chip.image-chip{width:80px;height:80px;flex-basis:80px;}
  .image-chip button.attachment-remove{width:28px;height:28px;top:-5px;right:-5px;}
  .app-dialog,.image-viewer{max-height:calc(var(--app-height,100dvh) - 24px);width:calc(100% - 24px);border-radius:18px;}
  .app-dialog form,.dialog-content{padding:22px 18px;}
  .dialog-head{gap:12px;margin-bottom:18px;}
  .dialog-head h2{font-size:24px;}
  .close-dialog{width:44px;height:44px;flex-shrink:0;margin:-7px -7px 0 0;}
  .field-label{font-size:12px;}
  .text-field{min-height:48px;}
  .primary-button,.secondary-button{min-height:44px;font-size:13px;}
  .settings-tools button{font-size:12px;}
  .settings-row strong{overflow-wrap:anywhere;}.settings-row small{font-size:11px;}
  .form-description{font-size:13px;}
  .allowance-grid{gap:8px;}.allowance-card{padding:14px 10px;}
  .allowance-head strong{font-size:11px;}.allowance-description,.allowance-status{font-size:10px;}
  .allowance-value{font-size:26px;}
  .tariff-name{font-size:15px;}.tariff-features{font-size:12px;}.tariff-card small{font-size:11px;}
  .tariff-card p.tariff-description{font-size:12px;}.tariff-card button{font-size:12px;}
  .studio-heading{padding:8px 18px 20px;}.studio-heading>div>p:last-child{max-width:100%;font-size:13px;}
  .studio-tabs button{font-size:13px;min-height:44px;}.studio-tabs{min-height:44px;}
  .studio-scroll{padding:18px 12px var(--composer-space);}
  .studio-intro>span{font-size:13px;}.studio-intro small{font-size:11px;}
  .studio-filters{flex-wrap:nowrap;overflow-x:auto;gap:6px;padding-bottom:4px;}
  .studio-filters button{min-height:38px;font-size:12px;flex-shrink:0;}
  .preset-card-copy strong{font-size:13px;line-height:1.4;}.preset-card-copy small{display:none;}
  .preset-badge{font-size:9px;}.studio-footnote{font-size:11px;}
  .preset-dialog form{padding:22px 18px;}.preset-preview-wrap{height:160px;}
  .preset-fields label{font-size:13px;}.preset-fields textarea{font-size:16px;}
  .preset-photo-hint,.prompt-details{font-size:12px;}
  .image-viewer-stage{max-height:calc(var(--app-height,100dvh) - 100px);}
  .image-viewer-stage img{max-height:calc(var(--app-height,100dvh) - 130px);}
  .toast{left:16px;right:16px;bottom:calc(18px + var(--safe-bottom));max-width:none;width:auto;transform:none;font-size:13px;line-height:1.5;}
  .auth-screen{display:flex;flex-direction:column;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) var(--safe-bottom) env(safe-area-inset-left,0px);overflow-y:auto;overscroll-behavior-y:contain;background:var(--canvas);}
  .auth-story{flex:none;padding:26px 24px 0;min-height:0;background:none;overflow:visible;}
  .auth-wordmark{position:static;font-size:17px;gap:10px;color:var(--ink);}
  .auth-story h1,.auth-story>p,.auth-story>small,.auth-kicker,.auth-models,.auth-story::after{display:none;}
  .auth-panel{flex:1 0 auto;align-items:flex-start;padding:28px 24px 24px;}
  .auth-form{max-width:420px;}.auth-form h2{font-size:30px;line-height:1.2;}
  .auth-form .field-label{font-size:13px;margin:15px 0;}
  .auth-form .text-field{height:50px;font-size:16px;}
  .auth-tabs{margin:24px 0;}.auth-tabs button{min-height:44px;font-size:14px;}
  .auth-submit{height:50px;font-size:15px;}.auth-footnote{font-size:12px;line-height:1.7;}
  #forgotPassword{font-size:13px;min-height:40px;margin:12px auto;}
  [data-keyboard="open"] .conversation.is-empty .welcome,[data-keyboard="open"] .suggestions{display:none;}
  [data-keyboard="open"] .conversation.is-empty .composer-wrap{margin-top:auto;margin-bottom:0;padding-bottom:10px;}
}
@media(max-width:760px) and (max-height:520px){
  .conversation.is-empty .welcome{display:none;}.suggestions{display:none;}
  .conversation.is-empty .composer-wrap{margin-top:auto;margin-bottom:0;padding-bottom:10px;}
  .disclaimer{display:none;}.auth-panel{padding-top:16px;}.auth-story{padding-top:18px;}
}
