/* Charter (thread detail) view — two panes: persistent sidebar | action box.
   Navbar owns identity (D16): no sticky title here; the action box starts at the
   graph. The charter's title/framing lives in the sidebar. */

.charter-grid {
  /* Flex (not grid) so the sidebar's animated width is honoured — a grid auto
     track ignores the item width and sizes to content, and grid-template-columns
     between minmax() values doesn't interpolate. */
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  width: 100%;
  transition: gap 0.28s ease;
}

.charter-grid.is-sidebar-collapsed {
  gap: var(--space-2);
}

/* Sidebar — kickoff framing + references + reply-to-kickoff. Stays in view while
   the action box scrolls. Clips its content so the collapse can animate its width. */
.charter-sidebar {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  /* Width via a custom property so the collapsed rule only changes the variable —
     no shorthand-vs-longhand cascade fight. min-height keeps the absolutely
     positioned expand button from being clipped once the content collapses. */
  flex: 0 0 var(--charter-sidebar-width, 320px);
  min-height: 44px;
  overflow: hidden;
  transition: flex-basis 0.28s ease;
}

.is-sidebar-collapsed .charter-sidebar {
  --charter-sidebar-width: 22px;
}

/* The framing lives in a wrapper so collapsing can fade + close it (while the
   column narrows) and the persistent expand button stays pinned — all animated.
   min-width keeps the text from rewrapping as the column animates; it clips. */
.charter-sidebar-content {
  display: grid;
  gap: var(--space-4);
  align-content: start;
  min-width: 17rem;
  max-height: 200vh;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.3s ease;
}

.is-sidebar-collapsed .charter-sidebar-content {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Expand affordance shown only while collapsed; pinned to the top of the rail. */
.charter-sidebar-expand {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.is-sidebar-collapsed .charter-sidebar-expand {
  opacity: 1;
  pointer-events: auto;
}

/* Heading — charter title + its type label. */
.charter-heading {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
}

.charter-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px;
  align-items: start;
  width: 100%;
}

.charter-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-2);
  align-items: start;
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

.charter-title-mark {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
}

.charter-sidebar-toggle {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  line-height: 1;
}

.charter-sidebar-toggle span {
  display: block;
  line-height: 1;
  transform: translateY(-0.5px);
}

.charter-sidebar-toggle:hover,
.charter-sidebar-toggle:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  outline: 0;
}

.charter-title-icon {
  display: grid;
  width: 24px;
  height: 22px;
}

.charter-title-icon svg {
  width: 24px;
  height: 22px;
}

.charter-type {
  display: inline-flex;
  padding: 1px var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-transform: uppercase;
}

/* Each sidebar block below the heading — References, Goal, Criteria, Kickoff —
   shares a top rule + eyebrow for scanability. */
.charter-section {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.charter-eyebrow {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.charter-section-empty,
.charter-prose {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
}

.charter-disclosure-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  list-style: none;
}

.charter-disclosure-summary::-webkit-details-marker {
  display: none;
}

.charter-disclosure-summary .charter-chevron {
  flex: 0 0 auto;
  color: var(--muted);
  opacity: 0.65;
}

details[open] > .charter-disclosure-summary .charter-chevron {
  transform: rotate(180deg);
}

.charter-disclosure-summary:hover {
  color: var(--ink);
}

.charter-disclosure-summary:hover .charter-chevron {
  color: var(--ink);
  opacity: 1;
}

.charter-references .reference-list {
  padding-left: var(--space-5);
}

.composer-criteria {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  line-height: var(--line-ui);
}

.composer-criteria-summary {
  color: var(--muted);
}

.composer-criteria-list {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
  color: var(--muted);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
}

.charter-support {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
  white-space: pre-wrap;
}

/* Action box — graph / conversations / composer (filled in across V2–V5). */
.charter-action-box {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: var(--space-5);
  align-content: start;
}

.charter-page-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.charter-page-title-icon {
  flex: 0 0 auto;
  display: grid;
  width: 24px;
  height: 22px;
}

.charter-page-title-icon svg {
  width: 24px;
  height: 22px;
}

.charter-page-title-text {
  min-width: 0;
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.25;
}

/* V1 scaffolding — each region is replaced by its real slice. */
.charter-action-box .placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: var(--font-ui);
}

.charter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.charter-tab {
  flex: 1 1 0;
  min-width: 9rem;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: var(--line-ui);
  cursor: pointer;
}

.charter-tab:hover,
.charter-tab:focus-visible {
  background: var(--paper);
  color: var(--ink);
}

.charter-tab.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.charter-map {
  display: grid;
  gap: var(--space-2);
}

