/* Scaneta web styles — Modern SaaS visual identity.
   Token-driven design system shared by all server-rendered pages.
   Source of truth for tokens: .planning/sketches/001-webapp-identity/saas.html */

/* Self-hosted Plus Jakarta Sans (first-party; no third-party font host). */
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-800.woff2') format('woff2');
}

:root {
  /* Accent */
  --accent: #4F46E5;
  --accent-600: #4338CA;
  --accent-700: #3730A3;
  --accent-soft: #EEF0FF;
  --accent-grad: linear-gradient(135deg, #6366F1 0%, #4F46E5 55%, #4338CA 100%);

  /* Ink / neutral */
  --ink: #0B1020;
  --ink-2: #3A415A;
  --muted: #6B7390;
  --line: #E7E9F3;
  --line-2: #EFF1F8;
  --surface: #FFFFFF;
  --bg: #F6F7FB;
  --bg-2: #FBFBFE;

  /* Status */
  --ok: #0EA371;
  --danger: #EF4444;
  --live: #EF4444;
  --warning: #B7791F;
  --warning-soft: #FFF8E6;
  --warning-line: #F0DBA8;
  --ok-soft: #E7F7F0;
  --ok-line: #B9E6D3;
  --danger-soft: #FEECEC;
  --danger-line: #F5C2C2;

  /* Radius */
  --radius: 16px;
  --radius-lg: 22px;
  --radius-sm: 11px;
  --radius-input: 13px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(16, 22, 48, .06), 0 1px 3px rgba(16, 22, 48, .04);
  --shadow: 0 6px 18px -6px rgba(20, 26, 60, .12), 0 12px 36px -12px rgba(20, 26, 60, .14);
  --shadow-lg: 0 18px 50px -12px rgba(28, 32, 84, .28);
  --shadow-accent: 0 10px 24px -8px rgba(79, 70, 229, .55);

  /* Focus + motion */
  --ring: 0 0 0 3px rgba(79, 70, 229, .35);
  --t: 200ms cubic-bezier(.2, .7, .3, 1);
  --t-slow: 340ms cubic-bezier(.2, .7, .3, 1);

  /* Back-compat aliases (legacy var names referenced in inline SVG/templates) */
  --color-bg: var(--bg);
  --color-surface: var(--surface);
  --color-accent: var(--accent);
  --color-error: var(--danger);
  --color-text: var(--ink);
  --color-text-secondary: var(--muted);
  --color-border: var(--line);
}

/* Browser destination handoff; reuse existing card/button/type tokens. */
.capture-page { overflow-wrap: anywhere; }
.capture-page h2 { margin-top: 32px; }
.capture-code { font-family: ui-monospace, monospace; font-size: 24px; letter-spacing: .08em; }
.capture-steps { padding-left: 24px; }
.capture-steps li { margin-bottom: 16px; }
.capture-actions { display: flex; flex-wrap: wrap; gap: 16px; margin: 24px 0; }
.capture-actions .btn { min-height: 44px; }
#capture-status { margin: 16px 0; }
#capture-connection:not(:empty) { padding: 16px; background: var(--warning-soft); margin: 16px 0; }
#capture-qr { padding: 16px; background: white; width: fit-content; max-width: 100%; margin: 24px auto; }
#capture-qr img, #capture-qr canvas { max-width: 100%; height: auto; }
.capture-link { font-size: 14px; }
.capture-page details { margin-top: 24px; }
.capture-page summary { cursor: pointer; }

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle page-background glow (saas.html body::before). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 540px at 82% -8%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(720px 480px at -6% 8%, rgba(13, 148, 136, .08), transparent 55%),
    linear-gradient(180deg, #FBFBFE 0%, #F6F7FB 100%);
}

a {
  color: var(--accent-700);
}

/* ---------- Type hierarchy ---------- */
h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin: 0 0 16px 0;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
  margin: 0 0 14px 0;
}

h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin: 0 0 10px 0;
}

/* ---------- Global focus ring ---------- */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 10px;
}

/* ============================================================
   Form primitives
   ============================================================ */
.form-label {
  font-size: 13px;
  font-weight: 600;
  display: block;
  margin-bottom: 7px;
  color: var(--ink-2);
}

