/* ============================
   Goldman Facts -- Dark Theme
   Institutional finance aesthetic
   ============================ */

:root {
  --bg: #0B0D11;
  --bg-card: #12141A;
  --bg-card-hover: #1A1C24;
  --border: #252830;
  --primary: #C9A84C;
  --primary-hover: #DCBE6A;
  --accent: #8B7332;
  --text: #F0EDE6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
  --buy: #22C55E;
  --sell: #EF4444;
  --hold: #EAB308;
  --wait: #6B7280;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
}

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

html {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================
   AUTH SCREEN
   ============================ */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-brand {
  margin-bottom: 2.5rem;
}
.auth-brand .brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bg);
  letter-spacing: 0.02em;
}
.auth-brand h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.auth-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
#auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}
.auth-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.auth-field input {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s;
}
.auth-field input::placeholder {
  color: var(--text-muted);
}
.auth-field input:focus {
  border-color: var(--primary);
}
.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--sell);
  font-size: 0.8rem;
  padding: 0.6rem 0.85rem;
  text-align: left;
  line-height: 1.4;
}
.auth-submit {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary);
  border: none;
  color: var(--bg);
  font-weight: 700;
  font-size: 0.88rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.25rem;
}
.auth-submit:hover {
  background: var(--primary-hover);
}
.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-toggle {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.auth-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
}
.auth-link:hover {
  color: var(--primary-hover);
}
.auth-forgot {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
}

/* ============================
   HISTORY PANEL (slide-out)
   ============================ */
.history-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  width: 380px;
  max-width: 90vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.history-panel.open {
  transform: translateX(0);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.history-header h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
}
.history-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: color 0.15s;
}
.history-close:hover {
  color: var(--text);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}
.history-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}
.history-item {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.history-item:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.history-item-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.history-item-tickers {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}
.history-item-ticker {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(201, 168, 76, 0.1);
  padding: 0.15rem 0.4rem;
}
.history-item-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.history-share-btn,
.history-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-family: var(--font-body);
  transition: color 0.15s;
}
.history-share-btn:hover {
  color: var(--primary);
}
.history-delete-btn:hover {
  color: var(--sell);
}
.history-loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ---- APP WRAPPER ---- */
#app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- HEADER ---- */
#header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-mark {
  width: 36px;
  height: 36px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bg);
  letter-spacing: 0.02em;
}
.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: none;
}
@media (min-width: 640px) {
  .brand-sub { display: block; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.header-icon-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.header-icon-btn:hover {
  color: var(--primary);
  border-color: var(--border);
}
.header-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: right;
}
.status-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse-glow 2s ease-in-out infinite;
}
.status-text {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 500;
}
.last-updated {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- TICKER BAR ---- */
#ticker-bar {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.ticker-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.ticker-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}
.ticker-toggle:hover { color: var(--primary); }
.ticker-chevron {
  transition: transform 0.25s ease;
}
#ticker-bar.collapsed .ticker-chevron {
  transform: rotate(-90deg);
}
.ticker-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}
.ticker-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  /* smooth collapse via max-height */
  overflow: hidden;
  max-height: 200px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}
#ticker-bar.collapsed .ticker-content {
  max-height: 0;
  opacity: 0;
  /* remove gap when collapsed so it doesn't take space */
  pointer-events: none;
}
#ticker-pills {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.ticker-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-body);
}
.ticker-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: none;
  transition: color 0.15s;
}
.ticker-remove:hover { color: var(--sell); }
.editing .ticker-remove { display: inline; }

.edit-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.15s;
  flex-shrink: 0;
}
.edit-btn:hover { color: var(--primary); }

