/* ============================================================
   APOLLO SHELL — cross-cutting chrome injected by apollo-core.js
   Sign-in gate · app switcher · sync badge · banners · toasts
   · confirm dialog · 404 · pull-to-refresh. Palette-only.
   ============================================================ */

.apx-host { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.apx-host > * { pointer-events: auto; }
.apx-host .sheet { z-index: 36; }

/* ── banners strip ────────────────────────────────────────────── */
.apx-banners { flex: 0 0 auto; display: flex; flex-direction: column; }
.apx-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 500;
  color: var(--fg);
  transform: translateY(-6px); opacity: 0;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.apx-banner.in { opacity: 1; transform: none; }
.apx-banner svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.apx-banner .tx { display: inline-flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.apx-banner.warn { color: var(--accent); background: color-mix(in oklch, var(--accent) 10%, var(--surface)); }
.apx-banner.update { color: var(--focus); background: color-mix(in oklch, var(--focus) 12%, var(--surface)); }
.apx-banner.info { color: var(--text-2); }
.apx-banner.error { color: var(--danger-text); }
.apx-banner-act {
  flex: none; border: 1px solid currentColor; background: transparent;
  color: inherit; font: inherit; font-size: 11.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 8px; cursor: pointer;
  transition: background 150ms var(--ease);
}
.apx-banner-act:hover { background: color-mix(in oklch, currentColor 14%, transparent); }

/* ── app switcher trigger (replaces .mark) ────────────────────── */
button.mark.apx-switch { padding: 0; cursor: pointer; transition: border-color 150ms var(--ease); }
button.mark.apx-switch:hover { border-color: var(--accent-line); }
button.mark.apx-switch:active { transform: scale(0.96); }

/* ── online / sync status dot (top-right of the app mark) ─────── */
.apx-markwrap { position: relative; width: 34px; height: 34px; }
.apx-markwrap .mark { width: 34px; height: 34px; }
.apx-synodot {
  position: absolute; top: -3px; right: -3px;
  width: 12px; height: 12px; border-radius: 50%;
  padding: 0; cursor: pointer; appearance: none;
  background: var(--text-2);
  border: 2px solid var(--bg);
  transition: background 180ms var(--ease), box-shadow 180ms var(--ease), transform 130ms var(--ease);
}
.apx-synodot[hidden] { display: none; }
.apx-synodot:hover { transform: scale(1.16); }
.apx-synodot:active { transform: scale(0.98); }
.apx-synodot:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.apx-synodot.live { background: var(--accent-solid); }
.apx-synodot.off  { background: var(--text-2); }
.apx-synodot.pend,
.apx-synodot.conf { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 30%, transparent); }
.apx-synodot.err  { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 28%, transparent); }
.apx-synodot.auth { background: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 30%, transparent); }

