/*
 * Intent's whole stylesheet: a thin layer over browser defaults.
 * If this file fails to load, layout should suffer but look-and-feel should not.
 * Colors come from the browser via color-scheme: every tint is CanvasText mixed into Canvas,
 * so the same rules hold up in light and dark.
 */

:root {
  color-scheme: light dark;
  /* The same system colours the browser would use, made explicit so tools (and embeds)
     that can't see the canvas don't assume black on white. */
  background-color: Canvas;
  color: CanvasText;
  --rule: color-mix(in srgb, CanvasText 12%, Canvas);
  --rule-strong: color-mix(in srgb, CanvasText 30%, Canvas);
  /* The edge of something you type in or choose from: findable without relying on its fill. */
  --field-rule: color-mix(in srgb, CanvasText 45%, Canvas);
  --muted: color-mix(in srgb, CanvasText 68%, Canvas);
  --panel: color-mix(in srgb, CanvasText 4%, Canvas);
  --panel-hover: color-mix(in srgb, CanvasText 9%, Canvas);
  /* intent.js replaces this with the measured height of the site bar. */
  --header-height: 2.75rem;
  --page-width: 80rem;
  --gutter: clamp(1rem, 3vw, 2rem);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono", "Segoe UI Mono",
    "Roboto Mono", "Liberation Mono", Consolas, monospace;
}

/* The same mix reads fainter on a dark canvas, so there the tints step up a little. */
@supports (color: light-dark(black, white)) {
  :root {
    --rule: light-dark(color-mix(in srgb, CanvasText 12%, Canvas), color-mix(in srgb, CanvasText 18%, Canvas));
    --panel: light-dark(color-mix(in srgb, CanvasText 4%, Canvas), color-mix(in srgb, CanvasText 7%, Canvas));
    --panel-hover: light-dark(color-mix(in srgb, CanvasText 9%, Canvas), color-mix(in srgb, CanvasText 15%, Canvas));
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

html {
  /* Anchors and focus targets land below the sticky bar. */
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
}

/* Several rules below set display on things that are sometimes hidden. */
[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.2rem;
  margin: 2.5rem 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}

/* Fainter than other muted text: a key is for finding a feature, and the title leads. */
.key {
  color: color-mix(in srgb, CanvasText 56%, Canvas);
  font-weight: 400;
}

a {
  text-underline-offset: 0.15em;
}

/* Icons are drawn in the text colour and sit on the text's line (see the icon template tag). */
.icon {
  flex: none;
  vertical-align: -0.15em;
}

p,
li,
dd {
  max-width: 70ch;
}

img {
  max-width: 100%;
  height: auto;
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Site bar: one sticky line, always in view. The brand, then (in a project) where you are and
   its sections, then search and the account menu at the right. */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: Canvas;
  border-bottom: 1px solid var(--rule);
}

.site-bar {
  box-sizing: border-box;
  max-width: var(--page-width);
  min-height: 2.75rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.5rem;
  font-size: 0.9rem;
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  color: inherit;
  text-decoration: none;
}

.site-bar .breadcrumb {
  flex: 0 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  padding: 0;
  white-space: nowrap;
}

.site-bar .breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.site-bar .breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem 0 0.25rem;
  list-style: none;
}

.breadcrumb li {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb li + li::before,
.site-bar .breadcrumb li:first-child::before {
  content: "/";
  content: "/" / "";
  margin-inline-end: 0.5rem;
  color: var(--muted);
}

/* The project's sections, taking what room the rest leaves and scrolling if short of it. */
.site-bar .tabs {
  flex: 1 1 0;
  min-width: 0;
  margin-inline-start: 1rem;
}

.tabs ul {
  display: flex;
  gap: 0 0.25rem;
  margin: 0 -0.7rem;
  padding: 0;
  list-style: none;
  overflow-x: auto;
}

.site-bar .tabs ul {
  margin: 0;
}

.tabs a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.tabs .icon {
  color: var(--muted);
}

.tabs a[aria-current="page"] .icon {
  color: inherit;
}

.tabs a:hover {
  border-color: var(--rule-strong);
}

.tabs a[aria-current="page"] {
  font-weight: 600;
  border-color: currentColor;
}

/* The sections of a page, under its tabs: settings and the members. */
.subnav {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.subnav a {
  margin-bottom: -1px;
}

/* Search and the account menu, at the right. */
.site-tools {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 0.25rem;
  margin-inline-start: auto;
  min-width: 0;
}

.site-bar .sign-in {
  white-space: nowrap;
  padding: 0.3rem 0.6rem;
  color: inherit;
  text-decoration: none;
  border-radius: 0.4rem;
}

.site-bar .sign-in:hover {
  background-color: var(--panel-hover);
}

.site-bar .icon {
  color: var(--muted);
}

/* Without JavaScript the search field is always out. With it, just the icon, until used. */
.site-search {
  display: flex;
  flex: 1 1 10rem;
  align-items: center;
  min-width: 0;
  max-width: 22rem;
  margin: 0;
  border: 1px solid var(--field-rule);
  border-radius: 0.4rem;
  background-color: Field;
}

.js .site-search:not(.is-open) {
  flex: 0 0 auto;
  border-color: transparent;
  background: none;
}

.js .site-search:not(.is-open) > :not(button) {
  display: none;
}

.site-search:has(input[type="search"]:focus) {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.site-search input[type="search"] {
  flex: 1 1 4rem;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border: 0;
  background: none;
  outline: none;
}

.site-search label {
  margin: 0;
}

/* Icon buttons: quiet until pointed at. */
.site-search button,
.user-menu > summary {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: 0.4rem;
  background: none;
  color: inherit;
  cursor: pointer;
}

.site-search button:hover,
.user-menu > summary:hover,
.user-menu[open] > summary {
  background-color: var(--panel-hover);
}

/* The project being searched in: a tick box that looks like a tag. Unticked, it reads "All
   projects" and the search is of everything. */
.site-search .scope {
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
  margin: 0.15rem 0 0.15rem 0.2rem;
  padding: 0 0.5rem;
  border-radius: 0.3rem;
  background-color: var(--panel-hover);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.site-search .scope span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-search .scope input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.site-search .scope:has(input:focus-visible) {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

/* A cross after the name, to say it can be taken off. */
.site-search .scope .in::after {
  content: " ×";
  content: " ×" / "";
  color: var(--muted);
}

.site-search .scope input:checked ~ .everywhere,
.site-search .scope input:not(:checked) ~ .in {
  display: none;
}

.site-search .scope:has(input:not(:checked)) {
  background: none;
  color: var(--muted);
  font-weight: 400;
}

/* The account menu: what isn't needed on every page, from a user icon. */
.user-menu {
  position: relative;
}

.user-menu > summary {
  list-style: none;
}

.user-menu > summary::-webkit-details-marker {
  display: none;
}

.user-menu .menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 11;
  box-sizing: border-box;
  min-width: 14rem;
  padding: 0.35rem;
  border: 1px solid var(--rule-strong);
  border-radius: 0.5rem;
  background-color: Canvas;
  box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.18);
}

.user-menu .who {
  margin: 0;
  padding: 0.4rem 0.6rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.25rem;
  color: var(--muted);
}

.user-menu .who strong {
  color: CanvasText;
}

.user-menu .menu a,
.user-menu .menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-sizing: border-box;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 0;
  border-radius: 0.35rem;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.user-menu .menu a:hover,
.user-menu .menu button:hover {
  background-color: var(--panel-hover);
}

.user-menu .menu form {
  margin: 0;
}

.user-menu #theme-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem;
}

.user-menu #theme-form[hidden] {
  display: none;
}

.user-menu #theme-form label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.user-menu #theme-form select {
  padding: 0.15rem 0.25rem;
  font-size: inherit;
}

.user-menu .menu form:last-child {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--rule);
}

