/* The phone app layout, used below 761px and inside the desktop phone preview. Made for the job site: large targets, one column. */
@media (max-width: 760px) {
  .app-body { --tabs: calc(60px + env(safe-area-inset-bottom, 0px)); font-size: 16px; }
  .is-embed { user-select: none; -webkit-user-select: none; }
  .is-embed :is(input, textarea) { user-select: text; -webkit-user-select: text; }
  .app-body.is-embed { --bar: 0px; }
  .is-embed .demo-bar { display: none; }
  html:has(.is-embed) { scrollbar-width: none; }
  html:has(.is-embed)::-webkit-scrollbar { display: none; }

  /* Title bar with the project switcher under the title */
  .m-bar { position: sticky; top: var(--bar); z-index: 12; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 7px 14px 7px 16px; background: var(--navy); color: #fff; }
  .m-head { display: grid; justify-items: start; flex: 1; min-width: 0; }
  .m-title { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 700 22px/1.25 var(--head); }
  .m-project { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-height: 28px; padding: 0 9px 0 10px; border: 1px solid #615a4b; border-radius: var(--radius); background: #3a352c; color: #f3e3a4; font-size: 13.5px; font-weight: 700; cursor: pointer; }
  .m-project span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .m-project .icon { width: 14px; height: 14px; }
  .m-icon { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; margin-left: -10px; border-radius: 8px; color: #fff; }
  .m-icon .icon { width: 22px; height: 22px; }
  .m-brand { display: grid; place-items: center; flex: none; width: 44px; height: 44px; }
  .m-app--sub .m-title { font-size: 19px; }

  .app-body .content.m-content { max-width: none; padding: 14px 14px calc(var(--tabs) + 28px); }
  .app-body .m-app--fab .content.m-content { padding-bottom: calc(var(--tabs) + 96px); }
  .m-content > * + *, .m-content .stack > * + *, .m-content #results > * + * { margin-top: 12px; }

  .m-tabs { position: fixed; z-index: 14; left: 0; right: 0; bottom: 0; height: var(--tabs); padding: 0 4px env(safe-area-inset-bottom, 0px); background: var(--surface); border-top: 1px solid var(--line-2); }
  .m-tabs ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 4px; height: 100%; }
  .m-tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 100%; color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; }
  .m-tabs i { display: grid; place-items: center; width: 44px; height: 26px; border-radius: 6px; font-style: normal; }
  .m-tabs i .icon { width: 19px; height: 19px; }
  .m-tabs a.is-on { color: var(--accent-dark); font-weight: 700; }
  .m-tabs a.is-on i { background: var(--accent-tint); }
  .m-fab { position: fixed; z-index: 13; right: 16px; bottom: calc(var(--tabs) + 16px); display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -8px rgba(70, 54, 0, .75); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }

  /* Screens shared with the desktop layout: the title bar already names them */
  .m-content .page-head { gap: 10px; }
  .m-content .page-head > div:first-child > h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .m-content .page-head p { margin: 0; font-size: 14.5px; }
  .m-content .page-head .page-actions { display: none; }
  .m-content .page-head .page-actions:has([data-act^="export"]) { display: flex; width: 100%; }
  .m-content .page-actions:has([data-act^="export"]) .btn:not([data-act^="export"]) { display: none; }
  .m-content .back { display: none; }
  .m-content .record-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .m-content .record-head h1 { font-size: 23px; }
  .m-content .actionbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m-content .actionbar:empty { display: none; }
  .m-content .actionbar .btn-primary:first-child, .m-content .actionbar .btn:first-child:last-child { grid-column: 1 / -1; }
  .m-content .actionbar > .btn-primary:first-child ~ :last-child:nth-child(even), .m-content .actionbar > :first-child:not(.btn-primary) ~ :last-child:nth-child(odd) { grid-column: 1 / -1; }

  .btn { min-height: 48px; font-size: 15.5px; }
  .btn-small { min-height: 44px; font-size: 14.5px; }
  .badge { font-size: 13px; }
  .card { padding: 14px; }
  .card-flush { padding: 0; }
  .card-head > a { display: inline-flex; align-items: center; min-height: 40px; }
  .cols { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .stats, .stats-3, .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-3 .stat:last-child { grid-column: 1 / -1; }
  .stat { padding: 11px 12px; }
  .stat strong { font-size: 22px; }
  .pill, .q-text span, .work a span, .jump small, .g-legend { font-size: 13px; }

  .filterbar { gap: 10px; }
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 48px; }
  .searchfield input { height: 46px; font-size: 16px; }
  .filter { flex: 1 1 140px; }
  .filter select { width: 100%; min-height: 46px; font-size: 16px; }
  .filter-selects { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
  .filter-end { width: 100%; margin: 0; }
  .filter-end .segmented { flex: 1 1 100%; }
  .filter-end .segmented button { flex: 1; min-height: 40px; }
  .filter-end .segmented + .segmented { flex: 1 1 60%; }
  .filter-end .btn { flex: 1; min-height: 48px; padding: 0 10px; }
  .m-content .tabs { width: calc(100% + 28px); max-width: none; margin-inline: -14px; padding-inline: 14px; }
  .tab { min-height: 42px; padding: 0 15px; }

  .m-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
  .m-list > li + li { border-top: 1px solid var(--line); }
  .m-row { display: flex; align-items: center; gap: 10px; min-height: 66px; padding: 11px 13px; color: var(--ink); text-decoration: none; }
  .m-row:active { background: var(--accent-tint); }
  .m-row-main { display: grid; flex: 1; min-width: 0; line-height: 1.38; }
  .m-row-main strong { font-size: 15.5px; }
  .m-row-main > span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--ink-2); font-size: 14px; }
  .m-row-main small { color: var(--ink-2); font-size: 13px; }
  .m-row-end { display: grid; justify-items: end; gap: 3px; flex: none; max-width: 42%; text-align: right; }
  .m-row-end small { color: var(--ink-2); font-size: 13px; }
  .m-row-end .badge { white-space: normal; text-align: right; }
  .m-line { display: grid; gap: 6px; padding: 11px 13px; }
  .m-line div:first-child { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
  .m-line div:first-child span { flex: none; font-weight: 600; }
  .m-line small { color: var(--ink-2); font-size: 13px; }

  .queue a { min-height: 60px; }
  .work-update > li { flex-wrap: wrap; }
  .work-update > li > a { flex: 1 1 100%; }
  .work-update > li .metered { flex: 1; }
  .work > li { min-height: 52px; }
  .sitefoot a { min-height: 40px; }
  .logline { flex-wrap: wrap; }
  .jump { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .jump a { padding: 12px 10px; gap: 9px; min-height: 62px; }
  .facts > div { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .plain th, .plain td { padding-inline: 4px; font-size: 14px; }
  .steps { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 10px 4px; }
  .steps li { flex-direction: column; gap: 4px; text-align: center; font-size: 12.5px; line-height: 1.2; }
  .steps li + li::before { display: none; }
  .xc { --xc-label: minmax(70px, 96px); --xc-value: 58px; }
  .xc-v { --xc-h: 180px; }
  .xc-yaxis b, .xc-ticks b, .xc-axisname, .xc-colbar em, .xc-xlabels span, .xc-legend li { font-size: 12px !important; }

  /* Timeline on a phone: each task name sits above its own bar and stays in view while you swipe */
  .gantt.is-small, .card .gantt.is-small { --lab: 0px; }
  .is-small .g-inner { width: var(--tw); }
  .is-small .g-row { display: block; height: 58px; border-bottom: 1px solid var(--soft); }
  .is-small .g-lab { display: flex; align-items: baseline; gap: 8px; width: min(340px, calc(100vw - 32px)); height: 26px; padding: 5px 10px 0; background: none; border: 0; }
  .is-small .g-lab :is(a, span) { flex: 0 1 auto; min-width: 0; font-size: 14px; background: rgba(255, 255, 255, .88); }
  .is-small .g-lab a { display: block; line-height: 22px; }
  .is-small .g-lab small { display: none; }
  .is-small .g-body .g-track { height: 31px; border: 0; background: none; }
  .is-small .g-body { background: repeating-linear-gradient(90deg, #eceae3 0 1px, transparent 1px calc(var(--dw) * 7)) var(--off) 0; }
  .is-small .g-bar { top: 5px; height: 17px; }
  .is-small .g-plan { top: 25px; }
  .is-small .g-over { top: 13px; }
  .is-small .g-stone, .is-small .g-planstone { top: 6px; }
  .is-small .g-text { top: 5px; font-size: 12px; }
  .is-small .g-in { line-height: 15px; }
  .is-small .g-today { z-index: 1; left: var(--x); opacity: .5; }
  .is-small .g-top { height: 48px; }
  .is-small .g-top .g-lab { display: none; }
  .is-small .g-top .g-track { height: 48px; }
  .is-small .g-group { height: 34px; }
  .is-small .g-group .g-lab { width: max-content; max-width: calc(100vw - 40px); height: 33px; align-items: center; padding-top: 0; }
  .is-small .g-group { background: #f1efe8; }
  .is-small .g-group .g-lab :is(span, button) { background: none; font-size: 15px; }
  .is-small .g-group button { min-height: 33px; }
  .is-small .g-group .g-track { display: none; }
  .is-small .g-ticks b, .is-small .g-months b, .is-small .g-todaytag { font-size: 12px; }

  .sched > * + * { margin-top: 10px; }
  .sched .callout { display: none; }
  .sched .searchfield { flex: 1 1 52%; min-width: 0; }
  .sched .filterbar > .filter { flex: 1 1 36%; min-width: 0; }
  .sched .filter-end { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .sched .filter-end .segmented:first-child { grid-column: 1 / -1; }
  .sched .filter-end .btn { min-height: 48px; }
  .textbtn { min-height: 40px; }

  /* Search results, More */
  .m-me { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
  .m-me .avatar { width: 52px; height: 52px; font-size: 17px; }
  .m-me div { display: grid; }
  .m-me strong { font-size: 18px; }
  .m-me div span { color: var(--ink-2); font-size: 14px; }
  .m-menu :is(a, button) { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 0 16px; border: 0; background: none; color: var(--ink); font-size: 16px; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu span { flex: 1; }
  .m-menu .icon:last-child { color: var(--ink-2); }
  .locked, .notfound { margin: 24px auto; }
  .field :is(input, select, textarea), .crewrow :is(input, select) { min-height: 48px; font-size: 16px; }
  .field em, .crews .hint, .crewrow label, .error { font-size: 13px; }
  .crewrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .crewrow label:first-child { grid-column: 1 / -1; }
  .crewrow .icon-btn { width: 48px; height: 48px; }

  /* Popups slide up from the bottom */
  dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; max-height: calc(100dvh - var(--bar) - 12px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog form { max-height: calc(100dvh - var(--bar) - 12px); }
  dialog[open] { animation: m-up .24s cubic-bezier(.2, .8, .2, 1); }
  dialog .modal-head { position: relative; padding-top: 20px; }
  dialog .modal-head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 99px; background: var(--line-2); }
  dialog .icon-btn { width: 44px; height: 44px; }
  dialog .modal-foot > .btn { flex: 1; min-height: 50px; padding: 0 8px; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .signin { padding: 28px 16px 40px; }
}
@media (max-width: 350px) {
  .stat strong { font-size: 20px; }
  .jump { grid-template-columns: minmax(0, 1fr); }
  .filter-end .segmented + .segmented { flex-basis: 100%; }
}
body.is-grabbing, body.is-grabbing * { cursor: grabbing !important; }
.tabs, .table-wrap { -webkit-overflow-scrolling: touch; }
@keyframes m-up { from { transform: translateY(40px); opacity: .4; } }

/* Desktop and phone switch in the demo bar */
.view-switch { display: none; }
.preview { display: none; }
@media (min-width: 900px) {
  .view-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 99px; background: rgba(59, 46, 0, .13); }
  .view-switch button { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 13px; border: 0; border-radius: 99px; background: none; color: #3b2e00; font-size: 13.5px; font-weight: 700; cursor: pointer; }
  .view-switch button .icon { width: 15px; height: 15px; }
  .view-switch button[aria-pressed="true"] { background: #fff; box-shadow: 0 1px 3px rgba(59, 46, 0, .25); }

  .app-body.is-preview { background: #e7e7e2; }
  .is-preview #app, .is-preview > dialog, .is-preview .toasts { display: none; }
  .is-preview .preview { display: flex; align-items: center; justify-content: center; gap: clamp(32px, 6vw, 96px); min-height: calc(100vh - var(--bar)); padding: 20px 32px; }
  .preview-notes { max-width: 360px; }
  .preview-notes h2 { font: 700 clamp(28px, 2.8vw, 38px)/1.12 var(--head); }
  .preview-notes > p { margin-top: 10px; color: var(--ink-2); font-size: 17px; }
  .preview-notes ul { margin-top: 20px; border-top: 1px solid var(--line-2); }
  .preview-notes li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
  .preview-notes li .icon { margin-top: 2px; color: var(--accent); }

  .device { --h: 844px; flex: none; width: 414px; padding: 11px; border-radius: 56px; background: #141517; box-shadow: 0 40px 70px -30px rgba(20, 21, 23, .65), inset 0 0 0 2px #45474c; }
  .device-screen { position: relative; display: flex; flex-direction: column; width: 392px; height: var(--h); border-radius: 45px; overflow: hidden; background: var(--surface); isolation: isolate; }
  .device-status { display: flex; align-items: center; justify-content: space-between; flex: none; height: 44px; padding: 0 30px; background: var(--surface); font-size: 15px; font-weight: 700; }
  .device-status::after { content: ""; width: 25px; height: 12px; border: 1.5px solid var(--ink); border-radius: 4px; background: linear-gradient(var(--ink), var(--ink)) 2px 50% / 16px 6px no-repeat; }
  .device-island { position: absolute; top: 10px; left: 50%; width: 108px; height: 26px; margin-left: -54px; border-radius: 99px; background: #141517; }
  .device iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--bg); }
  .device-home { flex: none; height: 12px; background: var(--surface); }
}

@media (max-width: 760px) {
  /* Role screen: both roles are visible at once, each as one large row */
  .signin .roles { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 22px; }
  .signin h1 { margin-top: 22px; font-size: 25px; text-wrap: balance; }
  .signin-sub { margin-inline: auto; font-size: 15px; text-wrap: balance; }
  .signin .role-points, .signin .role-org { display: none; }
  .signin .role { display: grid; grid-template-columns: 46px minmax(0, 1fr) 10px; grid-template-areas: "ico title go" "ico name go" "ico short go"; align-content: center; align-items: center; column-gap: 14px; row-gap: 1px; height: auto; min-height: 104px; padding: 16px; text-align: left; }
  .signin .role::after { content: ""; grid-area: go; width: 8px; height: 8px; border: solid currentColor; border-width: 2px 2px 0 0; transform: rotate(45deg); opacity: .55; }
  .signin .role-icon { grid-area: ico; align-self: center; }
  .signin .role-title { grid-area: title; margin: 0; font-size: 18px; line-height: 1.25; }
  .signin .role-name { grid-area: name; font-size: 14px; line-height: 1.35; }
  .signin .role-short { grid-area: short; display: block; font-size: 13.5px; line-height: 1.35; color: var(--ink-2); }
}

/* Desktop and Mobile switch sits in the exact middle of the bar */
@media (min-width: 900px) {
  .app-body .demo-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .app-body .demo-bar > p { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .app-body .demo-bar > .view-switch { justify-self: center; }
  .app-body .demo-bar > nav { justify-self: end; }
}
