:root {
  --bg: #0b0c10;
  --bg-2: #101218;
  --surface: #14161c;
  --border: #262a33;
  --text: #e6e8ec;
  --muted: #a7aebb;
  --accent: #5b8def;
  --accent-strong: #4178e6;
  --danger: #e5534b;
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: dark light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.gate-brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.14);
}

main.gate,
main.viewer {
  width: 100%;
}

main.gate {
  display: flex;
  justify-content: center;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.gate-heading {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
}

.gate-body {
  margin: 0;
  color: var(--muted);
  font-size: 0.97rem;
}

.gate-target {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.gate-target strong {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.gate-form {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.field-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  margin-bottom: 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.field-input:last-of-type {
  margin-bottom: 4px;
}

.field-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.gate-submit {
  margin-top: 10px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter 0.15s ease;
}

.gate-submit:hover {
  filter: brightness(1.06);
}

.gate-submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.page-gate-terminal .gate-card {
  border-color: var(--border);
}

/* App-origin ROOT landing (routes/root.ts -> renderAppRootPage): a primary CTA to
   the home page plus a quieter sign-in link, stacked below the card copy. Purely
   additive: no existing gate/viewer page uses these classes, so this changes
   nothing about the gate/viewer chrome. The CTA reuses the .gate-submit gradient
   button styling but as an anchor, so it needs block layout + no underline. */
.gate-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

a.gate-submit {
  display: block;
  margin-top: 0;
  text-align: center;
  text-decoration: none;
}

.gate-link {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.gate-link:hover {
  text-decoration: underline;
}

.gate-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.gate-footer {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.gate-footer a {
  color: var(--accent);
}

/* Viewer page: the iframe fills the available space below the brand row. */
body.page-viewer {
  justify-content: flex-start;
  gap: 12px;
  padding: 12px;
}

.viewer {
  flex: 1;
  width: 100%;
  display: flex;
  min-height: 0;
}

.viewer-frame {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* G2a viral badge: a small, unobtrusive pill anchored to the viewer corner on the
   FREE tier only. It is trusted app-origin chrome (never the document bytes), a
   fixed marketing link with no document detail. Kept low-contrast and out of the
   reading flow so it is tasteful, with a hover lift for affordance. The .viewer
   parent is the positioning context so the badge floats over the iframe corner
   without overlapping content the recipient is reading. */
.viewer {
  position: relative;
}

.viewer-viral-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 20px -10px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  opacity: 0.82;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.viewer-viral-badge:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.viewer-viral-badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}

.viewer-viral-mark {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 3px;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
}

.viewer-viral-text strong {
  font-weight: 700;
}

.viewer-viral-cta {
  color: var(--muted);
  font-weight: 500;
}

/* On a narrow screen, drop the secondary CTA clause so the pill stays compact. */
@media (max-width: 520px) {
  .viewer-viral-cta {
    display: none;
  }
}

/* Pro white-label full-bleed: no brand bar, no viral badge, no padding/border, so
   the shared document renders edge-to-edge (both sides + top). The brand wordmark
   AND the viral badge are also omitted server-side (renderViewerPage brandless),
   and the iframe's sandbox tokens + CSP are unchanged - this is presentation only.
   This rule additionally hides the badge defensively should the markup ever ship
   it under is-brandless. */
body.page-viewer.is-brandless {
  padding: 0;
  gap: 0;
}

.is-brandless .viewer-frame {
  border: 0;
  border-radius: 0;
}

.is-brandless .viewer-viral-badge {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .viewer-viral-badge {
    transition: none;
  }
}

@media (max-width: 520px) {
  body {
    padding: 16px;
  }

  .gate-card {
    padding: 24px;
  }

  .gate-heading {
    font-size: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gate-submit {
    transition: none;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fb;
    --bg-2: #ffffff;
    --surface: #ffffff;
    --border: #d8dde7;
    --text: #14161c;
    --muted: #545d6e;
  }

  .gate-card {
    box-shadow: 0 18px 50px -28px rgba(20, 22, 28, 0.35);
  }

  .viewer-frame {
    background: #fff;
  }
}
