/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:             #0f1117;
  --surface:        rgba(255, 255, 255, 0.05);
  --surface-raised: rgba(255, 255, 255, 0.08);
  --border:         rgba(255, 255, 255, 0.08);
  --border-strong:  rgba(255, 255, 255, 0.14);
  --panel-divider:  rgba(255, 255, 255, 0.06);

  --blue:   #4f8ef7;
  --green:  #4ade80;
  --amber:  #f59e0b;
  --red:    #f87171;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #475569;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 17, 23, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: relative;
  z-index: 20;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.wordmark {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #fff;
}

.tagline {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

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

.brief-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.badge-internal {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 4px;
  padding: 3px 8px;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.site-main {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.panel::-webkit-scrollbar          { width: 4px; }
.panel::-webkit-scrollbar-track    { background: transparent; }
.panel::-webkit-scrollbar-thumb    { background: rgba(255,255,255,0.08); border-radius: 2px; }
.panel::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.panel-left {
  width: 60%;
  padding: 24px;
  border-right: 1px solid var(--panel-divider);
}

.panel-right {
  width: 40%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
}

.card.card-animate {
  animation: cardIn 0.4s ease-out both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Opportunity — 2px green left border */
.opportunity-card { border-left: 2px solid var(--green); }

/* Watch — 2px amber left border */
.watch-card { border-left: 2px solid var(--amber); }

/* Do Not Do — amber left border */
.donot-card { border-left: 2px solid var(--amber); }

/* ── Card internals ───────────────────────────────────────────────────────── */
.card-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.card-label.blue  { color: var(--blue); }
.card-label.green { color: var(--green); }
.card-label.amber { color: var(--amber); }

.card-headline {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}
.card-title.green { color: var(--green); }
.card-title.amber { color: var(--amber); }

.card-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 8px;
}
.card-body.bold {
  color: var(--text-primary);
  font-weight: 500;
}

.card-recommendation {
  font-size: 12.5px;
  line-height: 1.55;
}
.card-recommendation.green { color: var(--green); }
.card-recommendation.amber { color: var(--amber); }
.card-recommendation em    { font-style: italic; }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 13px 0;
}

/* ── Action List ──────────────────────────────────────────────────────────── */
.action-list {
  padding-left: 18px;
  margin-top: 6px;
}
.action-list li {
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 5px;
}
.action-list.green li { color: var(--green); }
.action-list.amber li { color: var(--amber); }

/* ── KPI Strip ────────────────────────────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.kpi-cell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  padding: 7px 8px;
}

.kpi-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.kpi-value.accent-green { color: var(--green); }
.kpi-value.accent-amber { color: var(--amber); }

/* ── Section Header ───────────────────────────────────────────────────────── */
.section-header {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 18px 0 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Impact Ranking ───────────────────────────────────────────────────────── */
.ranking-list {
  display: flex;
  flex-direction: column;
}

.ranking-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.ranking-item:first-child { padding-top: 8px; }
.ranking-item:last-child  { border-bottom: none; padding-bottom: 0; }

.ranking-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.ranking-body    { flex: 1; }
.ranking-play    { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; }
.ranking-why     { font-size: 11.5px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 4px; }
.ranking-result  { font-size: 11.5px; color: var(--blue); margin-bottom: 7px; }
.ranking-meta    { display: flex; align-items: center; gap: 8px; }
.ranking-timeline { font-size: 11px; color: var(--text-muted); }

.effort-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 3px;
  padding: 2px 6px;
  text-transform: uppercase;
}
.effort-badge.effort-low    { background: rgba(74, 222, 128, 0.1); color: var(--green); }
.effort-badge.effort-medium { background: rgba(245, 158, 11, 0.1); color: var(--amber); }
.effort-badge.effort-high   { background: rgba(248, 113, 113, 0.1); color: var(--red); }

/* ── Loading State ────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 240px;
  gap: 14px;
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

.loading-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1); }
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 12px;
}
.empty-icon { font-size: 28px; color: var(--text-muted); }
.empty-text {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.65;
}

/* ── Chat Header ──────────────────────────────────────────────────────────── */
.chat-header {
  padding: 15px 20px 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-title   { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.chat-powered { font-size: 10px; color: var(--text-muted); }

.voice-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.voice-toggle-btn:hover { color: var(--text-secondary); border-color: var(--border-strong); }
.voice-toggle-btn.voice-on {
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(79, 142, 247, 0.45);
}

/* ── Chat Thread ──────────────────────────────────────────────────────────── */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.chat-thread::-webkit-scrollbar       { width: 4px; }
.chat-thread::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 2px; }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.message-lexi {
  align-self: flex-start;
  max-width: 92%;
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 85%;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.65;
}

.bubble-lexi {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 2px 10px 10px 10px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bubble-user {
  background: rgba(79, 142, 247, 0.14);
  border: 1px solid rgba(79, 142, 247, 0.28);
  color: var(--text-primary);
  border-radius: 10px 2px 10px 10px;
}

/* Loading pulse inside bubble */
.loading-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 14px;
}
.loading-bubble .dot { background: var(--text-muted); }

/* Error bubble */
.error-bubble { color: var(--amber); border-color: rgba(245, 158, 11, 0.2); }

/* ── Chat Input Area ──────────────────────────────────────────────────────── */
.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(15, 17, 23, 0.8);
  align-items: center;
}

/* ── Talk Button ──────────────────────────────────────────────────────────── */
.talk-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.talk-btn:hover { color: var(--text-secondary); border-color: var(--border-strong); }
.talk-btn.recording {
  color: var(--red);
  border-color: var(--red);
  animation: recordPulse 0.9s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(248, 113, 113, 0.35); }
  50%       { box-shadow: 0 0 16px rgba(248, 113, 113, 0.7); }
}

/* ── Input wrapper + Listening label ─────────────────────────────────────── */
.chat-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.chat-input-wrap .chat-input {
  width: 100%;
}

.listen-label {
  position: absolute;
  left: 14px;
  font-size: 12px;
  color: var(--red);
  pointer-events: none;
  white-space: nowrap;
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat-input::placeholder        { color: var(--text-muted); }
.chat-input:focus               { border-color: rgba(79, 142, 247, 0.45); background: rgba(255,255,255,0.08); }
.chat-input:disabled            { opacity: 0.45; cursor: not-allowed; }

.chat-send-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}
.chat-send-btn:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.chat-send-btn:active:not(:disabled){ transform: translateY(0); }
.chat-send-btn:disabled             { opacity: 0.4; cursor: not-allowed; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body  { overflow: auto; height: auto; }

  .site-main {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }

  .panel        { height: auto; overflow: visible; }
  .panel-left   { width: 100%; border-right: none; border-bottom: 1px solid var(--panel-divider); padding: 16px; }
  .panel-right  { width: 100%; height: 400px; flex-shrink: 0; overflow: hidden; }

  .kpi-strip    { grid-template-columns: repeat(2, 1fr); }
  .wordmark     { font-size: 17px; }
  .tagline      { display: none; }

  @media (prefers-reduced-motion: reduce) {
    .card.card-animate { animation: none; opacity: 1; }
    .dot               { animation: none; opacity: 0.6; }
  }
}
