/* src/public/css/app-shell.css
   Companion app: tab bar, /app pages, safe areas, and foldable layouts.

   iPhone Duo sizes this targets (CSS px, Safari):
     folded           ~382 × 580   (single column)
     folded sideways  ~678 × 340   (short: side rail, no sticky header)
     open             ~669 × 825 / 890 × 626 (two panes, split on the fold)
     open sideways    ~951 × 543   (two panes + side rail)
   Folding is just a resize: nothing here needs a reload or knows the device.
*/

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --app-tab-h: 60px;
  --app-rail-w: 78px;
  --fold-gap: 40px; /* keeps content 20px clear of each side of a center fold */
}

/* ---------------- Site-wide: safe areas (viewport-fit=cover) ---------------- */
.ps-shell {
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  overflow-x: clip; /* no sideways wobble on narrow folded screens */
}
.sh-header {
  padding-top: var(--safe-t);
}
.site-footer {
  padding-bottom: var(--safe-b);
}
.sp-toast-stack {
  top: calc(16px + var(--safe-t)) !important;
  right: calc(16px + var(--safe-r)) !important;
}
@media (max-width: 599px) {
  .sp-toast-stack {
    left: calc(12px + var(--safe-l)) !important;
    right: calc(12px + var(--safe-r)) !important;
    max-width: none !important;
  }
}

/* Phones (incl. folded Duo): keep the header to one row — brand + menu button.
   (The brand link was picking up width:100% from the mobile menu rules.) */
@media (max-width: 720px) {
  .sh-nav > .sh-link.brand {
    width: auto;
    flex: 0 1 auto;
    min-width: 0;
    min-height: 44px;
  }
}

/* Cookie notice on narrow screens: no tall empty box (flex-basis was acting as height) */
@media (max-width: 640px) {
  .ps-cookie-banner .ps-cookie-banner__text {
    flex: 0 0 auto;
    min-width: 0;
  }
  .ps-cookie-banner {
    left: calc(8px + var(--safe-l));
    right: calc(8px + var(--safe-r));
    bottom: calc(8px + var(--safe-b));
  }
}

/* In the app the tab bar already has Profile/Jobs/Dashboard/Messages */
@media (min-width: 721px) {
  html.is-app .sh-left a[href="/profile"],
  html.is-app .sh-left a[href="/listings"],
  html.is-app .sh-left a[href="/dashboard"],
  html.is-app .sh-left .sh-link--messages {
    display: none;
  }
}

/* iOS: short screens + dynamic toolbars → use the real visible height */
@supports (height: 100dvh) {
  html body #applyModal .modal-content {
    height: 92dvh !important;
  }
  html body #applyModal .modal-dialog {
    margin: 4dvh auto !important;
  }
  .ps-body .chat {
    max-height: 60dvh;
  }
}

/* Apply modal = full-screen sheet on phones (folded Duo included) */
@media (max-width: 599px), (max-height: 480px) {
  html body #applyModal .modal-dialog {
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  html body #applyModal .modal-content {
    height: 100vh !important;
    border-radius: 0 !important;
    padding-top: var(--safe-t);
    padding-bottom: var(--safe-b);
  }
  @supports (height: 100dvh) {
    html body #applyModal .modal-content {
      height: 100dvh !important;
    }
  }
  html body #applyModal .modal-body {
    padding: 16px max(16px, var(--safe-r)) 16px max(16px, var(--safe-l)) !important;
  }
}

/* ---------------- Tab bar (installed app only) ---------------- */
.app-tabbar {
  display: none;
}

html.is-app .app-tabbar {
  position: fixed;
  z-index: 60;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 6px calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
  background: rgba(5, 8, 22, 0.9);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
}
html[data-theme="light"].is-app .app-tabbar {
  background: rgba(255, 255, 255, 0.92);
}

html.is-app body {
  padding-bottom: calc(var(--app-tab-h) + var(--safe-b));
}
html.is-app {
  /* focused fields / anchors never hide under the tab bar */
  scroll-padding-bottom: calc(var(--app-tab-h) + var(--safe-b) + 12px);
}
html.is-app .site-footer {
  display: none; /* legal links live in App settings */
}

