/* ============================================================
   QR Social — design system
   Aesthetic: dark, confident, slightly futurist.
   Display: Fraunces (chunky modern serif). Body: Geist (clean).
   Accent: mint (#00E5A0). Background: charcoal with subtle grain.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,700;9..144,900&family=Geist:wght@300;400;500;600;700&display=swap');

:root {
  --bg:         #0b0b0d;
  --bg-2:       #131317;
  --bg-card:    #1a1a20;
  --bg-elev:    #22222a;
  --line:       rgba(60, 130, 255, 0.10);
  --line-2:     rgba(60, 130, 255, 0.18);
  --text:       #f4f4f6;
  --text-dim:   #a1a1aa;
  --text-faint: #6b6b75;
  --accent:     #3C82FF;
  --accent-2:   #00E5A0;
  --accent-hi:  #6BA3FF;
  --accent-glow: 0 0 0 4px rgba(60,130,255,0.18);
  --gradient-primary: linear-gradient(135deg, #3C82FF 0%, #00E5A0 100%);
  --danger:     #ff6b6b;
  --warn:       #ffd166;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;

  --serif: 'Fraunces', 'Times New Roman', serif;
  --sans:  'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Tokens that need to flip per-theme but aren't pure colors */
  --grain-opacity: 0.4;
  --grain-mix: 1; /* 1 = white grain (dark mode), 0 = black grain (light mode) */
  --shadow-card: 0 4px 18px rgba(60, 130, 255, 0.18);

  /* Surface tints — used for hover states, soft pills, recessed wells, etc.
     In dark mode these are translucent white; in light mode translucent black.
     Use these instead of literal rgba(255,255,255,X) so things stay visible
     when the theme flips. */
  --surface-1:    rgba(255, 255, 255, 0.04); /* very faint */
  --surface-2:    rgba(255, 255, 255, 0.06); /* hover */
  --surface-3:    rgba(255, 255, 255, 0.08); /* active / pressed */
  --surface-4:    rgba(255, 255, 255, 0.12); /* prominent chip */
  --surface-5:    rgba(255, 255, 255, 0.18); /* strongest tint */

  /* Frosted-glass tabbar background — a translucent version of the page bg
     so the blur underneath shows through */
  --tabbar-bg: rgba(11, 11, 13, 0.85);

  /* Fade gradient behind the chat composer — fades from transparent up top
     to near-solid bg at the bottom edge, so messages appear to slide
     "under" the composer cleanly */
  --composer-fade: linear-gradient(180deg, transparent 0%, rgba(11,11,13,0.5) 35%, rgba(11,11,13,0.92) 100%);
  /* The frosted pill the textarea sits in */
  --composer-pill-bg: rgba(26, 26, 32, 0.65);
  /* Shadow under the pill — heavy black in dark mode (invisible against
     dark bg, just adds depth), softer cool-tinted in light mode so the
     pill floats without a harsh halo */
  --composer-pill-shadow: 0 12px 40px rgba(0,0,0,0.45), inset 0 1px 0 var(--surface-1);
  /* Ambient strip pill ("X is typing", etc.) */
  --ambient-pill-bg: rgba(26, 26, 32, 0.6);

  /* Slide-up sheets (+ button, settings) — frosted panel + heavy upward shadow */
  --sheet-bg:     rgba(22, 22, 28, 0.92);
  --sheet-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);

  /* Full-screen recording stage backdrop (when holding the orb to record).
     Radial fade from a brand-tinted glow at the bottom-center to a near-solid
     bg at the edges. Theme-aware so it doesn't punch a black void on light. */
  --stage-bg:           radial-gradient(120% 60% at 50% 100%, rgba(60,130,255,0.20) 0%, rgba(11,11,13,0.92) 50%, rgba(11,11,13,0.98) 100%);
  --stage-bg-cancelling: radial-gradient(120% 60% at 50% 100%, rgba(255,91,91,0.25) 0%, rgba(11,11,13,0.95) 50%, rgba(11,11,13,0.98) 100%);
  --stage-preview-shadow: rgba(0, 0, 0, 0.7);

  /* Generic popover/menu shadow (reaction picker, etc.) */
  --popover-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);

  /* Scan-orb lens (the "glass" center the logo sits in) */
  --orb-lens-hi: rgba(60, 130, 255, 0.35);  /* highlight at top-left */
  --orb-lens-bg: #0e1220;                    /* main lens color */
  --orb-lens-lo: #050709;                    /* shadow at bottom-right */
  --orb-halo: rgba(60, 130, 255, 0.10);
  --orb-halo-hover: rgba(60, 130, 255, 0.18);

  /* CentroShield SSO button — cyan-on-dark brand identity */
  --cs-bg:           #0a0e17;
  --cs-bg-hover:     #0f1525;
  --cs-border:       rgba(95, 184, 212, 0.45);
  --cs-border-hover: rgba(95, 184, 212, 0.75);
  --cs-text:         #7fc7e0;
  --cs-emph:         #ffffff;
  --cs-glow:         rgba(95, 184, 212, 0.25);
}

