/* LeadQ drafts approval surface. Layered on top of site.css tokens. */

/* The app toggles visibility via the `hidden` attribute (app.js sets el.hidden
   ~44×). Author rules like `.app-login-form { display: flex }` outrank the UA
   `[hidden]{display:none}` (equal specificity, later source order), so hidden
   elements leak through — e.g. the sign-in code form showing under the email
   form. This global guard makes `hidden` authoritative everywhere. */
[hidden] { display: none !important; }

body[data-page="app"] {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  /* One shared column width + gutter, so the topbar chrome and the card body
     line up at every breakpoint — identical layout on phone, tablet, desktop. */
  --app-col: 720px;
  --app-gutter: 20px;
}

/* Full-bleed sticky bar; its content is centred to the column below. */
.app-topbar {
  /* Clear the iOS status bar. The web-app status bar is translucent and the
     viewport is `viewport-fit=cover`, so without the top inset the workspace
     name + menu render UNDER the clock/signal bars. max() keeps a comfortable
     10px on devices with no notch (inset = 0). */
  padding: 10px 0;
  padding-top: max(10px, calc(env(safe-area-inset-top) + 8px));
  border-bottom: 1px solid var(--border);
  /* Frosted + slightly translucent so cards blur softly beneath the bar as they
     scroll under it — calmer and more premium than a hard opaque strip. The
     solid line is the fallback for engines without color-mix. */
  background: var(--bg-elev-1);
  background: color-mix(in srgb, var(--bg-elev-1) 82%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  position: sticky;
  top: 0;
  z-index: 30;
}
/* No backdrop-filter support → fall back to a solid bar so it never reads as a
   washed-out translucent panel. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .app-topbar { background: var(--bg-elev-1); }
}
.app-topbar-inner {
  width: 100%;
  max-width: var(--app-col);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding-left: max(var(--app-gutter), env(safe-area-inset-left));
  padding-right: max(var(--app-gutter), env(safe-area-inset-right));
}

.app-account-email {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 2px 0;
  word-break: break-all;
}

/* ----- workspace dropdown (top-left) -------------------------------------- */
.app-ws { position: relative; min-width: 0; flex: 1 1 auto; }

.app-ws-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.app-ws-btn:hover { background: var(--bg-elev-3); border-color: var(--border-hover); }
.app-ws-btn:active { transform: scale(0.98); }
.app-ws-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-ws[data-multi="false"] .app-ws-btn { cursor: default; }
.app-ws[data-multi="false"] .app-ws-btn:hover { background: var(--bg-elev-2); border-color: var(--border); }
.app-ws[data-multi="false"] .app-ws-btn:active { transform: none; }
.app-ws-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60vw;
}
.app-ws-caret { flex: 0 0 auto; color: var(--text-3); font-size: 11px; }
/* With a single workspace there's nothing to switch to: the box just shows the
   name — no caret, no greyed-out disabled look. */
.app-ws[data-multi="false"] .app-ws-caret { display: none; }
.app-ws-btn:disabled { opacity: 1; cursor: default; }

.app-ws-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  max-width: 80vw;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  box-shadow: var(--shadow-lg);
  z-index: 40;
}
.app-ws-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  min-height: 40px;
  transition: background 120ms ease, color 120ms ease;
}
.app-ws-option:hover { background: var(--bg-elev-3); color: var(--text); }
.app-ws-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.app-ws-option.is-active { background: var(--accent-tint); color: var(--text); font-weight: 600; }

/* ----- menu button + dot (top-right) -------------------------------------- */
.app-menu-btn {
  flex: 0 0 auto;
  margin-left: auto; /* always pinned right, even if the workspace box is absent */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  /* Pill, to rhyme with the workspace button across the bar (was a 10px box
     sitting next to a pill — read as two mismatched controls). */
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  min-height: 40px;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.app-menu-btn:hover { background: var(--bg-elev-3); border-color: var(--border-hover); }
.app-menu-btn:active { transform: scale(0.96); }
.app-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-menu-btn[aria-expanded="true"] { background: var(--bg-elev-3); border-color: var(--border-hover); }
.app-menu-glyph { font-size: 16px; line-height: 1; }

/* ----- menu sheet --------------------------------------------------------- */
.app-menu {
  position: fixed;
  /* Anchor just under the bar, which now grows by the status-bar inset. */
  top: calc(env(safe-area-inset-top) + 58px);
  /* Align the sheet's right edge to the card column on wide screens; clamp to a
     12px viewport margin on phones. */
  right: max(12px, calc((100vw - var(--app-col)) / 2 + var(--app-gutter)));
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - env(safe-area-inset-top) - 76px);
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev-1);
  box-shadow: var(--shadow-lg);
  z-index: 35;
  display: grid;
  gap: 8px;
}
.app-menu[hidden] { display: none; }

