:root {
  --bg-wash: rgba(255, 255, 255, 0.28);
  --surface: #ffffff;
  --surface-soft: #f5f6f8;
  --surface-muted: #eceff3;
  --border: #dde3ea;
  --ink: #20242c;
  --ink-soft: #5e6775;
  --tv3-red: #e21f26;
  --chat-blue: #234b96;
  --chat-blue-dark: #1c3d7c;
  --orb-blue-1: #8fd7ff;
  --orb-blue-2: #4f82ff;
  --orb-blue-3: #213a88;

  --radius-pill: 999px;
  --radius-lg: 20px;
  --radius-md: 12px;

  --shadow-launcher: 0 1px 2px rgba(20, 30, 50, 0.06), 0 12px 32px rgba(20, 30, 50, 0.14);
  --shadow-launcher-hover: 0 2px 4px rgba(20, 30, 50, 0.08), 0 18px 44px rgba(20, 30, 50, 0.18);
  --shadow-panel: 0 4px 12px rgba(20, 30, 50, 0.08), 0 24px 60px rgba(20, 30, 50, 0.22);

  --font-stack: 'Manrope', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

input, button, textarea, select { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-stack);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ==== Background mock — swap .bg-mock for a real screenshot image when ready ==== */

.bg-mock {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--surface);
  z-index: 0;
}

.bg-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.bg-logo {
  background: var(--tv3-red);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  padding: 6px 10px;
  letter-spacing: 1px;
}

.bg-menu {
  display: flex;
  gap: 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}

.bg-menu .is-active { color: var(--tv3-red); }

.bg-live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tv3-red);
}

.bg-live-dot {
  width: 8px;
  height: 8px;
  background: var(--tv3-red);
  border-radius: 50%;
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.bg-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-areas: "hero side" "grid grid";
  gap: 20px;
  padding: 24px 32px;
  max-width: 1280px;
  margin: 0 auto;
}