.add-controls {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}
.ticker-input {
  width: 7rem;
  padding: 0.3rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-body);
  outline: none;
  text-transform: uppercase;
}
.ticker-input::placeholder { color: var(--text-muted); }
.ticker-input:focus { border-color: var(--primary); }
.add-btn {
  padding: 0.3rem 0.5rem;
  background: var(--primary);
  border: none;
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.add-btn:hover { background: var(--primary-hover); }

/* ---- MAIN ---- */
#main {
  flex: 1;
  padding: 1.5rem;
}
.main-inner {
  max-width: 1200px;
  margin: 0 auto;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.position-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* update button (desktop) */
.update-btn {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  background: var(--primary);
  border: none;
  color: var(--bg);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.update-btn:hover { background: var(--primary-hover); }
.update-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.update-btn .btn-icon { flex-shrink: 0; }
@media (min-width: 640px) {
  .update-btn { display: inline-flex; }
}

.update-btn.loading .btn-icon {
  animation: spin 1s linear infinite;
}

/* card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 1.5rem;
  overflow-x: auto;
}
@media (min-width: 640px) {
  .card { padding: 2rem; }
}

/* empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
}
.empty-mark {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 1rem;
}
.empty-state h2 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.85rem;
  max-width: 28rem;
  line-height: 1.6;
}

/* loading state */
.loading-state { padding: 1rem 0; }
.loading-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.pulse-dot {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse-glow 2s ease-in-out infinite;
  flex-shrink: 0;
  margin-top: 0.2rem;
}
.loading-text {
  font-size: 0.9rem;
  font-weight: 500;
}
.loading-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.5;
}
.skeleton { display: flex; flex-direction: column; gap: 0.75rem; }
.skel-line {
  height: 16px;
  background: var(--bg-card-hover);
  border-radius: 4px;
  animation: shimmer 1.5s ease-in-out infinite;
}
.skel-block {
  height: 80px;
  background: var(--bg-card-hover);
  border-radius: 4px;
  animation: shimmer 1.5s ease-in-out infinite;
}
.w-50 { width: 50%; }
.w-66 { width: 66%; }
.w-80 { width: 80%; }

/* mobile FAB */
.fab {
  display: flex;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  width: 56px;
  height: 56px;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  color: var(--bg);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
  transition: background 0.15s;
}
.fab:hover { background: var(--primary-hover); }
.fab:disabled { opacity: 0.6; cursor: not-allowed; }
.fab.loading svg { animation: spin 1s linear infinite; }
@media (min-width: 640px) {
  .fab { display: none; }
}

/* footer */
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ---- UTILITIES ---- */
.hidden { display: none !important; }

@keyframes pulse-glow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shimmer {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* typing cursor while streaming */
.streaming::after {
  content: "▊";
  color: var(--primary);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}

/* ==============================
   ANALYSIS CONTENT (markdown)
   ============================== */
.analysis-content {
  line-height: 1.7;
  font-size: 0.9rem;
}

.analysis-content h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  letter-spacing: 0.01em;
}
.analysis-content h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.01em;
}
.analysis-content h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--primary);
}
.analysis-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
  color: var(--text-secondary);
}
.analysis-content p {
  margin: 0.5rem 0;
  color: var(--text-secondary);
}
.analysis-content strong {
  color: var(--text);
  font-weight: 700;
}
.analysis-content em {
  color: var(--text-muted);
  font-style: italic;
}
.analysis-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.analysis-content a:hover {
  color: var(--primary-hover);
}
.analysis-content ul,
.analysis-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}
.analysis-content li {
  margin: 0.35rem 0;
  color: var(--text-secondary);
}
.analysis-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
.analysis-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
}
.analysis-content code {
  background: var(--bg-card-hover);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85em;
}
.analysis-content pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 0;
}
.analysis-content pre code {
  background: none;
  padding: 0;
}

/* tables */
.analysis-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.82rem;
}
.analysis-content thead {
  border-bottom: 2px solid var(--primary);
}
.analysis-content th {
  text-align: left;
  padding: 0.65rem 0.75rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-family: var(--font-body);
}
.analysis-content td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.analysis-content tr:hover td {
  background: var(--bg-card-hover);
}

