/* ------------------------------------------------------------------
   indie.ugc — app screens (port of ugc-bharat/project/App.html <style>)

   Scoped under body.app — keeps these tokens isolated from
   the landing-page tokens in application.css (body.landing).
------------------------------------------------------------------- */

body.app {
  /* Locked theme — magenta-led */
  --primary:   #E91E63;
  --primary-2: #C2185B;
  --secondary: #7A1238;
  --accent:    #FFB627;
  --bg:        #FFF6E8;
  --bg-2:      #F6ECD9;
  --ink:       #1C0309;
  --ink-2:     #3A0F1C;
  --muted:     #6E5D5A;
  --line:      rgba(28, 3, 9, 0.10);
  --line-2:    rgba(28, 3, 9, 0.18);
  --card:      #FFFFFF;
  --danger:    #DC2626;
  --success:   #15803D;
  --info:      #2563EB;

  --font-display: "Bricolage Grotesque", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-sans:    "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, monospace;

  --r-sm: 6px;
  --r:    10px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 9999px;

  --h-input: 36px;
  --h-input-sm: 32px;
  --h-input-lg: 40px;

  margin: 0;
  padding: 0;
  background: #E8DDC4;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.app * { box-sizing: border-box; }
body.app button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
body.app a { color: inherit; text-decoration: none; }
body.app img { display: block; max-width: 100%; }

body.app .display { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.025em; line-height: 1.05; }
body.app .mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }

/* Buttons */
body.app .btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--h-input); padding: 0 14px;
  font-size: 14px; font-weight: 500;
  border-radius: var(--r);
  transition: background .15s ease, color .15s ease, opacity .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