/* ---------- Light theme overrides ----------
   Triggered by <html data-theme="light">. Accent colors stay the same so
   the brand feel survives; backgrounds and text invert. */
:root[data-theme="light"] {
  --bg:         #f7f7f9;
  --bg-2:       #ffffff;
  --bg-card:    #ffffff;
  --bg-elev:    #f0f0f4;
  --line:       rgba(60, 130, 255, 0.16);
  --line-2:     rgba(60, 130, 255, 0.28);
  --text:       #15151a;
  --text-dim:   #5a5a66;
  --text-faint: #8a8a95;
  --accent-hi:  #2a6ce0;
  --accent-glow: 0 0 0 4px rgba(60,130,255,0.14);
  --grain-opacity: 0.25;
  --grain-mix: 0;
  --shadow-card: 0 4px 18px rgba(20, 30, 60, 0.08);

  --surface-1: rgba(20, 25, 45, 0.03);
  --surface-2: rgba(20, 25, 45, 0.05);
  --surface-3: rgba(20, 25, 45, 0.08);
  --surface-4: rgba(20, 25, 45, 0.10);
  --surface-5: rgba(20, 25, 45, 0.14);

  --tabbar-bg: rgba(255, 255, 255, 0.85);

  --composer-fade: none;
  --composer-pill-bg: rgba(255, 255, 255, 0.85);
  /* Light mode: cool-blue-tinted soft shadow instead of harsh black drop —
     the pill should look like it's floating, not casting a hole. */
  --composer-pill-shadow: 0 8px 24px rgba(60, 90, 160, 0.10), 0 2px 6px rgba(60, 90, 160, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --ambient-pill-bg: rgba(255, 255, 255, 0.75);

  /* Light-mode sheet: white frosted panel, soft cool-tinted upward shadow */
  --sheet-bg:     rgba(255, 255, 255, 0.94);
  --sheet-shadow: 0 -12px 40px rgba(60, 90, 160, 0.12), 0 -2px 8px rgba(60, 90, 160, 0.06);

  /* Light-mode stage: a soft cool-blue wash with brand-tinted glow at the
     bottom — keeps the cinematic "lights out" recording vibe without
     turning the whole screen black on light mode users. */
  --stage-bg:            radial-gradient(120% 60% at 50% 100%, rgba(60,130,255,0.28) 0%, rgba(220,230,250,0.95) 50%, rgba(247,247,249,0.98) 100%);
  --stage-bg-cancelling: radial-gradient(120% 60% at 50% 100%, rgba(255,91,91,0.30) 0%, rgba(250,225,225,0.96) 50%, rgba(247,247,249,0.98) 100%);
  --stage-preview-shadow: rgba(60, 90, 160, 0.25);

  --popover-shadow: 0 12px 32px rgba(60, 90, 160, 0.18), 0 4px 12px rgba(60, 90, 160, 0.08);

  /* Light-mode lens: bright, cool-tinted glass so the logo reads dark on
     light. The highlight picks up a touch of the mint accent for life. */
  --orb-lens-hi: rgba(0, 229, 160, 0.30);
  --orb-lens-bg: #e8eaef;
  --orb-lens-lo: #d6e0f0;
  --orb-halo: rgba(60, 130, 255, 0.14);
  --orb-halo-hover: rgba(60, 130, 255, 0.22);

  /* Light-mode CentroShield: white face, cyan border + text. The "Shield"
     emphasis flips from white-on-dark to deep-cyan-on-light so it still
     pops as the brand inflection. */
  --cs-bg:           #ffffff;
  --cs-bg-hover:     #f4fafe;
  --cs-border:       rgba(38, 130, 165, 0.45);
  --cs-border-hover: rgba(38, 130, 165, 0.75);
  --cs-text:         #1d6f8f;
  --cs-emph:         #0a3a4d;
  --cs-glow:         rgba(38, 130, 165, 0.20);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* subtle grain on the body bg, gives it depth without looking like AI slop */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: var(--grain-opacity);
  /* In light mode (--grain-mix: 0) we invert the white grain to dark */
  filter: invert(calc(1 - var(--grain-mix)));
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}
h1 {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.05;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.h-plain {
  background: none !important;
  -webkit-text-fill-color: var(--text) !important;
  color: var(--text) !important;
}
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; color: var(--text-dim); }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
}
.container-wide { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top nav ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  max-width: 480px;
  margin: 0 auto;
}
.nav-logo {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: -0.04em;
  color: var(--text);
}
.nav-logo span {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.nav-logo-mark {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.32em;
  margin: 0 0.12em;
  object-fit: contain;
}
.nav-actions { display: flex; gap: 12px; align-items: center; }
.nav-actions a { color: var(--text-dim); font-size: 0.9rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 999px;
  border: none;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  transition: transform 0.12s, background 0.18s, box-shadow 0.18s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(60, 130, 255, 0.32);
}
.btn-primary:hover {
  background: var(--gradient-primary);
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(60, 130, 255, 0.45);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover { background: var(--bg-elev); }
.btn-block { width: 100%; }
.btn-lg { padding: 18px 28px; font-size: 1.05rem; }

/* ---------- CentroShield SSO button ----------
   Branded element — keeps cyan as the through-line in both themes.
   Dark mode: deep navy face with cyan accents (the original brand look).
   Light mode: clean white face with cyan border + cyan text. */
.btn-centroshield {
  background: var(--cs-bg);
  color: var(--cs-text);
  border: 1px solid var(--cs-border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.btn-centroshield:hover {
  background: var(--cs-bg-hover);
  border-color: var(--cs-border-hover);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--cs-glow);
}
.btn-centroshield .cs-pre { font-weight: 800; letter-spacing: 0.04em; }
.btn-centroshield .cs-name { font-weight: 900; }
.btn-centroshield .cs-name em {
  color: var(--cs-emph);
  font-style: normal;
}
.btn-centroshield .cs-logo {
  width: 28px; height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}
/* Two logo variants — show the dark-bg one in dark theme, white-bg one in light. */
.btn-centroshield .cs-logo-dark { display: inline-block; }
.btn-centroshield .cs-logo-light { display: none; }
:root[data-theme="light"] .btn-centroshield .cs-logo-dark { display: none; }
:root[data-theme="light"] .btn-centroshield .cs-logo-light { display: inline-block; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.input, .textarea, .select {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  transition: border 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--accent-glow);
}
.textarea { min-height: 80px; resize: vertical; }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: 0 1px 0 rgba(60, 130, 255, 0.04) inset;
}

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--tabbar-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 500;
  text-decoration: none;
  padding: 4px 0;
}
.tabbar a.active { color: var(--accent); }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar .tab-scan {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-decoration: none;
  padding: 0;
}
.tabbar .tab-scan .scan-orb {
  width: 64px;
  height: 64px;
  margin-top: -26px;
  border-radius: 50%;
  padding: 3px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* The conic gradient gives the ring a subtle "swept" highlight that
     suggests motion without literally moving (which would be distracting
     in a tab bar). The conic angle is tied to a CSS var so we can
     gently drift it on hover. */
  background:
    conic-gradient(
      from var(--orb-angle, 135deg),
      #00E5A0 0deg,
      #3C82FF 120deg,
      #6BA3FF 200deg,
      #00E5A0 360deg
    );
  box-shadow:
    0 10px 28px rgba(60, 130, 255, 0.38),
    0 2px 6px rgba(60, 130, 255, 0.18),
    0 0 0 4px var(--orb-halo, rgba(60, 130, 255, 0.08));
  transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1),
              box-shadow 0.22s ease,
              --orb-angle 6s linear;
}
.tabbar .tab-scan .scan-orb-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  /* Flat lens color so the logo reads cleanly. The visual interest lives
     in the conic-gradient ring around the orb, not inside it. */
  background: var(--orb-lens-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  z-index: 2;
}
.tabbar .tab-scan .scan-orb-logo {
  width: 80%;
  height: 80%;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  /* Subtle drop shadow on the logo so it pops off the lens */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tabbar .tab-scan:hover .scan-orb,
.tabbar .tab-scan:active .scan-orb {
  transform: scale(1.06);
  --orb-angle: 495deg; /* gradient sweeps a full turn over the transition */
  box-shadow:
    0 14px 38px rgba(60, 130, 255, 0.55),
    0 2px 6px rgba(60, 130, 255, 0.25),
    0 0 0 4px var(--orb-halo-hover, rgba(60, 130, 255, 0.14));
}
.tabbar .tab-scan:active .scan-orb-logo {
  transform: scale(0.92);
}
/* The conic-gradient angle needs to be a registered custom property to
   actually animate; older browsers fall back to a static angle, which is
   still fine. */
@property --orb-angle {
  syntax: '<angle>';
  inherits: true;
  initial-value: 135deg;
}

body.has-tabbar { padding-bottom: 100px; }

/* ---------- Avatar ---------- */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-elev);
  object-fit: cover;
  display: inline-block;
  vertical-align: middle;
}
.avatar-lg { width: 88px; height: 88px; }
.avatar-xl { width: 120px; height: 120px; }
.avatar-fallback {
  display: inline-flex;
  align-items: center; justify-content: center;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--accent);
  background: linear-gradient(135deg, #1f2933, #0e1418);
  letter-spacing: -0.02em;
}

/* ---------- Helper utilities ---------- */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-md > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.center { text-align: center; }
.hidden { display: none !important; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(60, 130, 255, 0.14);
  color: var(--accent-hi);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-mint {
  background: rgba(0, 229, 160, 0.12);
  color: var(--accent-2);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.fade-up { animation: fadeUp 0.5s ease both; }

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(60, 130, 255, 0.55); }
  70%  { box-shadow: 0 0 0 24px rgba(60, 130, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(60, 130, 255, 0); }
}
.pulse-ring { animation: pulse-ring 1.6s infinite; }
