/* Fabrico Chat — light / dark */

:root,
html[data-theme="light"] {
  --bg: #F3F6FA;
  --bg-deep: #E8EEF5;
  --ink: #0B1220;
  --muted: #5B6B7C;
  --line: rgba(15, 23, 42, 0.1);
  --accent: #1D4ED8;
  --accent-soft: #DBEAFE;
  --surface: #FFFFFF;
  --code-bg: #0B1220;
  --code-fg: #E2E8F0;
  --code-bar: rgba(255, 255, 255, 0.05);
  --ok-bg: #ECFDF5; --ok-fg: #065F46; --ok-bd: #A7F3D0;
  --err-bg: #FEF2F2; --err-fg: #991B1B; --err-bd: #FECACA;
  --warn-bg: #FFFBEB; --warn-fg: #92400E; --warn-bd: #FDE68A;
  --bubble-v: #E2E8F0;
  --bubble-o: #DBEAFE;
  --bubble-o-fg: #1E3A8A;
  --topbar: rgba(247, 249, 252, 0.86);
  --prefer-bg: #0B1220;
  --prefer-fg: #F8FAFC;
  --prefer-muted: rgba(248, 250, 252, 0.72);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
  --grid: rgba(15, 23, 42, 0.045);
  --glow1: rgba(29, 78, 216, 0.12);
  --glow2: rgba(14, 165, 233, 0.08);
  --font: "Sora", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

html[data-theme="dark"] {
  --bg: #0A0F1A;
  --bg-deep: #070B12;
  --ink: #E8EEF9;
  --muted: #94A3B8;
  --line: rgba(148, 163, 184, 0.16);
  --accent: #60A5FA;
  --accent-soft: rgba(37, 99, 235, 0.28);
  --surface: #121A2B;
  --code-bg: #05080F;
  --code-fg: #E2E8F0;
  --code-bar: rgba(255, 255, 255, 0.04);
  --ok-bg: rgba(52, 211, 153, 0.12); --ok-fg: #A7F3D0; --ok-bd: rgba(52, 211, 153, 0.35);
  --err-bg: rgba(248, 113, 113, 0.12); --err-fg: #FECACA; --err-bd: rgba(248, 113, 113, 0.35);
  --warn-bg: rgba(251, 191, 36, 0.12); --warn-fg: #FDE68A; --warn-bd: rgba(251, 191, 36, 0.35);
  --bubble-v: #1E293B;
  --bubble-o: rgba(37, 99, 235, 0.35);
  --bubble-o-fg: #DBEAFE;
  --topbar: rgba(10, 15, 26, 0.88);
  --prefer-bg: #1E3A8A;
  --prefer-fg: #F8FAFC;
  --prefer-muted: rgba(248, 250, 252, 0.75);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --grid: rgba(148, 163, 184, 0.06);
  --glow1: rgba(59, 130, 246, 0.18);
  --glow2: rgba(56, 189, 248, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: light dark; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1200px 520px at 12% -10%, var(--glow1), transparent 55%),
    radial-gradient(900px 420px at 88% 0%, var(--glow2), transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  transition: background .25s ease, color .2s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.9;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 78%);
  animation: gridDrift 28s linear infinite;
}

@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 24px, 48px 24px; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 40px);
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--topbar);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none !important;
}
.logo span { color: var(--accent); }

.topbar nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
}
.topbar nav > a { color: var(--muted); text-decoration: none; font-weight: 500; }
.topbar nav > a:hover { color: var(--ink); }
.who {
  color: var(--muted);
  font-size: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg) !important;
  font-weight: 600;
  text-decoration: none !important;
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
html[data-theme="dark"] .btn-sm { color: #0B1220 !important; background: #E8EEF9; }
.btn-sm:hover { background: var(--accent); color: #fff !important; transform: translateY(-1px); }

.toggles {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted) !important;
  text-decoration: none !important;
}
.chip.on, .chip:hover {
  background: var(--ink);
  color: var(--bg) !important;
}
html[data-theme="dark"] .chip.on,
html[data-theme="dark"] .chip:hover {
  background: #E8EEF9;
  color: #0B1220 !important;
}
.theme-chip { font-size: 14px; min-width: 36px; }

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px clamp(18px, 4vw, 40px) 72px;
  position: relative;
  z-index: 1;
}
.main-marketing { max-width: 1180px; }