.bg-hero { grid-area: hero; }
.bg-side { grid-area: side; display: flex; flex-direction: column; gap: 16px; }
.bg-grid { grid-area: grid; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.bg-img {
  background: linear-gradient(135deg, #c8d0db, #9ca6b6);
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  margin-bottom: 10px;
}

.bg-img--hero { aspect-ratio: auto; height: 340px; background: linear-gradient(135deg, #1a2842, #3a5785); }
.bg-side .bg-card:nth-child(1) .bg-img { background: linear-gradient(135deg, #2a3042, #5a6585); }
.bg-side .bg-card:nth-child(2) .bg-img { background: linear-gradient(135deg, #422a2a, #854545); }
.bg-side .bg-card:nth-child(3) .bg-img { background: linear-gradient(135deg, #2a4230, #457855); }
.bg-grid .bg-card:nth-child(2) .bg-img { background: linear-gradient(135deg, #d4c8db, #a79ab6); }
.bg-grid .bg-card:nth-child(3) .bg-img { background: linear-gradient(135deg, #c8dbd3, #9ab6a7); }
.bg-grid .bg-card:nth-child(4) .bg-img { background: linear-gradient(135deg, #dbcec8, #b6a69a); }

.bg-hero h2 {
  font-size: 26px;
  line-height: 1.2;
  margin: 10px 0 4px;
  font-weight: 800;
  color: var(--ink);
}

.bg-hero .bg-byline {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
}

.bg-card h3, .bg-side h3 {
  font-size: 14px;
  line-height: 1.3;
  margin: 0;
  font-weight: 700;
  color: var(--ink);
}

.bg-side h3 { font-size: 15px; }

.bg-tag {
  display: inline-block;
  padding: 3px 8px;
  background: var(--tv3-red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 2px;
  margin-bottom: 6px;
}

.bg-tag--muted { background: var(--surface-muted); color: var(--ink-soft); }

/* ==== Overlay ==== */

.overlay-wash {
  position: fixed;
  inset: 0;
  background: var(--bg-wash);
  pointer-events: none;
  z-index: 1;
}

.overlay-spotlight {
  position: fixed;
  bottom: -160px;
  right: -200px;
  width: 760px;
  height: 620px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0) 62%);
  pointer-events: none;
  z-index: 1;
}

/* ==== Launcher ==== */

.launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 22px 6px 8px;
  min-height: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-launcher);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 180ms ease;
}

.launcher:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-launcher-hover);
}

.launcher:active { transform: translateY(0); }

.launcher.is-chat-open {
  opacity: 0;
  pointer-events: none;
}

/* ==== Teaser bubble ==== */

.launcher-teaser {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-launcher);
  font-family: var(--font-stack);
  animation: teaser-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.launcher-teaser-text { white-space: nowrap; }

.launcher-teaser[hidden] { display: none; }

.launcher-teaser::after {
  content: '';
  position: absolute;
  right: 32px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}

.launcher-teaser-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.launcher-teaser-body {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.3;
}

.launcher-teaser-body:hover { color: var(--chat-blue); }
.launcher-teaser-body:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 3px; border-radius: 4px; }

.launcher-teaser-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.launcher-teaser-close:hover { background: var(--surface-muted); color: var(--ink); }
.launcher-teaser-close:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }

.launcher-teaser.is-dismissing {
  animation: teaser-out 160ms ease forwards;
}

@keyframes teaser-in {
  0%   { opacity: 0; transform: translateY(10px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes teaser-out {
  to { opacity: 0; transform: translateY(4px) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  .launcher-teaser { animation: none; }
  .launcher-teaser.is-dismissing { animation: none; opacity: 0; }
}

.launcher:focus-visible {
  outline: 2px solid var(--orb-blue-2);
  outline-offset: 3px;
}

.launcher-orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, #ffffff 0%, var(--orb-blue-1) 14%, var(--orb-blue-2) 52%, var(--orb-blue-3) 100%);
  box-shadow:
    inset 0 -4px 8px rgba(0, 0, 0, 0.22),
    inset 0 3px 6px rgba(255, 255, 255, 0.5),
    0 0 18px rgba(79, 130, 255, 0.42);
  animation: orb-breathe 4.2s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.22), inset 0 3px 6px rgba(255,255,255,0.5), 0 0 18px rgba(79,130,255,0.42);
  }
  50% {
    transform: scale(1.05);
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.22), inset 0 3px 6px rgba(255,255,255,0.5), 0 0 26px rgba(79,130,255,0.62);
  }
}

/* ==== Chat panel ==== */

.chat {
  position: fixed;
  bottom: 104px;
  right: 20px;
  z-index: 11;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(680px, calc(100vh - 140px));
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: 100% 100%;
  animation: chat-open 220ms ease-out;
}

.chat[hidden] { display: none; }

@keyframes chat-open {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--chat-blue);
  color: #fff;
  border-bottom: 2px solid var(--tv3-red);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #ffffff 0%, var(--orb-blue-1) 14%, var(--orb-blue-2) 52%, var(--orb-blue-3) 100%);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.22), inset 0 2px 4px rgba(255,255,255,0.4);
}

.chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}

.chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background 120ms ease;
}

.chat-close:hover { background: rgba(255, 255, 255, 0.14); }
.chat-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  animation: msg-in 180ms ease-out;
}

.msg-bot {
  background: var(--surface-muted);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-user {
  background: var(--chat-blue);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.msg-brief {
  padding: 12px 14px;
  max-width: 92%;
}

.brief-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.brief-item:first-child { padding-top: 0; }
.brief-item:last-child { border-bottom: 0; padding-bottom: 0; }

.brief-head {
  display: flex;
  gap: 6px;
  align-items: baseline;
  line-height: 1.35;
}

.brief-num {
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
  font-size: 14px;
}

.brief-link {
  color: var(--chat-blue);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

.brief-link:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.brief-link:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; border-radius: 2px; }

.brief-context {
  margin-top: 3px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.msg-typing {
  align-self: flex-start;
  background: var(--surface-muted);
  padding: 12px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 4px;
}

.msg-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: typing 1.2s infinite;
}

.msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  align-self: stretch;
  animation: msg-in 200ms ease-out;
}

.chip {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--chat-blue);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.chip:hover {
  background: var(--surface-soft);
  border-color: var(--chat-blue);
}

.chip:active { transform: scale(0.98); }
.chip:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }

.chat-composer {
  display: flex;
  gap: 8px;
  padding: 10px 14px 4px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#chat-input {
  flex: 1;
  padding: 10px 16px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 120ms ease, background 120ms ease;
}

#chat-input::placeholder { color: var(--ink-soft); }
#chat-input:focus { outline: none; background: var(--surface); border-color: var(--chat-blue); }

.chat-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: var(--chat-blue);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.chat-send:hover { background: var(--chat-blue-dark); }
.chat-send:active { transform: scale(0.96); }
.chat-send:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; }

.chat-footer {
  margin: 0;
  padding: 6px 16px 12px;
  font-size: 11px;
  color: var(--ink-soft);
  text-align: center;
  background: var(--surface);
}

/* ==== Responsive ==== */

@media (max-width: 860px) {
  .bg-main { grid-template-columns: 1.3fr 1fr; padding: 16px; }
  .bg-grid { grid-template-columns: repeat(2, 1fr); }
  .bg-img--hero { height: 240px; }
}

@media (max-width: 640px) {
  .bg-main {
    grid-template-columns: 1fr;
    grid-template-areas: "hero" "side" "grid";
    padding: 14px;
    gap: 14px;
  }

  .bg-img--hero { height: 200px; }
  .bg-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  .bg-nav { padding: 10px 14px; gap: 12px; overflow-x: auto; }
  .bg-menu { font-size: 13px; gap: 14px; flex-wrap: nowrap; white-space: nowrap; }
  .bg-live { flex-shrink: 0; }

  .launcher {
    bottom: max(18px, env(safe-area-inset-bottom));
    right: 16px;
    min-height: 52px;
    padding: 5px 18px 5px 7px;
    font-size: 14px;
  }

  .launcher-orb { width: 38px; height: 38px; }

  .launcher-teaser {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
    right: 16px;
    max-width: calc(100vw - 32px);
  }

  .chat {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation: chat-open-mobile 240ms ease-out;
  }

  @keyframes chat-open-mobile {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}