/* make tables horizontally scrollable on mobile */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  -webkit-overflow-scrolling: touch;
}

/* ==============================
   TOC navigation bar
   ============================== */
.report-toc {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 0;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}
.report-toc::-webkit-scrollbar { display: none; }

.toc-item {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.toc-item:hover {
  color: var(--text);
  border-color: var(--primary);
  background: var(--bg-card-hover);
}
.toc-item.active {
  color: var(--bg);
  background: var(--primary);
  border-color: var(--primary);
}

/* ==============================
   Sectioned analysis layout
   ============================== */
.analysis-sections {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* individual section card */
.report-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  transition: border-color 0.2s ease;
  overflow: hidden;
}
.report-section:hover {
  border-left-color: var(--primary);
}
/* Preamble section -- no left accent */
.report-section.preamble {
  border-left: 1px solid var(--border);
}

/* section header (clickable) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}
.section-header:hover {
  background: var(--bg-card-hover);
}
.section-header-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}
.section-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}
.section-header.collapsed .section-chevron {
  transform: rotate(-90deg);
}

/* section body (collapsible) */
.section-body {
  padding: 0 1.5rem 1.25rem;
  /* smooth collapse via grid trick */
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease, padding 0.3s ease;
}
.section-body > .section-body-inner {
  overflow: hidden;
}
.section-body.collapsed {
  grid-template-rows: 0fr;
  padding-top: 0;
  padding-bottom: 0;
}

/* analysis content inside sections */
.section-body .analysis-content {
  line-height: 1.7;
  font-size: 0.9rem;
}

/* ==============================
   Follow-up research button
   ============================== */
.followup-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  min-height: 2.5rem;
}

.followup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.followup-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.2);
}
.followup-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.followup-btn.loading {
  animation: followup-pulse 1.5s ease-in-out infinite;
}

/* shimmer placeholders while haiku is thinking */
.followup-loading-group {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
}
.followup-loading {
  width: 110px;
  height: 32px;
  background: var(--bg-card-hover);
  border-radius: 999px;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes followup-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ==============================
   Deep-dive accordion
   ============================== */
.deep-dive-wrap {
  margin-top: 1rem;
  background: rgba(201, 168, 76, 0.04);
  border: 1px solid rgba(201, 168, 76, 0.15);
  border-left: 3px solid var(--primary);
  overflow: hidden;
  animation: deep-dive-open 0.3s ease;
}

@keyframes deep-dive-open {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 2000px;
  }
}

.deep-dive-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}
.deep-dive-header:hover {
  background: rgba(201, 168, 76, 0.06);
}
.dd-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}
.deep-dive-header.collapsed .dd-chevron {
  transform: rotate(-90deg);
}
.deep-dive-header.collapsed {
  border-bottom-color: transparent;
}
.deep-dive-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--primary);
  flex: 1;
}
.deep-dive-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}
.deep-dive-close:hover {
  color: var(--text);
}

/* collapsible body using grid trick for smooth animation */
.deep-dive-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease;
}
.deep-dive-body > .deep-dive-body-inner {
  overflow: hidden;
}
.deep-dive-body.collapsed {
  grid-template-rows: 0fr;
}

.deep-dive-content {
  padding: 1rem;
  line-height: 1.7;
  font-size: 0.88rem;
}
/* reuse analysis content styles inside deep dive */
.deep-dive-content h1,
.deep-dive-content h2,
.deep-dive-content h3,
.deep-dive-content h4 { font-family: var(--font-heading); }
.deep-dive-content h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.deep-dive-content h3 {
  font-size: 0.95rem;
  margin: 1rem 0 0.4rem;
  color: var(--primary);
}
.deep-dive-content p {
  margin: 0.4rem 0;
  color: var(--text-secondary);
}
.deep-dive-content strong { color: var(--text); font-weight: 700; }
.deep-dive-content em { color: var(--text-muted); }
.deep-dive-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.8rem;
}
.deep-dive-content thead { border-bottom: 2px solid var(--primary); }
.deep-dive-content th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.deep-dive-content td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.deep-dive-content ul, .deep-dive-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}
.deep-dive-content li {
  margin: 0.3rem 0;
  color: var(--text-secondary);
}
.deep-dive-content a { color: var(--primary); text-decoration: underline; }

