/* The phone app layout, used below 761px and inside the desktop phone preview. */
@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; }
  .app-body .demo-bar { position: static; }
  .app-body { --bar: 0px; }

  .m-bar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 7px 12px 7px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .m-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 22px/1.25 var(--head); }
  .m-app--sub .m-bar { padding-left: 6px; gap: 4px; }
  .m-app--sub .m-title { font-size: 19px; }
  .m-icon { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 10px; color: var(--ink); }
  .m-icon .icon { width: 24px; height: 24px; }

  .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 > * + * { margin-top: 14px; }

  .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)); 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; }
  .m-tabs i { position: relative; display: grid; place-items: center; width: 46px; height: 26px; border-radius: 99px; font-style: normal; }
  .m-tabs i .icon { width: 19px; height: 19px; }
  .m-tabs .count { position: absolute; top: -4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; }
  .m-tabs a.is-on { color: #8d2027; 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: 18px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -10px rgba(120, 20, 28, .7); cursor: pointer; }
  .m-fab .icon { width: 25px; height: 25px; }
  .m-fab:active { transform: scale(.95); }

  /* Shared screens: the title bar already names top level pages */
  .m-content .page-head { gap: 10px; }
  .m-app:not(.m-app--sub) .page-head h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .m-app--sub .page-head h1 { font-size: 22px; }
  .m-content .page-head > div:first-child { min-width: 0; }
  .m-content .page-head p { font-size: 15px; }
  .m-content .page-head .page-actions { display: none; }
  .m-content .page-head .page-actions:has(.segmented) { display: flex; width: 100%; }
  .m-content .page-head .segmented { width: 100%; }
  .m-content .segmented button { flex: 1; min-height: 40px; font-size: 14.5px; }
  .m-content .back { display: none; }
  .m-content .actionbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m-content .actionbar > :first-child:nth-last-child(odd) { grid-column: 1 / -1; }

  .btn { min-height: 46px; font-size: 15.5px; }
  .btn-small { min-height: 42px; font-size: 14.5px; }
  .badge { font-size: 12.5px; }
  .card { padding: 14px; }
  .card-head h2 { font-size: 17px; }
  .card-head a { display: inline-flex; align-items: center; min-height: 36px; font-size: 14.5px; }
  .grid-2, .grid-2.even, .with-aside { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .with-aside > .testbox { position: static; grid-row: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 13px; }
  .stat-name { line-height: 1.3; }
  .rowlist small, .hint, .when, .late, .stat-sub { font-size: 13.5px; }
  .rowlist > li > a { min-height: 56px; }
  .rowlist > li > div { flex-wrap: wrap; }
  .locked { margin: 24px auto !important; }

  /* Queue */
  .queue-m > .btn { width: 100%; }
  .queue-m .q-group h2 { display: flex; align-items: center; padding: 18px 2px 8px; font: 700 15px/1.3 var(--font); }
  .queue-m .q-group ul { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; gap: 0; }
  .queue-m .q-group li + li { border-top: 1px solid var(--line); }
  .queue-m .q-item { min-height: 70px; padding: 12px; border: 0; border-radius: 0; }
  .q-main strong { font-size: 16px; }
  .q-main > span { font-size: 14px; }
  .q-main small, .q-none { font-size: 13px; }
  .pill { font-size: 12px; }

  /* A conversation: the page scrolls and the reply box stays above the tabs */
  .m-app--talk .content.m-content { padding: 0 0 var(--tabs); }
  .m-app--talk .m-content > * + * { margin-top: 0; }
  .m-app--talk .m-content { display: flex; flex-direction: column; min-height: calc(100dvh - 58px); }
  .m-seg { display: grid !important; grid-template-columns: 1fr 1fr; margin: 10px 12px !important; flex: none; }
  .m-app--talk .talk { flex: 1; }
  .talk-head { padding: 10px 14px; border-top: 1px solid var(--line); }
  .talk-head > .ch { display: none; }
  .talk-head > .badge { order: 0; }
  .talk-head :is(h1, h2) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .talk-head p { font-size: 13px; }
  .talk-actions { width: 100%; }
  .talk-actions .btn { flex: 1 1 auto; padding: 0 10px; }
  .sim-note { padding: 8px 14px; font-size: 12.5px; }
  .lines { padding: 14px 12px 18px; overflow: visible; }
  .ln { max-width: 90%; }
  .ln-meta, .ln-meta time, .ln-system, .ln-system time, .ln-typing { font-size: 13px; }
  .source { min-height: 40px; font-size: 13px; border-radius: 12px; }
  .composer { position: sticky; bottom: var(--tabs); z-index: 5; padding: 10px 12px; }
  .composer textarea { font-size: 16px; }
  .composer-row .btn { padding: 0 14px; }
  .composer-top .segmented button { min-height: 36px; }
  .insert select { max-width: 150px; min-height: 42px; font-size: 14px; }
  .composer-tools .btn { flex: 1; padding: 0 8px; }
  .composer-idle { position: static; }
  .ctx { overflow: visible; border: 0; }
  .ctx-block { padding: 16px 14px; }
  .ctx-block h2 { font-size: 14px; }
  .ctx-list :is(a, button) { min-height: 48px; align-items: center; }
  .ctx-list span, .ctx-who span, .ctx-why p, .ctx-none, .kv > div { font-size: 14.5px; }
  .ctx-list small { font-size: 13px; }
  .ctx-badges a { display: inline-flex; align-items: center; min-height: 36px; }
  .detail .kv > div, .kv > div { grid-template-columns: 108px minmax(0, 1fr); }

  /* Lists and filters */
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 48px; }
  .searchfield input { height: 44px; font-size: 16px; }
  .tabs { width: calc(100% + 28px); max-width: none; margin-inline: -14px; padding: 2px 14px; gap: 8px; background: none; border-radius: 0; }
  .tab { min-height: 42px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); color: var(--ink); }
  .tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: none; }
  .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-width: 0; min-height: 46px; font-size: 16px; }
  .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: 12px; min-height: 68px; padding: 12px; 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 { flex: none; }
  .list-count { font-size: 14px; }
  .day h2 span { font-size: 13px; }
  .rule { grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 6px 12px 8px 4px; }
  .rule > a { grid-column: 1 / -1; min-height: 52px; }
  .rule > .badge { justify-self: start; margin-left: 10px; }
  .rule-main small { font-size: 13.5px; }
  .switch { min-height: 44px; font-size: 14px; }
  .test-tries button { min-height: 40px; font-size: 14px; }
  .test-out small { font-size: 13px; }
  .hours-row { grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr); }
  .hours-row .hours-day { grid-column: 1 / 3; }
  .hours-row .check { justify-self: end; min-height: 44px; }
  .hours-row input[type="time"] { min-height: 46px; font-size: 16px; }
  .hours-row > .field-error { grid-column: 1 / -1; }
  .formbar .btn { width: 100%; }

  /* 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: 50px; height: 50px; font-size: 16px !important; }
  .m-me div { display: grid; }
  .m-me strong { font-size: 18px; }
  .m-me div span { color: var(--ink-2); font-size: 14px; }
  .m-menu { display: grid; gap: 8px; }
  .m-menu :is(a, button) { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); font: 600 16px/1.2 var(--font); text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu :is(a, button) > span { flex: 1; }
  .m-menu .icon:last-child { color: var(--ink-2); }
  .m-foot { color: var(--ink-2); font-size: 13px; }

  /* 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 - 52px); border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  dialog form { max-height: calc(100dvh - 52px); }
  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; }
  .two { grid-template-columns: minmax(0, 1fr); }
  .field :is(input, select, textarea) { min-height: 48px; font-size: 16px; }
  .scenarios button { min-height: 64px; }
  .scenarios small { font-size: 13.5px; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .signin { padding: 24px 16px 32px; }
}
@media (max-width: 350px) {
  .app-body .demo-bar { gap: 8px; padding-inline: 10px; }
  .app-body .demo-bar nav { gap: 10px; }
  .app-body .demo-bar { font-size: 12.5px; }
  .m-tabs a { font-size: 12px; }
  .composer-row { flex-direction: column; }
  .stat-value { font-size: 26px; }
}
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(76, 17, 21, .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: #4c1115; 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(76, 17, 21, .25); }

  .app-body.is-preview { background: #ebe7e7; }
  .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: 600 clamp(28px, 2.8vw, 36px)/1.15 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; }
}
