/* Mobile content uses the existing Expecza tokens. Navigation lives in workspace-ui.css. */
@media (max-width:800px), (max-width:1000px) and (max-height:500px) {
  /* Keep text entry readable without automatic mobile-browser magnification. */
  body :is(input:not([type=checkbox]):not([type=radio]),textarea,select,[contenteditable=true]),
  .new-report-dialog #prompt,.shared-page textarea,.shared-page .version-select select,
  .shared-command input,.universal-command input,body.viewing-report .composer textarea {
    font-size:16px;line-height:1.5;
  }
  main :is(button,.primary,.secondary,.subtle),dialog :is(button,.primary,.secondary,.subtle),
  .shared-page .shared-report button {min-height:44px;}
  main :is(input,select),dialog :is(input,select) {min-height:44px;}
  .universal-heading {grid-template-columns:minmax(0,1fr) auto;gap:16px 10px;margin-bottom:24px;}
  .universal-heading .dashboard-actions {grid-column:2;grid-row:1;justify-self:end;}
  .universal-heading .command-slot {grid-column:1/-1;grid-row:2;max-width:none;}
  .dashboard-heading h1 {font-size:24px;line-height:1.35;}
  .dashboard-heading .new-task {min-height:44px;padding:10px 14px;}
  .header-voice {width:44px;height:44px;min-width:44px;}
  .universal-command,.shared-command {padding:4px;gap:2px;border-radius:28px;}
  .universal-command .composer-attach,.universal-command>button[type=submit],
  .shared-page .shared-report .shared-command>button {
    display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;
    min-width:44px;min-height:44px;max-height:44px;padding:10px;
  }
  .universal-command input,.shared-command input {min-height:44px;padding-inline:4px;}
  .shared-command {max-width:none;margin-bottom:24px;}
  .report-tabs {display:flex;flex-wrap:nowrap;justify-content:flex-start;width:100%;max-width:100%;
    overflow-x:auto;gap:4px;padding:4px;margin-bottom:20px;scrollbar-width:thin;}
  .report-tabs button {flex:0 0 auto;min-height:44px;padding:10px 12px;white-space:nowrap;}
  .report-tabs button:focus-visible {outline-offset:-3px;}
  .report-cards {gap:20px;}
  .report-stack .saved-report-card {height:auto;min-height:200px;max-height:none;padding:18px 18px 52px;}
  .report-stack .report-card-title {height:auto;min-height:42px;max-height:42px;}
  .stack-controls {right:12px;bottom:8px;gap:4px;}
  .stack-controls button {width:44px;height:44px;}
  .stack-controls svg {width:16px;height:16px;}
  .remove-source {width:44px;height:44px;flex-basis:44px;}
  .composer-selection {max-width:100%;padding-block:0;}
  .command-search,.command-sources,.activity-panel,.shared-command-results {
    overscroll-behavior:contain;max-height:min(480px,60dvh);
  }
  .command-search button,.shared-command-results :is(button,a),.activity-item button {min-height:44px;}
  .activity-item summary {min-height:44px;}
  .activity-panel {max-width:calc(100vw - 32px);}
  .workspace-page>.section-title {margin-bottom:16px;}
  .workspace-page .connection {padding:16px;gap:14px;}
  .connection-actions {gap:10px;}
  .connection-actions button,.connection-actions a {min-height:44px;}
  .workspace-page .notification-item {padding:16px;}
  .routine-card {min-width:0;}
  /* Dialogs scroll as one surface, including on landscape phones and with a keyboard. */
  dialog:not(.workspace-page) {max-height:calc(100dvh - 24px);max-width:calc(100vw - 24px);
    overscroll-behavior:contain;scroll-padding-block:16px;}
  dialog:not(.workspace-page) :is(.icon-button,.dialog-close) {min-width:44px;min-height:44px;}
  .new-report-dialog {padding:20px;width:min(600px,calc(100vw - 24px));}
  .new-report-heading {margin:-20px -20px 20px;padding:16px 20px;gap:12px;}
  .new-report-heading h2 {font-size:24px;}
  .new-report-heading .icon-button {width:44px;height:44px;padding:12px;}
  body .new-report-dialog .source-well,body .new-report-dialog .template-row {
    display:grid;grid-template-columns:minmax(0,1fr);align-items:start;gap:10px;
  }
  .new-report-dialog #sourceAction {width:100%;min-width:0;}
  .new-report-dialog #selectContent,.new-report-dialog #selectTemplate {
    width:100%;max-width:none;min-height:44px;font-size:14px;white-space:nowrap;
    padding:10px 14px;justify-content:center;
  }
  .new-report-dialog #selectContent {flex:1;min-width:0;}
  .new-report-dialog .selection-summary,.new-report-dialog #templateName {max-width:100%;}
  .new-report-dialog #prompt {min-height:112px;padding:12px;}
  .new-report-dialog .report-style-trigger {min-height:48px;font-size:16px;}
  .new-report-dialog .report-style-list {position:relative;top:auto;margin-top:8px;max-height:240px;overflow:auto;}
  .new-report-dialog .report-style-list button {min-height:44px;}
  .new-report-dialog .composer-toolbar {display:flex;flex-wrap:nowrap;justify-content:space-between;gap:8px;}
  body.writing-report .new-report-dialog .composer-toolbar #runButton {
    width:auto;min-width:142px;min-height:44px;flex:0 0 auto;padding:10px 16px;white-space:nowrap;
  }
  .new-report-dialog .composer-options {width:100%;max-width:none;padding:16px;max-height:none;overflow:visible;}
  .new-report-dialog .composer-options .options {grid-template-columns:1fr;}
  .new-report-dialog .report-options-trigger {padding:10px;white-space:nowrap;}
  .report-project-details>summary {padding-inline:10px;}
  .new-report-dialog .optional-label,.report-project-details summary small {margin-left:4px;}
  /* Reports use the phone width for reading; tables retain their own horizontal scroll. */
  body.viewing-report .results,body.viewing-report .composer {padding:20px 16px;}
  body.viewing-report .results .section-title {gap:12px;}
  body.viewing-report .results h2 {font-size:24px;line-height:1.4;}
  .results .report-document,.shared-page .report-document {font-size:14px;line-height:1.85;}
  .report-table {overscroll-behavior-x:contain;}
  .report-table :is(th,td) {overflow-wrap:normal;word-break:normal;min-width:110px;}
  .report-table table {min-width:520px;}
  .report-history-control button,.report-header-actions button,.history-heading button,
  .report-edit-button {width:44px;height:44px;min-width:44px;min-height:44px;}
  .history-content summary {min-height:44px;}
  .report-history-rail {inset:12px 12px 12px auto;max-height:calc(100dvh - 24px);overscroll-behavior:contain;}
  .report-history-control:hover .history-tooltip {display:none;}
  .report-history-control:focus-within .history-tooltip {display:block;}
  .chart-tabs button,.chart-footer button,.chart-controls select {min-height:44px;}
  .chart-controls label {flex-wrap:wrap;gap:8px;}
  .chart-controls {gap:12px;}
  .chart-insight {margin-inline:14px;}
  .shared-page .shared-report {padding-inline:16px;}
  .shared-page :is(#sharedResult,#editor) {padding:20px 16px;}
  .shared-toolbar {display:flex;flex-wrap:wrap;gap:10px;}
  .shared-toolbar button {white-space:nowrap;}
  .shared-message {padding:16px;}
  .download-options {max-width:calc(100vw - 48px);}
  #toast {bottom:calc(84px + env(safe-area-inset-bottom));}
  .int-banner {bottom:calc(76px + env(safe-area-inset-bottom));max-width:calc(100vw - 24px);
    overflow:hidden;text-overflow:ellipsis;font-size:11px;}
  .auth-card .auth-legal a {min-height:44px;}
}
@media (max-width:359px) {
  .dashboard-heading .new-task {padding-inline:10px;}
  .dashboard-actions {gap:6px;}
  .new-report-dialog {padding:16px;}
  .new-report-heading {margin:-16px -16px 16px;padding:12px 16px;}
  .new-report-dialog .composer-toolbar {gap:4px;}
  body.writing-report .new-report-dialog .composer-toolbar #runButton {min-width:132px;padding-inline:12px;}
  .new-report-dialog .report-options-trigger {padding-inline:6px;}
}
@media (max-width:1000px) {
  .report-history-rail[aria-modal=true] {box-shadow:0 0 0 100vmax #19233755,0 16px 48px #18294530;}
}
@media (max-width:800px), (max-width:1000px) and (max-height:500px) {
  body[data-view=connections] #connections>.section-title,
  body[data-view=notifications] .notification-dialog>.section-title,
  body[data-view=routines] .saved>.section-title {
    position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;
  }
}
@media (max-width:359px) {
  .universal-heading {grid-template-columns:minmax(0,1fr);gap:12px;}
  .universal-heading .dashboard-actions {grid-column:1;grid-row:2;justify-self:start;}
  .universal-heading .command-slot {grid-column:1;grid-row:3;}
}
@media (max-width:800px), (max-width:1000px) and (max-height:500px) {
  .report-status-actions .report-history-control button {width:44px;min-width:44px;height:44px;min-height:44px;padding:12px;}
}
@media (max-width:359px) {
  .report-tabs {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));overflow:visible;}
  .report-tabs button {min-width:0;min-height:56px;padding:8px 5px;white-space:normal;justify-content:center;text-align:center;line-height:1.4;}
}

