:root {
  color-scheme: dark;
  --bg: #07111c;
  --panel: rgba(11, 18, 31, 0.9);
  --panel-strong: rgba(13, 22, 37, 0.97);
  --surface: rgba(17, 27, 43, 0.94);
  --surface-strong: rgba(22, 34, 53, 0.98);
  --surface-soft: rgba(24, 37, 58, 0.88);
  --text: #e8eef7;
  --text-soft: #c8d6e8;
  --muted: #9aa9bd;
  --accent: #5aa9ff;
  --accent-strong: #9dc8ff;
  --accent-soft: rgba(90, 169, 255, 0.16);
  --user: rgba(27, 53, 82, 0.96);
  --assistant: rgba(14, 22, 36, 0.96);
  --border: rgba(135, 167, 206, 0.22);
  --warning: #f2c66d;
  --warning-bg: rgba(191, 144, 35, 0.18);
  --danger: #f08f98;
  --danger-bg: rgba(166, 56, 69, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(61, 118, 188, 0.24), transparent 24%),
    radial-gradient(circle at bottom left, rgba(35, 62, 106, 0.28), transparent 30%),
    linear-gradient(160deg, #050b14 0%, #09111c 46%, #07111c 100%);
  color: var(--text);
  font: 16px/1.5 "IBM Plex Sans", "Segoe UI", sans-serif;
}

.shell {
  width: min(1380px, calc(100vw - 24px));
  height: calc(100vh - 24px);
  margin: 12px auto;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
}

.card {
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
}

.sidebar {
  padding: 24px;
  height: 100%;
  overflow: auto;
}

.sidebar h1 {
  margin: 0 0 8px;
  font-size: 1.9rem;
}

.sidebar p {
  color: var(--muted);
  margin: 0 0 18px;
}

.meta {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.meta strong {
  display: block;
  font-size: 0.95rem;
}

.actions form {
  margin-top: 10px;
}

.actions button,
.composer button,
.chip-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.actions button {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #2f8f67);
  color: #041109;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.app-header {
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-strong);
}

.app-header h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

.message-stack {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 96%;
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.message.user {
  align-self: flex-end;
  background: var(--user);
  max-width: 78%;
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
  width: min(980px, 100%);
}

.message.system {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border);
}

.message-text {
  white-space: pre-wrap;
}

.meta-line {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.workspace {
  display: grid;
  gap: 16px;
}

.workspace--stock,
.workspace--compare,
.workspace--market,
.workspace--fundamentals {
  gap: 18px;
}

.workspace-header {
  display: grid;
  gap: 8px;
}

.workspace-header-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.workspace-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.template-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
}

.workspace-summary {
  margin: 0;
  font-size: 1rem;
}

.workspace-bullets {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.context-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.context-pill {
  display: grid;
  gap: 4px;
  min-width: 110px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.context-pill-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.context-pill-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.workspace-hero-grid {
  display: grid;
  gap: 14px;
}

.workspace-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.95fr);
  align-items: start;
}

.workspace-layout--market {
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 0.9fr);
}

.workspace-layout--compare {
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.95fr);
}

.workspace-main,
.workspace-side,
.workspace-grid {
  display: grid;
  gap: 14px;
}

.visual-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.visual-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.visual-card--support {
  padding: 14px 16px;
}

.component-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.stat-tile {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.stat-label {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.snapshot-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}

.snapshot-card h4 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.snapshot-list,
.detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.detail-list li,
.snapshot-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
}

.detail-list strong,
.snapshot-list strong {
  color: var(--muted);
  font-weight: 600;
}

.table-shell {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-strong);
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(135, 167, 206, 0.12);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.data-table th {
  position: sticky;
  top: 0;
  background: rgba(20, 31, 48, 0.98);
  color: var(--text);
}

.tab-row,
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tab-button,
.chip-button {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.88rem;
}