/* A narrow screen: the sections drop to a line of their own, and the open search takes the
   rest of the first. */
@media (max-width: 47.99rem) {
  .site-bar .tabs {
    order: 3;
    flex: 1 0 100%;
    margin-inline-start: 0;
  }

  .site-bar .tabs ul {
    margin: 0 -0.7rem;
  }

  /* The names give way (cut short) before the icons wrap. */
  .crumbs {
    flex: 1 1 0;
    min-width: 0;
  }

  .site-tools {
    flex: 0 0 auto;
  }

  /* The open search takes a line of its own. */
  .site-search.is-open {
    flex: 1 1 100%;
    max-width: none;
  }

  .site-tools:has(.is-open) {
    flex: 1 1 100%;
    order: 2;
  }
}


/* The reading page keeps the reader's place itself (reader.js); the browser's scroll anchoring
   would shift it a second time. */
main {
  overflow-anchor: none;
}

/* Pages. A page header, then (where it helps) a main column, a sidebar and a full-width tail. */

.page {
  box-sizing: border-box;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2rem var(--gutter) 5rem;
}

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.page-header h1 {
  margin: 0;
}

.page-header .meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.page-header .description {
  max-width: 70ch;
  margin: 0.25rem 0 0;
}

.page-header .meta a {
  color: inherit;
}

.page-header .actions {
  margin: 1rem 0 0;
}

/* Actions sit beside the title when there is room, and below it otherwise. */
@media (min-width: 48rem) {
  .page-header.with-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .page-header.with-actions .titles {
    min-width: 0;
  }

  .page-header.with-actions .actions {
    flex: none;
    margin-top: 0;
  }
}

.page-header nav .breadcrumb {
  padding: 0 0 0.4rem;
  font-size: 0.9rem;
}

.layout {
  display: grid;
  gap: 2.5rem 3.5rem;
  grid-template-columns: minmax(0, 1fr);
}

.layout > .below {
  grid-column: 1 / -1;
}

/* Under the main column on a narrow screen, with a rule to mark where it starts. */
.layout > aside {
  display: flex;
  flex-direction: column;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

@media (min-width: 64rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 20rem;
    align-items: start;
  }

  .layout.wide-aside {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
  }

  .layout > aside {
    padding-top: 0;
    border-top: 0;
  }
}

/* Sidebar sections: no boxes, just a hairline between one and the next. */
.panel {
  padding-block: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}

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

.panel:last-child {
  padding-bottom: 0;
}

.panel > h2,
.panel > h3,
.panel-heading > h2,
.panel-heading > h3 {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* A panel's heading with something beside it, such as how its contents are sorted. */
.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
}

.sort-toggle {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}

.sort-toggle a {
  color: var(--muted);
}

.sort-toggle a[aria-current] {
  color: CanvasText;
  font-weight: 600;
  text-decoration: none;
}

.panel > ul,
.panel > ol {
  margin-block: 0.25rem;
  padding-inline-start: 1.1rem;
}

.panel > p {
  margin-block: 0.4rem;
}

.panel > details {
  margin-top: 0.5rem;
}

.panel .thread {
  border-radius: 0 0.4rem 0.4rem 0;
  background-color: var(--panel);
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.6rem;
  border: 1px solid var(--rule-strong);
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.5;
  color: CanvasText;
}