body.app .btn:hover { opacity: 0.92; }
body.app .btn-primary { background: var(--primary); color: #fff; }
body.app .btn-primary:hover { background: var(--primary-2); opacity: 1; }
body.app .btn-ink { background: var(--ink); color: var(--bg); }
body.app .btn-ink:hover { background: var(--ink-2); opacity: 1; }
body.app .btn-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); }
body.app .btn-outline:hover { background: var(--bg-2); }
body.app .btn-ghost { background: transparent; color: var(--ink); }
body.app .btn-ghost:hover { background: var(--bg-2); }
body.app .btn-sm { height: var(--h-input-sm); padding: 0 10px; font-size: 13px; }
body.app .btn-lg { height: var(--h-input-lg); padding: 0 18px; font-size: 14px; }
body.app .btn-danger { background: var(--danger); color: #fff; }
body.app .btn-accent { background: var(--accent); color: var(--ink); }

/* Input */
body.app .input {
  height: var(--h-input);
  border-radius: var(--r);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line-2);
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  width: 100%;
  transition: box-shadow .15s ease;
  border: 0;
}
body.app .input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--primary), 0 0 0 3px rgba(233, 30, 99, 0.18); }
body.app textarea.input { padding: 10px 12px; min-height: 80px; line-height: 1.5; resize: vertical; }
body.app .label { font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
body.app .help  { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Card */
body.app .card {
  background: var(--card);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
body.app .card-header { padding: 20px 20px 14px; }
body.app .card-body   { padding: 20px; }
body.app .card-footer { padding: 14px 20px; border-top: 1px solid var(--line); }
body.app .card-title  { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -0.015em; margin: 0; }
body.app .card-desc   { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* Badge */
body.app .badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600;
  background: var(--bg-2); color: var(--ink);
}
body.app .badge-primary { background: var(--primary); color: #fff; }
body.app .badge-ink     { background: var(--ink); color: var(--bg); }
body.app .badge-accent  { background: var(--accent); color: var(--ink); }
body.app .badge-success { background: rgba(21, 128, 61, 0.12); color: var(--success); }
body.app .badge-info    { background: rgba(37, 99, 235, 0.12); color: var(--info); }
body.app .badge-warning { background: rgba(255, 182, 39, 0.18); color: #8B5A00; }
body.app .badge-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); }
body.app .badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* Radio chips / option cards — restyle live on input:checked via :has(). */
body.app .option-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 999px;
  background: var(--bg-2); color: var(--ink);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
body.app .option-chip input { accent-color: var(--accent); margin: 0; }
body.app .option-chip:hover { background: var(--bg); border-color: var(--line); }
body.app .option-chip:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }

body.app .option-card {
  display: block; flex: 1;
  padding: 12px 14px; border-radius: 10px;
  background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer; user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
body.app .option-card input { accent-color: var(--accent); }
body.app .option-card:hover { border-color: var(--line-2); }
body.app .option-card .option-card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; margin-left: 22px; }
body.app .option-card:has(input:checked) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
body.app .option-card:has(input:checked) .option-card-sub { color: rgba(255, 246, 232, 0.7); }

/* Tier-style card: lighter selected look (no inverse), for picking from a list. */
body.app .option-card-soft {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line);
  cursor: pointer; user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
body.app .option-card-soft input { accent-color: var(--primary); width: 18px; height: 18px; }
body.app .option-card-soft:hover { border-color: var(--line-2); }
body.app .option-card-soft:has(input:checked) { background: var(--bg-2); border-color: var(--primary); }
body.app .option-card-soft:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* Avatar */
body.app .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; font-weight: 600; font-size: 14px;
  overflow: hidden; flex-shrink: 0;
}
body.app .avatar-sm { width: 28px; height: 28px; font-size: 12px; }
body.app .avatar-lg { width: 56px; height: 56px; font-size: 22px; }
body.app .avatar-xl { width: 80px; height: 80px; font-size: 30px; }

/* Tabs */
body.app .tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0; }
body.app .tab {
  padding: 10px 14px; font-size: 14px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
body.app .tab:hover { color: var(--ink); }
body.app .tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Tables */
body.app .tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
body.app .tbl th, body.app .tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
body.app .tbl th {
  font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
body.app .tbl tbody tr:hover { background: var(--bg-2); }
body.app .tbl tbody tr:last-child td { border-bottom: 0; }

/* Top nav */
body.app .topnav {
  height: 64px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 246, 232, 0.85);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
body.app .topnav-tabs { display: flex; gap: 4px; align-items: center; }
body.app .topnav-tab {
  height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
}
body.app .topnav-tab:hover { background: var(--bg-2); color: var(--ink); }
body.app .topnav-tab.active { background: var(--ink); color: var(--bg); }

/* Wordmark */
body.app .wm {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: -0.03em; white-space: nowrap;
  color: var(--ink);
}

/* Section number kicker */
body.app .section-no {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
body.app .section-no::before { content: ""; width: 24px; height: 1px; background: var(--ink); }

/* Surfaces */
body.app .surface   { background: var(--bg); }
body.app .surface-2 { background: var(--bg-2); }

/* PWA install banner — pinned to the bottom of the viewport on mobile,
   tucked to the bottom-right on tablet+. Respects iOS safe areas. */
body.app .install-bar {
  position: fixed;
  left:   max(12px, env(safe-area-inset-left));
  right:  max(12px, env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow:
    0 1px 0 rgba(28, 3, 9, 0.04),
    0 12px 28px -8px rgba(28, 3, 9, 0.22),
    0 24px 60px -24px rgba(28, 3, 9, 0.28);
  animation: install-bar-in .22s ease-out;
}
body.app .install-bar[hidden] { display: none; }
body.app .install-bar__icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: block;
}
body.app .install-bar__body {
  flex: 1; min-width: 0; line-height: 1.3;
}
body.app .install-bar__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin: 0;
}
body.app .install-bar__desc {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}
body.app .install-bar__cta { flex-shrink: 0; }
body.app .install-bar__dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
body.app .install-bar__dismiss:hover {
  background: var(--bg-2);
  color: var(--ink);
}
body.app .install-bar--ios .install-bar__body { font-size: 13px; }
body.app .install-bar__share-icon {
  display: inline-block;
  vertical-align: -3px;
  color: var(--primary);
  margin: 0 2px;
}

@media (min-width: 720px) {
  body.app .install-bar {
    left: auto;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    max-width: 380px;
  }
}

@keyframes install-bar-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Helpers */
body.app .row { display: flex; }
body.app .col { display: flex; flex-direction: column; }
body.app .between { justify-content: space-between; }
body.app .center  { align-items: center; }
body.app .grow    { flex: 1; min-width: 0; }
body.app .wrap    { flex-wrap: wrap; }
body.app .gap-1 { gap: 4px; }
body.app .gap-2 { gap: 8px; }
body.app .gap-3 { gap: 12px; }
body.app .gap-4 { gap: 16px; }
body.app .gap-5 { gap: 20px; }
body.app .gap-6 { gap: 24px; }
body.app .gap-8 { gap: 32px; }

body.app .divider { height: 1px; background: var(--line); width: 100%; }

body.app ::-webkit-scrollbar { width: 8px; height: 8px; }
body.app ::-webkit-scrollbar-thumb { background: rgba(28, 3, 9, 0.15); border-radius: 8px; }
body.app ::-webkit-scrollbar-track { background: transparent; }
body.app .no-scrollbar::-webkit-scrollbar { display: none; }
body.app .no-scrollbar { scrollbar-width: none; }

/* Progress bar */
body.app .progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
body.app .progress > div { height: 100%; background: var(--primary); border-radius: 999px; }

/* Stepper */
body.app .stepper { display: flex; align-items: center; gap: 0; }
body.app .stepper .step {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
body.app .stepper .step .n {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--bg-2); color: var(--muted);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
body.app .stepper .step.done .n { background: var(--ink); color: var(--bg); box-shadow: none; }
body.app .stepper .step.done { color: var(--ink); }
body.app .stepper .step.active .n { background: var(--primary); color: #fff; box-shadow: none; }
body.app .stepper .step.active { color: var(--ink); }
body.app .stepper .sep { width: 36px; height: 1px; background: var(--line-2); margin: 0 12px; }

/* Video frame */
body.app .video-frame {
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  background: linear-gradient(135deg, #2a1015, #1c0309);
  position: relative;
  overflow: hidden;
}

body.app .timeline-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--ink);
  cursor: pointer;
}

body.app .hover-lift { transition: transform .15s ease, box-shadow .15s ease; }
body.app .hover-lift:hover { transform: translateY(-2px); box-shadow: 0 8px 24px -8px rgba(28, 3, 9, 0.18); }

/* Checkbox */
body.app .check-box {
  width: 18px; height: 18px; border-radius: 5px;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2);
  display: inline-grid; place-items: center; flex-shrink: 0;
  color: #fff;
}
body.app .check-box.done { background: var(--success); box-shadow: none; }

/* Switch */
body.app .switch {
  width: 32px; height: 18px; border-radius: 999px;
  background: var(--line-2); position: relative;
  transition: background .15s;
}
body.app .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: left .15s;
}
body.app .switch.on { background: var(--primary); }
body.app .switch.on::after { left: 16px; }

body.app .accent-line { height: 3px; background: var(--accent); border-radius: 2px; width: 32px; }

/* ------------------------------------------------------------------
   App canvas (the /app index page that lays every screen out at scale)
------------------------------------------------------------------- */

body.app .canvas { padding: 56px 48px 120px; min-height: 100vh; }
body.app .canvas-section { margin-bottom: 80px; }
body.app .canvas-section-head { margin-bottom: 28px; max-width: 760px; }
body.app .canvas-section-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; margin: 8px 0 6px; }
body.app .canvas-section-head p  { color: var(--muted); font-size: 15px; margin: 0; }
body.app .artboard {
  display: inline-block; vertical-align: top;
  background: var(--bg);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -28px rgba(28, 3, 9, 0.30);
  overflow: hidden;
  position: relative;
}
body.app .artboard-label {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
body.app .artboards { display: grid; grid-template-columns: 1fr; gap: 56px; }
@media (min-width: 1500px) { body.app .artboards.desk-2up { grid-template-columns: 1fr 1fr; } }
body.app .artboards.phones {
  display: flex; flex-wrap: wrap; gap: 56px;
}

/* iOS-style phone frame for mobile screens */
body.app .ios-frame {
  width: 402px; height: 874px;
  border-radius: 54px;
  background: #0E0E10;
  padding: 12px;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.06),
    0 24px 56px -20px rgba(0, 0, 0, 0.30),
    inset 0 0 0 2px rgba(255, 255, 255, 0.04);
  position: relative;
}
body.app .ios-frame-inner {
  width: 100%; height: 100%;
  border-radius: 42px;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}
