:root {
  --paper: #F5F3EE;
  --paper-warm: #EFEBE0;
  --teal-dark: #356259;
  --teal: #36AE6C;
  --green: #46A84F;
  --green-light: #9EBC83;
  --green-mid: #80BDBD;
  --olive: #B1BE4D;
  --sage: #657A4E;
  --transfer: #458484;
  --integration: #C18F59;
  --slate: #465555;
  --slate-light: #6C7A7A;
  --gray: #6C6C6C;
  --gray-light: #F5F5F5;
  --line: #DCD7CC;
  --line-soft: #E7E3D8;
  --ink: #1A1A1A;
  --shadow-card: 0 1px 2px rgba(54, 80, 75, 0.04), 0 6px 18px rgba(54, 80, 75, 0.08);
  --shadow-drawer: -16px 0 48px rgba(54, 80, 75, 0.10);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --serif: "DM Serif Display", "Source Serif Pro", Georgia, serif;
  --sans: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Spacing scale (4pt base) — used by responsive + new layout rules */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 22px;
  --space-6: 28px;
  --space-8: 40px;
  --space-10: 60px;

  /* Layout rails */
  --legend-w: 240px;
  --filters-w: 280px;
  --drawer-w: 460px;
  --gutter: 28px;
  --gutter-tight: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--slate);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; color: var(--teal-dark); margin: 0; line-height: 1.15; }
button { font-family: inherit; }
::selection { background: rgba(53, 98, 89, 0.18); }

/* ---------- App shell ---------- */

#root { min-height: 100%; }
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- Top bar ---------- */

.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: flex; }
.brand-eyebrow {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 500;
}
.brand-title { font-family: var(--serif); font-size: 19px; color: var(--teal-dark); line-height: 1.1; }
.tabs { display: flex; gap: 4px; padding: 4px; background: rgba(53, 98, 89, 0.06); border-radius: 999px; }
.tab {
  border: 0; background: transparent; padding: 8px 18px; cursor: pointer;
  border-radius: 999px; color: var(--slate); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--teal-dark); }
.tab.is-active { background: var(--paper); color: var(--teal-dark); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.top-right { display: flex; flex-direction: column; align-items: flex-end; }
.top-meta { font-size: 14px; font-weight: 500; color: var(--slate-light); font-style: italic; white-space: nowrap; text-align: right; }

/* ---------- Concept page ---------- */

.concept-page { flex: 1; display: flex; min-height: 0; position: relative; }

/* Drawer layout */
.layout-drawer .concept-stage {
  flex: 1; display: grid; grid-template-columns: var(--legend-w) 1fr;
  transition: padding-right .35s ease;
}
.layout-drawer.drawer-open .concept-stage { padding-right: var(--drawer-w); }

.diagram-wrap {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: safe center;
  padding: 16px 28px 40px;
  min-width: 0;
}
.diagram-headline {
  text-align: center; max-width: 560px; margin: 8px auto 4px;
}
.diagram-headline h1 { font-size: 30px; margin-bottom: 6px; }
.diagram-headline p { color: var(--slate-light); font-size: 14.5px; margin: 0; }
.concept-svg {
  width: min(720px, 100%); aspect-ratio: 1/1; display: block;
  margin-top: 4px;
}

.diagram-stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Ring hit areas — invisible but interactive */
.ring-hits path { pointer-events: all; transition: fill-opacity .2s; }
.ring-hits path:hover { fill-opacity: 0.02; }

/* Context layer tooltip — overlays the diagram, top-right corner */
.context-tooltip {
  position: absolute;
  top: 12px; right: 12px;
  width: 280px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-card);
  pointer-events: none;
  z-index: 10;
  animation: tooltipIn .18s ease-out;
}
@keyframes tooltipIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ct-eyebrow {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600;
}
.ct-title {
  font-family: var(--serif); font-size: 18px; color: var(--teal-dark);
  margin: 4px 0 8px; line-height: 1.2;
}
.ct-short { color: var(--slate); font-size: 13px; margin: 0 0 12px; line-height: 1.45; }
.ct-section {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin-bottom: 6px;
}
.ct-members { margin: 0; padding-left: 18px; }
.ct-members li { font-size: 13px; color: var(--slate); margin-bottom: 2px; }

/* Legend hover hint + interactive context rows */
.legend-hint {
  font-size: 9.5px; letter-spacing: 0; text-transform: none;
  color: var(--slate-light); font-weight: 400; font-style: italic;
  margin-left: 8px;
}
.context-row {
  cursor: help;
  padding: 4px 8px; margin-left: -8px;
  border-radius: 6px;
  transition: background .12s;
}
.context-row.is-hovered {
  background: rgba(53, 98, 89, 0.08);
  color: var(--teal-dark);
}