.charter-graph {
  align-content: start;
  min-height: 280px;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
}

.charter-graph-map {
  position: relative;
  min-height: 248px;
}

.charter-graph-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--line);
  pointer-events: none;
}

.charter-graph-lines path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.charter-graph-center,
.charter-graph-spoke {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

.charter-graph-center {
  top: 50%;
  left: 50%;
  width: min(42%, 220px);
  min-height: 86px;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-reading);
  font-size: 1rem;
  line-height: 1.25;
  transform: translate(-50%, -50%);
}

.charter-graph-center-body {
  display: grid;
  width: 100%;
  min-height: 100%;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
}

button.charter-graph-center-body {
  cursor: pointer;
}

.charter-graph-spoke {
  width: 138px;
  min-height: 58px;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: var(--line-ui);
  cursor: pointer;
}

.charter-graph-spoke.is-top-left {
  top: 0;
  left: 0;
}

.charter-graph-spoke.is-top-right {
  top: 0;
  right: 0;
}

.charter-graph-spoke.is-bottom-left {
  bottom: 0;
  left: var(--space-3);
}

.charter-graph-spoke.is-bottom-right {
  right: var(--space-3);
  bottom: 0;
}

.charter-graph-label {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 650;
}

.charter-graph-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.charter-graph-count::before {
  content: "(";
}

.charter-graph-count::after {
  content: ")";
}

.charter-graph-spoke.is-selected {
  border-color: var(--clay);
  background: var(--soft);
}

.charter-graph-center.is-filter-resettable {
  background: var(--soft);
}

.charter-graph-center.is-filter-resettable:hover {
  border-color: var(--ink);
}

.charter-graph-spoke-clear {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1;
}

.charter-graph-spoke:hover,
.charter-graph-spoke:focus-visible {
  border-color: var(--ink);
  outline: 0;
}

.charter-graph-center-body:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 2px;
}

.charter-graph-up {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  display: inline-grid;
  width: var(--space-5);
  height: var(--space-5);
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1;
}

.charter-graph-up:hover,
.charter-graph-up:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-list {
  display: grid;
  gap: var(--space-4);
  min-height: 200px;
}

@supports (view-transition-name: none) {
  html[data-charter-list-transition] .charter-transition-target {
    view-transition-name: charter-changing-contribution;
  }

  html[data-charter-list-transition]::view-transition-old(root),
  html[data-charter-list-transition]::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
  }

  html[data-charter-list-transition]::view-transition-group(charter-changing-contribution) {
    animation-duration: 0.24s;
    animation-timing-function: ease;
  }

  html[data-charter-list-transition="forward"]::view-transition-old(charter-changing-contribution) {
    animation: charter-contributions-out-left 0.24s ease both;
  }

  html[data-charter-list-transition="forward"]::view-transition-new(charter-changing-contribution) {
    animation: charter-contributions-in-right 0.24s ease both;
  }

  html[data-charter-list-transition="back"]::view-transition-old(charter-changing-contribution) {
    animation: charter-contributions-out-right 0.24s ease both;
  }

  html[data-charter-list-transition="back"]::view-transition-new(charter-changing-contribution) {
    animation: charter-contributions-in-left 0.24s ease both;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-charter-list-transition]::view-transition-group(charter-changing-contribution),
  html[data-charter-list-transition]::view-transition-old(charter-changing-contribution),
  html[data-charter-list-transition]::view-transition-new(charter-changing-contribution) {
    animation-duration: 1ms;
  }
}

@keyframes charter-contributions-in-right {
  from {
    opacity: 0;
    transform: translateX(var(--space-5));
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes charter-contributions-out-left {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(calc(var(--space-5) * -1));
  }
}

@keyframes charter-contributions-in-left {
  from {
    opacity: 0;
    transform: translateX(calc(var(--space-5) * -1));
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes charter-contributions-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(var(--space-5));
  }
}

.charter-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  min-height: 28px;
}

.charter-filter-trail {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: var(--space-1);
  row-gap: 0;
  min-width: 0;
}

.charter-filter-connector,
.charter-filter-node {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: var(--line-ui);
}

.charter-filter-node {
  max-width: 18rem;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.charter-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  max-width: 14rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  line-height: var(--line-ui);
  cursor: pointer;
}

.charter-filter-chip span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.charter-filter-chip:hover,
.charter-filter-chip:focus-visible {
  outline: 0;
}

.charter-filter-chip-x {
  color: color-mix(in srgb, var(--muted) 48%, transparent);
  font-size: 0.82rem;
  line-height: 1;
  opacity: 1;
  transform: translateY(-0.22em);
  transition: color 0.16s ease, opacity 0.16s ease;
}