.tab-button.active,
.chip-button:hover,
.chip-button:focus-visible {
  background: var(--accent);
  color: white;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 140px) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.bar-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.bar-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(92, 121, 163, 0.16);
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #3f87d9, #6eb4ff);
}

.bar-fill.negative {
  background: linear-gradient(90deg, #b65c7d, #e18ca3);
}

.bar-value {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}

.series-shell {
  display: grid;
  gap: 12px;
}

.series-svg {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.series-grid-line {
  stroke: rgba(135, 167, 206, 0.18);
  stroke-width: 1;
}

.series-line-a,
.series-line-b {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.series-line-a {
  stroke: #63aefc;
}

.series-line-b {
  stroke: #f2c66d;
}

.series-dot-a,
.series-dot-b {
  stroke: white;
  stroke-width: 2;
}

.series-dot-a {
  fill: #63aefc;
}

.series-dot-b {
  fill: #f2c66d;
}

.series-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--muted);
}

.series-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.legend-swatch-a,
.legend-swatch-b {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-swatch-a {
  background: #1f7a5c;
}

.legend-swatch-b {
  background: #c58728;
}

.compare-bars {
  display: grid;
  gap: 14px;
}

.compare-row {
  display: grid;
  gap: 8px;
}

.compare-row-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
}

.compare-dual {
  display: grid;
  gap: 8px;
}

.compare-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(92, 121, 163, 0.16);
}

.compare-fill-a,
.compare-fill-b {
  height: 100%;
  border-radius: 999px;
}