.app-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 12px;
  color: var(--text-muted, #cbd5e1);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.app-tab:hover {
  color: var(--text-main, #f9fafb);
}
.app-tab.is-on {
  color: var(--accent, #38bdf8);
}
.app-tab:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(56, 189, 248, 0.28));
}
.app-tab-icon {
  position: relative;
  display: inline-flex;
}
.app-tab-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.app-tab-badge {
  position: absolute;
  top: -6px;
  left: 14px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(5, 8, 22, 0.9);
}
.app-tab-badge[hidden] {
  display: none;
}

/* Cookie banner sits above the tab bar */
html.is-app .ps-cookie-banner {
  bottom: calc(var(--app-tab-h) + var(--safe-b) + 10px) !important;
}

/* Short landscape (folded sideways, or open sideways): tab bar → side rail */
@media (orientation: landscape) and (max-height: 560px) {
  html.is-app .app-tabbar {
    top: 0;
    right: auto;
    width: calc(var(--app-rail-w) + var(--safe-l));
    grid-auto-flow: row;
    grid-auto-rows: minmax(0, 60px);
    grid-auto-columns: auto;
    align-content: center;
    padding: calc(8px + var(--safe-t)) 6px calc(8px + var(--safe-b)) calc(6px + var(--safe-l));
    border-top: 0;
    border-right: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  }
  html.is-app body {
    padding-bottom: 0;
    padding-left: var(--app-rail-w);
  }
  html.is-app .ps-shell {
    padding-left: 0; /* the rail already covers the left safe area */
  }
  html.is-app .ps-cookie-banner {
    bottom: calc(10px + var(--safe-b)) !important;
  }
}

/* Very short screens: don't let a sticky header eat the view */
@media (max-height: 480px) {
  .sh-header {
    position: static;
  }
}

/* ---------------- /app pages ---------------- */
.app-page [hidden],
.app-tabbar [hidden] {
  display: none !important;
}

.app-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 28px;
  color: var(--text-main, #f9fafb);
}
.app-page a {
  text-decoration: none;
}

