/* The phone app layout, used below 761px and inside the desktop phone preview. One column, large targets. */
@media (max-width: 760px) {
  .app-body { --tabs: calc(62px + 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; }

  .m-bar { position: sticky; top: var(--bar); z-index: 12; display: flex; align-items: center; gap: 6px; min-height: 60px; padding: 8px 10px 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .m-bar h1 { flex: 1; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 22px/1.3 var(--head); }
  .m-bar > div { display: flex; }
  .m-bar > div:empty { display: none; }
  .m-app--sub .m-bar { padding-left: 6px; }
  .m-app--sub .m-bar h1 { font-size: 19px; }
  .m-icon { position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 10px; color: var(--ink); }
  .m-icon:active { background: var(--soft); }
  .m-icon .icon { width: 22px; height: 22px; }
  .m-icon .dot { top: 3px; right: 2px; }

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

  .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); }
  .m-tabs ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); 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: 700; line-height: 1.2; text-decoration: none; white-space: nowrap; }
  .m-tabs i { position: relative; display: grid; place-items: center; width: 46px; height: 27px; border-radius: 99px; font-style: normal; }
  .m-tabs i .dot { top: -4px; right: 1px; min-width: 17px; height: 17px; font-size: 12px; line-height: 17px; }
  .m-tabs a.is-on { color: var(--accent-dark); }
  .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: 18px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -8px rgba(110, 40, 58, .75); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }

  /* The title bar names each screen, and the add button replaces the header actions */
  .m-content .page-head { gap: 8px; }
  .m-content .page-head p { margin: 0; font-size: 15px; }
  .m-content .page-head .page-actions { display: none; }
  .m-content .record-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .m-content .record-head p { font-size: 15px; }
  .m-content .actionbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); width: 100%; }

  .btn { min-height: 46px; font-size: 15.5px; }
  .btn-small { min-height: 42px; font-size: 14.5px; }
  .card { padding: 14px; }
  .card-flush { padding: 0; }
  .card-head a:not(.btn) { display: inline-flex; align-items: center; min-height: 36px; }
  .columns, .column, .balances, .hires { gap: 14px; }
  .columns, .columns-wide, .hires { grid-template-columns: minmax(0, 1fr); }
  .balances { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .balance { grid-template-columns: minmax(0, 1fr); align-content: start; padding: 12px; }
  .balance > span:first-child { font-size: 13.5px; line-height: 1.3; }
  .balance b { grid-row: auto; grid-column: 1; font-size: 30px; line-height: 1.15; }
  .balance small { font-size: 13px; line-height: 1.35; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 25px; }
  .stat-sub { font-size: 13px; line-height: 1.35; }
  .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
  .segmented button { min-height: 42px; padding: 0 4px; font-size: 14px; gap: 5px; white-space: normal; line-height: 1.2; }
  .tab { min-height: 44px; padding: 0 13px; }
  .badge { font-size: 12.5px; }

  .filterbar { gap: 10px; }
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 48px; }
  .searchfield input { height: 46px; font-size: 16px; }
  .filter-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .filter-selects .filter:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .filter select { width: 100%; min-height: 46px; font-size: 16px; }

  .m-list { display: block; 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: 12px; min-height: 66px; padding: 11px 14px; 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: 16px; }
  .m-row-main > span { color: var(--ink-2); font-size: 14.5px; }
  .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: 12.5px; }
  .m-qty { font: 600 22px/1.15 var(--head); font-variant-numeric: lining-nums; }

  .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: 19px; }
  .m-me div span { color: var(--ink-2); font-size: 14.5px; }
  .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: 16.5px; font-weight: 700; text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu span { flex: 1; }
  .m-menu b { min-width: 22px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 13px; line-height: 22px; text-align: center; }
  .m-menu .icon:last-child { color: var(--ink-2); }

  .queue-main { flex-basis: 100%; align-items: flex-start; }
  .queue-actions { width: 100%; padding-left: 48px; }
  .queue-actions .btn { flex: 1; }
  .queue > li > .queue-main:not(a) + .adj-amount { justify-items: start; padding-left: 48px; flex: 1; }
  .queue > li > a.queue-main:has(+ .badge) { flex: 1 1 0; }
  .away li { grid-template-columns: 96px minmax(0, 1fr); }

  /* Team calendar: one week, every day in view */
  .cal-tools { padding: 10px; }
  .cal-nav { width: 100%; flex-wrap: nowrap; gap: 6px; }
  .cal-nav strong { flex: 1; min-width: 0; font-size: 15px; }
  .cal-nav .icon-btn { width: 40px; height: 42px; }
  .cal-nav .btn { padding: 0 8px; font-size: 13.5px; white-space: nowrap; }
  .cal-tools .filter { width: 100%; }
  .cal { min-width: 0; width: 100%; }
  .cal .cal-name { width: 96px; padding: 0 4px 0 10px !important; font-size: 13px; }
  .cal thead .cal-name { font-size: 13px; }
  .cal th, .cal td { height: 40px; }
  .cal-team .cal-name { white-space: normal; line-height: 1.15; }
  .cal-day span { font-size: 12px; }
  .bar { height: 28px; margin: 0 1px; }
  .cal-legend { gap: 6px 12px; padding: 12px 12px 4px; }
  .cal-foot { padding-inline: 12px; }

  .stages { gap: 4px; }
  .stages li { flex-direction: column; align-items: center; gap: 5px; text-align: center; padding-top: 10px; }
  .stages b { font-size: 12.5px; }
  .stages small { display: none; }
  .runbanner-top .btn { width: 100%; }
  .runnums { grid-template-columns: 1fr 1fr; }
  .runnums dd { font-size: 19px; }
  .stagepanel-top > div:first-child { flex-basis: 100%; }
  .totals dl > div { padding: 10px 12px; }
  .totals dd { font-size: 18px; }
  .reconcile { padding: 10px 12px; font-size: 14.5px; }
  .costline { padding: 0 12px 12px 38px; font-size: 14px; }
  .blockers li { flex-wrap: wrap; }
  .blockers a { display: grid; flex: 1 1 150px; }

  .slip { padding: 16px 14px; }
  .slip header dl { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
  .slip-net b { font-size: 22px; }
  .days li { grid-template-columns: 62px minmax(0, 1fr) 84px; gap: 8px; min-height: 58px; }
  .days input { min-height: 46px; font-size: 17px; }
  .day-note { font-size: 13px; line-height: 1.3; }
  .formbar .btn { flex: 1 1 100%; }
  .formbar > span { width: 100%; text-align: center; }
  .tick { width: 34px; height: 34px; }
  .tasks li { gap: 10px; }
  .task-tools { flex-direction: column; }
  .profile > div:nth-child(2) { flex: 1 1 160px; }
  .profile strong { display: block; font: 600 20px/1.3 var(--head); }
  .avatar-big { width: 52px; height: 52px; font-size: 18px; }
  .content .tabs { gap: 2px; }
  .icon-btn { width: 42px; height: 42px; }
  .locked { margin: 24px auto !important; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }

  dialog { position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; margin: 0; max-height: calc(100dvh - var(--bar) - 40px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog form { max-height: calc(100dvh - var(--bar) - 40px); }
  dialog[open] { animation: m-up .24s cubic-bezier(.2, .8, .2, 1); }
  dialog .icon-btn { width: 44px; height: 44px; }
  dialog .modal-foot > .btn { flex: 1; min-height: 50px; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .signin { padding: 28px 16px 40px; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  .cal .cal-name { width: 80px; font-size: 12px; padding-left: 6px !important; }
  .segmented button { font-size: 12.5px; }
  .segmented .pill { min-width: 17px; padding: 0 4px; }
  .balances { grid-template-columns: minmax(0, 1fr); }
  .totals dd { font-size: 16px; }
  .slip header dl { grid-template-columns: minmax(0, 1fr); }
  .m-row { gap: 8px; padding-inline: 10px; }
  .m-row .avatar { display: none; }
}
/* 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(74, 29, 39, .12); }
  .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: #4a1d27; 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(74, 29, 39, .25); }

  .app-body.is-preview { background: #ebe5e6; }
  .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; }
}
