/* Financy design system (gray-blue light theme), drawn in a comic-book style:
   thick ink outlines, hard offset shadows, halftone dots and speech bubbles. */
:root {
  color-scheme: light;

  /* Financy tokens */
  --background: #f3f4f6;
  --surface: #ffffff;
  --surface-hover: #f6f8fb;
  --muted: #eef2f7;
  --input-background: #f8fafc;
  --foreground: #111827;
  --muted-foreground: #6b7280;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-muted: rgba(37, 99, 235, 0.14);
  --brand-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
  --success: #15803d;
  --destructive: #dc2626;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* Comic layer */
  --ink: #111827;
  --ink-width: 3px;
  --pop: #fde047; /* highlighter yellow */
  --pop-soft: #fef9c3;
  --shadow-hard: 6px 6px 0 var(--ink);
  --shadow-hard-sm: 3px 3px 0 var(--ink);
  --halftone: radial-gradient(rgba(37, 99, 235, 0.16) 1.4px, transparent 1.6px);

  --font: "Heebo", system-ui, sans-serif;
  --font-display: "Karantina", "Heebo", sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--foreground);
  background-color: var(--background);
  background-image: var(--halftone);
  background-size: 14px 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--brand); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* ---------- type ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.4rem, 9vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  margin: 0;
}
.display--md { font-size: clamp(2.4rem, 6vw, 3.6rem); }

.hl {
  background: var(--pop);
  padding: 0 0.18em;
  border: var(--ink-width) solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow-hard-sm);
  display: inline-block;
  transform: rotate(-2deg);
}
.hl--blue { background: var(--brand); color: #fff; transform: rotate(1.5deg); }

.lead {
  font-size: 1.1rem;
  max-width: 40ch;
  margin: 22px 0 0;
  padding: 12px 16px;
  color: #1f2937;
  /* comic caption box: keeps the text readable over the background characters */
  background: #fff;
  border: var(--ink-width) solid var(--ink);
  box-shadow: var(--shadow-hard-sm);
}

/* ---------- panels & buttons ---------- */
.panel {
  background: var(--surface);
  border: var(--ink-width) solid var(--ink);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-hard);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 700 0.95rem/1 var(--font);
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  border: var(--ink-width) solid var(--ink);
  box-shadow: var(--shadow-hard-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-hard-sm), 0 0 0 4px var(--brand-muted); }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; }
.btn-primary { background: var(--brand-gradient); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--foreground); }
.btn-secondary:hover { background: var(--pop-soft); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 0.85rem; }
.btn-lg { height: 54px; padding: 0 30px; font-size: 1.05rem; }
.icon { width: 20px; height: 20px; }

.chip {
  font: 600 0.88rem/1 var(--font);
  padding: 9px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}
.chip:hover { background: var(--pop-soft); transform: rotate(-1.5deg); }
.chip.is-active { background: var(--ink); color: #fff; }

.input {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 2px solid var(--ink);
  background: var(--input-background);
  font: 400 0.95rem var(--font);
  color: var(--foreground);
  min-width: 0;
}
.input:focus { outline: none; box-shadow: 0 0 0 4px var(--brand-muted); background: #fff; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(243, 244, 246, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: var(--ink-width) solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--foreground); }
.brand-mark {
  width: 44px; height: 44px;
  object-fit: cover;
  background: var(--pop);
  border: var(--ink-width) solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-hard-sm);
}
.brand-name { font-weight: 800; font-size: 1.05rem; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 40px;
  align-items: center;
  padding-top: 48px;
}
.hero-copy { position: relative; padding-top: 34px; }

.burst {
  position: absolute;
  top: -30px;
  inset-inline-end: 0;
  width: 92px; height: 92px;
  display: grid; place-items: center;
  font: 700 1.9rem/1 var(--font-display);
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--pop);
  transform: rotate(12deg);
  clip-path: polygon(50% 0%, 61% 18%, 82% 8%, 80% 30%, 100% 35%, 85% 52%, 98% 70%, 77% 72%, 78% 94%, 60% 83%, 50% 100%, 40% 83%, 22% 94%, 23% 72%, 2% 70%, 15% 52%, 0% 35%, 20% 30%, 18% 8%, 39% 18%);
  filter: drop-shadow(3px 3px 0 var(--ink));
  animation: wobble 4s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(12deg) scale(1); } 50% { transform: rotate(4deg) scale(1.06); } }