.form-hint,
.auth-card__hint,
.scan-card__date {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.form-group {
  margin-bottom: 16px;
}

.form-input {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}

.form-input::placeholder {
  color: #9aa1bd;
}

.form-input:hover {
  border-color: #cfd3ea;
}

.form-input:focus,
.form-input:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: 2px solid transparent;
  outline-offset: 2px;
}

/* ============================================================
   Buttons — pill by default
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid transparent;
  background: none;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  margin-bottom: 12px;
  transition: transform var(--t), box-shadow var(--t), background var(--t), color var(--t), border-color var(--t), opacity var(--t);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--ring);
}

.btn--primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn--primary:hover {
  box-shadow: 0 14px 30px -8px rgba(79, 70, 229, .62);
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0);
}

/* Neutral / ghost button on surface */
.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.btn--ghost:hover {
  border-color: #cfd3ea;
  background: #fcfcff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Subtle accent-tinted button */
.btn--subtle {
  background: var(--accent-soft);
  color: var(--accent-700);
}

.btn--subtle:hover {
  background: #e4e7ff;
  transform: translateY(-1px);
}

/* Google OAuth secondary button — neutral border, white surface */
.btn--google {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.btn--google:hover {
  border-color: #cfd3ea;
  background: #fcfcff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn--google .btn__icon {
  flex: none;
}

/* Tertiary text link styled as a button */
.btn--text {
  display: inline;
  width: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--accent-700);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: none;
}

.btn--text:hover {
  text-decoration: underline;
  transform: none;
}

.btn--text:focus-visible {
  box-shadow: var(--ring);
}

/* Auto-width helper for inline buttons */
.btn--auto {
  width: auto;
  padding: 0 24px;
}

/* ============================================================
   Top navbar
   ============================================================ */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(251, 251, 254, .82);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 18px;
}

.site-nav__brand:hover .site-nav__logo {
  transform: translateY(-1px);
}

.site-nav__logo {
  width: 32px;
  height: 32px;
  display: block;
  transition: transform var(--t);
}

.site-nav__link {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  transition: color var(--t), background var(--t);
}

.site-nav__link:hover {
  color: var(--accent-700);
  background: var(--accent-soft);
}

/* ============================================================
   Messages framework
   ============================================================ */
.messages {
  max-width: 960px;
  margin: 16px auto 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.message--success {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: #0a6e4d;
}

.message--info {
  background: var(--accent-soft);
  border-color: #d6daff;
  color: var(--accent-700);
}

.message--warning {
  background: var(--warning-soft);
  border-color: var(--warning-line);
  color: #7a560f;
}

.message--error,
.message--danger {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: #a31515;
}

/* Verification nag uses message--warning treatment (no inline styles). */
.verification-nag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.verification-nag .btn--text {
  margin-left: auto;
}

/* ============================================================
   Error banner (form-level errors)
   ============================================================ */
.error-banner {
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  color: #a31515;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ============================================================
   Auth card
   ============================================================ */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(24px, 3vw, 34px);
  max-width: 420px;
  margin: 56px auto;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--accent-grad);
}

.auth-card__heading {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 22px;
}

.auth-card__heading--code {
  font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  letter-spacing: 0.2em;
  text-align: center;
  margin-bottom: 8px;
  color: var(--accent-700);
}

.auth-card__body {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink-2);
  margin-bottom: 8px;
}

.auth-card__hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* "or" divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  margin: 18px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}

.auth-links {
  text-align: center;
  margin-top: 16px;
}

/* ============================================================
   Generic page shells
   ============================================================ */
.scans-page,
.viewer-page,
.account-page {
  max-width: 960px;
  margin: 32px auto;
  padding: 0 clamp(16px, 4vw, 24px);
}

.scans-page__heading {
  margin-bottom: 6px;
}

.scans-page__subhead {
  color: var(--muted);
  font-size: 15px;
  margin: 0 0 24px;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 70px 24px 90px;
}

.empty-state__icon {
  width: 120px;
  height: 120px;
  border-radius: 30px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  color: var(--accent);
  box-shadow: inset 0 1px 0 #fff, var(--shadow-sm);
}

