/* ===== Design Tokens ===== */
:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --ink: #1a1f2b;
  --ink-secondary: #4b5563;
  --muted: #6b7280;
  --line: #e2e5ea;
  --line-light: #f0f1f4;
  --accent: #0f766e;
  --accent-light: #f0fdfa;
  --accent-hover: #0d635c;
  --accent-subtle: #ccfbf1;
  --danger: #dc2626;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* ===== Reset and Base ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Top Navigation Bar ===== */
.topbar {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}

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

.brand-sub {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 0.75rem;
}

#page-nav {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

#page-nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
  white-space: nowrap;
}

#page-nav button:hover {
  background: var(--line-light);
  color: var(--ink);
}

#page-nav button.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--accent-subtle);
}

/* Step progress indicator */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: max-content;
}

.step-indicator .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.step-indicator .dot.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* ===== Main Layout ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
}

/* ===== Content Panel ===== */
.content-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  min-height: 75vh;
  box-shadow: var(--shadow-sm);
}

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

.content-fade-in {
  animation: fadeIn 0.18s ease-out;
}

/* ===== Right Rail ===== */
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.panel-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

/* ===== Prose / Page Content ===== */
.prose h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  line-height: 1.25;
  color: var(--ink);
}

.prose h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line-light);
  color: var(--ink);
}

.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.35rem;
  color: var(--ink-secondary);
}

.prose p {
  margin: 0.5rem 0 1rem;
  line-height: 1.65;
  color: var(--ink-secondary);
}

.prose ul {
  margin: 0.5rem 0 1.25rem;
  padding-left: 1.25rem;
}

.prose li {
  line-height: 1.6;
  margin-bottom: 0.35rem;
  color: var(--ink-secondary);
}

.prose li::marker {
  color: var(--accent);
}

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

/* Hero treatment for Overview page */
.prose .hero {
  margin: -0.5rem 0 0.25rem;
}

.prose .hero h1 {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.prose .hero-subtitle {
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 400;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-light);
}

/* CTA section rendered from markdown */
.prose .cta-block {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--accent-light);
  border: 1px solid var(--accent-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--accent);
}

.prose .cta-block p {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.prose .cta-block.cta-clickable {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.prose .cta-block.cta-clickable:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.prose .cta-block.cta-clickable::after {
  content: "\2192";
  float: right;
  font-size: 1.1rem;
  color: var(--accent);
  margin-top: -1.4rem;
}

/* Comparison cards rendered from markdown */
.prose .option-card {
  margin: 0.75rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prose .option-card:hover {
  border-color: var(--accent-subtle);
  box-shadow: var(--shadow-md);
}

.prose .option-card.recommended {
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
}

.prose .option-label {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}

.prose .option-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* Ordered list styling for numbered steps */
.prose ol {
  margin: 0.5rem 0 1.25rem;
  padding-left: 1.5rem;
  counter-reset: step-counter;
}

.prose ol li {
  line-height: 1.6;
  margin-bottom: 0.5rem;
  color: var(--ink-secondary);
}

.prose ol li::marker {
  color: var(--accent);
  font-weight: 700;
}

/* Timeline items for "How the Pilot Works" */
.prose .timeline-item {
  position: relative;
  padding: 0.75rem 1rem 0.75rem 1.5rem;
  margin: 0.5rem 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
}

.prose .timeline-label {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.prose .timeline-desc {
  color: var(--ink-secondary);
  font-size: 0.93rem;
}

/* FAQ accordion */
.prose details {
  margin: 0.5rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.prose details + details {
  margin-top: 0.375rem;
}

.prose summary {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.1s ease;
  list-style: none;
}

.prose summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.15s ease;
  color: var(--accent);
}

.prose details[open] summary::before {
  transform: rotate(90deg);
}

.prose summary:hover {
  background: var(--accent-light);
}

.prose details .faq-answer {
  padding: 0.5rem 1rem 0.85rem;
  color: var(--ink-secondary);
  line-height: 1.6;
  font-size: 0.93rem;
}

/* Horizontal rule */
.prose hr {
  border: none;
  border-top: 1px solid var(--line-light);
  margin: 1.5rem 0;
}

/* ===== Source Drawer ===== */
#source-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

#source-list li {
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line-light);
  transition: border-color 0.15s ease;
}

#source-list li:hover {
  border-color: var(--accent-subtle);
}

.source-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.source-meta {
  color: var(--muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  line-height: 1.4;
  word-break: break-all;
}

.source-scope-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.source-scope-badge.scope-page {
  background: var(--accent-light);
  color: var(--accent);
}

.source-scope-badge.scope-shared-core {
  background: #fef3c7;
  color: #92400e;
}

/* Source excerpts section */
#source-drawer details {
  margin-top: 0.5rem;
  border: none;
}

#source-drawer summary {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 0.35rem 0;
  background: none;
  list-style: none;
}

#source-drawer summary::before {
  content: "\25B8";
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 0.15s ease;
  color: var(--accent);
  font-size: 0.7rem;
}

#source-drawer details[open] summary::before {
  transform: rotate(90deg);
}

#source-excerpts {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ===== Chatbot Panel ===== */
#chatbot-panel {
  display: flex;
  flex-direction: column;
}

#chat-log {
  min-height: 140px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  margin-bottom: 0.65rem;
  background: var(--bg);
  font-size: 0.875rem;
}

.chat-message {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 95%;
}

.chat-message-you {
  background: var(--accent-light);
  border: 1px solid var(--accent-subtle);
  color: var(--ink);
  margin-left: auto;
  text-align: right;
}

.chat-message-proposalguide {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-secondary);
}

.chat-message-system {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.25rem 0.5rem;
  font-style: italic;
  max-width: 100%;
}

.chat-author {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
  color: var(--muted);
}

.chat-message-you .chat-author {
  color: var(--accent);
}

/* Chat input area */
.chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
  min-height: 40px;
  transition: border-color 0.15s ease;
}

#chat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

#chat-form button[type="submit"] {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s ease;
  height: 40px;
}

#chat-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

#chat-form button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--muted);
}

/* ===== Accessibility ===== */
.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;
}

/* ===== Home Page ===== */
.prose .home-intro {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-secondary);
  margin-bottom: 1.5rem;
}

/* ===== Section Anchors (AI Workflows page) ===== */
.section-anchor {
  scroll-margin-top: 72px;
}

.prose .section-divider {
  border: none;
  border-top: 2px solid var(--line);
  margin: 2.5rem 0 2rem;
}

/* ===== Toolkit Page ===== */
.prose .prompt-block {
  background: var(--bg);
  border: 1px solid var(--line-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.prose code {
  background: var(--bg);
  border: 1px solid var(--line-light);
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  font-size: 0.85em;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ===== Sub-navigation for AI Workflows page ===== */
.section-subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-light);
}

.section-subnav a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-secondary);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}

.section-subnav a:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-subtle);
}

/* ===== No-rail layout for pages without source drawer ===== */
.layout.no-rail {
  grid-template-columns: minmax(0, 1fr);
  max-width: 900px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .right-rail {
    position: static;
    max-height: none;
  }

  .content-panel {
    padding: 1.5rem 1.25rem;
  }

  .topbar {
    padding: 0 1rem;
    gap: 0.75rem;
  }

  .brand-sub {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    height: auto;
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  #page-nav {
    width: 100%;
    justify-content: center;
  }

  #page-nav button {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
  }

  .content-panel {
    padding: 1.25rem 1rem;
  }

  .prose h1 {
    font-size: 1.4rem;
  }
}

/* ===== Scrollbar styling (Webkit) ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