.foot {
  text-align: center;
  padding: 28px 18px 40px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 1;
}

.hero-stage {
  min-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0 64px;
  animation: rise .7s ease both;
}
.brand-mark {
  font-family: var(--display);
  font-size: clamp(2.8rem, 7vw, 4.6rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin: 0 0 18px;
  color: var(--ink);
}
.brand-mark em {
  font-style: italic;
  color: var(--accent);
  font-weight: 450;
}
.hero-stage h1 {
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
  letter-spacing: -0.02em;
  line-height: 1.35;
  max-width: 34rem;
  margin: 0 0 14px;
  color: var(--ink);
}
.hero-stage .lede {
  max-width: 32rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none !important;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}
html[data-theme="dark"] .btn-primary {
  background: #E8EEF9;
  color: #0B1220;
}
.btn-primary:hover { background: var(--accent); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.section {
  padding: 56px 0 8px;
  animation: rise .75s ease both;
}
.section-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.section h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  max-width: 28rem;
  line-height: 1.15;
}
.section .lede {
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
  max-width: 36rem;
  margin: 0 0 22px;
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 8px;
}
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.compare article {
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}
.compare article.prefer {
  background: var(--prefer-bg);
  color: var(--prefer-fg);
  border-color: transparent;
  box-shadow: var(--shadow);
}
.compare article.prefer p { color: var(--prefer-muted); }
.compare h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.compare p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.compare ul {
  margin: 12px 0 0;
  padding-left: 1.1rem;
  color: inherit;
  font-size: 0.92rem;
  line-height: 1.65;
  opacity: 0.92;
}

.code-shell {
  margin-top: 8px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--code-bar);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #94A3B8;
  font-size: 12px;
  font-family: var(--mono);
}
.code-bar button {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #E2E8F0;
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
.code-bar button:hover { background: rgba(29, 78, 216, 0.55); }
pre.embed {
  margin: 0;
  overflow: auto;
  padding: 18px 16px 20px;
  background: transparent;
  color: var(--code-fg);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 8px;
  counter-reset: step;
  padding: 0;
}
@media (max-width: 800px) { .flow { grid-template-columns: 1fr; } }
.flow li {
  list-style: none;
  margin: 0;
  padding: 20px 18px;
  border-top: 2px solid var(--accent);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}
.flow li::before {
  counter-increment: step;
  content: "0" counter(step);
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 600;
}
.flow strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.flow span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  margin-top: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}
html[data-theme="dark"] .card { box-shadow: none; }
.card h2 { margin: 0 0 10px; font-size: 1.05rem; letter-spacing: -0.01em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.login-wrap {
  max-width: 440px;
  margin: 48px auto 0;
  animation: rise .55s ease both;
}
.login-wrap .brand-mini {
  font-family: var(--display);
  font-size: 1.8rem;
  margin: 0 0 8px;
}
.login-wrap .brand-mini em { font-style: italic; color: var(--accent); }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; font-weight: 500; }
input, textarea, select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
input:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
textarea { min-height: 88px; resize: vertical; }

.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 14px; }
.alert.err { background: var(--err-bg); color: var(--err-fg); border: 1px solid var(--err-bd); }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-bd); }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-bd); }

.row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.lede { color: var(--muted); line-height: 1.55; }

.threads { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow: auto; }
.threads li a {
  display: block;
  padding: 12px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  border: 1px solid transparent;
}
.threads li a:hover, .threads li a.on {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.threads .t { font-weight: 600; }
.threads .p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}
.msgs { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow: auto; padding: 4px; }
.bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.visitor { align-self: flex-start; background: var(--bubble-v); }
.bubble.owner { align-self: flex-end; background: var(--bubble-o); color: var(--bubble-o-fg); }
.bubble .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; }
.reply-row { display: flex; gap: 8px; margin-top: 12px; }
.reply-row textarea { flex: 1; min-height: 56px; }
.meta-bar { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