/* ── sync detail sheet ────────────────────────────────────────── */
.apx-sync-state { display: flex; align-items: center; gap: 11px; margin: 2px 0 16px; }
.apx-sync-state .lamp {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: var(--text-2); box-shadow: 0 0 0 3px color-mix(in oklch, var(--text-2) 24%, transparent);
}
.apx-sync-state .lamp.live { background: var(--accent-solid); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 26%, transparent); }
.apx-sync-state .lamp.off  { background: var(--text-2); box-shadow: 0 0 0 3px color-mix(in oklch, var(--text-2) 22%, transparent); }
.apx-sync-state .lamp.pend,
.apx-sync-state .lamp.conf { background: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 30%, transparent); }
.apx-sync-state .lamp.err  { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 28%, transparent); }
.apx-sync-state .lamp.auth { background: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 30%, transparent); }
.apx-sync-state .tx { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.apx-sync-state .tx small { display: block; font-family: var(--font-body); font-size: 12.5px; font-weight: 400; color: var(--text-2); letter-spacing: 0; margin-top: 2px; }
.apx-sync-actions { display: flex; flex-direction: column; gap: 9px; }

.apx-approw {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 13px;
  width: 100%; padding: 11px 0;
  background: none; border: 0; border-top: 1px solid var(--border);
  color: var(--fg); font: inherit; text-align: left; cursor: pointer;
  transition: opacity 150ms var(--ease);
}
.apx-approw:first-of-type { border-top: 0; }
.apx-approw:hover .nm { color: var(--accent); }
.apx-approw.here { cursor: default; }
.apx-approw.here:hover .nm { color: var(--fg); }
.apx-appmark {
  width: 44px; height: 44px; border-radius: 8px; overflow: hidden;
  background: color-mix(in oklch, var(--a) 16%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--a) 34%, var(--border));
  display: grid; place-items: center;
}
.apx-appmark img { width: 100%; height: 100%; object-fit: cover; }
.apx-appmeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.apx-appmeta .nm { font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; transition: color 150ms var(--ease); }
.apx-appmeta .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-appmeta .pp { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-cv { width: 18px; height: 18px; stroke: var(--text-2); fill: none; stroke-width: 2; }

/* ── toasts ───────────────────────────────────────────────────── */
.apx-toasts {
  position: absolute; left: 50%; bottom: 92px; z-index: 40;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: 320px;
}
.apx-toast {
  background: var(--surface-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 14px 30px -12px rgba(0,0,0,0.8);
  opacity: 0; transform: translateY(8px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  cursor: pointer; text-align: center;
}
.apx-toast.in { opacity: 1; transform: none; }
.apx-toast.error { border-color: color-mix(in oklch, var(--danger) 40%, var(--border)); color: var(--danger-text); }

/* ── scrim + dialog ───────────────────────────────────────────── */
.apx-scrim {
  position: absolute; inset: 0; z-index: 34;
  background: rgba(6,6,8,0.62);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease);
}
.apx-scrim.open { opacity: 1; pointer-events: auto; }
.apx-dialog {
  position: absolute; z-index: 35;
  left: 18px; right: 18px; top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.85);
}
.apx-dialog-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.apx-dialog-body { margin: 0 0 18px; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.apx-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.apx-danger {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px;
  background: var(--danger-solid); color: var(--fg); border: 0; border-radius: 8px;
  font: inherit; font-family: var(--font-display); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: filter 150ms var(--ease);
}
.apx-danger:hover { filter: brightness(1.15); }

/* ── conflict rows ────────────────────────────────────────────── */
.apx-conflict {
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.apx-conflict:first-of-type { border-top: 0; }
.apx-conflict-title { margin: 0; font-size: 14.5px; font-weight: 600; }
.apx-conflict-sub { margin: 3px 0 10px; color: var(--text-2); font-size: 12.5px; }
.apx-conflict-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.apx-mini {
  padding: 9px 6px; min-height: 40px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: all 150ms var(--ease);
}
.apx-mini:hover { border-color: var(--accent-line); }
.apx-mini.primary { background: var(--accent-solid); color: var(--accent-ink); border-color: transparent; }

/* ── auth gate ────────────────────────────────────────────────── */
.apx-gate {
  position: absolute; inset: 0; z-index: 50;
  background:
    radial-gradient(90% 60% at 50% 0%, color-mix(in oklch, var(--accent) 14%, var(--bg)) 0%, var(--bg) 62%),
    var(--bg);
  display: grid; place-items: center;
  padding: 32px 24px;
}
.apx-gate[hidden] { display: none; }
.apx-gate-card { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 12px; }
.apx-gate-mark {
  width: 54px; height: 54px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 4px;
}
.apx-gate-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.apx-gate-app {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 2px;
}
.apx-gate-sub { margin: 0 0 6px; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.apx-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.apx-field span { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-2); }
.apx-field input {
  width: 100%; min-height: 46px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font: inherit; font-size: 15px;
}
.apx-field input:focus { border-color: var(--accent-line); }
.apx-field input::placeholder { color: var(--text-2); }
.apx-code { display: flex; flex-direction: column; gap: 10px; }
.apx-resend { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.apx-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.apx-link:disabled { color: var(--text-2); cursor: default; text-decoration: none; }
.apx-gate-foot { margin: 6px 0 0; text-align: center; color: var(--text-2); font-size: 12px; line-height: 1.5; }
.apx-gate.busy { opacity: 0.72; pointer-events: none; }
.apx-gate-alt { align-self: center; margin-top: 4px; }
.apx-gate-back {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; margin-top: 6px;
  background: none; border: 0; padding: 8px 0; min-height: 44px; cursor: pointer;
  color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600;
  transition: color 150ms var(--ease);
}
.apx-gate-back svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.apx-gate-back:hover { color: var(--fg); }
.apx-google { display: flex; align-items: center; justify-content: center; gap: 10px; }
.apx-g { width: 18px; height: 18px; flex: none; }
.apx-half { width: 100%; }
.apx-or { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.apx-or::before, .apx-or::after { content: ''; height: 1px; flex: 1; background: var(--border); }
.apx-em { color: var(--fg); font-weight: 600; word-break: break-word; }
.apx-acct {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 56px;
  padding: 10px 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--fg); font: inherit;
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
.apx-acct:hover { background: var(--surface-2); border-color: var(--accent-line); }
.apx-acct-av {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--fg);
}
.apx-acct-av svg { width: 16px; height: 16px; stroke: var(--text-2); fill: none; stroke-width: 2; }
.apx-acct-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.apx-acct-meta .nm { font-size: 14px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-acct-meta .em { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-acct .apx-cv { width: 16px; height: 16px; flex: none; }
.apx-acct-go { margin-left: auto; color: var(--accent); display: grid; place-items: center; }
.apx-acct-go svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; }

/* session identity row inside the app-switcher sheet */
.apx-ids {
  display: flex; align-items: center; gap: 11px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.apx-ids-av {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 16%, var(--surface));
  border: 1px solid color-mix(in oklch, var(--accent) 34%, var(--border));
  font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--accent);
}
.apx-ids-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.apx-ids-meta .nm { font-size: 13.5px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.apx-ids-meta .em { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── pull to refresh ──────────────────────────────────────────── */
.apx-ptr {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  height: 0; overflow: hidden;
  color: var(--text-2); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase;
  transition: height 180ms var(--ease);
}
.apx-ptr svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.apx-ptr.ready { color: var(--accent); }
.apx-ptr.busy svg { animation: apxspin 900ms linear infinite; }
.apx-ptr.done { color: var(--accent); }
@keyframes apxspin { to { transform: rotate(360deg); } }

/* ── 404 ──────────────────────────────────────────────────────── */
.apx-404 .code {
  font-family: var(--font-display); font-size: 46px; font-weight: 600; letter-spacing: -0.04em;
  color: var(--accent); line-height: 1;
}