body.app .ios-notch {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 32px; border-radius: 20px; background: #000;
  z-index: 10;
}

/* ------------------------------------------------------------------
   Responsive — tablet / mobile

   App screens were authored desktop-first with inline grid + padding
   styles. We target those via attribute selectors so we don't need to
   edit every view. !important is required to beat inline styles.

   Audience is mobile-heavy — every body.app screen needs to reflow
   on small viewports.
------------------------------------------------------------------- */

/* Tablet & below */
@media (max-width: 960px) {
  /* Collapse common 4/3/2-col inline grids */
  body.app [style*="grid-template-columns: repeat(4"],
  body.app [style*="grid-template-columns: repeat(3"],
  body.app [style*="grid-template-columns:repeat(4"],
  body.app [style*="grid-template-columns:repeat(3"],
  body.app [style*="grid-template-columns: 1.5fr 1fr"],
  body.app [style*="grid-template-columns: 1fr 380px"],
  body.app [style*="grid-template-columns: 1fr 360px"],
  body.app [style*="grid-template-columns: 1fr 340px"],
  body.app [style*="grid-template-columns: 1fr 320px"],
  body.app [style*="grid-template-columns: 1fr 1.1fr"],
  body.app [style*="grid-template-columns: 1.1fr 1fr"],
  body.app [style*="grid-template-columns: 1.4fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
  /* 3-up form rows still need to collapse further */
  body.app [style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Shell padding from _screen_shell and friends */
  body.app [style*="padding: 32px 40px 40px"],
  body.app [style*="padding: 48px 40px"] {
    padding: 24px 24px 32px !important;
  }
  /* Auth shell header strip + pre-auth headers */
  body.app [style*="padding: 20px 40px"] {
    padding: 16px 20px !important;
  }
  /* Auth-shell content area */
  body.app [style*="padding: 56px 24px"] {
    padding: 32px 20px !important;
  }

  /* Topnav — give it a little less side gutter on tablet */
  body.app .topnav { padding: 0 20px; }
}

/* Phone */
@media (max-width: 720px) {
  /* Collapse everything to single column */
  body.app [style*="grid-template-columns: repeat(4"],
  body.app [style*="grid-template-columns: repeat(3"],
  body.app [style*="grid-template-columns:repeat(4"],
  body.app [style*="grid-template-columns:repeat(3"],
  body.app [style*="grid-template-columns: 1fr 1fr"],
  body.app [style*="grid-template-columns: 1fr 1fr 1fr"],
  body.app [style*="grid-template-columns: 1.5fr 1fr"],
  body.app [style*="grid-template-columns: 1.4fr 1fr"],
  body.app [style*="grid-template-columns: 1fr 380px"],
  body.app [style*="grid-template-columns: 1fr 360px"],
  body.app [style*="grid-template-columns: 1fr 340px"],
  body.app [style*="grid-template-columns: 1fr 320px"],
  body.app [style*="grid-template-columns: 1fr 1.1fr"],
  body.app [style*="grid-template-columns: 1.1fr 1fr"],
  body.app [style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Shell paddings tighten further */
  body.app [style*="padding: 32px 40px 40px"],
  body.app [style*="padding: 48px 40px"] {
    padding: 20px 16px 28px !important;
  }
  body.app [style*="padding: 20px 40px"] {
    padding: 14px 16px !important;
  }
  body.app [style*="padding: 56px 24px"] {
    padding: 24px 16px !important;
  }

  /* Topnav — tabs row gets a horizontal scroll, brand stays */
  body.app .topnav {
    height: 56px;
    padding: 0 14px;
    gap: 8px;
  }
  body.app .topnav > .row:first-child { gap: 12px !important; min-width: 0; flex: 1; }
  body.app .topnav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    max-width: 100%;
  }
  body.app .topnav-tabs::-webkit-scrollbar { display: none; }
  body.app .topnav-tab {
    flex-shrink: 0;
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }
  /* Right-cluster: keep avatar + sign-out, drop verbose context badge */
  body.app .topnav .badge-outline { display: none; }

  /* Page title row — stack the actions under the heading */
  body.app .row.between { flex-wrap: wrap; gap: 12px; }

  /* Display headings scale down */
  body.app h1.display { font-size: 26px !important; line-height: 1.15; }
  body.app h2.display { font-size: 22px !important; }
  body.app h3.display { font-size: 18px !important; }
  body.app [style*="font-size: 44px"] { font-size: 28px !important; }
  body.app [style*="font-size: 40px"] { font-size: 26px !important; }
  body.app [style*="font-size: 36px"] { font-size: 24px !important; }
  body.app [style*="font-size: 32px"] { font-size: 22px !important; }
  body.app [style*="font-size: 28px"] { font-size: 20px !important; }

  /* Card paddings tighten */
  body.app .card-header { padding: 16px 16px 10px; }
  body.app .card-body   { padding: 16px; }
  body.app .card-footer { padding: 10px 16px; }
  body.app [style*="padding: 36px"] { padding: 20px !important; }
  body.app [style*="padding: 28px"] { padding: 18px !important; }
  body.app [style*="padding: 56px"] { padding: 28px !important; }

  /* Tables — horizontal scroll instead of squashing */
  body.app .card:has(> .tbl),
  body.app .card:has(> table) {
    overflow-x: auto;
  }
  body.app .tbl { font-size: 12px; min-width: 560px; }
  body.app .tbl th, body.app .tbl td { padding: 10px 12px; }

  /* Stepper — make it scroll horizontally rather than wrap awkwardly */
  body.app .stepper {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  body.app .stepper::-webkit-scrollbar { display: none; }
  body.app .stepper .step { flex-shrink: 0; font-size: 12px; }
  body.app .stepper .sep { width: 16px; margin: 0 6px; }

  /* Sticky right rail (brief preview/cost) — drop sticky on mobile,
     it makes the scroll behavior weird in a stacked column */
  body.app [style*="position: sticky"] { position: static !important; }

  /* Min-width breakers — kill onboarding's "min-width: 280px" card */
  body.app [style*="min-width: 280px"] { min-width: 0 !important; }
  body.app [style*="max-width: 600px"],
  body.app [style*="max-width: 760px"] { max-width: 100% !important; }

  /* Buttons: keep them tappable but tighter on the right side */
  body.app .btn { white-space: nowrap; }
  body.app .row.gap-2,
  body.app .row.gap-3 { flex-wrap: wrap; }

  /* iOS phone frame mock would dwarf the screen — scale or hide */
  body.app .ios-frame { transform: scale(0.55); transform-origin: top left; }
  body.app .artboards { gap: 28px !important; }
}

/* Very small phones */
@media (max-width: 380px) {
  body.app .topnav { padding: 0 10px; }
  body.app .topnav .wm { font-size: 14px; }
  body.app .btn-sm { padding: 0 8px; font-size: 12px; }
}

/* ------------------------------------------------------------------
   Mobile shell — fixed bottom tab bar, per-screen mobile header,
   sticky bottom CTA, safe-area handling for PWA fullscreen.

   - Tab bar lives in the DOM on every shelled page but only shows at
     <=720px. Desktop keeps the .topnav.
   - When the PWA is installed (display: standalone / fullscreen) the
     OS status bar overlays the page; .m-tabbar / .m-sticky-cta /
     .m-header use env(safe-area-inset-*) so nothing sits under the
     notch or home indicator. In a browser the insets are 0 so the
     same rules degrade gracefully.
------------------------------------------------------------------- */

body.app .m-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: none;
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 246, 232, 0.95);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--line);
}
body.app .m-tabbar > * { flex: 1 1 0; min-width: 0; }
body.app .m-tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0;
  position: relative;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
  min-height: 48px;
  border-radius: 10px;
  transition: color .15s ease, background .15s ease;
}
body.app .m-tabbar-item:hover { background: var(--bg-2); }
body.app .m-tabbar-item.active { color: var(--ink); }
body.app .m-tabbar-item .m-tabbar-label { line-height: 1; }
body.app .m-tabbar-item .m-tabbar-icon { display: grid; place-items: center; }
body.app .m-tabbar-item.active .m-tabbar-icon { color: var(--ink); }
body.app .m-tabbar-item .m-tabbar-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--bg);
}

