/* The phone app layout, used below 761px and inside the desktop phone preview.
   Made to be worked one handed: large targets, one column, the next trip step first. */
@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; }

  .m-bar { position: sticky; top: 0; z-index: 12; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 10px 8px 16px; background: var(--navy); color: #fff; }
  .m-bar > img { border-radius: 7px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .3); }
  .m-bar h1, .m-bar .m-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 21px; font-weight: 800; line-height: 1.3; }
  .m-icon { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: inherit; cursor: pointer; }
  .m-bar a.m-icon { margin: 0 -6px 0 -10px; }
  .m-icon .icon { width: 22px; height: 22px; }
  .m-bar .m-icon.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-dark); font-size: 13px; }
  .m-content { padding: 14px 14px calc(var(--tabs) + 28px); }
  .has-fab .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-2); }
  .m-tabs ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: 100%; gap: 2px; }
  .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: 800; }
  .m-tabs a.is-on i { background: var(--accent); color: #fff; }
  .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(15, 60, 40, .75); cursor: pointer; }
  .m-fab .icon { width: 26px; height: 26px; }

  .btn { min-height: 46px; font-size: 15.5px; }
  .btn-small { min-height: 40px; font-size: 14px; }
  .btn-big { min-height: 56px; font-size: 17px; }
  .m-intro { color: var(--ink-2); font-size: 14.5px; }
  .m-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .m-actions .btn { flex: 1 1 140px; }
  .record-head h2 { font-size: 22px; font-weight: 800; }
  .record-head .page-actions, .record-head > div { width: 100%; }
  .page-actions .btn { flex: 1 1 130px; }

  .card { padding: 14px; }
  .card-flush { padding: 0; }
  .stats, .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-3 .stat:last-child { grid-column: 1 / -1; }
  .stat { padding: 11px 13px; }
  .stat strong { font-size: 23px; }
  .detail-grid, .over-grid, .chart-grid, .form-grid, .pick-grid { grid-template-columns: minmax(0, 1fr); }
  .tab { min-height: 42px; font-size: 14px; }
  .filterbar .searchfield { flex: 1 1 100%; max-width: none; min-height: 46px; }
  .filterbar .filter { flex: 1 1 130px; min-width: 0; }
  .filterbar .filter select { width: 100%; min-height: 44px; }
  .field input, .field select { min-height: 46px; font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }

  .rows > li { border-bottom: 1px solid var(--line); }
  .rows > li:last-child { border-bottom: 0; }
  .rows > li > a, .rows > li > div:first-child { display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 11px 12px 11px 14px; color: inherit; text-decoration: none; }
  .rows > li > a > .icon { color: var(--ink-2); }
  .row-main { flex: 1; display: grid; gap: 2px; min-width: 0; line-height: 1.35; }
  .row-main strong small { font-weight: 500; color: var(--ink-2); font-size: 13px; margin-left: 4px; }
  .row-main > span { font-size: 14px; color: var(--ink-2); }
  .row-main > .badges { margin-top: 4px; }
  .row-main .nowrap { font-size: 12.5px; }
  .row-end { display: grid; justify-items: end; font-weight: 800; font-variant-numeric: tabular-nums; }
  .row-end small { font-size: 12px; font-weight: 500; color: var(--ink-2); }
  .row-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: -8px; padding: 0 12px 8px; }

  .board-list > * + * { margin-top: 10px; }
  .board-list .trip-list { margin-inline: -14px; border-block: 1px solid var(--line); background: var(--surface); }
  .trip-day { top: 60px; }
  .trip-body > span { font-size: 14px; }
  .trip-body strong { font-size: 15.5px; }
  .trip-detail > .trip-head h2 { font-size: 21px; }
  .trip-head h2 span { display: block; margin: 0; font-size: 15px; }
  .trip-head .page-actions { width: 100%; }
  .progress li span { font-size: 12px; }
  .progress { gap: 3px; }
  .sketch { margin-inline: -14px; border-radius: 0; border-inline: 0; }
  .lines > li { flex-wrap: wrap; gap: 6px 10px; }
  .lines > li > .badges { flex-basis: 100%; }
  .attn.today a { grid-template-columns: 62px minmax(0, 1fr); }
  .today .badges { grid-column: 2; justify-content: flex-start; max-width: none; }
  .xc { --xc-label: minmax(60px, 92px); --xc-value: 52px; }
  .xc-tip { white-space: normal; max-width: 220px; width: max-content; }
  .xc-xlabels span, .xc-yaxis b, .xc-ticks b, .xc-axisname, .xc-colbar em { font-size: 12px; }
  .xc-v .xc-colbar em { display: none; }
  .xc-ticks b:nth-child(even) { display: none; }

  .week-nav { justify-content: space-between; }
  .week-nav strong { flex: 1; }
  .day-chips .tab { flex: 1 0 46px; flex-direction: column; justify-content: center; gap: 0; min-height: 54px; padding: 0 6px; }
  .day-chips .tab span { font-size: 12px; }
  .day-chips .tab b { font-size: 17px; opacity: 1; }
  .plan-rows .row-main strong a { text-decoration: none; color: var(--ink); margin-right: 4px; }
  .plan-stack { display: grid; gap: 4px; margin-top: 4px; }
  .plan-chip { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 44px; margin: 0; font-size: 14px; }
  .plan-block { padding: 0; font-size: 13px; }

  .who-card { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
  .who-card div { display: grid; }
  .who-card div span { font-size: 14px; color: var(--ink-2); }
  .menu-list { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
  .menu-list li + li { border-top: 1px solid var(--line); }
  .menu-list :is(a, button) { display: grid; grid-template-columns: 22px minmax(0, 1fr) 18px; gap: 12px; align-items: center; width: 100%; min-height: 56px; padding: 0 14px; border: 0; background: none; color: inherit; font-weight: 700; text-align: left; text-decoration: none; cursor: pointer; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--tabs, 0px) + 12px); max-width: none; }
  .locked { padding: 48px 8px; }
  .empty { background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius-lg); }
  .card .empty { border: 0; padding: 18px 6px; }
  dialog, dialog.is-wide { width: 100%; max-width: 100%; max-height: calc(100dvh - 48px); margin: auto 0 0; border-radius: 16px 16px 0 0; }
  dialog form { max-height: calc(100dvh - 48px); }
  .modal-foot .btn { flex: 1; }

  /* Role screen: all three roles are visible at once, each as one large row */
  .signin { padding: 22px 14px 24px; }
  .signin h1 { margin-top: 20px; font-size: 24px; line-height: 1.2; text-wrap: balance; }
  .signin-sub { font-size: 15px; text-wrap: balance; }
  .signin .roles { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 18px; }
  .signin .role-points { 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: 12px; min-height: 100px; padding: 13px; }
  .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; }
  .signin .role-title { grid-area: title; margin: 0; font-size: 17.5px; 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); }
}
@media (max-width: 360px) {
  .stats, .stats-3 { grid-template-columns: minmax(0, 1fr); }
  .progress li span { visibility: hidden; width: 0; }
  .progress li.is-now span { visibility: visible; width: max-content; }
  .progress li:last-child.is-now span { justify-self: end; }
}

/* Desktop and phone preview switch */
.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(18, 39, 30, .13); }
  .view-switch button { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 13px; border: 0; border-radius: 99px; background: none; color: #12271e; 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(18, 39, 30, .28); }
  .app-body.is-preview { background: #e4e9e6; }
  .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-weight: 800; font-size: clamp(27px, 2.7vw, 36px); line-height: 1.15; }
  .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(--navy); color: #fff; font-size: 15px; font-weight: 700; }
  .device-status::after { content: ""; width: 25px; height: 12px; border: 1.5px solid #fff; border-radius: 4px; background: linear-gradient(#fff, #fff) 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: #000; }
  .device iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--bg); }
  .device-home { flex: none; height: 12px; background: var(--surface); }
  /* Desktop and Mobile switch sits in the exact middle of the bar */
  .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; }
}