.compare-fill-a {
  background: linear-gradient(90deg, #3f87d9, #6eb4ff);
}

.compare-fill-b {
  background: linear-gradient(90deg, #7e5f1b, #d4a958);
}

.evidence-strip,
.caveat-strip,
.followup-strip {
  display: grid;
  gap: 10px;
}

.support-stack {
  display: grid;
  gap: 10px;
}

.evidence-items,
.followup-strip .chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.evidence-pill,
.caveat-pill {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

.caveat-pill {
  background: var(--warning-bg);
  color: var(--warning);
}

.data-gap-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(176, 48, 48, 0.12);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.92rem;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 18px 24px 24px;
  background: var(--panel-strong);
  flex: 0 0 auto;
}

.composer textarea {
  width: 100%;
  min-height: 112px;
  max-height: 160px;
  resize: none;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.composer-row {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.composer button {
  background: linear-gradient(135deg, var(--accent), #3ea373);
  color: #041109;
  min-width: 140px;
}

.composer .secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  min-width: 0;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .workspace-layout,
  .workspace-layout--market,
  .workspace-layout--compare {
    grid-template-columns: 1fr;
  }

  .app-main {
    min-height: 72vh;
  }

  .message.user,
  .message.assistant,
  .message.system {
    max-width: 100%;
    width: 100%;
  }

  .workspace-header-top,
  .compare-row-header,
  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}


.assistant-narrative {
  margin-bottom: 14px;
}

body.public-mode .message.assistant {
  background: rgba(12, 18, 29, 0.95);
}

body.public-mode .workspace-title {
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

body.public-mode .context-pill {
  min-width: 0;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(135, 167, 206, 0.18);
}

body.public-mode .context-pill-label {
  font-size: 0.68rem;
}

body.public-mode .workspace-header {
  gap: 12px;
}

body.public-mode .workspace-main,
body.public-mode .workspace-side {
  gap: 16px;
}

body.public-mode .visual-card {
  background: linear-gradient(180deg, rgba(15, 24, 37, 0.92), rgba(12, 19, 30, 0.88));
  border-color: rgba(135, 167, 206, 0.22);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

body.public-mode .visual-card h3 {
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

body.public-mode .table-shell {
  background: rgba(255, 255, 255, 0.025);
  border-radius: 14px;
}

body.public-mode .data-table {
  background: rgba(12, 20, 32, 0.94);
}

body.public-mode .data-table th {
  background: rgba(16, 26, 40, 0.99);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

body.public-mode .data-table td {
  font-size: 0.92rem;
  line-height: 1.45;
}

body.public-mode .visual-card--table-compact .data-table th,
body.public-mode .visual-card--table-compact .data-table td {
  padding: 8px 10px;
}

body.public-mode .snapshot-card {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(135, 167, 206, 0.14);
}

body.public-mode .visual-card--snapshot-cards {
  padding: 18px;
}

body.public-mode .card-grid--story {
  gap: 14px;
}

body.public-mode .snapshot-card--public {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 100%;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(18, 29, 44, 0.94), rgba(12, 19, 31, 0.9));
  border-color: rgba(135, 167, 206, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

body.public-mode .snapshot-card--public::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(110, 180, 255, 0.96), rgba(122, 198, 167, 0.92));
}

body.public-mode .snapshot-card--market::before {
  background: linear-gradient(90deg, rgba(240, 197, 106, 0.94), rgba(110, 180, 255, 0.92));
}

body.public-mode .snapshot-card--lead {
  grid-column: span 2;
}

body.public-mode .snapshot-card-head {
  display: grid;
  gap: 10px;
}

body.public-mode .snapshot-card-title {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

body.public-mode .snapshot-card-hero {
  display: grid;
  gap: 4px;
}

body.public-mode .snapshot-card-hero-value {
  font-size: 1.34rem;
  line-height: 1.05;
  font-weight: 700;
  color: var(--text);
}

body.public-mode .snapshot-card-hero-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

body.public-mode .snapshot-card h4 {
  font-size: 0.9rem;
}

body.public-mode .snapshot-list {
  gap: 8px;
}

body.public-mode .snapshot-list--compact {
  padding-top: 10px;
  border-top: 1px solid rgba(135, 167, 206, 0.1);
}

body.public-mode .snapshot-list li {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(135, 167, 206, 0.08);
}

body.public-mode .snapshot-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

body.public-mode .snapshot-list li strong {
  color: var(--text-soft);
}

body.public-mode .snapshot-list--compact li {
  align-items: flex-start;
  font-size: 0.88rem;
}

body.public-mode .snapshot-list--compact li strong {
  color: var(--muted);
}

body.public-mode .compare-row-header {
  margin-bottom: 10px;
}

body.public-mode .compare-row-header strong {
  font-size: 0.9rem;
}

body.public-mode .compare-row-header span {
  color: var(--text-soft);
}

body.public-mode .bar-label {
  color: var(--text-soft);
}

body.public-mode .series-svg {
  background: rgba(10, 18, 29, 0.98);
}

body.public-mode .followup-strip {
  background: rgba(12, 20, 31, 0.78);
}

body.public-mode .chip-button {
  background: rgba(90, 169, 255, 0.08);
  border-color: rgba(90, 169, 255, 0.2);
  color: var(--accent-strong);
  font-weight: 600;
}

body.public-mode .tab-button {
  background: rgba(255, 255, 255, 0.035);
}

body.public-mode .tab-button.active {
  background: rgba(90, 169, 255, 0.16);
  border-color: rgba(90, 169, 255, 0.3);
}

.message-text--streaming,
.message-text--thinking {
  min-height: 1.6em;
}

.message--thinking {
  background: rgba(12, 21, 33, 0.96);
}

.thinking-shell {
  display: grid;
  gap: 10px;
}

.thinking-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.thinking-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.thinking-dots span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.3;
  animation: askgreyoak-thinking-pulse 1s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

.composer textarea:focus,
button:focus {
  outline: 2px solid rgba(146, 225, 181, 0.38);
  outline-offset: 2px;
}

.composer button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.message-stack::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
  width: 10px;
}

.message-stack::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(146, 225, 181, 0.2);
  border-radius: 999px;
}

@keyframes askgreyoak-thinking-pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.26;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 880px) {
  body.public-mode .snapshot-card--lead {
    grid-column: auto;
  }
}
