/* ===== Design Tokens ===== */
:root {
  /* Backgrounds -- three clearly distinct levels */
  --bg:          #0c1220;   /* page background */
  --surface:     #14213d;   /* panels, cards */
  --surface-2:   #1a2b4a;   /* raised elements, hover */
  --surface-3:   #1f3158;   /* highly elevated, active */

  /* Borders */
  --border:       #243654;
  --border-bright:#2e4670;

  /* Text */
  --text:         #f0f4ff;   /* primary */
  --text-heading: #c9a96e;   /* headings - warm gold for visual hierarchy */
  --text-soft:    #b8ccec;   /* secondary */
  --text-dim:     #6e8aad;   /* muted */

  /* Accent */
  --accent:       #5b8dd9;
  --accent-hover: #7aa6e8;
  --accent-glow:  rgba(91, 141, 217, 0.12);

  /* Status */
  --success:      #4caf7d;
  --warning:      #e09a44;

  /* Layout */
  --topbar-h:    56px;
  --sidenav-w:   200px;
  --rail-w:      360px;
  --content-pad: 48px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

/* ===== Topbar ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 8px;
  letter-spacing: 0;
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidenav-w) 1fr var(--rail-w);
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

/* ===== Side Nav ===== */
.side-nav {
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text-soft);
  width: 100%;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.nav-card:hover {
  border-color: var(--border-bright);
  background: var(--surface-2);
  color: var(--text);
}

.nav-card.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

.nav-card-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}

/* ===== Content Panel ===== */
.content-panel {
  overflow-y: auto;
  padding: var(--content-pad);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.content-panel::-webkit-scrollbar { width: 6px; }
.content-panel::-webkit-scrollbar-track { background: transparent; }
.content-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===== Prose (page content) ===== */
.prose {
  max-width: none;
}

.prose > p,
.prose > h1,
.prose > h2,
.prose > h3,
.prose > h4,
.prose > ul,
.prose > ol,
.prose > .page-subtitle {
  max-width: 680px;
}

.prose h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 10px;
}

.prose .page-subtitle {
  font-size: 1.05rem;
  color: var(--text-soft);
  margin-bottom: 40px;
  line-height: 1.5;
}

.prose h2 {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 24px 0 8px;
}

.prose p {
  color: var(--text);
  margin-bottom: 16px;
}

.prose p strong {
  color: var(--text);
  font-weight: 600;
}

.prose ul, .prose ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.prose li {
  color: var(--text);
  margin-bottom: 6px;
}

.prose a {
  color: var(--accent);
  text-decoration: none;
}

.prose a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.prose code {
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 20px 0 32px;
}

.card-grid--single {
  grid-template-columns: 1fr;
  max-width: 420px;
  gap: 8px;
}

.card-grid--2col {
  grid-template-columns: repeat(2, 360px);
  justify-content: start;
  gap: 16px;
}

.section-row {
  display: grid;
  grid-template-columns: repeat(2, 360px);
  justify-content: start;
  gap: 48px;
  margin: 0 0 32px;
}

.section-col > h2 {
  margin-top: 0;
}

.card-grid--3col {
  grid-template-columns: repeat(3, 360px);
  justify-content: start;
  gap: 16px;
}

.card-grid.card-grid--full {
  grid-template-columns: 1fr;
  gap: 16px;
}

.card-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.55;
}

.card-step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover {
  border-color: var(--border-bright);
  background: var(--surface-2);
}

.card-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.card-title {
  font-size: 1.01rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 8px;
  line-height: 1.3;
}

.card-title--divided {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card-body {
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.55;
}

.card-meta {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.badge-green {
  background: rgba(76, 175, 125, 0.15);
  color: var(--success);
}

.badge-blue {
  background: var(--accent-glow);
  color: var(--accent);
}

.badge-amber {
  background: rgba(224, 154, 68, 0.15);
  color: var(--warning);
}

/* ===== Callout boxes ===== */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 24px 0;
}

.callout p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.callout strong {
  color: var(--text);
}

/* Skeleton / coming-soon state */
.skeleton-section {
  background: var(--surface);
  border: 1px dashed var(--border-bright);
  border-radius: 10px;
  padding: 40px 32px;
  text-align: center;
  margin: 24px 0;
}

.skeleton-section p {
  color: var(--text-dim);
  font-size: 0.92rem;
  margin: 0;
}

/* ===== Chat Rail ===== */
.chat-rail {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-rail-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-rail-title {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.chat-rail-note {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ===== Chat Log ===== */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.chat-message {
  font-size: 0.875rem;
  line-height: 1.6;
  max-width: 100%;
}

.chat-message-you {
  align-self: flex-end;
  background: var(--surface-3);
  border: 1px solid var(--border-bright);
  border-radius: 12px 12px 3px 12px;
  padding: 9px 13px;
  color: var(--text);
}

.chat-author {
  display: none;
}

.chat-message-proposalguide,
.chat-message-emissary {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px 12px 12px 12px;
  padding: 9px 13px;
  color: var(--text);
  white-space: pre-wrap;
}

.chat-message-thinking {
  align-self: flex-start;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.82rem;
  padding: 4px 0;
}

/* ===== Chat Form ===== */
.chat-form {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
  transition: border-color 0.15s;
}

#chat-input::placeholder {
  color: var(--text-dim);
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

#chat-submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

#chat-submit:hover {
  background: var(--accent-hover);
}

#chat-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Differentiator List (inside card) ===== */
.card-diff-list {
  list-style: disc;
  padding-left: 18px;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-diff-list li {
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.55;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card-diff-list li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.card-diff-list li strong {
  display: block;
  color: var(--text);
}

/* ===== Comparison Table ===== */
.comparison-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 560px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 20px 0 32px;
}

.comparison-header {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.comparison-header--other {
  background: rgba(224, 154, 68, 0.08);
  color: var(--warning);
}

.comparison-header--emissary {
  background: rgba(76, 175, 125, 0.08);
  color: var(--success);
  border-left: 1px solid var(--border);
}

.comparison-item {
  padding: 10px 16px;
  font-size: 0.82rem;
  line-height: 1.45;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.comparison-item:nth-last-child(-n+2) {
  border-bottom: none;
}

.comparison-item--other {
  color: var(--warning);
}

.comparison-item--emissary {
  color: var(--success);
  border-left: 1px solid var(--border);
}

/* ===== Utilities ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  :root { --rail-w: 300px; --sidenav-w: 170px; --content-pad: 32px; }
}

@media (max-width: 800px) {
  :root { --sidenav-w: 140px; --content-pad: 20px; }
}

@media (max-width: 680px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .side-nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .nav-card { white-space: nowrap; flex-shrink: 0; }
  .chat-rail {
    border-left: none;
    border-top: 1px solid var(--border);
    height: 320px;
  }
}