.empty-state__icon svg {
  width: 58px;
  height: 58px;
  display: block;
}

.empty-state__heading {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}

.empty-state__body {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  max-width: 38ch;
  margin: 0 auto;
}

.empty-state__cta {
  margin-top: 24px;
}

/* ============================================================
   Scan grid + cards
   ============================================================ */
.scan-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding-bottom: 60px;
}

.scan-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  display: flex;
  flex-direction: column;
}

.scan-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #dfe2f1;
}

.scan-card:focus-within {
  box-shadow: var(--ring);
  border-color: var(--accent);
}

.scan-card__link {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  width: 100%;
  height: 100%;
}

.scan-card__link:focus-visible {
  outline: none;
  box-shadow: none;
}

.scan-card__thumb {
  width: 100%;
  aspect-ratio: 4 / 3.1;
  object-fit: cover;
  background: var(--bg-2);
  display: block;
}

.scan-card__meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 16px;
}

.scan-card__name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-card__date {
  margin-top: 2px;
}

.scan-card__format-chip {
  align-self: flex-start;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-700);
  margin-top: 4px;
}

/* ============================================================
   Viewer page
   ============================================================ */
.viewer-page__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.viewer-page__heading {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.viewer-page__actions {
  display: flex;
  gap: 8px;
}

.viewer-page__image-wrap {
  position: relative;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.viewer-page__image {
  max-width: 100%;
  border-radius: 14px;
  display: block;
  margin: 0 auto;
}

.viewer-page__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.viewer-page__filename {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.viewer-page__date {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

/* Share URL row */
.share-url-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.share-url-input,
input.share-url-input.form-input {
  flex: 1 1 0%;
  min-width: 0;
  width: auto;
  background: var(--bg-2);
  color: var(--ink-2);
  font-weight: 500;
}

.share-url-input:focus-visible {
  background: var(--surface);
}

/* ============================================================
   Inline / contextual buttons
   ============================================================ */
.btn--revoke {
  width: auto;
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--danger-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--danger);
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
}

.btn--revoke:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn--revoke:active {
  transform: translateY(0);
}

.btn--share {
  width: auto;
  min-height: 44px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-accent);
  margin-bottom: 0;
}

.btn--share:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px -8px rgba(79, 70, 229, .62);
}

.btn--share:active {
  transform: translateY(0);
}

.btn--inline-copy {
  width: auto;
  min-height: 48px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0;
  transition: transform var(--t), box-shadow var(--t), background var(--t), border-color var(--t);
}

.btn--inline-copy:hover {
  border-color: #cfd3ea;
  background: #fcfcff;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn--inline-copy:active {
  transform: translateY(0);
}

.btn--inline-copy:focus-visible {
  box-shadow: var(--ring);
}

.btn--inline-copy:disabled {
  opacity: .8;
  cursor: default;
  transform: none;
}

/* ============================================================
   Export toolbar
   ============================================================ */
.export-toolbar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.export-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t), background var(--t), border-color var(--t), color var(--t);
}

.export-btn svg {
  width: 20px;
  height: 20px;
}

.export-btn:hover {
  background: #fcfcff;
  border-color: #cfd3ea;
  color: var(--accent-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.export-btn:active {
  transform: translateY(0);
}

.export-btn:focus-visible {
  box-shadow: var(--ring);
}

/* Download submenu (<details>) */
.export-btn--download-menu {
  position: relative;
}

.export-btn--download-menu summary {
  list-style: none;
  cursor: pointer;
}

.export-btn--download-menu summary::-webkit-details-marker {
  display: none;
}

.export-btn--download-menu[open] > summary {
  background: #fcfcff;
  border-color: #cfd3ea;
  color: var(--accent-700);
}

.download-submenu {
  list-style: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  margin: 0;
  box-shadow: var(--shadow);
  z-index: 30;
}

.download-submenu li a {
  display: block;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--t), color var(--t);
}

.download-submenu li a:hover {
  background: var(--accent-soft);
  color: var(--accent-700);
}

.download-submenu li a:focus-visible {
  box-shadow: var(--ring);
}

/* ============================================================
   Account page
   ============================================================ */
.account-page section {
  margin-bottom: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}

.account-page section h1,
.account-page section h2 {
  margin-top: 0;
}

.account-page__empty {
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 0;
}

.device-row,
.share-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.device-row:last-child,
.share-row:last-child {
  border-bottom: none;
}

.device-row__name,
.share-row__name {
  font-weight: 600;
  font-size: 14px;
}

.share-row__url {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--muted);
  font-size: 14px;
}

