:root {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-code: #0f172a;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-inverse: #f8fafc;
  --primary: #2563eb;
  --primary-subtle: #eff6ff;
  --primary-border: #bfdbfe;
  --accent-teal: #0d9488;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 270px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #090d16;
    --bg-surface: #111827;
    --bg-subtle: #1f2937;
    --bg-code: #030712;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-subtle: #6b7280;
    --primary: #3b82f6;
    --primary-subtle: #1e293b;
    --primary-border: #1d4ed8;
    --border: #1f2937;
    --border-strong: #374151;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Banner */
.banner {
  background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
}
.banner .badge {
  background: #f59e0b;
  color: #0f172a;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
}
.banner .pin {
  font-family: var(--font-mono);
  color: #cbd5e1;
  font-size: 0.78rem;
}

/* Layout container */
.layout-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}

/* Sidebar Navigation */
.sidebar {
  position: sticky;
  top: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
}
.sidebar-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
}
.proposal-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.proposal-nav a {
  display: block;
  padding: 0.45rem 0.65rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.proposal-nav a:hover,
.proposal-nav a.active {
  color: var(--primary);
  background: var(--primary-subtle);
  font-weight: 600;
}

/* Main Content */
.main-content {
  min-width: 0;
}

/* Document Header */
.doc-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.doc-header h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-subtle);
  margin-top: 0.75rem;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.meta-chip.strong {
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

/* Section Common */
.section-block {
  margin-bottom: 3.5rem;
  scroll-margin-top: 2rem;
}
.section-block h2 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-block h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 1.5rem 0 0.75rem;
}
.section-block p {
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
}

/* Callout Box */
.callout {
  background: var(--bg-surface);
  border-left: 4px solid var(--primary);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-left-color: var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}
.callout.warning {
  border-left-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.05);
}
.callout-title {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

/* Domain Models Grid */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}
.domain-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.domain-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}
.domain-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}
.module-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--primary-subtle);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--primary-border);
}
.domain-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.domain-card li {
  position: relative;
  padding-left: 1.25rem;
  line-height: 1.5;
}
.domain-card li::before {
  content: "•";
  position: absolute;
  left: 0.25rem;
  color: var(--primary);
  font-weight: bold;
}
.domain-card code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-subtle);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-main);
}

/* Architecture Intent Card */
.intent-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.intent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.intent-name {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}
.intent-details {
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 0.75rem;
  column-gap: 1rem;
  font-size: 0.9rem;
}
.intent-label {
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.15rem;
}
.intent-value {
  color: var(--text-muted);
  line-height: 1.55;
}
.intent-value ul {
  padding-left: 1.25rem;
  margin-top: 0.25rem;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
table.styled-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}
table.styled-table th {
  background: var(--bg-subtle);
  color: var(--text-main);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-strong);
}
table.styled-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}
table.styled-table tbody tr:last-child td {
  border-bottom: none;
}
table.styled-table tbody tr:hover {
  background: var(--primary-subtle);
}

/* Code Blocks */
pre.code-block {
  background: var(--bg-code);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.5;
  border: 1px solid var(--border-strong);
  margin: 1.25rem 0;
}

/* Trade-offs Grid */
.tradeoff-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.tradeoff-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
}
.tradeoff-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.option-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
}
.option-box.selected {
  border-color: var(--accent-teal);
  background: rgba(13, 148, 136, 0.05);
}
.option-tag {
  display: inline-block;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 0.35rem;
  background: var(--border-strong);
  color: var(--text-main);
}
.option-box.selected .option-tag {
  background: var(--accent-teal);
  color: #ffffff;
}
.tradeoff-choice {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-main);
}

/* Responsive */
@media (max-width: 900px) {
  .layout-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1rem;
  }
  .sidebar {
    position: static;
    max-height: none;
  }
  .proposal-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .tradeoff-options {
    grid-template-columns: 1fr;
  }
  .intent-details {
    grid-template-columns: 1fr;
    row-gap: 0.35rem;
  }
}