.app-menu-group {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.app-menu-group:first-child { padding-top: 0; border-top: 0; }
.app-menu-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.app-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.app-menu-item:hover { background: var(--bg-elev-3); border-color: var(--border-hover); }
.app-menu-item:active { transform: scale(0.99); }
.app-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-menu-item[aria-pressed="true"] {
  border-color: var(--warning, #d8a200);
  color: var(--warning, #d8a200);
}
.app-menu-item-quiet { font-weight: 500; color: var(--text-2); }
.app-menu-item:disabled { opacity: 0.5; cursor: default; }
.app-menu-footer { display: grid; gap: 8px; }

/* The agent panel is now the top of the menu — strip its standalone-card chrome. */
.app-menu .app-agent-panel {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: grid;
  gap: 8px;
}

/* ----- ambient worker strip ----------------------------------------------- */
.app-worker-strip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.28);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text-2);
  line-height: 1.4;
}
.app-worker-strip::before {
  content: "";
  flex: 0 0 auto;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  animation: lq-pulse 2.4s ease-in-out infinite;
}
.app-worker-strip[data-state="stale"] { color: var(--text-3); }
.app-worker-strip[data-state="stale"]::before,
.app-worker-strip[data-state="paused"]::before { background: var(--text-3); box-shadow: none; animation: none; }

/* Stage chip on a card — tone-coded to match the marketing site's
   Discover (coral) / Engage (rose) / Grow (violet) arc. */
.app-pill-stage {
  background: var(--bg-elev-3);
  border-color: var(--border);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.app-pill-stage[data-stage="discover"] {
  color: var(--tone-discover);
  background: color-mix(in srgb, var(--tone-discover) 14%, transparent);
  border-color: color-mix(in srgb, var(--tone-discover) 35%, transparent);
}
.app-pill-stage[data-stage="engage"] {
  color: var(--tone-engage);
  background: color-mix(in srgb, var(--tone-engage) 14%, transparent);
  border-color: color-mix(in srgb, var(--tone-engage) 35%, transparent);
}
.app-pill-stage[data-stage="grow"] {
  color: var(--tone-grow);
  background: color-mix(in srgb, var(--tone-grow) 14%, transparent);
  border-color: color-mix(in srgb, var(--tone-grow) 35%, transparent);
}

.app-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent-2);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.app-main {
  max-width: var(--app-col);
  margin: 0 auto;
  padding: 16px max(var(--app-gutter), env(safe-area-inset-right)) 80px
    max(var(--app-gutter), env(safe-area-inset-left));
}

.app-intro h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.app-lede {
  margin: 0 0 24px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

/* Action feedback is a FIXED toast, not an in-flow banner. As an in-flow block
   above the decks it pushed every deck DOWN when it appeared and let them snap
   back UP when it auto-cleared — so approving a card made the deck jump out from
   under the user's thumb, forcing a re-scroll after every action. Fixed + zero
   margin means showing/clearing it never reflows the page: the deck the user is
   working stays put, and the next card rises into the exact same spot.
   pointer-events:none so it can never intercept a tap meant for a card. */
.app-status {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 45; /* above content + topbar(30); below pair overlay(50) */
  width: min(var(--app-col), calc(100vw - 32px));
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .app-status { animation: app-status-in 0.18s ease-out; }
}
@keyframes app-status-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.app-status[data-tone="error"] {
  border-color: var(--danger);
  background: var(--danger-tint);
  color: var(--text);
}

.app-status[data-tone="success"] {
  border-color: var(--success);
  background: var(--success-tint);
}

/* Agent control panel — now lives at the top of the menu sheet. */
.app-agent-panel {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev-1);
}

.app-agent-dial {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev-2);
}