.charter-filter-chip:hover .charter-filter-chip-x,
.charter-filter-chip:focus-visible .charter-filter-chip-x {
  color: var(--color-youtube-dark);
}

.charter-list-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.charter-list-header > .charter-breadcrumb {
  margin-bottom: 0;
}

.charter-filter-control {
  position: relative;
}

.charter-filter-button,
.charter-sort-button {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.charter-filter-button:hover,
.charter-filter-button:focus-visible,
.charter-sort-button:hover,
.charter-sort-button:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  outline: 0;
}

.charter-filter-button.is-active {
  color: var(--ink);
  border-color: var(--clay);
  background: var(--soft);
}

.charter-filter-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 5;
  min-width: 176px;
  padding: var(--space-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.charter-filter-item {
  width: 100%;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  text-align: left;
}

.charter-filter-item.is-active,
.charter-filter-item:hover,
.charter-filter-item:focus-visible {
  background: var(--soft);
  color: var(--ink);
  outline: 0;
}

.charter-conversations {
  display: grid;
}

.charter-conversation {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--line);
}

.charter-conversation:first-child {
  padding-top: 0;
  border-top: 0;
}

.charter-conversations-more {
  justify-self: start;
  padding: var(--space-1) 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
}

.charter-conversations-more:hover,
.charter-conversations-more:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-post {
  display: grid;
  gap: var(--space-1);
}

/* Indentation now comes from the .charter-replies container + the chevron
   gutter inside each node, so the per-kind left padding is gone. */
.charter-post-reply,
.charter-post-nested-reply {
  padding-left: 0;
}

.charter-post-body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
}

.charter-post-footer {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.charter-post .charter-post-byline,
.charter-kickoff-footer .charter-post-byline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 500;
}

.charter-byline-avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  place-items: center;
  color: var(--muted);
  opacity: 0.8;
}

.charter-byline-avatar svg {
  width: 13px;
  height: 13px;
}

.charter-post-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}

.charter-row-reply {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
}

.charter-row-reply:hover,
.charter-row-reply:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-row-aha {
  position: relative;
  display: inline-grid;
  width: var(--space-5);
  height: var(--space-5);
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  line-height: 1;
  opacity: 0.7;
}

.charter-row-aha .aha-bulb {
  width: 17px;
  height: 17px;
}

/* Unlit: just the bulb outline — the glow rays appear only once it's lit. */
.charter-row-aha:not(.is-active) .aha-bulb-rays {
  opacity: 0;
}

.charter-row-aha:hover,
.charter-row-aha:focus-visible {
  opacity: 1;
  outline: 0;
}

.charter-row-aha.is-active {
  opacity: 1;
  color: var(--clay);
}

/* Replies belong to their post — indented under a thread line. */
.charter-replies {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-3);
  margin-left: var(--space-2);
  padding-left: var(--space-4);
  border-left: 1px solid var(--line);
}

.charter-reply-block,
.charter-nested-replies {
  display: grid;
  gap: var(--space-2);
}

.charter-reply-expand {
  justify-self: start;
  margin-left: var(--space-5);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.charter-reply-expand:hover,
.charter-reply-expand:focus-visible {
  color: var(--ink);
  outline: 0;
}

/* --- pairs view ------------------------------------------------------- */

.charter-summary {
  display: grid;
  gap: var(--space-2);
}

/* Striped placeholder until the AI summary lands. */
.charter-summary-box {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 9px,
    var(--line) 9px,
    var(--line) 10px
  );
}

.charter-pair {
  gap: var(--space-2);
}

.charter-expansion {
  display: grid;
}

/* The footer's left group: the disclosure chevron sits just before the byline,
   so the body keeps the full width and the chevron reads as "open this thread." */
.charter-post-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.charter-down {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0.65;
  cursor: pointer;
}

.charter-down:hover,
.charter-down:focus-visible {
  opacity: 1;
  color: var(--ink);
  outline: 0;
}

.charter-chevron {
  width: 13px;
  height: 13px;
  transition: transform 0.18s ease;
}

.charter-down.is-open .charter-chevron {
  transform: rotate(180deg);
}


/* Bare back chevrons — depth without labels. */
.charter-back {
  padding: 0 var(--space-1);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.7;
  cursor: pointer;
}

.charter-back:hover,
.charter-back:focus-visible {
  opacity: 1;
  color: var(--ink);
  outline: 0;
}

.charter-pair-empty {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
}