.deep-dive-loading {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.5rem 0;
}
.deep-dive-loading .pulse-dot {
  margin-top: 0.15rem;
}
.deep-dive-loading span {
  font-weight: 500;
  color: var(--text-secondary);
}
.deep-dive-loading-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.deep-dive-error {
  color: var(--sell);
  font-size: 0.85rem;
}

/* ==============================
   Predictions modal + ticker cards
   ============================== */

/* overlay backdrop */
.predictions-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* modal container */
.predictions-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: 90vw;
  max-width: 640px;
  max-height: 85vh;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.predictions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.predictions-header h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}
.predictions-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: color 0.15s;
}
.predictions-close:hover {
  color: var(--text);
}

.predictions-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

/* legend bar */
.pred-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.pred-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.pred-legend-swatch {
  width: 14px;
  height: 10px;
}
.pred-legend-swatch.win { background: var(--buy); }
.pred-legend-swatch.loss { background: var(--sell); }
.pred-legend-swatch.expired { background: var(--text-muted); }

/* section headers inside modal */
.pred-section-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.pred-section {
  margin-bottom: 1.75rem;
}

/* card grid */
.pred-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

/* individual card */
.pred-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.2s;
}
.pred-card:hover {
  border-color: rgba(201, 168, 76, 0.35);
}

/* card header row: ticker + badge + days */
.pred-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.pred-card-ticker {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.pred-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

/* direction badge */
.pred-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pred-badge-bullish {
  background: rgba(34, 197, 94, 0.12);
  color: var(--buy);
  border: 1px solid rgba(34, 197, 94, 0.25);
}
.pred-badge-bearish {
  background: rgba(239, 68, 68, 0.12);
  color: var(--sell);
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.pred-badge-neutral {
  background: rgba(234, 179, 8, 0.12);
  color: var(--hold);
  border: 1px solid rgba(234, 179, 8, 0.25);
}

/* days left indicator */
.pred-days {
  font-size: 0.68rem;
  font-weight: 600;
}
.pred-days-ok { color: var(--buy); }
.pred-days-warn { color: var(--hold); }
.pred-days-urgent { color: var(--sell); }

/* price levels row */
.pred-levels {
  display: flex;
  gap: 0.75rem;
}
.pred-level {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.pred-level-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pred-level-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

/* history toggle */
.pred-history-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
  width: 100%;
}
.pred-history-toggle:hover {
  color: var(--primary);
}
.pred-history-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.pred-history-toggle.expanded .pred-history-chevron {
  transform: rotate(90deg);
}

/* history container */
.pred-history {
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}
.pred-history.open {
  display: flex;
}

/* history row - single past prediction */
.pred-history-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}
.pred-history-date {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 48px;
}
.pred-history-badge {
  padding: 0.08rem 0.3rem;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}
.pred-history-levels {
  display: flex;
  gap: 0.35rem;
  flex: 1;
}
.pred-history-levels span {
  color: var(--text-secondary);
}
.pred-history-days {
  font-weight: 600;
  flex-shrink: 0;
}

/* delta arrows for history comparison */
.pred-delta-up { color: var(--buy); }
.pred-delta-down { color: var(--sell); }

/* resolved card overlay/badge */
.pred-card.resolved {
  opacity: 0.85;
}
.pred-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pred-result-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pred-result-win {
  background: rgba(34, 197, 94, 0.15);
  color: var(--buy);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.pred-result-loss {
  background: rgba(239, 68, 68, 0.15);
  color: var(--sell);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.pred-result-expired {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.3);
}
.pred-return {
  font-size: 0.82rem;
  font-weight: 700;
}
.pred-return.positive { color: var(--buy); }
.pred-return.negative { color: var(--sell); }

/* stats table */
.pred-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.pred-stats-table thead {
  border-bottom: 2px solid var(--primary);
}
.pred-stats-table th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pred-stats-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* empty state */
.pred-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* mobile: stack cards in 1 column */
@media (max-width: 560px) {
  .predictions-modal {
    width: 95vw;
    max-height: 90vh;
  }
  .predictions-body {
    padding: 1rem;
  }
  .pred-grid {
    grid-template-columns: 1fr;
  }
  .pred-card {
    padding: 0.75rem 0.85rem;
  }
}

/* ==============================
   Share toast
   ============================== */
.share-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  animation: share-toast-in 0.3s ease;
}
.share-toast-inner {
  background: var(--bg-card);
  border: 1px solid var(--primary);
  padding: 0.85rem 1rem;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.share-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.share-toast-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}
.share-toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
}
.share-toast-close:hover { color: var(--text); }
.share-toast-body {
  display: flex;
  gap: 0.4rem;
}
.share-toast-url {
  flex: 1;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: var(--font-body);
  outline: none;
}
.share-toast-copy {
  padding: 0.4rem 0.75rem;
  background: var(--primary);
  border: none;
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
  white-space: nowrap;
}
.share-toast-copy:hover { background: var(--primary-hover); }
@keyframes share-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ==============================
   Quick Analysis bar
   ============================== */