.ask-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: rotate(-0.6deg);
}
.ask-panel > * { transform: rotate(0.6deg); }

/* speech-bubble input */
.bubble-input {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  background: var(--input-background);
  border: var(--ink-width) solid var(--ink);
  border-radius: var(--radius-xl);
}
.bubble-input::after {
  content: "";
  position: absolute;
  bottom: -14px;
  inset-inline-start: 28px;
  width: 22px; height: 14px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.bubble-input:focus-within { box-shadow: 0 0 0 4px var(--brand-muted); background: #fff; }
.bubble-input textarea {
  flex: 1;
  border: 0;
  background: transparent;
  resize: none;
  font: 500 1.05rem/1.5 var(--font);
  color: var(--foreground);
  padding: 6px 4px;
  min-height: 52px;
  max-height: 160px;
}
.bubble-input textarea:focus { outline: none; }
.bubble-input textarea::placeholder { color: var(--muted-foreground); }

.turnstile:empty { display: none; }
.turnstile { margin-top: 18px; }

.disclaimer { margin: 14px 0 0; font-size: 0.78rem; line-height: 1.5; color: var(--muted-foreground); }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }

/* ---------- conversation ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.thread:empty { display: none; }

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg--user { justify-content: flex-start; }
.msg--user .bubble { background: var(--pop-soft); }
.msg--ai .avatar {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font: 700 1.5rem/1 var(--font-display);
  background: var(--brand);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.bubble {
  position: relative;
  max-width: 100%;
  padding: 12px 16px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-hard-sm);
  overflow-wrap: anywhere;
}
.bubble p { margin: 0 0 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 0 0 10px; padding-inline-start: 20px; }
.bubble a { font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.bubble.is-error { background: #fef2f2; border-color: var(--destructive); color: var(--destructive); }

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink);
  animation: bounce 1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-6px); } }

.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 4px; }
.related .card { box-shadow: var(--shadow-hard-sm); }
.related .card-title { font-size: 0.85rem; }

.inline-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 4px; padding: 10px 14px;
  background: var(--pop-soft);
  border: 2px dashed var(--ink);
  border-radius: var(--radius);
  font-weight: 600; font-size: 0.92rem;
}

/* ---------- Financy CTA ---------- */
.cta-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 28px;
  align-items: center;
  padding: 32px;
  background-color: #fff;
  background-image: radial-gradient(rgba(17, 24, 39, 0.1) 1.4px, transparent 1.6px), linear-gradient(135deg, var(--pop) 0%, #fef08a 100%);
  background-size: 12px 12px, 100% 100%;
  transform: rotate(0.5deg);
}
.cta-copy { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.cta-copy p { margin: 0; font-size: 1.05rem; max-width: 44ch; }
.cta-logo { height: 40px; width: auto; }
.cta-art { display: flex; flex-direction: column; gap: 14px; }
.cta-bubble {
  align-self: flex-start;
  max-width: 85%;
  padding: 12px 16px;
  font-weight: 600;
  background: #fff;
  border: var(--ink-width) solid var(--ink);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--shadow-hard-sm);
  transform: rotate(-1.5deg);
}
.cta-bubble--answer {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  transform: rotate(1.5deg);
}

/* ---------- library ---------- */
.library { display: flex; flex-direction: column; gap: 18px; }
.library-head { display: flex; align-items: baseline; gap: 14px; }
.count { font-weight: 700; color: var(--muted-foreground); }
.library-tools { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.library-tools .input { flex: 1 1 240px; max-width: 360px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--foreground);
  background: var(--surface);
  border: var(--ink-width) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.grid .card:nth-child(3n + 1) { transform: rotate(-0.8deg); }
.grid .card:nth-child(3n + 2) { transform: rotate(0.6deg); }
.card:hover { transform: translate(-2px, -3px) rotate(0deg) !important; box-shadow: 9px 9px 0 var(--ink); }
.card:focus-visible { outline: 4px solid var(--brand-muted); }

.card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--muted) var(--halftone);
  background-size: 10px 10px;
  border-bottom: var(--ink-width) solid var(--ink);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .play {
  position: absolute; inset: 0; margin: auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: #fff;
  border: var(--ink-width) solid var(--ink);
  border-radius: 50%;
  box-shadow: var(--shadow-hard-sm);
}
.card-media .play svg { width: 18px; height: 18px; margin-inline-end: -3px; }
.card-media--text { display: grid; place-items: center; padding: 14px; }
.card-media--text .card-media-title { font: 700 2rem/1 var(--font-display); text-align: center; }

.badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  font: 800 0.72rem/1 var(--font);
  padding: 6px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pop);
}
.badge--article { background: #fff; }
.badge--short { background: #f9a8d4; }

.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.card-title { margin: 0; font-size: 1rem; font-weight: 800; line-height: 1.35; }
.card-summary { margin: 0; color: var(--muted-foreground); font-size: 0.88rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-date { font-size: 0.78rem; font-weight: 700; color: var(--muted-foreground); }

.more-wrap { display: flex; justify-content: center; }
.empty { text-align: center; color: var(--muted-foreground); font-weight: 600; }

/* ---------- footer ---------- */
.footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  padding: 24px 16px 36px;
  border-top: var(--ink-width) solid var(--ink);
  font-size: 0.85rem;
  color: var(--muted-foreground);
  text-align: center;
}
.footer img { height: 22px; width: auto; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero, .cta-panel { grid-template-columns: 1fr; }
  .hero { padding-top: 28px; gap: 28px; }
  .cta-panel { padding: 22px; }
  .burst { width: 72px; height: 72px; font-size: 1.5rem; top: -14px; }
}
@media (max-width: 480px) {
  main { gap: 36px; }
  .brand-name { display: none; }
  .bubble-input { flex-direction: column; align-items: stretch; }
  .bubble-input .btn { width: 100%; }
  .library-tools .input { max-width: none; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 8-bit Elirons in the background ---------- */
main, .footer { position: relative; z-index: 1; }
.sprites {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.6; /* background characters: present, never competing with the text */
}
.sprite {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}
.sprite-body {
  width: calc(var(--px) * 12);
  height: calc(var(--px) * 17);
  background-size: 100% 100%;
  image-rendering: pixelated;
  filter: drop-shadow(var(--px) var(--px) 0 rgba(17, 24, 39, 0.18));
}
.sprite-bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  translate: -50% 0;
  white-space: nowrap;
  padding: 6px 10px;
  font: 700 0.8rem/1.2 var(--font);
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s steps(2), transform 0.15s steps(2);
}
/* square pixel tail */
.sprite-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 9px;
  height: 9px;
  translate: -50% 0;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 9px 3px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 3px 3px / 3px 6px no-repeat;
}
.sprite.is-talking .sprite-bubble { opacity: 1; transform: scale(1); }

/* ---------- video player ---------- */
.player {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: var(--ink-width) solid var(--ink);
  border-radius: var(--radius-2xl);
  box-shadow: 8px 8px 0 var(--ink);
  background: var(--surface);
  color: var(--foreground);
  overflow: hidden;
}
.player.is-short { width: min(420px, calc(100vw - 32px)); }
.player::backdrop {
  background-color: rgba(17, 24, 39, 0.72);
  background-image: radial-gradient(rgba(253, 224, 71, 0.22) 1.4px, transparent 1.6px);
  background-size: 12px 12px;
}
.player-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: var(--ink-width) solid var(--ink);
  background: var(--pop);
}
.player-title { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-close {
  width: 36px; height: 36px; flex: 0 0 auto;
  border: 2px solid var(--ink); border-radius: 50%;
  background: #fff; font-weight: 900; cursor: pointer;
  box-shadow: var(--shadow-hard-sm);
}
.player-frame { aspect-ratio: 16 / 9; background: #000; }
.player.is-short .player-frame { aspect-ratio: 9 / 16; max-height: calc(100vh - 110px); margin: 0 auto; }
.player-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 480px) { .player-head .btn { display: none; } }

/* ---------- answer feedback ---------- */
.feedback { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--muted-foreground); }
.thumb {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 50%;
  background: #fff; color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.thumb svg { width: 16px; height: 16px; }
.thumb--down svg { transform: rotate(180deg); }
.thumb:hover { background: var(--pop-soft); transform: rotate(-6deg); }
.thumb.is-picked { background: var(--brand); color: #fff; }
.thumb--down.is-picked { background: var(--ink); }