.app-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}
.app-head-text {
  min-width: 0;
}
.app-kicker {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, #38bdf8);
}
.app-title {
  margin: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.app-lead {
  margin: 10px auto 0;
  max-width: 560px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-muted, #cbd5e1);
}
.app-h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.app-muted {
  margin: 0 0 12px;
  color: var(--text-muted, #cbd5e1);
  line-height: 1.5;
}
.app-fine {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted, #cbd5e1);
  line-height: 1.45;
}
.app-count {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted, #cbd5e1);
  margin-left: 6px;
}
.app-flash {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
}
.app-error {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(249, 115, 115, 0.12);
  border: 1px solid rgba(249, 115, 115, 0.4);
  color: var(--text-main, #f9fafb);
}

.app-icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  background: var(--card-2, rgba(15, 23, 42, 0.78));
  color: var(--text-main, #f9fafb);
}

.app-card {
  background: var(--card, rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow-md, none);
}
.app-card + .app-card,
.app-card + .app-split,
.app-split + .app-card {
  margin-top: 14px;
}
.app-card-accent {
  border-color: rgba(56, 189, 248, 0.45);
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.14), rgba(56, 189, 248, 0.02)),
    var(--card, rgba(15, 23, 42, 0.92));
  margin-bottom: 14px;
}
.app-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.app-link {
  color: var(--accent, #38bdf8);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.app-stack {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

/* Buttons */
.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  background: transparent;
  color: var(--text-main, #f9fafb);
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.app-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(56, 189, 248, 0.28));
}
.app-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.app-btn-primary {
  background: var(--accent, #38bdf8);
  border-color: transparent;
  color: #04121f;
}
html[data-theme="light"] .app-btn-primary {
  color: #fff;
}
.app-btn-ghost {
  border-color: transparent;
  background: rgba(148, 163, 184, 0.12);
}
.app-btn-block {
  width: 100%;
}
.app-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.app-btn-row:empty {
  display: none;
}

/* Hero (guest) */
.app-hero {
  text-align: center;
  padding: 18px 4px 22px;
}
.app-hero-mark {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 10px;
}
.app-hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

/* Alerts nudge */
.app-nudge {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
  color: var(--text-main, #f9fafb);
}
.app-nudge[hidden] {
  display: none;
}
.app-nudge-icon {
  font-size: 22px;
}
.app-nudge-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.app-nudge-text span {
  color: var(--text-muted, #cbd5e1);
  font-size: 14px;
}
.app-chev {
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted, #cbd5e1);
}

/* Stats */
.app-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.app-stat {
  display: grid;
  gap: 2px;
  padding: 12px;
  border-radius: 16px;
  background: var(--card, rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  color: var(--text-main, #f9fafb);
  min-width: 0;
}
.app-stat-num {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.app-stat-label {
  font-size: 12.5px;
  color: var(--text-muted, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick actions */
.app-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.app-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  background: var(--card-2, rgba(15, 23, 42, 0.78));
  color: var(--text-main, #f9fafb);
  font-weight: 650;
  font-size: 15px;
  min-width: 0;
}
.app-action span {
  font-size: 20px;
}
.app-action:hover,
.app-stat:hover,
.app-row:hover {
  border-color: var(--border-strong, rgba(148, 163, 184, 0.28));
}

/* Lists */
.app-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.app-list > li + li {
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
}
.app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 2px;
  color: var(--text-main, #f9fafb);
}
.app-row-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.app-row-title {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-row-sub {
  font-size: 13.5px;
  color: var(--text-muted, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}
.app-row-date {
  font-size: 12px;
  color: var(--text-muted, #cbd5e1);
  white-space: nowrap;
}
.app-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.app-pill-info {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent, #38bdf8);
}
.app-pill-good {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
html[data-theme="light"] .app-pill-good {
  color: #15803d;
}
.app-pill-muted {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-muted, #cbd5e1);
}

.app-feature-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  line-height: 1.5;
  color: var(--text-muted, #cbd5e1);
}
.app-feature-list strong {
  color: var(--text-main, #f9fafb);
}
.app-feature-list a {
  color: var(--accent, #38bdf8);
}

/* Install card */
.app-install [hidden] {
  display: none !important;
}
.app-install-for {
  margin: 12px 0 6px;
  font-weight: 700;
}
.app-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
  line-height: 1.5;
}
.app-kbd {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  font-size: 13px;
}
html.is-app [data-install-card] {
  display: none;
}

/* Settings */
.app-toggles {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
  display: grid;
}
.app-toggles[hidden] {
  display: none;
}
.app-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  cursor: pointer;
}
.app-toggle span {
  display: grid;
  gap: 2px;
}
.app-toggle small {
  color: var(--text-muted, #cbd5e1);
  font-size: 13px;
}
.app-toggle input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}
.app-toggle input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.app-toggle input:checked {
  background: #22c55e;
}
.app-toggle input:checked::after {
  transform: translateX(20px);
}
.app-toggle input:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(56, 189, 248, 0.28));
}
.app-devices {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
}
.app-devices .app-fine {
  margin: 0 0 8px;
}
.app-logout {
  margin: 12px 0 0;
}
.app-legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
}
.app-legal-links a {
  color: var(--accent, #38bdf8);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

/* Self-tape */
.app-tape-pick {
  display: grid;
  gap: 10px;
}
.app-tape-pick[hidden],
.app-tape-form[hidden] {
  display: none;
}
.app-file-btn {
  position: relative;
  width: 100%;
}
.app-video-wrap {
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}
.app-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.app-label {
  display: block;
  margin: 14px 0 6px;
  font-weight: 650;
  font-size: 14px;
}
.app-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  background: rgba(2, 6, 23, 0.5);
  color: var(--text-main, #f9fafb);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming on focus */
}
html[data-theme="light"] .app-input {
  background: #fff;
}
.app-input:focus {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(56, 189, 248, 0.28));
}
.app-progress {
  margin-top: 14px;
}
.app-progress[hidden] {
  display: none;
}
.app-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}
.app-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent, #38bdf8);
  transition: width 0.2s ease;
}
.app-tips {
  margin-top: 16px;
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  padding-top: 12px;
}
.app-tips summary {
  cursor: pointer;
  font-weight: 650;
  min-height: 32px;
}
.app-tips ul {
  margin: 8px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--text-muted, #cbd5e1);
  line-height: 1.5;
}
.app-tape-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.app-tape-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.app-tape-thumb {
  position: relative;
  flex: none;
  width: 120px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  display: grid;
  place-items: center;
}
.app-tape-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-tape-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
}
.app-tape-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

/* ---------------- Two panes (open foldables, tablets, desktop) ---------------- */
.app-split {
  display: grid;
  gap: 14px;
  align-items: start;
}
@media (min-width: 600px) {
  /* Equal halves: on a book-style foldable the gap lands on the fold */
  .app-split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--fold-gap);
    row-gap: 14px;
  }
  .app-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (min-width: 600px) and (max-width: 759px) {
  .app-action {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 4px;
    font-size: 13.5px;
  }
}

/* Exact fold position when the browser reports it (Safari feature flag
   "Viewport Segments API", Chrome on Android foldables). */
@media (horizontal-viewport-segments: 2) {
  .app-page {
    max-width: none;
    padding-left: 16px;
    padding-right: 16px;
  }
  .app-split {
    grid-template-columns: calc(env(viewport-segment-width 0 0) - 32px) minmax(0, 1fr);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0) + 32px);
  }
}

/* ---------------- Messages: list + conversation side by side ----------------
   Only for the app and touch screens ≥600px (open Duo, tablets).
   Desktop browsers keep the original one-column page. */
.msg-split-list {
  display: none;
}
@media (min-width: 600px) and (pointer: coarse) {
  .msg-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--fold-gap);
    align-items: start;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
  }
  .msg-split-list {
    display: block;
  }
  .msg-split .msg-split-main > .container {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
}
@media (min-width: 600px) {
  html.is-app .msg-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--fold-gap);
    align-items: start;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
  }
  html.is-app .msg-split-list {
    display: block;
  }
  html.is-app .msg-split .msg-split-main > .container {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }
}
@media (min-width: 1100px) {
  html.is-app .msg-split {
    grid-template-columns: 340px minmax(0, 1fr);
  }
}
@media (horizontal-viewport-segments: 2) {
  .msg-split {
    max-width: none;
    grid-template-columns: calc(env(viewport-segment-width 0 0) - 32px) minmax(0, 1fr) !important;
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0) + 32px);
  }
}

/* Conversation header on phones: buttons wrap instead of running off-screen
   (app.css gives .btn-row-inline width:max-content), and a smaller title. */
#msgThreadRoot .btn-row-inline {
  width: auto;
  max-width: 100%;
}
@media (max-width: 599px) {
  #msgThreadRoot .ps-name {
    font-size: 22px;
    line-height: 1.25;
  }
}

