/* ===========================================================================
   Market Phase — minimal single-page dashboard.
   Color: lime accent + ember on near-black + paper.
   Type:  Archivo Narrow (display) · Instrument Serif (italic accents) ·
          Archivo (body) · JetBrains Mono (labels).
   ========================================================================== */

:root {
  --accent: #c6ff3d;
  --ember:  #ff5e2b;
  --bg:     #0a0d0a;
  --paper:  #f2efe6;
  --muted:  rgba(242,239,230,0.55);
  --line:   rgba(242,239,230,0.12);
  --ff-display: "Archivo Narrow", "Arial Narrow", sans-serif;
  --ff-serif:   "Instrument Serif", "Times New Roman", serif;
  --ff-body:    "Archivo", "Helvetica Neue", Helvetica, sans-serif;
  --ff-mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--paper);
  font-family: var(--ff-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }

h1, h2 {
  font-family: var(--ff-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 0.9;
}
.accent {
  color: var(--accent);
  font-family: var(--ff-serif);
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  letter-spacing: -0.01em;
}
.eyebrow {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-family: var(--ff-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
.topbar .meta {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar .source {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.topbar .source:hover { color: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------- main layout ---------- */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px 120px;
}
section { margin-bottom: 56px; }

/* ---------- action block (the headline verdict) ---------- */
.action-block {
  border-bottom: 1px solid var(--line);
  padding-bottom: 48px;
}
.action-block .eyebrow { color: var(--accent); }
.action-block h1 {
  font-size: clamp(56px, 11vw, 144px);
  line-height: 0.85;
  letter-spacing: -0.035em;
}
.action-block h1 .line { display: block; }
.action-block h1 .accent { display: block; }
.action-block .reason {
  font-family: var(--ff-serif);
  font-style: italic;
  font-size: clamp(20px, 2vw, 26px);
  color: var(--paper);
  margin-top: 24px;
  max-width: 60ch;
  line-height: 1.35;
}

/* ---------- stats row ---------- */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--line);
}
.stats-row .stat .n {
  font-family: var(--ff-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.stats-row .stat .n.n-sm {
  font-size: clamp(20px, 2.2vw, 28px);
  color: var(--paper);
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.stats-row .stat .l {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}

/* ---------- sectors ---------- */
.sectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--line);
}
.sec-col .l {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.sec-col .v {
  font-family: var(--ff-display);
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.sec-col.favor .v { color: var(--accent); }
.sec-col.avoid .v { color: var(--muted); }

/* ---------- explanation prose ---------- */
.explanation .eyebrow { margin-bottom: 20px; }
.prose {
  max-width: 68ch;
  font-size: 17px;
  line-height: 1.65;
  color: var(--paper);
}
.prose p { margin-bottom: 16px; }
.prose p:last-child { margin-bottom: 0; }
.prose em {
  font-family: var(--ff-serif);
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

/* ---------- triggered signals ---------- */
.signals .eyebrow { margin-bottom: 20px; }
.signals ul {
  list-style: none;
  border-top: 1px solid var(--line);
}
.signals li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: baseline;
}
.signals .sig-name {
  font-family: var(--ff-display);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--paper);
}
.signals .sig-detail {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.5;
}
.signals .empty {
  font-family: var(--ff-serif);
  font-style: italic;
  color: var(--muted);
  text-align: center;
  padding: 20px 0;
  display: block;
  border-bottom: 1px solid var(--line);
}

/* ---------- fine print ---------- */
.fine-print {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.7;
  max-width: 68ch;
}
.fine-print em {
  font-family: var(--ff-serif);
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0;
}

/* ===========================================================================
   FLOATING CHAT BUBBLE
   ========================================================================= */

.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(198,255,61,0.3), 0 0 0 1px rgba(198,255,61,0.4);
  z-index: 200;
  transition: transform .2s ease, box-shadow .2s ease;
}
.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(198,255,61,0.4), 0 0 0 1px rgba(198,255,61,0.6);
}
.chat-toggle svg {
  width: 24px;
  height: 24px;
}
.chat-toggle.hidden {
  transform: scale(0);
  pointer-events: none;
}

.chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-height: 580px;
  background: #11140f;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 201;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.chat-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(198,255,61,0.04);
}
.chat-title {
  font-family: var(--ff-display);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--paper);
}
.chat-sub {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.chat-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s, color .15s;
}
.chat-close:hover { background: var(--line); color: var(--paper); }

.chat-window {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.chat-window::-webkit-scrollbar { width: 4px; }
.chat-window::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.chat-msg {
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 85%;
  margin-bottom: 10px;
  font-family: var(--ff-body);
  word-wrap: break-word;
}
.chat-msg em {
  font-family: var(--ff-serif);
  font-style: italic;
  color: var(--accent);
}
.chat-msg.bot {
  background: rgba(242,239,230,0.05);
  color: var(--paper);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  background: var(--accent);
  color: var(--bg);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.chat-msg.typing {
  color: var(--muted);
  font-style: italic;
  font-family: var(--ff-serif);
}

#chatForm {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
#chatInput {
  flex: 1;
  background: rgba(242,239,230,0.04);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 10px 14px;
  font-family: var(--ff-body);
  font-size: 14px;
  border-radius: 999px;
  transition: border-color .2s, background .2s;
}
#chatInput::placeholder {
  color: var(--muted);
  font-family: var(--ff-serif);
  font-style: italic;
}
#chatInput:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(198,255,61,0.04);
}
#chatForm button {
  background: var(--accent);
  border: none;
  color: var(--bg);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: transform .15s, opacity .15s;
}
#chatForm button:hover { transform: scale(1.05); }
#chatForm button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: 16px 20px; }
  .topbar .meta { display: none; }
  main { padding: 32px 20px 120px; }
  .stats-row { grid-template-columns: 1fr; gap: 24px; }
  .sectors { grid-template-columns: 1fr; gap: 20px; }
  .signals li { grid-template-columns: 1fr; gap: 4px; }

  .chat-panel {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 88px;
    max-height: calc(100vh - 120px);
  }
  .chat-toggle { right: 16px; bottom: 16px; }
}