/* A project's labels, side by side. */
.labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
  list-style: none;
}

/* A label's color: a tint of the hue over the page, so the text keeps its own contrast in light
   and dark. Without one, a badge is just outlined. */
.badge-red { --hue: #d9453f; }
.badge-orange { --hue: #e07a2b; }
.badge-yellow { --hue: #d4a514; }
.badge-green { --hue: #3f9e5a; }
.badge-teal { --hue: #1f9d94; }
.badge-blue { --hue: #3b82d6; }
.badge-purple { --hue: #8b5cd6; }
.badge-pink { --hue: #d6559b; }
.badge-gray { --hue: #77808c; }

/* Status badges use the same tints: open is green, accepted blue, rejected red, and a
   withdrawn or duplicate issue (or a withdrawn feature) is gray, as it is set aside. */
.badge.open, .badge.active { --hue: #3f9e5a; }
.badge.accepted { --hue: #3b82d6; }
.badge.rejected { --hue: #d9453f; }
.badge.withdrawn, .badge.duplicate, .badge.superseded { --hue: #77808c; }

.badge[class*="badge-"],
.badge.open,
.badge.active,
.badge.accepted,
.badge.rejected,
.badge.withdrawn,
.badge.duplicate,
.badge.superseded,
.tags a[class*="badge-"] {
  border-color: color-mix(in srgb, var(--hue) 55%, Canvas);
  background-color: color-mix(in srgb, var(--hue) 24%, Canvas);
}

/* Hovering deepens the label's own tint and its edge, rather than turning it grey. */
a.badge[class*="badge-"]:hover,
.tags a[class*="badge-"]:hover {
  border-color: var(--hue);
  background-color: color-mix(in srgb, var(--hue) 38%, Canvas);
}

.messages {
  margin: 0 0 2rem;
  padding: 0.75rem 1rem;
  list-style: none;
  border: 1px solid var(--rule-strong);
  border-inline-start-width: 3px;
  border-radius: 0.4rem;
}

[role="note"] {
  padding: 0.75rem 1rem;
  border-inline-start: 3px solid var(--rule-strong);
  border-radius: 0 0.4rem 0.4rem 0;
  background-color: var(--panel);
}

.muted {
  color: var(--muted);
}

/* Controls: the browser's, with one consistent shape. */

button,
.button,
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--rule-strong);
  border-radius: 0.4rem;
  background-color: var(--panel);
  color: inherit;
  cursor: pointer;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  vertical-align: middle;
  text-decoration: none;
}

button:hover,
.button:hover,
input[type="file"]::file-selector-button:hover {
  background-color: var(--panel-hover);
}

.primary,
button[type="submit"].primary {
  border-color: CanvasText;
  background-color: CanvasText;
  color: Canvas;
}

.primary:hover {
  background-color: color-mix(in srgb, CanvasText 80%, Canvas);
}

input:not([type="checkbox"], [type="radio"], [type="file"]),
select,
textarea {
  box-sizing: border-box;
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--field-rule);
  border-radius: 0.4rem;
  background-color: Field;
  color: FieldText;
}

input[type="file"] {
  font: inherit;
}

textarea {
  width: 100%;
  max-width: 80ch;
}

label:has(+ input, + textarea, + select),
fieldset > legend {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.helptext {
  display: block;
  color: var(--muted);
  font-size: 0.9em;
}

/* Django's field groups: a label, perhaps a hint, then the control, with room between fields. */
form > div:has(> label) {
  margin-block: 1.25rem;
}

form > div > label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

form > div > .helptext {
  margin-bottom: 0.3rem;
}

/* A checkbox sits on its label's line, with any hint underneath. */
form > div:has(> input[type="checkbox"]) {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.5rem;
  align-items: center;
  justify-items: start;
}

form > div:has(> input[type="checkbox"]) > label {
  grid-area: 1 / 1;
  margin: 0;
}

form > div:has(> input[type="checkbox"]) > input {
  grid-area: 1 / 2;
  margin: 0;
}

form > div:has(> input[type="checkbox"]) > :not(label, input) {
  grid-column: 1 / -1;
}

fieldset {
  margin: 0.75rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
}

summary {
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

ul.actions {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
}

form.inline {
  display: inline;
}

/* Tables. */

table {
  border-collapse: collapse;
  max-width: 100%;
}

th,
td {
  padding: 0.6rem 1.5rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: start;
  vertical-align: top;
}

th {
  font-weight: 500;
}

thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

/* Name and value pairs: the name small above its value. */
dt {
  color: var(--muted);
  font-size: 0.85rem;
}

dd {
  margin: 0 0 0.75rem;
}

caption {
  text-align: start;
  caption-side: bottom;
  padding-top: 0.4rem;
  color: var(--muted);
  font-size: 0.9em;
}

.diff tbody + tbody {
  border-top: 2px solid var(--rule-strong);
}

.diff td:last-child {
  white-space: pre-wrap;
  font-family: monospace;
}

/* What changed between two versions of some text: removed words struck through, added ones
   underlined, so it reads without colour. The text keeps its line breaks. */
.changes,
.comment-text {
  max-width: 70ch;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.changes {
  margin-block: 0.5rem;
}

.changes del,
.changes ins {
  border-radius: 0.2rem;
  padding-inline: 0.1em;
  text-decoration-thickness: 1.5px;
}

.changes del {
  background-color: color-mix(in srgb, CanvasText 10%, transparent);
  color: var(--muted);
}

.changes ins {
  background-color: color-mix(in srgb, Highlight 22%, transparent);
  text-decoration-line: underline;
  text-decoration-style: solid;
}

/* A stored version's own text, apart from the page around it. */
.comment-text {
  margin-block: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-inline-start: 2px solid var(--rule-strong);
  background-color: var(--panel);
  border-radius: 0 0.4rem 0.4rem 0;
}

section > .comment-text {
  border-inline-start-color: CanvasText;
  background: none;
  padding-inline-start: 1rem;
}

.edits {
  margin: 0;
  padding: 0;
  list-style: none;
}

.edits > li {
  padding-block: 1rem;
  border-top: 1px solid var(--rule);
}

.edits h3,
.edit-event h3 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.edits details,
.edit-event details {
  font-size: 0.9rem;
}

.edit-event {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.edit-event details {
  margin-top: 0.5rem;
}

/* The event line is the whole disclosure: no marker, a quiet "see changes" at its end. */
.edit-event > summary {
  list-style: none;
}

.edit-event > summary::-webkit-details-marker {
  display: none;
}

.edit-event .see-changes {
  text-decoration: underline;
}

.edit-event[open] .see-changes {
  display: none;
}

/* Discussion. Threads and comments sit under what they're about, marked by a rule. */

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

/* A feature's text that an LLM wrote, or that is meant for one: monospace, so it is never
   taken for a person's own words. */
.prose.llm {
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.7;
}

.block {
  margin-block: 1rem;
}

/* So the first line of a block, and its comment icon, start where the block does. */
.block > :first-child {
  margin-top: 0;
}

.mention {
  background: color-mix(in srgb, Highlight 22%, transparent);
  border-radius: 0.25rem;
  padding-inline: 0.2em;
  font-weight: 600;
}

.thread,
.timeline > li {
  margin-block: 0.75rem;
}

.thread {
  padding: 0.5rem 0.75rem;
  border-inline-start: 2px solid var(--rule-strong);
}

.thread {
  position: relative;
}

.thread > details > summary {
  font-size: 0.9em;
}

/* A collapsed thread reads as who, a snippet of what, and how lively it is. */
.thread-who {
  font-weight: 600;
}

.thread-lines {
  display: block;
  font-size: 0.85em;
  font-weight: 600;
  color: var(--muted);
}

.thread-snippet {
  display: block;
  margin-block: 0.1rem;
  overflow-wrap: anywhere;
}

.thread-meta {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
}

/* An open thread keeps only a quiet line of its own (how lively it is, then what it is
   about), so the comments are what you read. Who started it is on the first comment. */
.thread > details[open] > summary .thread-snippet,
.thread > details[open] > summary .thread-lines {
  display: none;
}

.thread > details[open] > summary .thread-who {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.thread > details[open] > summary .thread-meta {
  display: inline;
}

.thread > details > p.muted {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
}

.thread-anchor {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0 0.3rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85em;
}

.thread-anchor:hover,
.thread-anchor:focus-visible {
  color: CanvasText;
  text-decoration: underline;
}

/* Resolve, turn into an issue: there when wanted, smaller than the conversation. */
.thread > details > .actions {
  margin-top: 0.6rem;
}

.thread > details > .actions button,
.thread > details > .actions .button {
  padding: 0.2rem 0.6rem;
  background-color: transparent;
  font-size: 0.8rem;
}

.thread > details > .actions button:hover,
.thread > details > .actions .button:hover {
  background-color: var(--panel-hover);
}

/* A comment: a small line saying who and when, with edit and delete as quiet icons at its
   end, then the text, which is the part that matters. */
.comment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.75rem;
  margin-block: 0.9rem;
}

.comment + .comment {
  padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
}

.comment > header {
  grid-area: 1 / 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.comment > header .badge {
  font-size: 0.7rem;
}

.comment > header strong {
  color: CanvasText;
  font-size: 0.85rem;
}

.comment > header a {
  color: inherit;
  text-decoration: none;
}

.comment > header a:hover {
  text-decoration: underline;
}

.comment > .view,
.comment > p {
  grid-column: 1 / -1;
}

.comment .prose {
  margin-block: 0.3rem 0;
}

.comment > .actions {
  grid-area: 1 / 2;
  gap: 0.125rem;
  font-size: 0.8rem;
}

.comment > .actions summary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.3rem;
  border-radius: 0.3rem;
  list-style: none;
  color: var(--muted);
}

.comment > .actions summary::-webkit-details-marker {
  display: none;
}

.comment > .actions summary:hover,
.comment > .actions details[open] > summary {
  color: CanvasText;
  background-color: var(--panel-hover);
}

/* Just the icon until it is opened; the word is still there for screen readers. */
.comment > .actions details:not([open]) .label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Opened, an edit or delete form takes a row of its own under the comment, and the other
   control steps aside. Editing swaps the form in for the text, in the same spot. */
.comment:has(> .actions > details[open]) > .actions {
  grid-area: auto / 1 / auto / -1;
  margin-top: 0.4rem;
}

.comment > .actions > details[open] {
  flex: 1 1 100%;
}

.comment > .actions > details[open] > summary {
  margin-bottom: 0.4rem;
}

.comment > .actions form {
  font-size: 0.9rem;
}

.comment > .actions:has(> details[open]) > details:not([open]) {
  display: none;
}

.comment:has(> .actions > details.edit[open]) > .view {
  display: none;
}

/* Scratchpad notes: comments with a link and a button beside the edit control. */

.note > .actions .action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.3rem;
  border: 0;
  border-radius: 0.3rem;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: none;
}

.note > .actions .action:hover {
  color: CanvasText;
  background-color: var(--panel-hover);
}

.note > .actions:has(> details[open]) > :not(details) {
  display: none;
}

.note-archive {
  padding: 0;
  list-style: none;
}

.note-archive > li {
  padding-block: 0.6rem;
  border-top: 1px solid var(--rule);
}

.note-archive summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
}

.note-archive summary time {
  flex: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.note-archive details[open] > summary {
  margin-bottom: 0.5rem;
}

.timeline {
  padding: 0;
  list-style: none;
}

.event {
  font-size: 0.9em;
}

/* Inline comment: a small icon in the right margin of its paragraph, at every width. */

.line-comment > summary,
.line-link {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 0.4rem;
  list-style: none;
  color: var(--muted);
}

.line-count {
  margin-inline-start: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
}

.line-count[hidden] {
  display: none;
}

.line-comment > summary::-webkit-details-marker {
  display: none;
}

.line-link:hover,
.line-comment > summary:hover,
.line-comment[open] > summary {
  color: CanvasText;
  background-color: var(--panel-hover);
}

.line-comment[open] > form {
  margin-top: 0.25rem;
}

.prose .block {
  position: relative;
  padding-inline-end: 2.25rem;
}

.prose .block:has(.beside-form) {
  padding-inline-end: 4rem;
}

.line-link[hidden] {
  display: none;
}

/* Next to the comment icon, which sits at the right edge. */
.line-link.beside-form {
  right: 1.9rem;
}

.line-link {
  text-decoration: none;
}

.line-comment > summary,
.line-link {
  position: absolute;
  top: 0;
  right: 0;
}

/* Quiet until you're near it, but always reachable by keyboard. */
.line-comment:not([open]) > summary {
  opacity: 0.45;
}

.line-comment:not([open]) > summary:has(.line-count:not([hidden])),
.block:hover .line-comment > summary,
.line-comment > summary:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .line-comment > summary {
    opacity: 1 !important;
  }
}

/* Files. Pins are an SVG overlay positioned in percentages, so they track the image. */

.pinboard {
  position: relative;
  display: inline-block;
  margin: 0;
  border: 1px solid var(--rule);
}

.pinboard img {
  display: block;
}

.pinboard.placing img {
  cursor: crosshair;
}

.pins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.pins a {
  pointer-events: auto;
}

.pins circle {
  fill: Mark;
  stroke: MarkText;
  stroke-width: 2;
}

.pins circle.pending {
  fill: none;
  stroke-dasharray: 4 3;
}

.pins text {
  fill: MarkText;
  font: bold 12px sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
}

.pins a:focus-visible circle {
  stroke-width: 4;
}

.prototype {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--rule-strong);
}

pre.quote {
  white-space: pre-wrap;
  padding-inline-start: 0.75rem;
  border-inline-start: 2px solid var(--rule-strong);
}

.skip-link {
  position: absolute;
  left: -100vw;
}

.skip-link:focus {
  position: static;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Attachments: images as small previews linking to the full file. */

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
}

.attachments li {
  font-size: 0.9em;
}

.attachments img {
  display: block;
  /* Auto, not the width attribute, so both limits apply and the shape is kept. */
  width: auto;
  height: auto;
  max-width: 16rem;
  max-height: 12rem;
  margin-bottom: 0.25rem;
  border: 1px solid var(--rule);
}

/* A feature's files: a row of cards that wraps, each with a picture of the file (or an icon,
   when it isn't an image) over its name. */

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem;
  margin: 0.75rem 0 1rem;
  padding: 0;
  list-style: none;
}

.file-list > li {
  display: flex;
  flex-direction: column;
  max-width: none;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
}

.file-list .thumb {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 10rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--rule);
  background-color: var(--panel);
  color: var(--muted);
}

.file-list img {
  display: block;
  /* Auto, not the width attribute, so the picture fits the space and keeps its shape. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  border: 1px solid var(--rule);
  border-radius: 0.2rem;
}

.file-list > li > div {
  padding: 0.6rem 0.75rem 0.75rem;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.file-list .muted {
  display: block;
  font-size: 0.8rem;
}

/* The form to start a thread on some lines sits in an inset box, apart from the text itself. */

.line-comment[open] > form {
  box-sizing: border-box;
  max-width: 90ch;
  margin-block: 0.5rem;
  margin-inline-start: 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  background-color: var(--panel);
  /* Looks like a thread, not just a comment: keep the rule on the left. */
  border-inline-start: 3px solid var(--rule-strong);
}

.line-comment[open] > form textarea {
  background-color: Field;
}

/* Markdown fields: Write and Preview tabs over a CodeMirror editor (see markdown-editor.js). */

.md-field {
  box-sizing: border-box;
  max-width: 80ch;
  margin-bottom: 0.5rem;
  border: 1px solid var(--field-rule);
  border-radius: 0.4rem;
  background-color: Field;
  color: FieldText;
}

.md-field:focus-within {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.md-field.md-invalid {
  border-color: CanvasText;
  border-width: 2px;
}

.md-field.md-invalid .md-hint::before {
  content: "Write something first · ";
  font-weight: 600;
  color: CanvasText;
}

.md-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0;
  border-bottom: 1px solid var(--rule);
  background-color: var(--panel);
  border-radius: 0.4rem 0.4rem 0 0;
}

.md-bar [role="tablist"] {
  display: flex;
  gap: 0.125rem;
}

.md-bar [role="tab"] {
  padding: 0.25rem 0.75rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.35rem 0.35rem 0 0;
  background: none;
  font-size: 0.875em;
  color: var(--muted);
  margin-bottom: -1px;
}

.md-bar [role="tab"][aria-selected="true"] {
  border-color: var(--rule);
  background-color: Field;
  color: FieldText;
  font-weight: 600;
}

.md-bar [role="tab"]:focus-visible {
  outline-offset: -2px;
}

.md-hint {
  padding-inline-end: 0.5rem;
  font-size: 0.8em;
  color: var(--muted);
}

.md-preview {
  padding: 0.5rem 0.75rem;
}

.md-preview:focus-visible {
  outline-offset: -2px;
}

/* CodeMirror's base theme sets .cm-scroller's font and comes later in the cascade (it's an
   adopted stylesheet), so these editor rules carry one extra class to win. */
.md-field .md-write .cm-scroller {
  font-family: var(--mono);
  font-size: 0.875rem;
}

/* The field's own outline already shows focus. */
.md-field .md-write .cm-editor.cm-focused {
  outline: none;
}

.md-field .md-write .cm-content {
  padding: 0.5rem 0.75rem;
  line-height: 1.6;
  caret-color: FieldText;
}

.md-field .md-write .cm-line {
  padding: 0;
}

.md-field .md-write .cm-cursor {
  border-left-color: FieldText;
}

.md-field .md-write .cm-selectionBackground,
.md-field .md-write .cm-focused .cm-selectionBackground {
  background-color: color-mix(in srgb, Highlight 35%, transparent) !important;
}

.md-heading {
  font-weight: 700;
}

.md-strong {
  font-weight: 700;
}

.md-emphasis {
  font-style: italic;
}

.md-strike {
  text-decoration: line-through;
}

.md-link {
  color: LinkText;
}

.md-code {
  background-color: var(--panel-hover);
  border-radius: 0.2rem;
}

.md-quote {
  color: var(--muted);
  font-style: italic;
}

/* Markup characters (#, *, `, >, list markers) recede so the words read first. */
.md-mark {
  color: var(--muted);
  font-weight: normal;
}

/* Labels. */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.tags a {
  display: inline-block;
  padding: 0 0.65rem;
  border: 1px solid var(--rule-strong);
  border-radius: 1rem;
  color: inherit;
  font-size: 0.9em;
  text-decoration: none;
}

.tags a:hover {
  background-color: var(--panel-hover);
}

.tags a[aria-current="true"] {
  border-color: CanvasText;
  background-color: CanvasText;
  color: Canvas;
}

a.badge {
  color: inherit;
  text-decoration: none;
}

a.badge:hover {
  background-color: var(--panel-hover);
}

/* Checkbox lists from Django forms (labels on the issue form). */
form ul:has(> li > label > input[type="checkbox"]) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0;
  list-style: none;
}

/* Implementation status tree: each feature's status row, children nested beneath. */
.status-tree ul { list-style: none; margin: 0; padding: 0; }
.status-tree ul ul { margin-inline-start: 0.75rem; padding-inline-start: 1rem; border-inline-start: 1px solid var(--rule); }
.tree-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; padding: 0.4rem 0; border-block-end: 1px solid var(--rule); }
.tree-name { flex: 1 1 16rem; min-width: 0; font-weight: 600; }
.tree-status { flex: 0 0 auto; min-width: 9rem; }
.tree-revision { flex: 0 0 auto; min-width: 7rem; }
.tree-confirm { flex: 1 1 100%; }

/* Files on the feature form. */
.file-fields .file-edit {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
}

.file-fields .file-edit[open] > summary {
  margin-bottom: 0.5rem;
}

/* @mention suggestions in the Markdown editor (CodeMirror's autocomplete popup). */
.cm-tooltip.cm-tooltip-autocomplete {
  background: Canvas;
  color: CanvasText;
  border: 1px solid GrayText;
  border-radius: 0.375rem;
  font-family: inherit;
  overflow: hidden;
}

.cm-tooltip-autocomplete > ul {
  font-family: inherit;
  max-height: 14rem;
}

.cm-tooltip-autocomplete > ul > li {
  padding: 0.25rem 0.75rem;
}

.cm-tooltip-autocomplete > ul > li[aria-selected] {
  background: Highlight;
  color: HighlightText;
}

.cm-completionDetail {
  margin-inline-start: 0.75em;
  font-style: normal;
  opacity: 0.75;
}

.cm-completionMatchedText {
  text-decoration: none;
  font-weight: 700;
}

/* Feature list: filter bar, sortable headings, tree indentation. */
.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-block: 0 0.75rem;
}

/* A small icon that opens a short list, for things most people never need. */
.menu {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.menu > summary {
  display: inline-flex;
  padding: 0.25rem;
  border-radius: 0.3rem;
  list-style: none;
  color: var(--muted);
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary:hover,
.menu[open] > summary {
  color: CanvasText;
  background-color: var(--panel-hover);
}

.menu > ul {
  position: absolute;
  z-index: 5;
  inset-inline-end: 0;
  min-width: max-content;
  margin: 0.25rem 0 0;
  padding: 0.35rem;
  list-style: none;
  border: 1px solid var(--rule-strong);
  border-radius: 0.4rem;
  background-color: Canvas;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px color-mix(in srgb, CanvasText 15%, transparent);
}

.menu > ul a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: 0.25rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.menu > ul a:hover {
  background-color: var(--panel-hover);
}

/* Under a page's title the list opens from the icon's left edge instead of its right. */
.page-header .menu {
  margin: 0.25rem 0 0 -0.25rem;
}

.page-header .menu > ul {
  inset-inline-start: 0;
  inset-inline-end: auto;
}

/* Beside the page's buttons it sits at the right edge, so the list opens leftwards. */
.page-header .actions .menu {
  margin: 0;
}

.page-header .actions .menu > ul {
  inset-inline-start: auto;
  inset-inline-end: 0;
}

.list-tools form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.list-tools label {
  margin: 0 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
}

.view-toggle {
  display: flex;
}

.view-toggle a {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rule-strong);
  color: inherit;
  text-decoration: none;
}

.view-toggle a:hover {
  background-color: var(--panel-hover);
}

.view-toggle a:first-child {
  border-radius: 0.375rem 0 0 0.375rem;
}

.view-toggle a:last-child {
  border-radius: 0 0.375rem 0.375rem 0;
  margin-inline-start: -1px;
}

/* The chosen one is filled in and outlined in the text colour, over its neighbours' edges. */
.view-toggle a[aria-current] {
  position: relative;
  border-color: CanvasText;
  background-color: var(--panel-hover);
  font-weight: 600;
}

[data-feature-table] {
  width: 100%;
}

/* Reorder mode: handles and move buttons beside each title, and a line where a drop would go. */
.reorder-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  margin-inline-end: 0.5rem;
  vertical-align: middle;
}

.reorder-controls[hidden] {
  display: none;
}

.reorder-controls button {
  padding: 0.1rem 0.25rem;
  line-height: 1;
}

.reorder-handle {
  display: inline-flex;
  padding: 0.25rem 0.1rem;
  cursor: grab;
  color: var(--muted);
}

.reordering tr.dragging {
  opacity: 0.45;
}

.reordering tr.drop-before {
  box-shadow: inset 0 2px 0 CanvasText;
}

.reordering tr.drop-after {
  box-shadow: inset 0 -2px 0 CanvasText;
}

[data-reorder-toggle][aria-pressed="true"] {
  border-color: CanvasText;
  background-color: var(--panel-hover);
  font-weight: 600;
}

th[aria-sort] a {
  color: inherit;
  text-decoration: none;
}

th[aria-sort] a:hover {
  text-decoration: underline;
}

th[aria-sort="ascending"] a::after {
  content: " ▲";
  font-size: 0.7em;
}

th[aria-sort="descending"] a::after {
  content: " ▼";
  font-size: 0.7em;
}

tr.context a,
tr.context td {
  color: var(--muted);
}

/* Classes rather than inline styles, which the CSP forbids. Deeper levels stop indenting. */
.depth-1 { padding-inline-start: 1.25rem; }
.depth-2 { padding-inline-start: 2.5rem; }
.depth-3 { padding-inline-start: 3.75rem; }
.depth-4 { padding-inline-start: 5rem; }
.depth-5 { padding-inline-start: 6.25rem; }
.depth-6 { padding-inline-start: 7.5rem; }
.depth-7 { padding-inline-start: 8.75rem; }
.depth-8 { padding-inline-start: 10rem; }

/* Composer forms (reply, new thread): just a one-line box until it is focused. The label stays
   for screen readers. */
.js form[data-composer]:not(.is-open) > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.js form[data-composer]:not(.is-open) > :not(label, textarea) {
  display: none;
}

/* Until then it is the plain text box, sized and set like one line of the editor that
   markdown-editor.js puts in its place on focus. */
.js form[data-composer]:not(.is-open) > textarea {
  height: calc(1.6em + 1rem + 2px);
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  font: 0.875rem/1.6 var(--mono);
  resize: none;
  overflow: hidden;
}

.js form[data-composer]:not(.is-open) > textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* CodeMirror's default placeholder grey is too faint; use the theme's muted text. */
.md-field .cm-editor .cm-placeholder {
  color: var(--muted);
}

/* The reading page: the feature tree down the side and every feature in order beside it, each
   with what is linked to it and its discussion in a rail of its own. Three columns on a wide
   screen; the rail drops under its feature on a narrower one, and on a narrow one the tree
   becomes a row above the features that opens. */

.full-width .site-bar {
  max-width: none;
}

.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.reader-main {
  box-sizing: border-box;
  min-width: 0;
  /* Room at the top for the tree's row. */
  padding: 4.75rem var(--gutter) 5rem;
}

/* The first feature's rule does the job of the header's. */
.reader-main > .page-header {
  margin-bottom: 0;
  border-bottom: 0;
}

/* On a narrow screen the tree is a row under the site bar that opens over the features
   (over, not above: opening it doesn't move what is being read). Fixed, not sticky: it sits
   in the space scroll-padding keeps clear, and focus on something sticky there scrolls the
   page to "show" it. */
.reader-nav {
  position: fixed;
  top: var(--header-height);
  inset-inline: 0;
  z-index: 8;
  border-bottom: 1px solid var(--rule);
  background-color: Canvas;
  font-size: 0.875rem;
  transition: top 0.2s ease;
}

.reader-nav > details > summary {
  padding: 0.6rem var(--gutter);
  font-weight: 600;
  /* One line: the feature being read, cut short if it is long. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-current {
  font-weight: 400;
}

/* Anchors land below that row too. */
@media (max-width: 55.99rem) {
  html:has(.reader-nav) {
    scroll-padding-top: calc(var(--header-height) + 3.75rem);
  }
}

@media (max-width: 55.99rem) {
  .reader-nav .tree {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    box-sizing: border-box;
    max-height: calc(100dvh - var(--header-height) - 3.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 1px solid var(--rule-strong);
    background-color: Canvas;
    box-shadow: 0 8px 16px color-mix(in srgb, CanvasText 15%, transparent);
  }
}

.reader-nav .tree {
  margin: 0;
  padding: 0.5rem var(--gutter) 1rem;
}

.reader-nav .tree,
.reader-nav .tree ul {
  list-style: none;
}

.reader-nav .tree ul {
  margin: 0 0 0 0.6rem;
  padding: 0 0 0 0.4rem;
  border-inline-start: 1px solid var(--rule);
}

.reader-nav .tree a {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 0.3rem;
  color: inherit;
  line-height: 1.35;
  text-decoration: none;
}

.reader-nav .tree a:hover {
  background-color: var(--panel-hover);
}

/* The feature being read: filled in and bold, not by colour alone. */
.reader-nav .tree a[aria-current] {
  background-color: var(--panel-hover);
  font-weight: 600;
}

.reader-nav .key {
  font-size: 0.85em;
}

.reader-earlier {
  margin: 1.5rem 0 0;
  font-size: 0.9rem;
}

.feature {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem 3.5rem;
  margin-top: 2.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
}

.feature-header {
  margin-bottom: 1.25rem;
}

.feature-header .breadcrumb {
  padding: 0 0 0.3rem;
  font-size: 0.85rem;
}

.feature-header .breadcrumb a {
  color: var(--muted);
}

.feature h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.25;
}

.feature h2 a {
  color: inherit;
  text-decoration: none;
}

.feature h2 a:hover {
  text-decoration: underline;
}

.feature-header .meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.feature-header .meta a {
  color: inherit;
}

.feature-header .menu {
  margin-inline-start: 0.25rem;
}

.feature-header .menu > ul {
  inset-inline-start: 0;
  inset-inline-end: auto;
}

.feature-header .actions {
  margin: 0.75rem 0 0;
}

.feature-main > .prose {
  max-width: 75ch;
}

.feature-files {
  margin-top: 2rem;
}

.feature-files > h3 {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Under its feature, with a rule to mark where it starts. */
.feature-rail {
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

/* A feature that hasn't been loaded: its heading, smaller, as a link to it. */
.feature.stub {
  margin-top: 1rem;
  padding-top: 1rem;
}

.feature.stub h2 {
  font-size: 1.1rem;
  font-weight: 500;
}

@media (min-width: 56rem) {
  .reader {
    grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
    align-items: start;
  }

  .reader-main {
    padding-top: 2rem;
  }

  /* The tree scrolls by itself, and stays put while the features go by. */
  .reader-nav {
    position: sticky;
    inset-inline: auto;
    z-index: auto;
    /* Entries brought into view clear the same space the page keeps clear, or focus on one
       at the very top would nudge the page as well. */
    scroll-padding-top: 1.25rem;
    box-sizing: border-box;
    height: calc(100dvh - var(--header-height));
    padding-block: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 0;
    border-inline-end: 1px solid var(--rule);
  }

  /* Always shown here, so there is nothing to open. A browser that can't show the inside
     of a closed <details> keeps the row instead (and reader.js opens it). */
  @supports selector(::details-content) {
    .reader-nav > details > summary {
      display: none;
    }

    .reader-nav > details::details-content {
      content-visibility: visible;
    }
  }

  .reader-nav > details[open] > summary {
    display: none;
  }

  .reader-nav .tree {
    padding: 0 0.75rem;
  }
}

@media (min-width: 1600px) {
  .reader {
    grid-template-columns: 350px minmax(0, 1fr);
  }
}

@media (min-width: 2000px) {
  .reader {
    grid-template-columns: 500px minmax(0, 1fr);
  }
}

@media (min-width: 80rem) {
  .feature:not(.stub) {
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
    align-items: start;
  }

  /* Beside its feature, and in view for as long as the feature is. A long discussion
     scrolls inside it. */
  .feature-rail {
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    box-sizing: border-box;
    max-height: calc(100dvh - var(--header-height) - 3rem);
    padding-top: 0;
    overflow-y: auto;
    border-top: 0;
    transition: top 0.2s ease;
  }
}

/* A mention of a feature or an issue, and the card that previews it (reference-popover.js). */
a.reference {
  white-space: nowrap;
}

/* A reference to something that isn't there, most likely a typo in its key. */
.reference.broken {
  text-decoration: underline wavy;
  text-decoration-color: #d9453f;
  text-underline-offset: 0.2em;
  cursor: help;
}

.reference-card {
  position: fixed;
  z-index: 20;
  box-sizing: border-box;
  max-width: min(24rem, calc(100vw - 1rem));
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule-strong);
  border-radius: 0.4rem;
  background-color: Canvas;
  color: CanvasText;
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: 0 2px 8px color-mix(in srgb, CanvasText 15%, transparent);
}

/* What a search found. */
.found {
  padding: 0;
  list-style: none;
}

.found > li {
  padding-block: 0.6rem;
  border-top: 1px solid var(--rule);
}

.found > li > p {
  max-width: 80ch;
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

/* The lines a thread is about while the thread is pointed at or has focus, and the threads
   about some lines while those are (intent.js): a bar down the side, not colour alone. */
.block.is-linked,
.block.is-referenced {
  box-shadow: -0.75rem 0 0 0 Canvas, -1rem 0 0 0 CanvasText;
  background-color: var(--panel);
}

.thread.is-linked {
  outline: 2px solid CanvasText;
  outline-offset: -2px;
}

/* In the discussion's form, once it is pointed at some lines: a way back to the whole feature. */
.line-clear {
  display: block;
  margin: 0 0 0.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.line-clear[hidden] {
  display: none;
}
