/* The phone app layout, used below 761px and inside the desktop phone preview.
   Made for someone standing in a warehouse: large targets, one column, bins first. */
@media (max-width: 760px) {
  .app-body { --tabs: calc(60px + env(safe-area-inset-bottom, 0px)); font-size: 16px; }
  /* Inside the preview it should feel like a phone: dragging moves the screen instead of selecting text */
  .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 */
  .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, .m-bar .m-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 700 23px/1.2 var(--head); }
  .m-bar > div { display: flex; gap: 2px; }
  .m-bar > div:empty { display: none; }
  .m-app--sub .m-bar { padding-left: 6px; }
  .m-app--sub .m-bar h1, .m-app--sub .m-bar .m-title { font-size: 21px; }
  .m-icon { position: relative; display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--ink); cursor: pointer; }
  .m-icon:active { background: var(--soft); }
  .m-icon .icon { width: 22px; height: 22px; }
  .m-icon .dot { top: 2px; right: 1px; }

  .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); }

  /* Bottom tab bar and add button */
  .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%; padding: 6px 0; color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; }
  .m-tabs i { position: relative; display: grid; place-items: center; width: 44px; height: 25px; border-radius: 99px; font-style: normal; }
  .m-tabs i .icon { width: 18px; height: 18px; }
  .m-tabs i .dot { top: -4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 12px; line-height: 18px; }
  .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: 16px; background: var(--accent); color: #fff; box-shadow: 0 12px 24px -8px rgba(111, 26, 39, .7); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }
  .m-fab:active { transform: scale(.95); }

  /* 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: 15px; }
  .m-content .page-head .page-actions:not(:has(.filter)) { display: none; }
  .m-content .page-head .page-actions, .m-content .page-head .filter { width: 100%; }
  .m-content .back { display: none; }
  .m-content .record-head { align-items: stretch; flex-direction: column; gap: 10px; }
  .m-content .record-head h1 { font-size: 24px; line-height: 1.2; }
  .m-content .record-head p { font-size: 15px; }
  .m-content .actionbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m-content .actionbar .btn:first-child:last-child, .m-content .actionbar .btn-primary:first-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; border-radius: 12px; }
  .card-flush { padding: 0; }
  .card-head a { display: inline-flex; align-items: center; min-height: 36px; }
  .columns { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .column { gap: 12px; }
  .content .segmented { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .segmented button { min-height: 44px; padding: 0 8px; }
  .content > .m-list { margin-top: 12px; }
  .list-count { font-size: 14px; }

  /* Filters */
  .filterbar { gap: 10px; }
  .searchfield { flex: 1 1 100%; max-width: none; min-height: 48px; }
  .searchfield input { height: 46px; font-size: 16px; }
  .m-content .tabs { margin-inline: -14px; padding: 2px 14px; max-width: none; width: calc(100% + 28px); gap: 8px; background: none; border-radius: 0; }
  .m-content .tabs .tab { min-height: 42px; padding: 0 15px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); color: var(--ink); box-shadow: none; }
  .m-content .tabs .tab.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
  .m-content .tabs .tab.is-active .pill { background: #fff; color: var(--ink); }
  .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; }
  .filter-inline select { min-height: 44px; }

  /* Lists */
  .m-list { display: block; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .m-list > li + li { border-top: 1px solid var(--line); }
  .m-card { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
  .m-card--list { padding: 6px 14px; }
  .m-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 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; font-weight: 600; }
  .m-row-main > span { color: var(--ink-2); font-size: 14.5px; }
  .m-row-main small { margin-top: 2px; color: var(--ink-2); font-size: 13.5px; }
  .m-row-main small .late { font-size: inherit; }
  .m-row-end { display: grid; justify-items: end; gap: 2px; flex: none; max-width: 44%; text-align: right; }
  .m-row-end small { color: var(--ink-2); font-size: 13px; }
  .m-me { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
  .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: 600; text-align: left; text-decoration: none; cursor: pointer; }
  .m-menu :is(a, button):active { background: var(--accent-tint); }
  .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); }

  .m-row-main small:empty { display: none; }
  .m-row-end b { font-size: 16px; }
  .m-group h2 { margin: 6px 2px 8px; font: 700 19px/1.2 var(--head); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 11px 13px; }
  .stat-value { font-size: 25px; }
  .stat-name, .stat-sub { font-size: 13px; line-height: 1.35; }
  .kids, .fields { grid-template-columns: minmax(0, 1fr); }
  .rows > li > a, .rows > li > div { min-height: 58px; }
  .rows-main { flex-basis: 150px; }
  .rows-main span { font-size: 13.5px; }
  .rows-card { padding: 0 14px; border-radius: 12px; }
  .callout { padding: 16px; border-radius: 12px; }
  .m-content .page-head .page-actions:has(.btn) { display: none; }
  .m-content .actionbar .btn { padding: 0 10px; }
  .seatline { grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 12px; }
  .steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 4px; padding: 14px 6px; }
  .steps li, .steps li + li { flex-direction: column; gap: 4px; text-align: center; font-size: 13px; }
  .daystrip { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .regtools { gap: 8px; }
  .daypick, .daypick .filter { width: 100%; }
  .daypick .filter select { width: 100%; }
  .regcount { gap: 6px 12px; font-size: 13.5px; }
  .m-reg { background: #fffefb; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
  .m-reg li { display: grid; gap: 6px; padding: 8px 12px 12px; }
  .m-reg li + li { border-top: 1px solid #dfe3ea; }
  .m-reg a { display: flex; align-items: center; gap: 10px; min-height: 34px; color: var(--ink); text-decoration: none; }
  .m-reg a i { display: grid; place-items: center; align-self: stretch; width: 28px; border-right: 2px solid #c9707c; color: var(--ink-2); font-style: normal; font-size: 13px; }
  .m-reg a strong { font-size: 16px; }
  .m-reg .pale { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .m-reg .pale button { height: 46px; border-radius: 10px; font-size: 16px; }
  .m-reg-mark { display: flex; align-items: center; gap: 8px; padding-left: 38px; font-weight: 700; }
  .m-submit { position: sticky; bottom: calc(var(--tabs) + 8px); z-index: 11; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 12px 26px -14px rgba(43, 34, 36, .55); }
  .m-submit > span { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
  .m-submit .btn { padding: 0 14px; }
  .m-content .actionbar:has([data-act="reg-submit"]) { display: none; }
  .key { font-size: 13px; }
  .key .mk, .mk { font-size: 13px; width: 24px; height: 24px; }
  .subjects { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .subjects button { padding: 10px; border-radius: 12px; }
  .subjects span, .subjects em { font-size: 13px; }
  .marksheet { columns: 1; }
  .marksheet li { grid-template-columns: minmax(0, 1fr) 84px 18px; gap: 4px 8px; }
  .marksheet label span { font-size: 13px; }
  .marksheet input { height: 48px; font-size: 17px; }
  .marksheet input::placeholder { font-size: 13px; }
  .sheet-tools .btn { flex: 1 1 140px; }
  .reportcard table { font-size: 13.5px; }
  .reportcard th { white-space: normal; font-size: 13px; vertical-align: bottom; }
  .reportcard th, .reportcard td { padding-inline: 3px !important; }
  .reportcard td:first-child, .reportcard th:first-child { padding-left: 0 !important; }
  .letter { padding: 18px 16px; }
  .board a { gap: 12px; padding: 12px; }
  .facts > div { grid-template-columns: minmax(96px, 36%) minmax(0, 1fr); }
  .facts dd a, .rows-main a { display: inline-flex; align-items: center; min-height: 28px; }
  .m-search { display: flex; }
  .ref { font-size: 13px; }
  .pill, .navpill { font-size: 13px; }
  .locked, .missing { margin: 24px auto; }
  /* 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; }
  .toasts { left: 12px; right: 12px; max-width: none; bottom: calc(var(--tabs, 0px) + 84px); }
  .signin { padding: 28px 16px 40px; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }
}
@media (max-width: 350px) {
  .stat { padding: 10px; }
  .m-submit .btn { padding: 0 10px; font-size: 14px; }
  .subjects { grid-template-columns: minmax(0, 1fr); }
}
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(74, 18, 27, .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: #4a121b; 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, 18, 27, .25); }

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