.quick-analyze-bar {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.5rem;
  background: rgba(201, 168, 76, 0.03);
}
.quick-analyze-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.quick-analyze-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.quick-analyze-controls {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.quick-analyze-input {
  width: 8rem;
  padding: 0.3rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-body);
  outline: none;
  text-transform: uppercase;
}
.quick-analyze-input::placeholder { color: var(--text-muted); }
.quick-analyze-input:focus { border-color: var(--primary); }
.quick-analyze-btn {
  padding: 0.3rem 0.7rem;
  background: var(--accent);
  border: none;
  color: var(--bg);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.quick-analyze-btn:hover { background: var(--primary); }
.quick-analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.quick-analyze-btn.loading {
  animation: followup-pulse 1.5s ease-in-out infinite;
}
.quick-analyze-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Quick Analysis section badge inside report */
.qa-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: rgba(139, 115, 50, 0.12);
  border: 1px solid rgba(139, 115, 50, 0.3);
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
  vertical-align: middle;
  font-family: var(--font-body);
}

/* Quick Analysis section card accent */
.report-section.qa-section {
  border-left-color: var(--accent);
}
.report-section.qa-section:hover {
  border-left-color: var(--primary);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 639px) {
  #header { padding: 0.75rem 1rem; }
  #ticker-bar { padding: 0.5rem 1rem; }
  #main { padding: 1rem; }
  .card { padding: 1rem; }
  footer { padding: 0.75rem 1rem; }

  .brand-text h1 { font-size: 1rem; }
  .section-title { font-size: 1rem; }

  .analysis-content h1 { font-size: 1.3rem; }
  .analysis-content h2 { font-size: 1.1rem; }
  .analysis-content h3 { font-size: 0.9rem; }
  .analysis-content { font-size: 0.85rem; }
  .analysis-content table { font-size: 0.78rem; }
  .analysis-content th,
  .analysis-content td { padding: 0.45rem 0.5rem; }

  .section-header { padding: 0.75rem 1rem; }
  .section-header-title { font-size: 0.95rem; }
  .section-body { padding: 0 1rem 1rem; }
  .report-toc { padding: 0.5rem 0; margin-bottom: 0.75rem; }
  .deep-dive-content { padding: 0.75rem; font-size: 0.82rem; }
  .predictions-panel { width: 100%; max-width: 100%; }
  .pred-stats-bar { grid-template-columns: repeat(2, 1fr); }
}