/* The single "walk into this" affordance — the three dots plus a count. */
.charter-pair-more {
  justify-self: start;
  margin-top: var(--space-1);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.charter-reply-block .charter-pair-more {
  margin-left: var(--space-5);
}

.charter-pair-more:hover,
.charter-pair-more:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.charter-crumb {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  cursor: pointer;
}

.charter-crumb:hover,
.charter-crumb:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-crumb-sep {
  color: var(--muted);
  opacity: 0.6;
}

.charter-focus {
  display: grid;
  gap: var(--space-4);
}

/* The focused node anchors the view: full-width, never indented, even when
   it is itself a reply drilled into. */
.charter-post-focus {
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.charter-post-focus .charter-post-body {
  font-size: 1.05rem;
}

/* Related is about the post, so it sits at the post's level (not indented like
   the replies), set off by a rule above. */
.charter-related {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.charter-related-title {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.charter-related-list {
  display: grid;
  gap: var(--space-2);
}

.charter-related-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: var(--space-1) 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.charter-related-body {
  color: var(--ink);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
}

.charter-related-item:hover .charter-related-body,
.charter-related-item:focus-visible .charter-related-body {
  text-decoration: underline;
}

.charter-related-item:focus-visible {
  outline: 0;
}

.charter-composer {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
}

.charter-reply-target {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: center;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  line-height: var(--line-ui);
}

.charter-reply-target p {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.charter-reply-cancel {
  display: inline-grid;
  width: var(--space-5);
  height: var(--space-5);
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.charter-reply-cancel:hover,
.charter-reply-cancel:focus-visible {
  color: var(--ink);
  outline: 0;
}

.charter-composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
  align-items: end;
}

.charter-composer-input {
  min-height: 44px;
  max-height: 180px;
  resize: none;
  overflow: hidden;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-reading);
  line-height: var(--line-reading);
}

.charter-composer-input:focus {
  border-color: var(--ink);
  outline: 0;
}

.charter-composer-submit {
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 700;
}

.charter-composer-submit:hover,
.charter-composer-submit:focus-visible {
  background: var(--clay);
  border-color: var(--clay);
  outline: 0;
}

@media (max-width: 780px) {
  .charter-grid {
    flex-direction: column;
    gap: var(--space-5);
  }

  .charter-sidebar {
    position: relative;
    top: auto;
    width: 100%;
    /* Stacks full-width on mobile (flex column), so reset the basis — collapse is
       handled by the content's max-height, not the desktop width animation. */
    flex: 0 0 auto;
  }

  .charter-action-box {
    width: 100%;
  }

  .charter-tab {
    min-width: 0;
  }

  .is-sidebar-collapsed .charter-sidebar {
    flex-basis: auto;
  }

  /* The sidebar stacks vertically on mobile, so the toggle should point up
     (collapse) / down (expand), not left/right. Swap the angle-quote glyph for a
     border chevron — it rotates around its own centre, so it stays centred in the
     button (unlike a rotated text glyph). */
  .charter-sidebar-toggle span {
    display: none;
  }

  .charter-sidebar-toggle::before {
    content: "";
    width: 3px;
    height: 3px;
    border-right: 1.2px solid currentColor;
    border-bottom: 1.2px solid currentColor;
    transition: transform 0.18s ease;
  }

  /* The 2-border box only inks its lower-right corner, so the caret sits off the
     box centre; translateY (applied in screen space, before the rotate) pulls it
     back. Collapse = up caret nudged down; expand = down caret nudged up. */
  .charter-sidebar-toggle[aria-expanded="true"]::before {
    transform: translateY(0.75px) rotate(225deg);
  }

  .charter-sidebar-toggle[aria-expanded="false"]::before {
    transform: translateY(-0.75px) rotate(45deg);
  }

  .charter-grid.is-sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .charter-graph {
    min-height: 252px;
    padding: var(--space-3);
  }

  .charter-graph-map {
    min-height: 226px;
  }

  .charter-graph-center {
    width: min(44%, 184px);
    min-height: 76px;
    padding: var(--space-2);
    font-size: 0.92rem;
  }

  .charter-graph-spoke {
    width: min(38%, 128px);
    min-height: 54px;
    padding: var(--space-2) var(--space-1);
  }

  .charter-graph-spoke.is-bottom-left {
    left: 0;
  }

  .charter-graph-spoke.is-bottom-right {
    right: 0;
  }

  .charter-graph-label {
    font-size: 0.78rem;
  }

  .charter-graph-count {
    font-size: 0.72rem;
  }

  .charter-composer-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .charter-composer-submit {
    justify-self: end;
  }
}