body.app .m-tabbar-fab {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px -6px rgba(233, 30, 99, 0.55);
}

body.app .m-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
}
body.app .m-header-title { text-align: center; flex: 1; min-width: 0; }
body.app .m-header-title .m-header-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
body.app .m-header-title .m-header-text {
  font-weight: 600;
  font-size: 14px;
}
body.app .m-header-side {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  min-width: 32px;
}
body.app .m-header-side-end { justify-content: flex-end; }
body.app .m-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
  position: relative;
}
body.app .m-icon-btn:hover { background: var(--bg-2); }
body.app .m-icon-btn .m-icon-btn-dot {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

body.app .m-sticky-cta {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 246, 232, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.app .m-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
body.app .m-shell-content { flex: 1; }

body.app .topnav {
  padding-top: env(safe-area-inset-top);
  height: calc(64px + env(safe-area-inset-top));
}

@media (max-width: 720px) {
  body.app .m-tabbar { display: flex; }
  body.app .topnav { display: none; }

  /* Reserve bottom space so the last content isn't hidden behind the bar. */
  body.app .m-has-tabbar,
  body.app .m-shell {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  body.app .install-bar {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 721px) {
  body.app .m-header { display: none; }
  body.app .m-fab { display: none !important; }
  body.app .m-sticky-cta {
    position: static;
    background: transparent;
    border-top: 0;
    padding-left: 0;
    padding-right: 0;
  }
}

/* Per-screen responsive overrides — placed AFTER the generic collapse rules
   so they win source-order ties (both rules use !important with equal class
   specificity). */
@media (max-width: 720px) {
  /* Brand dashboard KPI grid → 2x2 on phones (default 4-col rule would
     collapse it to 1-col). */
  body.app .dash-kpi-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  /* Creator feed brief grid → single column on phones (full-width cards
     with gradient covers). */
  body.app .feed-brief-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  /* Feed-wrap → mobile gutters */
  body.app .feed-wrap {
    padding: 8px 16px 16px !important;
  }
  /* Onboarding 2-col → 1-col on phones */
  body.app .onb-cols {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
  }
}

/* Hide the m-fab class on desktop, show only on phones */
body.app .m-fab { display: grid; }

/* Mobile / desktop visibility helpers */
body.app .m-mobile-only { display: none; }
body.app .m-desktop-only { display: block; }
body.app .m-desktop-only.row { display: flex; }
@media (max-width: 720px) {
  body.app .m-mobile-only { display: block; }
  body.app .m-mobile-only.row { display: flex; }
  body.app .m-mobile-only.col { display: flex; flex-direction: column; }
  body.app .m-desktop-only,
  body.app .m-desktop-only.row,
  body.app .m-desktop-only.col { display: none !important; }
}
