/* The phone app, used below 761px and inside the desktop phone preview: a friendly member app with a tab bar. */
@media (max-width: 760px) {
  .app-body { --tabs: calc(64px + 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: 8px; min-height: 60px; padding: 8px 10px 8px 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: 400 22px/1.35 var(--head); }
  .m-icon { position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 99px; color: var(--ink); }
  .m-icon:first-child { margin-left: -10px; }
  .m-icon:active { background: var(--soft); }
  .m-icon .icon { width: 22px; height: 22px; }
  .m-icon i { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 99px; background: var(--accent); }

  .app-body .content { max-width: none; padding: 14px 14px calc(var(--tabs) + 28px); }
  .app-body .m-app--fab .content { padding-bottom: calc(var(--tabs) + 96px); }
  .content > * + * { 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); }
  .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: 50px; height: 28px; border-radius: 99px; font-style: normal; }
  .m-tabs i .icon { width: 20px; height: 20px; }
  .m-tabs i b { position: absolute; top: -3px; right: 5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 12px; line-height: 17px; text-align: center; }
  .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: 58px; height: 58px; border: 0; border-radius: 99px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -8px rgba(111, 24, 79, .75); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }

  /* Screens shared with the desktop layout: the top bar already names list pages */
  .content:not(.is-detail) > .page-head h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .content:not(.is-detail) > .page-head .page-actions { display: none; }
  .page-head p { margin: 0; font-size: 15px; }
  .m-app:has([data-act="bill-all"]) .page-head .page-actions { display: flex; width: 100%; }
  .m-app:has([data-act="export-dues"]) .page-head .page-actions { display: flex; }
  .page-head .page-actions .btn { flex: 1; }
  .back { display: none; }
  .btn { min-height: 48px; font-size: 15.5px; }
  .btn-small { min-height: 44px; font-size: 14.5px; }
  .badge { font-size: 12.5px; }
  .card { padding: 15px; }
  .card-flush { padding: 0; }
  .card-head a { display: inline-flex; align-items: center; min-height: 36px; }
  .layout, .layout-main, .layout-side { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .grid2, .reports, .plans { gap: 12px; grid-template-columns: minmax(0, 1fr); }
  .phone-first { display: block; }
  .wide-only { display: none; }
  .layout-side:has(> .wide-only:only-child) { display: none; }
  .figures-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures-row > :first-child { grid-column: 1 / -1; }
  .figures b { font-size: 25px; }

  .tabs { margin-inline: -14px; padding: 2px 14px; width: calc(100% + 28px); max-width: none; }
  .card .tabs { margin-inline: -15px; padding-inline: 15px; width: calc(100% + 30px); }
  .tab { min-height: 44px; }
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 48px; }
  .searchfield input { height: 46px; font-size: 16px; }
  .filter { flex: 1 1 130px; min-width: 0; }
  .filter select { width: 100%; min-height: 46px; font-size: 16px; }
  .segmented { width: 100%; }
  .segmented a { flex: 1; min-height: 44px; }
  .showmore .btn { width: 100%; }

  /* Lists become rows */
  .event { gap: 12px; flex-wrap: wrap; }
  .event-main { flex-basis: calc(100% - 70px); }
  .event-end { margin-left: 68px; }
  .event-end:empty { display: none; }
  .dateblock { width: 54px; height: 58px; }
  .todo em span { display: none; }
  .todo em .icon { width: 20px; height: 20px; }
  .todo a, .notes a { min-height: 62px; }
  .notes .badge { flex: none; }
  .notes a:has(.badge) { flex-wrap: wrap; }
  .notes a:has(.badge) > span:nth-child(2) { flex-basis: calc(100% - 52px); }
  .notes a .badge { margin-left: 50px; }
  .post { gap: 10px; }
  .mcards { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .mcard { padding: 13px; gap: 8px 12px; }
  .applist a { flex-wrap: wrap; padding: 14px; gap: 6px 12px; }
  .applist a > span:nth-child(2) { flex-basis: calc(100% - 66px); }
  .applist a .badge { margin-left: 64px; }
  ul.rows.card { padding: 2px 14px; }
  .rows > li > a { gap: 10px; flex-wrap: wrap; }

  .today { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .today-count { justify-items: start; }
  .profile, .eventhead { grid-template-columns: auto minmax(0, 1fr); gap: 12px 14px; }
  .profile .actionbar, .eventhead .actionbar { grid-column: 1 / -1; max-width: none; }
  .actionbar > .btn { flex: 1 1 40%; }
  .profile .avatar.av-xl { width: 58px; height: 58px; font-size: 21px; }
  .profile > div:nth-child(2) { align-self: center; }
  .profile h1, .eventhead h1 { font-size: 22px; }
  .eventhead .dateblock { width: 58px; height: 64px; align-self: start; }
  .eventhead .dateblock b { font-size: 25px; }
  .record-head h1 { font-size: 24px; }
  .record-head .actionbar { width: 100%; }
  .entry-post { display: block; }
  .entry-post > .avatar { float: left; margin: 0 12px 6px 0; width: 42px; height: 42px; font-size: 14px; }
  .entry-post h1 { clear: both; font-size: 22px; padding-top: 4px; }
  .entry-post .post-by { min-height: 42px; }
  .replies .entry > .avatar { width: 32px; height: 32px; font-size: 12px; }
  .entry-tools .btn { min-height: 44px; }
  .replyform .btn { width: 100%; }
  .roster > li { gap: 10px; padding-inline: 4px; }
  .roster .btn-small .icon { display: none; }
  .roster .icon-btn { width: 44px; height: 44px; }
  .faces { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .faces .avatar { width: 32px; height: 32px; font-size: 12px; }
  .topics button { min-height: 46px; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }
  .checks label { min-height: 44px; }
  .receipt-total { font-size: 34px; }
  .locked { margin: 24px auto; }

  .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 div { display: grid; }
  .m-me strong { font-size: 18px; }
  .m-me div span { color: var(--ink-2); font-size: 14.5px; }
  .m-menu { padding: 4px 6px; }
  .m-menu li + li { border-top: 1px solid var(--line); }
  .m-menu :is(a, button) { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 0 10px; border: 0; background: none; color: var(--ink); font-size: 16px; 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-foot { font-size: 13.5px; text-align: center; }
  .xc-colbar em, .xc-yaxis b, .xc-xlabels span, .xc-ticks b, .xc-axisname, .xc-legend li { font-size: 12px !important; }

  /* 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) - 40px); border-radius: 22px 22px 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 .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; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .signin { padding: 28px 16px 40px; }
}
@media (max-width: 380px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .m-tabs a { font-size: 12px; }
  .m-tabs i { width: 42px; }
}
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, 18, 55, .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: #4c1237; 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, 18, 55, .25); }

  .app-body.is-preview { background: #ede7ea; }
  .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: 400 clamp(26px, 2.6vw, 34px)/1.2 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: 17px; 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; }
}