/* Phase arc segments */
.phase-arc .phase-arc-fill { transition: filter .2s; }
.phase-arc:hover .phase-arc-fill { filter: brightness(1.1) saturate(1.08); }
.phase-arc.is-selected .phase-arc-fill { filter: brightness(1.05); }
.phase-arc text { user-select: none; }

/* Phase nodes hover (legacy, kept for compatibility) */
.phase-node circle { transition: transform .2s, filter .2s, opacity .2s; transform-origin: center; transform-box: fill-box; }
.phase-node:hover circle:first-of-type { filter: brightness(1.08); }
.phase-node text { user-select: none; pointer-events: none; }
.actor-marker text { user-select: none; }

/* ---------- Legend ---------- */

.legend {
  border-right: 1px solid var(--line);
  padding: 22px 22px 22px 28px;
  font-size: 13px;
  background: var(--paper);
}
.legend-section { margin-bottom: 22px; }
.legend-title {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin-bottom: 10px;
}
.legend ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.legend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; margin-left: -8px; border-radius: 6px; cursor: pointer;
  transition: background .12s;
}
.legend-row:hover { background: rgba(53, 98, 89, 0.06); }
.legend-row.is-active { background: rgba(53, 98, 89, 0.10); color: var(--teal-dark); font-weight: 500; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.context-list li { display: flex; align-items: center; gap: 10px; padding: 4px 0; color: var(--slate); }
.ring-swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(53, 98, 89, 0.3); }
.ring-swatch.outer { background: rgba(53, 98, 89, 0.05); }
.ring-swatch.mid   { background: rgba(53, 98, 89, 0.10); }
.ring-swatch.inner { background: rgba(53, 98, 89, 0.18); }
.dash-swatch {
  width: 14px; height: 0; flex-shrink: 0;
  border-top: 1.3px dashed rgba(53, 98, 89, 0.55);
}
.dot-swatch {
  width: 14px; height: 0; flex-shrink: 0;
  border-top: 1.5px dotted rgba(53, 98, 89, 0.7);
}

/* ---------- Phase drawer ---------- */