/* Touch tablets retain the larger-screen composition with comfortable controls. */
@media (pointer:coarse) and (min-width:801px) {
  body :is(input:not([type=checkbox]):not([type=radio]),textarea,select,[contenteditable=true]),
  .new-report-dialog #prompt,.shared-page textarea,.shared-page .version-select select,
  .shared-command input,.universal-command input,body.viewing-report .composer textarea {font-size:16px;line-height:1.5;}
  main :is(button,.primary,.secondary,.subtle),dialog :is(button,.primary,.secondary,.subtle),
  .shared-page .shared-report button,.voice-dialog .actions button {min-height:44px;}
  .universal-command .composer-attach,.universal-command>button[type=submit],
  .shared-page .shared-report .shared-command>button {flex:0 0 44px;width:44px;height:44px;min-width:44px;min-height:44px;max-height:44px;padding:10px;}
  .header-voice,.stack-controls button,.report-status-actions .report-history-control button,
  .history-heading button,.new-report-heading .icon-button {width:44px;height:44px;min-width:44px;min-height:44px;}
  .remove-source {width:44px;height:44px;flex-basis:44px;}
  .collapse-control,.sidebar-collapsed .collapse-control {width:44px;height:44px;}
  .report-stack .saved-report-card {padding-bottom:54px;}
  .nav,.workspace-profile,.brand,.aside-note a {min-height:44px;}
}
@media (max-width:800px), (max-width:1000px) and (max-height:500px) {
  .voice-dialog .actions button {min-height:44px;}
}
@media (max-width:800px), (max-width:1000px) and (max-height:500px), (pointer:coarse) {
  dialog button[aria-label],.share-person button {min-width:44px;min-height:44px;}
}
@media (max-width:800px), (max-width:1000px) and (max-height:500px), (pointer:coarse) {
  .shared-back,.auth-card .auth-legal a {min-height:44px;}
}