/* ============================================================
   Loading skeletons (D-16)
   ============================================================ */
@keyframes scaneta-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--line) 0%,
    var(--line-2) 50%,
    var(--line) 100%
  );
  background-size: 200% 100%;
  animation: scaneta-shimmer 1.2s infinite linear;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--line);
  }
}

/* ============================================================
   Live stitch-session badge (D-09)
   ============================================================ */
@keyframes badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}

.live-badge {
  position: absolute;
  top: 30px;
  left: 30px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--live);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.live-badge__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  animation: badge-pulse 1.4s ease-in-out infinite;
}

.live-badge--done .live-badge__dot {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .live-badge__dot {
    animation: none;
  }
}

/* xdev_login waiting-state badge variant (no absolute positioning) */
.live-badge--inline {
  position: static;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 13px;
}

/* ============================================================
   QR code container (xdev_login)
   ============================================================ */
#xdev-qr {
  display: flex;
  justify-content: center;
  margin: 8px 0 18px;
}

#xdev-qr img,
#xdev-qr canvas {
  border-radius: var(--radius-sm);
}

#xdev-status {
  margin: 14px 0;
}

/* ============================================================
   Error pages (404 / 500 / 403)
   ============================================================ */
.error-page {
  max-width: 520px;
  margin: 72px auto;
  padding: 0 24px;
  text-align: center;
}

.error-page__code {
  display: inline-block;
  font-size: clamp(64px, 14vw, 96px);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--accent);
  margin-bottom: 16px;
}

.error-page__heading {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  margin: 0 0 10px;
}

.error-page__body {
  color: var(--muted);
  font-size: 15px;
  max-width: 40ch;
  margin: 0 auto 26px;
}

.error-page .btn {
  width: auto;
  display: inline-flex;
  padding: 0 26px;
}

/* ============================================================
   MOBILE OVERRIDES — responsive breakpoints (D-17/D-18)
   ============================================================ */
@media (max-width: 1024px) {
  .scans-page,
  .viewer-page,
  .account-page {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  /* Touch targets >= 44px (D-18) */
  .btn,
  .form-input,
  .btn--inline-copy,
  .export-btn,
  .btn--share,
  .btn--revoke {
    min-height: 44px;
  }

  .scan-list {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Viewer edge-to-edge image padding shrinks */
  .viewer-page__image-wrap {
    padding: 10px;
    border-radius: var(--radius);
  }

  /* Share-URL row stacks vertically */
  .share-url-row {
    flex-direction: column;
    align-items: stretch;
  }

  .share-url-row .btn--inline-copy {
    width: 100%;
  }

  .export-toolbar {
    flex-wrap: wrap;
  }

  .live-badge {
    top: 18px;
    left: 18px;
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* ============================================================
   Accessible mobile bottom-sheet for the download submenu.
   Replaces the fragile position:fixed;bottom:0 approach. On small
   screens the <details> menu becomes a centered bottom sheet with a
   backdrop; a close affordance is provided via the [open] summary,
   which remains tappable above the sheet.
   ============================================================ */
@media (max-width: 560px) {
  /* Backdrop appears when the menu is open. */
  .export-btn--download-menu[open]::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(11, 16, 32, .42);
    z-index: 40;
  }

  .export-btn--download-menu[open] > summary {
    position: relative;
    z-index: 42;
  }

  .download-submenu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    min-width: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -10px 30px -8px rgba(20, 26, 60, .28);
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    z-index: 41;
    animation: sheet-up var(--t) both;
  }

  .download-submenu::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    margin: 2px auto 10px;
  }

  .download-submenu li a {
    padding: 14px 16px;
    text-align: center;
  }
}

@keyframes sheet-up {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .download-submenu {
    animation: none;
  }
}

.capture-preview { display: block; width: 100%; max-height: 70vh; object-fit: contain; margin: 1rem 0; }