/* Conversation header when the inbox sits beside it (same conditions as above) */
@media (min-width: 600px) and (pointer: coarse) {
  .msg-split .ps-top {
    flex-direction: column;
    align-items: stretch;
  }
  .msg-split .ps-name {
    font-size: clamp(20px, 2.8vw, 28px);
    line-height: 1.2;
  }
}
@media (min-width: 600px) {
  html.is-app .msg-split .ps-top {
    flex-direction: column;
    align-items: stretch;
  }
  html.is-app .msg-split .ps-name {
    font-size: clamp(20px, 2.8vw, 28px);
    line-height: 1.2;
  }
}
@media (max-width: 720px), (pointer: coarse) {
  .ps-body .reply textarea {
    font-size: 16px; /* stops iOS zooming in when you tap to type */
  }
}
html.is-app .ps-body .reply {
  bottom: calc(var(--app-tab-h) + var(--safe-b) + 8px); /* stay above the tab bar */
}
@media (orientation: landscape) and (max-height: 560px) {
  html.is-app .ps-body .reply {
    bottom: calc(8px + var(--safe-b));
  }
}
@media (max-height: 720px) {
  .ps-body .reply textarea {
    min-height: 72px;
  }
}
@media (max-height: 480px) {
  .ps-body .reply {
    position: static;
  }
  .ps-body .reply textarea {
    min-height: 64px;
  }
}