.app-agent-dial-opt {
  flex: 1 1 0;
  min-height: 38px;
  padding: 8px 6px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.app-agent-dial-opt:not(.is-active):hover { color: var(--text); background: var(--bg-elev-3); }
.app-agent-dial-opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-agent-dial-opt.is-active {
  background: var(--accent-tint);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.app-agent-dial-opt.is-danger.is-active {
  background: var(--danger-tint);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.app-agent-dial-opt:disabled { opacity: 0.5; cursor: default; }

.app-agent-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-3);
}

/* Recent activity feed (revealed from the Activities menu item). */
.app-activity-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}
.app-activity-list[hidden] { display: none; }
.app-activity-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 4px;
  border-top: 1px solid var(--border, #eee);
  font-size: 13px;
}
.app-activity-icon { flex: 0 0 auto; }
.app-activity-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.app-activity-when { font-size: 11px; color: var(--text-3, #888); }
.app-activity-item.is-warn .app-activity-body > :first-child { color: #8a5d10; }

/* "Today" digest line */
.app-agent-today {
  margin: 8px 2px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2, #444);
}

/* Trust-runway graduation offer */
.app-grad-offer {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--c-engage, #2a7a5a);
  border-radius: 12px;
  background: color-mix(in srgb, #2a7a5a 8%, transparent);
}
.app-grad-text {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-1, #111);
}
.app-grad-btn {
  width: 100%;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: var(--c-engage, #2a7a5a);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}
.app-grad-btn:disabled { opacity: 0.6; }

/* Audit badge on a draft the agent auto-approved (auto-post mode). */
.app-card-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}
.app-pill-auto {
  border-color: var(--warning, #d8a200);
  color: var(--warning, #d8a200);
}

.app-section {
  margin-top: 28px;
}

.app-section:first-of-type {
  margin-top: 0;
}

.app-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.app-section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-section-head-collapsible {
  justify-content: space-between;
}

.app-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-pill-quiet {
  background: var(--bg-elev-2);
  border-color: var(--border);
  color: var(--text-3);
}

/* P3 — confidence triage. "Review closely" flag on low-confidence cards + the
   one-line "why this prospect" rationale under the excerpt. */
.app-pill-review {
  background: var(--danger-tint);
  border-color: rgba(244, 63, 94, 0.35);
  color: #fb7185;
}
.app-card-why {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-3);
  font-style: italic;
}

/* P2 — batch approve. Sits at the right of the pending section header. */
.app-approve-all {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-tint);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.app-approve-all:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.app-approve-all:active { transform: scale(0.97); }
.app-approve-all:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-approve-all:disabled {
  opacity: 0.6;
  cursor: default;
}

.app-empty {
  margin: 12px 0 0;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* Shown only when every queue is empty (empty queues collapse, so this is the
   one compact "nothing to do" line — no big dashed boxes). */
.app-allclear {
  margin: 24px 4px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.app-card-list {
  display: grid;
  /* minmax(0,1fr) — not the implicit min-width:auto — so a wide child (the
     pills row, a long draft) can never blow the column past the viewport. */
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.app-card-list-quiet .app-card {
  opacity: 0.85;
}

/* ----- deck layout --------------------------------------------------------
   Each queue is a deck: only the top card is in flow (it defines the height);
   two decorative ghost layers peek out below so it reads as a stack of N. */
.app-deck { margin-top: 28px; }
.app-deck:first-of-type { margin-top: 0; }

.app-deck-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.app-deck-head h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
/* Count badge — ticks down as cards swoosh out. */
.app-deck-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Empty-deck message — shown in the Review deck when there's nothing to triage
   (the heading stays put so the app never looks broken/blank). */
.app-deck-empty {
  margin: 0;
  padding: 22px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.app-deck-stack {
  position: relative;
  /* The .app-card-list grid collapses to a single in-flow child (the top
     card); the rest of the deck is drawn by the ghost pseudo-layers below. */
}
.app-deck-stack > * { position: relative; z-index: 2; }
.app-deck-stack::before,
.app-deck-stack::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev-1);
  pointer-events: none;
}
.app-deck-stack::before { transform: translateY(6px) scale(0.972); z-index: 1; opacity: 0.9; }
.app-deck-stack::after  { transform: translateY(12px) scale(0.944); z-index: 0; opacity: 0.6; }
/* Reveal ghost layers only when the deck is deep enough (data-stack = N-1, capped 2). */
.app-deck-stack[data-stack="0"]::before,
.app-deck-stack[data-stack="0"]::after,
.app-deck-stack[data-stack="1"]::after { display: none; }

/* Button-triggered swoosh: the acted card slides off + fades; the next card
   then rises from the deck into the top slot. */
@keyframes app-card-swoosh {
  to { transform: translateX(112%) rotate(3deg); opacity: 0; }
}
.app-card.is-swooshing {
  animation: app-card-swoosh 0.30s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}
@keyframes app-card-rise {
  from { transform: translateY(10px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.app-deck-stack > .app-card { animation: app-card-rise 0.22s ease-out; }

@media (prefers-reduced-motion: reduce) {
  .app-card.is-swooshing { animation: none; opacity: 0; }
  .app-deck-stack > .app-card { animation: none; }
}

.app-card {
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  /* A whisper of top-light over the elevated surface gives the card a tactile,
     lifted feel instead of a flat panel. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 64px),
    var(--bg-elev-1);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 13px;
  min-width: 0;
}
/* Every row can shrink below its content's intrinsic width (prevents overflow). */
.app-card > * { min-width: 0; }

/* Stage-tone identity — a top accent strip + matching excerpt edge + avatar,
   so a card reads as Discover / Engage / Grow at a glance, consistent with the
   marketing site's tone arc. */
.app-card[data-stage="discover"] { box-shadow: inset 0 2px 0 color-mix(in srgb, var(--tone-discover) 75%, transparent), var(--shadow-sm); }
.app-card[data-stage="engage"]   { box-shadow: inset 0 2px 0 color-mix(in srgb, var(--tone-engage) 75%, transparent), var(--shadow-sm); }
.app-card[data-stage="grow"]     { box-shadow: inset 0 2px 0 color-mix(in srgb, var(--tone-grow) 75%, transparent), var(--shadow-sm); }
.app-card[data-stage="discover"] .app-card-excerpt { border-left-color: color-mix(in srgb, var(--tone-discover) 55%, transparent); }
.app-card[data-stage="engage"]   .app-card-excerpt { border-left-color: color-mix(in srgb, var(--tone-engage) 55%, transparent); }
.app-card[data-stage="grow"]     .app-card-excerpt { border-left-color: color-mix(in srgb, var(--tone-grow) 55%, transparent); }
.app-card[data-stage="discover"] .app-card-avatar { background: linear-gradient(135deg, var(--tone-discover), #c14d22); box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(242,147,92,0.3); }
.app-card[data-stage="engage"]   .app-card-avatar { background: linear-gradient(135deg, var(--tone-engage), #b23a63); box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(242,88,138,0.3); }
.app-card[data-stage="grow"]     .app-card-avatar { background: linear-gradient(135deg, var(--tone-grow), #714aa6); box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 4px 12px rgba(167,139,250,0.3); }

.app-card[data-status="posted"] {
  border-color: var(--success);
}

.app-card[data-status="failed"] {
  border-color: var(--danger);
}

/* Actionable cards — the lead awaiting your verdict (prospect) and the draft
   awaiting approval — sit at the top of the deck and earn a soft accent ring +
   glow so the thing to act on reads as the hero, not just another row. */
.app-card-prospect[data-status="new"],
.app-card[data-status="pending"],
.app-card[data-status="approved"] {
  border-color: var(--accent-border);
}
.app-card-prospect[data-status="new"],
.app-card[data-status="pending"] {
  box-shadow: var(--shadow-sm), 0 14px 34px -16px var(--accent-glow);
}

/* "Drafting on your computer…" — the user acted, the computer is working. */
.app-card-working {
  opacity: 0.7;
}

.app-card-working .app-card-meta {
  color: var(--accent-2);
}

/* Locked card — an encrypted lead this phone can't read until paired. */
.app-card-locked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-style: dashed;
  border-color: var(--accent-border);
}
.app-card-locked-body {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-card-locked-icon { font-size: 22px; }
.app-card-locked-title { font-weight: 600; }
.app-card-locked-sub { font-size: 13px; color: var(--muted); }

/* Done card — a compact, content-free outcome row (the lead is scrubbed once
   terminal). One line: outcome + when on the left, stage chip on the right. */
.app-card-done {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.app-card-done-outcome {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-card-done .app-card-meta {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  white-space: nowrap;
}
/* When the author survived, the meta keeps its margin-auto; the stage chip
   sits flush right after it. */
.app-card-done .app-pill-stage { margin-left: 0; flex: none; }

/* ----- pairing dialog ----------------------------------------------------- */
.app-pair-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 0;
}
@media (min-width: 600px) {
  .app-pair-overlay { align-items: center; padding: 24px; }
}
/* The `hidden` attribute must win over the display rule above, or the overlay
   renders permanently and covers the login screen. Also never show it while
   signed out (the overlay lives outside .app-main, so the data-auth hide rule
   doesn't reach it). */
.app-pair-overlay[hidden] { display: none !important; }
body[data-auth="out"] .app-pair-overlay { display: none !important; }
.app-pair-card {
  width: 100%;
  max-width: 520px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1px solid var(--border-strong);
  border-radius: 18px 18px 0 0;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}
@media (min-width: 600px) {
  .app-pair-card { border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
}
@media (min-width: 600px) {
  .app-pair-card { border-radius: 18px; }
}
.app-pair-card h2 { margin: 0 0 8px; font-size: 19px; }
.app-pair-lede { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.app-pair-buttons .button { width: 100%; min-height: 48px; }
.app-pair-step {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
.app-pair-sas-wrap { margin-top: 18px; text-align: center; }
.app-pair-sas-label { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.app-pair-sas {
  font-family: var(--font-mono);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 0.22em;
  padding: 16px 0;
  margin: 4px auto 0;
  color: var(--accent-2);
  background: linear-gradient(180deg, var(--accent-tint), transparent);
  border: 1px solid var(--accent-border);
  border-radius: var(--r-md);
  text-shadow: 0 0 18px var(--accent-glow);
}
.app-pair-sas-hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.app-pair-error {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--danger);
}
.app-pair-close {
  display: block;
  width: 100%;
  margin-top: 16px;
  text-align: center;
  min-height: 44px;
}

.app-pill-workspace {
  background: var(--bg-elev-2);
  border-color: var(--border);
  color: var(--text-2);
  text-transform: none;
  letter-spacing: 0;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.app-card-author {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.app-card-author > div { min-width: 0; }

.app-card-avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 12px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.app-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-card-author-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card-post-link {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-3);
  text-decoration: none;
}

.app-card-post-link:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.app-card-excerpt {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-border);
  background: var(--bg-elev-2);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  /* Collapsed by default to the first 5 lines so cards stay a roughly uniform
     height while still showing real context (3 lines is often just a greeting +
     a blank line or two — not enough to judge a lead). The More toggle (added in
     JS) lifts the clamp to reveal the full post. Applies to every deck. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
}
.app-card-excerpt.is-expanded {
  display: block; /* leave -webkit-box so the clamp is fully lifted (line-clamp:unset alone is unreliable on iOS) */
  -webkit-line-clamp: unset;
  overflow: visible;
}

/* "More" / "Less" — only shown when the excerpt actually overflows 3 lines. */
.app-card-more {
  justify-self: start;
  margin: -6px 0 0;
  padding: 2px 0;
  background: none;
  border: 0;
  color: var(--accent-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.app-card-more:hover { text-decoration: underline; }
.app-card-more[hidden] { display: none; }

.app-card-label {
  display: grid;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.app-card-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.app-card-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.app-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button-quiet {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}

.button-quiet:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.app-card-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-3);
}

.app-card[data-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

@media (max-width: 480px) {
  /* Tighter gutter on phones — drives the topbar inner row AND the card column
     together, so they stay aligned. */
  body[data-page="app"] { --app-gutter: 14px; }
  .app-main {
    padding-top: 20px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }
  .app-intro h1 { font-size: 22px; }

  /* Full-width, thumb-sized actions. 48px is the minimum comfortable touch
   * target; on a phone the primary action shouldn't share a row with the
   * meta text. */
  .app-card-actions {
    gap: 10px;
    align-items: stretch;
  }
  .app-card-actions .button {
    flex: 1 1 0;
    min-height: 48px;
    min-width: 48px;
    font-size: 15px;
  }
  .app-card-meta {
    margin-left: 0;
    width: 100%;
    order: 3;
    margin-top: 2px;
  }
  .app-card-textarea { font-size: 16px; } /* 16px stops iOS Safari zoom-on-focus */
  .app-card-post-link { padding: 4px 0; display: inline-block; }
}

/* ----- in-app sign-in ------------------------------------------------------
   When signed out, hide everything in the console except the login screen and
   the topbar brand, so the app doubles as its own login page (no /account/). */
body[data-auth="out"] .app-main > *:not(#appLogin) { display: none !important; }
/* Signed out: the topbar tools and the menu sheet have no meaning yet. */
body[data-auth="out"] #appWorkspaceMenu,
body[data-auth="out"] #appMenuBtn,
body[data-auth="out"] #appMenu { display: none !important; }

.app-login {
  max-width: 380px;
  margin: 40px auto 0;
  padding: 32px 28px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, 0.13), transparent 70%),
    linear-gradient(180deg, var(--bg-elev-2), var(--bg-elev-1));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.app-login-brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--text);
}
.app-login-brand img { display: block; }
.app-login-eyebrow {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 14px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-2);
}
.app-login-eyebrow .live-dot { width: 7px; height: 7px; background: var(--success); border-radius: 50%; }
.app-login-title {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: -0.02em;
}
.app-login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.app-login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}
.app-login-label input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 16px; /* 16px stops iOS Safari zoom-on-focus */
}
.app-login-label input:focus {
  outline: none;
  border-color: var(--accent-2);
}
.app-login-error {
  margin: 0 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--r-md);
  background: var(--danger-tint);
  color: var(--text);
  font-size: 13px;
}
.app-login-sent {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
}
.app-login-form .app-link {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-2);
  font: inherit;
  cursor: pointer;
}