.phase-drawer {
  position: fixed; top: 64px; bottom: 0; right: 0; width: var(--drawer-w);
  background: #FFFFFF;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-drawer);
  display: flex; flex-direction: column;
  z-index: 15;
  animation: slideInRight .35s cubic-bezier(.2,.7,.2,1);
}
@keyframes slideInRight {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.drawer-head {
  padding: 28px 28px 20px;
  border-top: 4px solid var(--teal-dark);
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.drawer-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600;
}
.phase-pip { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.phase-pip.lg { width: 9px; height: 9px; }
.drawer-title { font-size: 28px; margin: 8px 0 6px; color: var(--teal-dark); }
.drawer-short { color: var(--slate); font-size: 15px; margin: 0; font-style: italic; }
.drawer-close {
  position: absolute; top: 18px; right: 18px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  color: var(--slate); cursor: pointer; font-size: 22px; line-height: 1; padding: 0;
  transition: background .15s, color .15s;
}
.drawer-close:hover { background: var(--gray-light); color: var(--ink); }
.drawer-body { padding: 22px 28px 32px; overflow-y: auto; flex: 1; }
.drawer-desc { color: var(--slate); margin: 0 0 22px; font-size: 14.5px; }
.drawer-section-head {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin: 18px 0 10px;
  display: flex; align-items: center; gap: 8px;
}
.drawer-section-head .count {
  font-size: 10.5px; color: var(--slate-light); font-weight: 500;
  background: var(--gray-light); border-radius: 999px; padding: 2px 8px;
  letter-spacing: 0;
}
.drawer-objectives { margin: 0 0 6px; padding-left: 18px; }
.drawer-objectives li { margin-bottom: 6px; color: var(--slate); font-size: 14px; }

.method-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.method-item {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.method-item:hover { border-color: var(--teal-dark); background: #FFFFFF; }
.method-item-name { font-weight: 500; color: var(--ink); font-size: 14.5px; margin-bottom: 4px; }
.method-item-blurb { color: var(--slate-light); font-size: 12.5px; line-height: 1.45; }
.method-item-meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.method-chevron { color: var(--slate-light); font-size: 20px; line-height: 1; }

.chip {
  display: inline-flex; align-items: center;
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  font-weight: 500; white-space: nowrap;
}
.chip-effort.effort-low    { background: rgba(70, 168, 79, 0.12);  color: #2D6A4F; }
.chip-effort.effort-medium { background: rgba(177, 190, 77, 0.20); color: #6E7A2A; }
.chip-effort.effort-high   { background: rgba(193, 143, 89, 0.20); color: #8A5A2C; }
.chip-skill { background: rgba(70, 85, 85, 0.08); color: var(--slate); }

/* ---------- Method detail ---------- */

.md-overlay {
  position: fixed; inset: 0; background: rgba(22, 37, 32, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 40px; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.md-modal {
  background: var(--paper);
  border-radius: var(--radius-lg);
  max-width: 680px; width: 100%;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(22, 37, 32, 0.35);
  animation: modalIn .25s cubic-bezier(.2,.7,.2,1);
}
@keyframes modalIn {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0)    scale(1);   opacity: 1; }
}

.md-sheet-overlay {
  position: fixed; inset: 0; background: rgba(22, 37, 32, 0.30);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 50; animation: fadeIn .2s ease;
}
.md-sheet {
  background: var(--paper);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  width: 100%; max-width: 1100px;
  max-height: 75vh; overflow-y: auto;
  box-shadow: 0 -16px 48px rgba(22, 37, 32, 0.20);
  animation: sheetUp .3s cubic-bezier(.2,.7,.2,1);
  position: relative;
  padding-top: 10px;
}
@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.md-sheet-grabber {
  width: 44px; height: 5px; border-radius: 3px; background: var(--line);
  margin: 6px auto 0;
}

.method-detail { padding: 28px 32px 32px; }
.method-detail.variant-inline {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.md-head { position: relative; margin-bottom: 18px; padding-right: 40px; }
.md-eyebrow {
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600;
}
.md-title { font-size: 26px; margin: 6px 0 0; color: var(--teal-dark); }
.md-close {
  position: absolute; top: -2px; right: -4px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent;
  cursor: pointer; font-size: 22px; line-height: 1; padding: 0; color: var(--slate);
}
.md-close:hover { background: var(--gray-light); }
.md-blurb { color: var(--slate); font-size: 15px; margin: 0 0 22px; }

.md-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 24px;
  padding: 16px;
  background: rgba(53, 98, 89, 0.04);
  border-radius: var(--radius-md);
}
.md-stat-label {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin-bottom: 4px;
}
.md-stat-val { font-size: 14px; color: var(--ink); font-weight: 500; }
.md-stat-val.effort-low    { color: #2D6A4F; }
.md-stat-val.effort-medium { color: #6E7A2A; }
.md-stat-val.effort-high   { color: #8A5A2C; }

.md-section-head {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin: 18px 0 8px;
}
.md-when { color: var(--slate); font-size: 14px; margin: 0 0 6px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.phase-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: #FFFFFF; border: 1px solid currentColor;
  font-weight: 500;
}
.actor-chip {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(70, 85, 85, 0.08); color: var(--slate);
}

.md-refs {
  list-style: none; margin: 0; padding: 0;
  font-family: var(--sans); font-size: 13px; line-height: 1.5;
  color: var(--slate);
}
.md-refs li { padding-left: 18px; text-indent: -18px; margin-bottom: 8px; }
.md-refs li:last-child { margin-bottom: 0; }
.md-refs a { color: var(--teal-dark); text-decoration: none; }
.md-refs a:hover { color: var(--teal); text-decoration: underline; }

/* ---------- Method grid / cards (below diagram & in library) ---------- */

.below-top {
  display: grid; grid-template-columns: 240px 1fr 380px;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
}
.layout-below .legend { border-right: 1px solid var(--line); }
.layout-below .diagram-wrap { padding-bottom: 24px; }

.phase-summary {
  padding: 28px 26px;
  border-left: 1px solid var(--line);
  background: var(--paper);
  overflow-y: auto;
}
.ps-eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600;
}
.phase-summary h2 { font-size: 24px; margin: 8px 0 4px; }
.ps-short { font-style: italic; color: var(--slate); margin: 0 0 14px; font-size: 14.5px; }
.ps-desc  { color: var(--slate); margin: 0 0 16px; font-size: 13.5px; }
.ps-section-head {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin: 6px 0 8px;
}
.phase-summary ul { margin: 0 0 16px; padding-left: 18px; }
.phase-summary li { color: var(--slate); font-size: 13.5px; margin-bottom: 4px; }
.ps-clear {
  background: transparent; border: 1px solid var(--line); padding: 7px 14px;
  border-radius: 999px; color: var(--teal-dark); cursor: pointer; font-size: 12.5px;
}
.ps-clear:hover { background: var(--gray-light); }

.below-grid {
  padding: 28px 36px 60px;
  background: var(--paper-warm);
}
.below-grid-head {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px;
}
.below-grid-head h2 { font-size: 22px; }
.grid-count { color: var(--slate-light); font-size: 13px; }

.method-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.method-card {
  background: #FFFFFF;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s, opacity .2s;
  display: flex; flex-direction: column; gap: 10px;
}
.method-card:hover {
  border-color: var(--teal-dark);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.method-card.is-expanded { border-color: var(--teal-dark); box-shadow: var(--shadow-card); }
.method-card.is-dim { opacity: 0.4; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-name { font-family: var(--serif); font-size: 17px; color: var(--teal-dark); line-height: 1.2; }
.card-chevron { color: var(--slate-light); font-size: 18px; }
.card-blurb { color: var(--slate); font-size: 13px; margin: 0; flex: 1; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.card-phase-dots { display: flex; gap: 3px; margin-left: auto; }

.inline-detail-host { margin-top: 4px; }

/* ---------- Method library page ---------- */

.library { flex: 1; display: grid; grid-template-columns: var(--filters-w) 1fr; min-height: 0; }
.library-filters {
  border-right: 1px solid var(--line);
  padding: 24px 22px 32px 28px;
  overflow-y: auto;
  background: var(--paper);
}
.filters-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.filters-head h2 { font-size: 18px; color: var(--teal-dark); }
.clear-all {
  background: transparent; border: 0; color: var(--teal-dark);
  cursor: pointer; font-size: 12px; text-decoration: underline;
}
.filter-group { margin-bottom: 20px; }
.filter-label {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 600; margin-bottom: 10px; display: block;
}
.filter-input {
  width: 100%; padding: 9px 12px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 13px; color: var(--ink);
}
.filter-input:focus { outline: none; border-color: var(--teal-dark); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #FFFFFF; border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px;
  font-size: 12px; color: var(--slate); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.filter-chip:hover { border-color: var(--teal-dark); color: var(--teal-dark); }
.filter-chip.is-active { background: var(--teal-dark); color: #FFFFFF; border-color: var(--teal-dark); }
.filter-chip.is-active .phase-pip { box-shadow: 0 0 0 1.5px #FFFFFF; }

.library-results {
  padding: 28px 36px 60px;
  overflow-y: auto;
  background: var(--paper-warm);
}
.results-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 22px;
}
.results-head h1 { font-size: 28px; }
.results-count { color: var(--slate-light); font-size: 14px; }
.empty-state {
  padding: 60px 20px; text-align: center; color: var(--slate-light);
  background: #FFFFFF; border: 1px dashed var(--line); border-radius: var(--radius-md);
}

/* ---------- Brand logo ---------- */
.brand-logo { height: 32px; width: auto; display: block; }

/* ---------- Authorship line (top-right, beneath tagline) ---------- */
.top-authorship {
  font-size: 11.5px; color: var(--slate-light); text-align: right;
  margin-top: 2px; white-space: nowrap;
}
.top-authorship a {
  color: var(--slate-light);
  text-decoration: underline;
  text-decoration-color: var(--line);
  transition: color .15s, text-decoration-color .15s;
}
.top-authorship a:hover { color: var(--teal-dark); text-decoration-color: var(--teal-dark); }

/* ---------- Draft state ---------- */

.method-card.is-draft { opacity: 0.52; filter: grayscale(30%); }
.method-card.is-draft:hover { opacity: 0.78; filter: grayscale(15%); }
.method-item.is-draft { opacity: 0.52; filter: grayscale(30%); }
.method-item.is-draft:hover { opacity: 0.78; filter: grayscale(15%); }

.draft-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: rgba(108, 122, 122, 0.12); color: var(--slate-light);
  font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line);
}

/* ---------- Content-load error state ---------- */
.content-error {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px; background: var(--paper);
}
.content-error-box { max-width: 520px; text-align: center; }
.ce-icon { font-size: 36px; margin-bottom: 12px; }
.ce-message {
  font-family: monospace; font-size: 13px; color: var(--slate);
  background: rgba(0,0,0,0.05); border-radius: 6px;
  padding: 12px 16px; margin: 12px 0; text-align: left; white-space: pre-wrap;
}
.ce-hint { font-size: 13px; color: var(--slate-light); }
.ce-hint code {
  font-family: monospace; background: rgba(0,0,0,0.05);
  padding: 2px 5px; border-radius: 3px;
}

/* ---------- Page footer (bottom-right attribution) ---------- */
/* In normal flow as the last child of .app: pinned to the bottom by the
   flex:1 page region above it, so it never overlaps scrolling content. */
.page-footer {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line-soft);
}
.page-footer-label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--slate-light); font-weight: 500;
}
.page-footer-link { pointer-events: auto; display: block; }
.page-footer-logo { width: 188px; height: auto; display: block; opacity: 0.82; transition: opacity .15s; }
.page-footer-link:hover .page-footer-logo { opacity: 1; }

/* ---------- Loading placeholder ---------- */
.loading-msg {
  text-align: center; padding: 100px 20px;
  color: var(--slate-light); font-size: 14px; font-family: var(--sans);
}

/* ======================================================================
   Responsive — the two-column views collapse structurally below desktop.
   Breakpoints: lg 1024  ·  md 768  ·  sm 560
   ====================================================================== */

/* ---- Tablet and down: collapse both rails to a single column ---- */
@media (max-width: 1023px) {

  /* Top bar: drop the secondary tagline column, keep brand + tabs */
  .top-bar {
    grid-template-columns: auto 1fr;
    gap: var(--space-4);
    padding: var(--space-3) var(--gutter);
  }
  .top-right { display: none; }
  .tabs { justify-self: end; }

  /* Concept: legend becomes a horizontal strip above the diagram */
  .layout-drawer .concept-stage { grid-template-columns: 1fr; }
  .layout-drawer.drawer-open .concept-stage { padding-right: 0; }

  .legend {
    border-right: none;
    border-bottom: 1px solid var(--line);
    display: flex; flex-wrap: wrap; align-items: center;
    gap: var(--space-2) var(--gutter);
    padding: var(--space-3) var(--gutter);
  }
  .legend-section { display: flex; align-items: center; gap: var(--space-3); margin-bottom: 0; }
  .legend-title { margin-bottom: 0; white-space: nowrap; }
  .legend ul { flex-direction: row; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
  .legend-row, .context-row { margin-left: 0; }
  .legend-hint { display: none; }

  .diagram-wrap { justify-content: flex-start; }
  .concept-svg { width: min(560px, 100%); }

  /* Library: filters become a wrapping bar above the results */
  .library { grid-template-columns: 1fr; }
  .library-filters {
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    display: flex; flex-wrap: wrap; align-items: flex-start;
    gap: var(--space-3) var(--gutter);
    padding: var(--space-4) var(--gutter);
  }
  .filters-head { flex-basis: 100%; margin-bottom: 0; }
  .filter-group { margin-bottom: 0; }
  .filter-group:first-of-type { flex: 1 1 240px; }  /* search input grows */
}

/* ---- Mobile: tighten gutters, full-screen overlays ---- */
@media (max-width: 767px) {

  .top-bar { padding: var(--space-3) var(--gutter-tight); }

  .diagram-headline h1 { font-size: 24px; }
  .diagram-headline p { font-size: 13.5px; }
  .diagram-wrap { padding: var(--space-3) var(--gutter-tight) var(--space-6); }
  .legend { padding: var(--space-3) var(--gutter-tight); }
  .concept-svg { width: min(460px, 100%); }

  /* Phase drawer fills the screen and sits above the sticky top bar */
  .phase-drawer { top: 0; width: 100vw; z-index: 30; border-left: none; }

  .library-filters { padding: var(--space-3) var(--gutter-tight); }
  .library-results { padding: var(--space-5) var(--gutter-tight) var(--space-8); }
  .results-head h1 { font-size: 23px; }

  /* Method modal: more room, stats wrap to two columns */
  .md-overlay { padding: var(--gutter-tight); align-items: flex-start; padding-top: 8vh; }
  .method-detail { padding: var(--space-5) var(--space-5) var(--space-6); }
  .md-stats { grid-template-columns: repeat(2, 1fr); }

  .page-footer { padding: var(--space-3) var(--gutter-tight); }
}

/* ---- Small phones: stack the top bar, full-width tabs ---- */
@media (max-width: 559px) {
  .top-bar {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .tabs { justify-self: stretch; }
  .tab { flex: 1; text-align: center; padding: 8px 12px; }
  .diagram-headline h1 { font-size: 22px; }
}

/* ---- Honour reduced-motion across the app's transitions ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