.msg-split-list {
  position: sticky;
  top: 12px;
  margin-top: 16px;
  max-height: calc(100vh - 140px);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: 16px;
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  background: var(--card-2, rgba(15, 23, 42, 0.78));
}
@supports (height: 100dvh) {
  .msg-split-list {
    max-height: calc(100dvh - 140px);
  }
}
.msg-split-title {
  margin: 0;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 750;
  border-bottom: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
}
.msg-split-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.msg-split-list li + li {
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.12));
}
.msg-mini {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  color: var(--text-main, #f9fafb);
  text-decoration: none;
  min-height: 56px;
}
.msg-mini:hover {
  background: rgba(148, 163, 184, 0.08);
}
.msg-mini[aria-current="page"] {
  background: rgba(56, 189, 248, 0.14);
  box-shadow: inset 3px 0 0 var(--accent, #38bdf8);
}
.msg-mini-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.msg-mini-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-mini-count {
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent, #38bdf8);
  color: #04121f;
  font-size: 11px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}
.msg-mini-sub,
.msg-mini-preview {
  font-size: 13px;
  color: var(--text-muted, #cbd5e1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-mini.is-unread .msg-mini-preview {
  color: var(--text-main, #f9fafb);
  font-weight: 600;
}

/* ---------------- "Get the app" banner + links ---------------- */
.app-promo[hidden],
.app-promo [hidden] {
  display: none !important;
}
.app-promo {
  margin: 10px max(12px, var(--safe-r)) 0 max(12px, var(--safe-l));
  padding: 10px 10px 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(56, 189, 248, 0.04)),
    var(--card, rgba(15, 23, 42, 0.92));
  color: var(--text-main, #f9fafb);
  max-width: 1120px;
}
@media (min-width: 1144px) {
  .app-promo {
    margin-left: auto;
    margin-right: auto;
  }
}
.app-promo-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-promo-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.app-promo-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}
.app-promo-text strong {
  font-size: 14.5px;
}
.app-promo-text span {
  font-size: 13px;
  color: var(--text-muted, #cbd5e1);
}
.app-promo-btn {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: var(--accent, #38bdf8);
  color: #04121f;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
html[data-theme="light"] .app-promo-btn {
  color: #fff;
}
.app-promo-close {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--text-muted, #cbd5e1);
  cursor: pointer;
}
.app-promo-btn:focus-visible,
.app-promo-close:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 3px rgba(56, 189, 248, 0.28));
}
.app-promo-steps {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  font-size: 14px;
  line-height: 1.5;
}
.app-promo-steps p {
  margin: 0;
}

/* "Get the app" menu link: phone menu only, never inside the app */
@media (min-width: 721px) {
  .sh-get-app {
    display: none !important;
  }
}
html.is-app .sh-get-app {
  display: none !important;
}

/* Install steps on the app home (browser only; hidden once installed) */
.app-home-install {
  margin-top: 14px;
  max-width: 560px;
}
#install {
  scroll-margin-top: 90px;
}

html.is-app .app-home-install {
  display: none;
}

/* =====================================================================
   Actor app screens: Roles / Role / Apply / Applied
   ===================================================================== */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin: 0 0 10px;
}
.app-bar-title {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.app-back {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin-left: -6px;
  padding-right: 10px;
  color: var(--accent, #38bdf8);
  font-weight: 600;
  font-size: 16px;
}
.app-pro-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--text-main, #f9fafb);
  font-size: 14.5px;
}
.app-search {
  margin: 0 0 10px;
}
.app-search .app-input {
  border-radius: 999px;
  padding-left: 16px;
}
.app-chips {
  display: flex;
  gap: 8px;
  margin: 0 0 14px;
}
.app-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  color: var(--text-main, #f9fafb);
  font-weight: 600;
  font-size: 14px;
}
.app-chip.is-on {
  background: var(--text-main, #f9fafb);
  border-color: transparent;
  color: var(--bg, #050816);
}
html[data-theme="light"] .app-chip.is-on {
  background: #0f172a;
  color: #fff;
}

.app-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
@media (min-width: 760px) {
  .app-roles-page .app-cards,
  .app-applied-page .app-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--fold-gap);
  }
}
.app-role-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--card, rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  color: var(--text-main, #f9fafb);
  min-width: 0;
}
.app-role-card:active {
  transform: scale(0.99);
}
.app-role-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.app-role-title {
  font-size: 17px;
  font-weight: 750;
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}
.app-role-line {
  font-size: 14.5px;
  color: var(--text-muted, #cbd5e1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-role-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13.5px;
  color: var(--text-muted, #cbd5e1);
}
.app-pay {
  color: #4ade80;
  font-weight: 700;
  white-space: nowrap;
}
html[data-theme="light"] .app-pay {
  color: #15803d;
}
.app-pill-warn {
  background: rgba(251, 191, 36, 0.16);
  color: #fbbf24;
}
.app-empty {
  text-align: center;
  padding: 36px 12px;
}
.app-empty-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}
.app-pager {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0 4px;
}

/* One listing */
.app-company {
  margin: 4px 0 0;
}
.app-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 14px 0 0;
}
.app-facts div {
  min-width: 0;
}
.app-facts dt {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #cbd5e1);
}
.app-facts dd {
  margin: 2px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.app-desc {
  margin-top: 14px;
  white-space: pre-line;
  line-height: 1.55;
  color: var(--text-main, #f9fafb);
  overflow-wrap: anywhere;
}
.app-closed {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.14);
  font-weight: 600;
}
.app-section-h {
  margin: 18px 2px 10px;
}
@media (min-width: 600px) {
  .app-section-h {
    margin-top: 0;
  }
}
.app-role {
  display: grid;
  gap: 8px;
}
.app-role-name {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
}
.app-role-facts {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted, #cbd5e1);
}
.app-tag-tape {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.app-role-desc {
  margin: 0;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.app-role-action {
  margin-top: 4px;
}
.app-applied {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  color: #4ade80;
  font-weight: 700;
}

/* Apply */
.app-apply-head {
  margin: 0 0 14px;
}
.app-apply-head .app-muted {
  margin: 4px 0 0;
}
.app-hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, #cbd5e1);
}
.app-hs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.app-hs {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.15);
  cursor: pointer;
}
.app-hs input,
.app-pick input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.app-hs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-hs .app-check {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent, #38bdf8);
  color: #04121f;
  font-weight: 900;
  font-size: 14px;
}
.app-hs:has(input:checked) {
  box-shadow: 0 0 0 3px var(--accent, #38bdf8);
}
.app-hs:has(input:checked) .app-check {
  display: grid;
}
.app-hs:has(input:focus-visible) {
  outline: 3px solid var(--accent, #38bdf8);
  outline-offset: 2px;
}

.app-pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.app-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-soft, rgba(148, 163, 184, 0.16));
  cursor: pointer;
}
.app-pick:has(input:checked) {
  border-color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.1);
}
.app-pick:has(input:focus-visible) {
  outline: 3px solid var(--accent, #38bdf8);
  outline-offset: 2px;
}
.app-pick-thumb {
  flex: none;
  width: 72px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.app-pick-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-pick-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.app-box {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--border-strong, rgba(148, 163, 184, 0.45));
  display: grid;
  place-items: center;
}
.app-pick:has(input:checked) .app-box {
  background: var(--accent, #38bdf8);
  border-color: transparent;
}
.app-pick:has(input:checked) .app-box::after {
  content: "✓";
  color: #04121f;
  font-weight: 900;
  font-size: 15px;
}
.app-pick-audio {
  display: grid;
  gap: 6px;
}
.app-pick-audio audio {
  width: 100%;
  height: 36px;
}
.app-pick-list + .app-pick-list {
  margin-top: 8px;
}
.app-add {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 6px;
}
.app-links {
  list-style: none;
  margin: 10px 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.app-links a {
  color: var(--accent, #38bdf8);
  font-weight: 600;
}
.app-instructions {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.1);
}
.app-textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}
.app-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 6px;
  font-size: 14.5px;
}
.app-check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent, #38bdf8);
}
.app-stats-tight {
  margin-bottom: 0;
}

/* Send bar: sticks above the tab bar */
.app-apply-form {
  padding-bottom: 8px;
}
.app-submit-bar {
  position: sticky;
  bottom: 8px;
  z-index: 20;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--border-strong, rgba(148, 163, 184, 0.28));
  background: rgba(5, 8, 22, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
html[data-theme="light"] .app-submit-bar {
  background: rgba(255, 255, 255, 0.95);
}
html.is-app .app-submit-bar {
  bottom: calc(var(--app-tab-h) + var(--safe-b) + 8px);
}
@media (orientation: landscape) and (max-height: 560px) {
  html.is-app .app-submit-bar {
    bottom: calc(8px + var(--safe-b));
  }
}
.app-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.app-summary {
  font-size: 13.5px;
  color: var(--text-muted, #cbd5e1);
  min-width: 0;
}
.app-submit-bar .app-progress {
  margin: 0 0 8px;
}
.app-submit-bar .app-error {
  margin: 0 0 8px;
}

/* App screens own the top of the screen in the installed app (no site header) */
html.is-app body:has(.app-page) .sh-header {
  display: none;
}
html.is-app .app-page {
  padding-top: calc(12px + var(--safe-t));
}
.app-switch {
  margin: 0 0 10px;
}

@media (max-height: 480px) {
  .app-submit-bar,
  html.is-app .app-submit-bar {
    position: static; /* folded sideways: don't cover the form */
  }
}
