/* A page: the text in the middle of the window at its measure, its outline against the
   left edge and a rail against the right, so the text reads as the middle of the page.
   The rail is part of the page and scrolls with it; the outline stays in view. Below a
   thousand pixels the outline folds above the text and the rail drops under it, its
   blocks in two columns. The grid is the page's own, in its
   two layouts: a source and a diff are an article.page too, and flow as one column. */

main.full {
  max-width: none;
}

article.page.sided,
article.page.reader {
  --reading: 45rem;
  --rail: 19rem;
  --side: 15rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--reading)) minmax(calc(var(--rail) + 2.5rem), 1fr);
  grid-template-areas:
    "top top top"
    "side head rail"
    "side body rail";
  /* The trees span the head row and the body row; only the body row stretches for them,
     so a fold opening in the rail never pushes the text down. */
  grid-template-rows: auto auto 1fr auto;
  column-gap: 2.5rem;
  align-items: start;
}

/* The left column makes room for the outline, whether or not the page has one, so the
   text sits at the same place on every page. */
article.page.sided {
  grid-template-columns: minmax(calc(var(--side) + 2.5rem), 1fr) minmax(0, var(--reading)) minmax(calc(var(--rail) + 2.5rem), 1fr);
}

article.page.reader {
  --reading: 44rem;
  grid-template-areas:
    "top top top"
    ". head ."
    ". body ."
    ". comments ."
    ". notes .";
}

article.page .top {
  grid-area: top;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  margin-bottom: 1.6rem;
}

/* The way here, discreet, over the text and level with the switch. */
article.page .top .crumbs {
  grid-column: 2;
  margin: 0;
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

article.page .top .page-views {
  grid-column: 3;
  justify-self: end;
}

/* The switch between the page, the text alone and the stored text: one control with
   three steps, the current one raised, on the crumbs line; the only chrome the reader
   keeps, since it is the way back. */
.page-views {
  display: inline-flex;
  margin-left: auto;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--wash);
  font-size: var(--text-xs);
  line-height: 1;
}

.page-views a {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
}

.page-views a:hover {
  color: var(--ink);
  text-decoration: none;
}

.page-views [aria-current="page"] {
  color: var(--ink);
  background: var(--sheet);
  font-weight: 500;
  box-shadow: 0 1px 2px rgb(0 0 0 / 8%), 0 0 0 1px color-mix(in srgb, var(--line) 70%, transparent);
}

article.page .head {
  grid-area: head;
}

article.page .head h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0;
}

/* The title, and beside it the way to work on the page in the person's assistant. */
article.page .head .title {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem 1.5rem;
}

article.page .head .title h1 {
  flex: 1 1 22rem;
}

article.page .head .title .assistant-split .menu {
  left: auto;
  right: 0;
}

article.page .head .line {
  margin-top: 0.6rem;
  font-size: var(--text-sm);
  color: var(--muted);
}

article.page .head .line .warn {
  color: var(--warn);
}

/* What comes next, and the pages the page leads to: the first thing to read. */
article.page .head .next {
  margin-top: 1.4rem;
  padding: 1rem 1.2rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

article.page .head .next h2 {
  margin: 0 0 0.3rem;
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

article.page .head .next .text p {
  margin: 0 0 0.5rem;
}

article.page .head .next .text p:last-child {
  margin-bottom: 0;
}

article.page .head .next .ways {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.6rem;
  margin: 0.8rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-md);
}

article.page .head .next .text + .ways:first-child,
article.page .head .next .ways:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

article.page .head .next .ways .key {
  color: var(--muted);
  margin-right: 0.3rem;
}

article.page .head .banner {
  max-width: none;
}

/* Context links remain recognisable without relying on their color alone. */
article.page .banner a,
article.page .rail .standing > a {
  text-decoration: underline;
}

/* The rail: one column of short rows, a label beside each value, a rule between blocks.
   Nothing in it wraps mid-word: a value too long for its line is cut, carries the whole
   of itself in its tooltip, and the raw view has all of it. */
article.page .rail {
  grid-area: rail;
  justify-self: end;
  width: var(--rail);
  padding-left: 1.5rem;
  border-left: 1px solid var(--line);
  font-size: var(--text-sm);
  line-height: 1.45;
  display: grid;
  align-content: start;
}

article.page .rail > section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 0.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

article.page .rail > section:first-child {
  border-top: 0;
  padding-top: 0.3rem;
}

article.page .rail h2,
article.page .side h2,
article.page .written-from h2,
article.page .comments.foot h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

article.page .rail h2 span {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  white-space: nowrap;
}

article.page .rail a {
  color: var(--ink);
}

article.page .rail .quiet {
  color: var(--muted);
}

article.page .rail .warn {
  color: var(--warn);
}

article.page .rail .evidence.old {
  color: var(--in);
}

article.page .rail .row {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: baseline;
  margin: 0;
}

article.page .rail .row > :first-child {
  color: var(--muted);
  font-size: var(--text-xs);
}

article.page .rail .row > :last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

article.page .rail .standing .row > :last-child {
  white-space: normal;
}

article.page .rail .standing .rows {
  margin-top: 0.6rem;
}

article.page .rail .standing summary > span.warn {
  color: var(--warn);
}

article.page .rail .badge {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 0.4rem;
  background: var(--sheet);
}

article.page .rail ol,
article.page .rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

article.page .rail li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.45rem;
  align-items: baseline;
}

article.page .rail li .n {
  color: var(--muted);
  min-width: 1.1em;
  font-size: var(--text-xs);
}

article.page .rail .sources li .n {
  color: var(--in);
  font-weight: 600;
}

article.page .rail li .n.v {
  color: var(--out);
  font-weight: 600;
}

article.page .rail li .t {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

article.page .rail li .k,
article.page .rail li small {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

article.page .rail li .k a {
  color: var(--muted);
  text-decoration: underline;
}

/* The history and the links unfold in place, a fold each. */
article.page .rail summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
}

article.page .rail summary::-webkit-details-marker {
  display: none;
}

article.page .rail summary > span:first-child {
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

article.page .rail summary > span:last-child {
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

article.page .rail summary > span:last-child::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 0.5rem;
  border-right: 1.2px solid currentcolor;
  border-bottom: 1.2px solid currentcolor;
  transform: rotate(-45deg) translateY(-1px);
}

article.page .rail details[open] summary > span:last-child::after {
  transform: rotate(45deg) translateY(-2px);
}

article.page .rail details > turbo-frame {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

article.page .rail details section {
  display: grid;
  gap: 0.35rem;
}

article.page .rail details section h2 {
  margin-top: 0.4rem;
}

article.page .rail details .wide {
  color: var(--muted);
  font-size: var(--text-xs);
}

article.page .tree {
  gap: 0.1rem;
}

article.page .tree h2 {
  margin-bottom: 0.4rem;
}

article.page .tree .branch {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem;
  align-items: baseline;
  margin: 0;
}

article.page .tree .branch > span:first-child {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--text-xs);
  white-space: pre;
}

article.page .tree a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A group of children folds: its count on the branch, its pages as deeper branches. */
article.page .tree details.group {
  display: block;
}

article.page .tree details.group > .pages {
  display: grid;
  gap: 0.1rem;
  margin-top: 0.1rem;
}

article.page .tree details.group > summary {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.5rem;
  align-items: baseline;
  cursor: pointer;
  list-style: none;
}

article.page .tree details.group > summary::-webkit-details-marker {
  display: none;
}

article.page .tree details.group > summary > span:first-child {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--text-xs);
  white-space: pre;
}

article.page .tree details.group > summary > span:last-child {
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

article.page .tree details.group > summary > span:last-child::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 0.5rem;
  border-right: 1.2px solid var(--muted);
  border-bottom: 1.2px solid var(--muted);
  transform: rotate(-45deg) translateY(-1px);
}

article.page .tree details.group[open] > summary > span:last-child::after {
  transform: rotate(45deg) translateY(-2px);
}

article.page .tree .more a {
  color: var(--muted);
  font-size: var(--text-xs);
  text-decoration: underline;
}

/* The outline: the page's sections against the left edge, the rail's mirror, in view
   while the text scrolls. */
article.page .side {
  grid-area: side;
  justify-self: start;
  position: sticky;
  top: 1.5rem;
  width: var(--side);
  min-width: 0;
  padding-right: 1.5rem;
  border-right: 1px solid var(--line);
  font-size: var(--text-sm);
  line-height: 1.45;
}

article.page .outline summary {
  list-style: none;
  pointer-events: none;
}

article.page .outline summary::-webkit-details-marker {
  display: none;
}

article.page .outline ol {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
}

article.page .outline a {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

article.page .outline a:hover {
  color: var(--ink);
  text-decoration: none;
}

article.page .outline a[aria-current] {
  border-left-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

article.page .body h2[id] {
  scroll-margin-top: 1.5rem;
}

/* Every fact about the page, behind one fold at the foot of the rail. */
article.page .rail .details .facts {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.8rem;
}

article.page .rail .details section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 0.5rem;
  padding: 0.9rem 0 0;
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
}

article.page .tree .n {
  color: var(--muted);
  margin-left: 0.3rem;
}

/* Page body: a document's typography, not the app's. */

article.page .body {
  grid-area: body;
  margin-top: 1.8rem;
  font-size: 16px;
  line-height: 1.6;
}

article.page .body > * + * {
  margin-top: 1em;
}

article.page .body > :first-child {
  margin-top: 0;
}

article.page .body h1 {
  font-size: 22px;
  margin-top: 2rem;
}

article.page .body h2 {
  font-size: 19px;
  margin-top: 2.4rem;
  margin-bottom: 0.7rem;
  letter-spacing: -0.01em;
}

article.page .body h3 {
  font-size: 16px;
  margin-top: 1.7rem;
  margin-bottom: 0.4rem;
}

article.page .body h2 + *,
article.page .body h3 + * {
  margin-top: 0;
}

article.page .body ul,
article.page .body ol {
  padding-left: 1.4rem;
}

article.page .body li + li {
  margin-top: 0.45rem;
}

article.page .body li::marker {
  color: var(--muted);
}

/* A table is as wide as the text and scrolls on its own when it is wider than that. */
article.page .body table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--text-md);
  line-height: 1.45;
  display: block;
  overflow-x: auto;
}

article.page .body th {
  text-align: left;
  padding: 0.4rem 0.9rem 0.4rem 0;
  border-bottom: 1px solid var(--ink);
  vertical-align: bottom;
}

article.page .body td {
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

article.page .body blockquote {
  margin: 0;
  padding: 0.8rem 1rem;
  background: var(--wash);
  border-left: 3px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92em;
  line-height: 1.55;
}

article.page .body blockquote > * + * {
  margin-top: 0.5em;
}

/* A bare address in the text breaks where it must rather than run past the measure. */
article.page .body a {
  overflow-wrap: anywhere;
}

article.page .body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

article.page .body img {
  max-width: 100%;
  border-radius: var(--radius);
}

article.page .body code {
  background: var(--wash);
  padding: 0.05em 0.35em;
  border-radius: var(--radius-sm);
}

article.page .body pre code {
  background: none;
  padding: 0;
}

/* The reader's sources: the rail's list, under the text. */
article.page .written-from,
article.page .comments.foot {
  grid-area: notes;
  margin-top: 2.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  display: grid;
  gap: 0.5rem;
}

article.page .comments.foot {
  grid-area: comments;
}

article.page .written-from h2 span,
article.page .comments.foot h2 span {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

article.page .written-from ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

article.page .written-from li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.45rem;
  align-items: baseline;
}

article.page .written-from li .n {
  color: var(--in);
  font-weight: 600;
  font-size: var(--text-xs);
  min-width: 1.1em;
}

article.page .written-from li .k {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* The text's own footnotes: a mark in the text, the notes at its foot, and the way back. */
article.page .body sup.footnote-ref,
article.question .body sup.footnote-ref {
  font-size: 0.7em;
  line-height: 0;
  margin-left: 1px;
}

article.page .body section.footnotes,
article.question .body section.footnotes {
  margin-top: 2.4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--muted);
}

article.page .body section.footnotes::before,
article.question .body section.footnotes::before {
  content: "Notes";
  display: block;
  margin-bottom: 0.5rem;
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
}

article.page .body section.footnotes ol {
  padding-left: 1.4rem;
}

article.page .body section.footnotes li + li {
  margin-top: 0.35rem;
}

article.page .body section.footnotes li:target {
  color: var(--ink);
}

article.page .body section.footnotes p + p {
  margin-top: 0.35rem;
}

article.page .body .footnote-backref {
  margin-left: 0.3rem;
  color: var(--muted);
}

/* Citation marks, on a page's body and a question's alike. */
article.page .body sup.cite,
article.question .body sup.cite {
  font-size: 0.7em;
  line-height: 0;
  margin-left: 1px;
}

article.page .body sup.cite a,
article.question .body sup.cite a {
  color: var(--in);
  font-weight: 600;
}

/* An HTML page's cover: the document at a glance, drawn at two and a half times the
   column's width and scaled down to it, so it lays itself out as in a window; the
   whole of it is the link into the window. */
article.page .cover {
  grid-area: body;
  margin-top: 1.8rem;
  display: grid;
  gap: 1rem;
  justify-items: start;
}

article.page .cover .preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

article.page .cover .preview iframe {
  width: 250%;
  height: 250%;
  margin: 0;
  border: 0;
  transform: scale(0.4);
  transform-origin: 0 0;
  pointer-events: none;
}

article.page .cover .preview a {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

article.page .cover .preview a:hover {
  box-shadow: inset 0 0 0 1px var(--muted);
}

article.page .cover p {
  margin: 0;
}

article.page .cover a.open {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
}

article.page .cover a.open:hover {
  text-decoration: none;
  opacity: 0.9;
}

.meta {
  color: var(--muted);
  font-size: var(--text-sm);
}

@media (max-width: 1000px) {
  article.page.sided,
  article.page.reader {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "head"
      "side"
      "body"
      "comments"
      "notes"
      "rail";
  }

  article.page .rail {
    justify-self: stretch;
    width: auto;
    padding-left: 0;
    border-left: 0;
    margin-top: 2.4rem;
    border-top: 1px solid var(--line);
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    column-gap: 2.5rem;
  }

  article.page .side {
    position: static;
    justify-self: stretch;
    width: auto;
    padding: 0;
    border-right: 0;
    margin-top: 1.4rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  article.page .outline summary {
    pointer-events: auto;
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  article.page .outline summary h2 {
    margin: 0;
  }

  article.page .outline summary::after {
    content: "›";
    margin-left: auto;
    color: var(--muted);
  }

  article.page .outline details[open] summary::after {
    transform: rotate(90deg);
  }

  article.page .outline ol {
    margin: 0 0 0.8rem;
  }

  article.page .rail > section,
  article.page .rail > section:first-child {
    border-top: 0;
    padding-top: 1.1rem;
  }
}

@media (max-width: 720px) {
  article.page .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .page-views {
    margin-left: auto;
  }

  article.page .body {
    font-size: 15.5px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .page-views a {
    transition: color 0.15s ease, background-color 0.15s ease;
  }
}

/* Front door */

section.now {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1.5rem;
}

section.now .head {
  display: grid;
  gap: 0.25rem;
  align-content: start;
}

section.now .head h2 {
  font-size: var(--text-base);
}

section.now .head small {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}

section.now .head a {
  font-size: var(--text-sm);
}

section.now .body {
  max-width: 66ch;
  font-size: var(--text-base);
  line-height: 1.5;
}

section.now .body > * + * {
  margin-top: 0.6rem;
}

section.now .body ul {
  padding-left: 1.1rem;
  margin: 0;
}

section.now .body li + li {
  margin-top: 0.45rem;
}

section.now .body h1,
section.now .body h2 {
  display: none;
}

section.index {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1.6rem;
}

section.now + section.index {
  margin-top: 2.2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

section.index h2 {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

section.index h2 a {
  color: var(--muted);
}

section.index ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  font-size: var(--text-md);
}

section.index li a {
  color: var(--ink);
}

section.index li .context {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

section.index .more {
  font-size: var(--text-sm);
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  section.now {
    grid-template-columns: 1fr;
  }
}

/* Page diffs */

.diff .head-changes {
  margin-top: 1.2rem;
  max-width: var(--measure);
  font-size: var(--text-md);
}

.diff .head-changes h2 {
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.diff .head-changes ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.diff .head-changes b {
  font-weight: 500;
  margin-right: 0.3rem;
}

.diff del {
  color: var(--bad);
  text-decoration: line-through;
}

.diff ins {
  color: var(--good);
  text-decoration: none;
}

.diff .lines {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  max-width: var(--measure);
  font-family: var(--mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  border-top: 1px solid var(--line);
}

/* On the line, not the list, so the whitespace between two items is not printed as a blank line. */
.diff .lines li {
  padding: 0.05rem 0.6rem;
  border-left: 3px solid transparent;
  white-space: pre-wrap;
}

.diff .lines li.keep {
  color: var(--muted);
}

.diff .lines li.add {
  border-left-color: var(--good);
  background: color-mix(in srgb, var(--good) 8%, transparent);
  color: var(--ink);
}

.diff .lines li.del {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 7%, transparent);
  color: var(--bad);
  text-decoration: line-through;
}

/* The wide surfaces */

main.wide {
  max-width: 88rem;
}

/* Comments: a person's remarks on passages. The open ones are marked in the text, and a
   selection opens the form under it, inside the text's own box. */
/* The box holding the text and its comment furniture takes the text's place in the grid;
   the text inside keeps its rules and loses the margin the box now carries. */
article.page .commentable {
  grid-area: body;
  position: relative;
  margin-top: 1.8rem;
}

article.page .commentable .body {
  margin-top: 0;
}

::highlight(comments) {
  background: var(--mark);
}

:is(article.page .commentable, article.artifact) form.comment[hidden],
:is(article.page .commentable, article.artifact) .comment-mark[hidden],
:is(article.page .commentable, article.artifact) .comment-card[hidden] {
  display: none;
}

:is(article.page .commentable, article.artifact) .comment-mark {
  position: absolute;
  z-index: 2;
  margin: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 3px 10px rgb(0 0 0 / 0.1);
  cursor: pointer;
}

:is(article.page .commentable, article.artifact) .comment-mark:hover {
  border-color: var(--ink);
}

:is(article.page .commentable, article.artifact) form.comment {
  position: absolute;
  z-index: 2;
  margin: 0;
  width: min(28rem, 100%);
  padding: 0.75rem 0.9rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.1);
  display: grid;
  gap: 0.6rem;
  font-size: var(--text-sm);
}

:is(article.page .commentable, article.artifact) form.comment blockquote {
  margin: 0;
  padding-left: 0.6rem;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-size: var(--text-sm);
}

:is(article.page .commentable, article.artifact) form.comment label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

:is(article.page .commentable, article.artifact) form.comment textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font: inherit;
  resize: none;
}

:is(article.page .commentable, article.artifact) form.comment .foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
}

:is(article.page .commentable, article.artifact) form.comment .buttons {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

:is(article.page .commentable, article.artifact) form.comment button {
  min-height: 34px;
  padding: 0 0.9rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

:is(article.page .commentable, article.artifact) form.comment button.cancel {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

:is(article.page .commentable, article.artifact) form.comment button.cancel:hover {
  color: var(--ink);
}

/* A comment's card, shown over its passage on hover: the remark, who and when, and for
   its author the way to reword or withdraw it. */
:is(article.page .commentable, article.artifact) .comment-card {
  position: absolute;
  z-index: 2;
  margin: 0;
  width: min(24rem, 100%);
  padding: 0.7rem 0.9rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.1);
  font-size: var(--text-sm);
  line-height: 1.45;
}

:is(article.page .commentable, article.artifact) .comment-card .text,
:is(article.page .commentable, article.artifact) .comment-card .meta {
  margin: 0;
}

:is(article.page .commentable, article.artifact) .comment-card .meta {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: var(--text-xs);
}

:is(article.page .commentable, article.artifact) .comment-card .meta form {
  display: inline;
}

:is(article.page .commentable, article.artifact) .comment-card button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

:is(article.page .commentable, article.artifact) .comment-card button.link:hover {
  color: var(--ink);
}

:is(article.page .commentable, article.artifact) .comment-card form.edit[hidden],
:is(article.page .commentable, article.artifact) .comment-card form.close[hidden] {
  display: none;
}

:is(article.page .commentable, article.artifact) .comment-card form.edit,
:is(article.page .commentable, article.artifact) .comment-card form.close {
  margin-top: 0.6rem;
}

:is(article.page .commentable, article.artifact) .comment-card form.close label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: var(--text-xs);
}

:is(article.page .commentable, article.artifact) .comment-card textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font: inherit;
  resize: none;
}

:is(article.page .commentable, article.artifact) .comment-card .foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.25rem;
  margin: 0.4rem 0 0;
}

:is(article.page .commentable, article.artifact) .comment-card .foot button {
  min-height: 30px;
  padding: 0 0.8rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

:is(article.page .commentable, article.artifact) .comment-card .foot button.cancel {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

:is(article.page .commentable, article.artifact) .comment-card .foot button.cancel:hover {
  color: var(--ink);
}

:is(article.page, article.artifact) .comments ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

:is(article.page, article.artifact) .comments li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
}

:is(article.page, article.artifact) .comments li.done {
  background: transparent;
  color: var(--muted);
}

:is(article.page, article.artifact) .comments blockquote {
  margin: 0;
  padding-left: 0.5rem;
  border-left: 2px solid var(--mark);
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

:is(article.page, article.artifact) .comments li.done blockquote {
  border-left-color: var(--line);
}

:is(article.page, article.artifact) .comments li p {
  margin: 0;
}

:is(article.page, article.artifact) .comments small form {
  display: inline;
}

:is(article.page, article.artifact) .comments details.close summary {
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: var(--text-xs);
  text-decoration: underline;
}

:is(article.page, article.artifact) .comments details.close summary::-webkit-details-marker {
  display: none;
}

:is(article.page, article.artifact) .comments details.close form {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

:is(article.page, article.artifact) .comments details.close textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font: inherit;
  font-size: var(--text-xs);
  resize: none;
}

:is(article.page, article.artifact) .comments details.close button {
  justify-self: end;
  min-height: 28px;
  padding: 0 0.7rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

:is(article.page, article.artifact) .comments small button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* An HTML page read on its own: one line over the document, and the document has the
   rest of the window. The sources it was written from fold out under the line. */
main.artifact {
  max-width: none;
  padding: 0;
}

article.artifact {
  flex: 1;
  display: flex;
  flex-direction: column;
}

article.artifact > header {
  display: flex;
  align-items: center;
  gap: 0.4rem 1rem;
  flex-wrap: wrap;
  padding: 0.45rem var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
  font-size: var(--text-sm);
}

article.artifact h1 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

article.artifact .line {
  margin: 0;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.8rem;
}

article.artifact .line .warn {
  color: var(--warn);
}

article.artifact details.sources {
  position: relative;
  color: var(--muted);
}

article.artifact details.sources > summary {
  cursor: pointer;
  list-style: none;
}

article.artifact details.sources > summary:hover {
  color: var(--ink);
}

article.artifact details.sources .menu {
  position: absolute;
  left: 0;
  top: 1.6rem;
  z-index: 3;
  width: min(28rem, 90vw);
  max-height: 60vh;
  overflow: auto;
  padding: 0.7rem 0.9rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgb(0 0 0 / 8%);
  color: var(--ink);
}

article.artifact details.sources ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

article.artifact details.sources li {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.45rem;
  align-items: baseline;
}

article.artifact details.sources li .n {
  color: var(--in);
  font-weight: 600;
  font-size: var(--text-xs);
}

article.artifact details.sources li .t {
  display: block;
}

article.artifact details.sources li .k {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
}

article.artifact .page-views {
  margin-left: 0;
}

/* The way to the comments panel, beside the switch, open or not. */
article.artifact .comments-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--wash);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1;
}

article.artifact .comments-toggle:hover,
article.artifact .comments-toggle[aria-expanded="true"] {
  color: var(--ink);
  background: var(--sheet);
  border-color: var(--muted);
}

article.artifact .comments-toggle span {
  min-width: 1.3em;
  padding: 0.15rem 0.35rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--ink);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

article.artifact .comments-toggle span.open {
  background: var(--warn-wash);
  color: var(--warn);
}

article.artifact aside.comments .none {
  margin: 0;
  color: var(--muted);
}

/* The document, and over its right edge, when it is open, the comments panel: floated,
   so the document never reflows and the passage stays where it was selected. The mark
   floats over the document, where the document says the selection is. */
article.artifact .stage {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 0;
}

article.artifact iframe.document {
  flex: 1;
  width: 100%;
  border: 0;
  background: white;
}

article.artifact .stage .comment-mark,
article.artifact .stage form.comment,
article.artifact .stage .comment-card {
  position: absolute;
  z-index: 3;
}

article.artifact aside.comments {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(22rem, 100%);
  overflow-y: auto;
  box-shadow: -8px 0 24px rgb(0 0 0 / 8%);
  padding: 0.8rem 1rem 1.2rem;
  border-left: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  font-size: var(--text-sm);
}

article.artifact aside.comments[hidden] {
  display: none;
}

article.artifact aside.comments header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

article.artifact aside.comments h2 {
  margin: 0;
  font-size: var(--text-xs);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

article.artifact aside.comments button.link {
  color: var(--muted);
  font-size: var(--text-xs);
  text-decoration: underline;
}

article.artifact .comments li.current {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

article.artifact .comments li.lost blockquote {
  text-decoration: line-through;
  text-decoration-color: var(--line);
}

@media (max-width: 700px) {
  article.artifact aside.comments {
    top: auto;
    left: 0;
    width: auto;
    max-height: 60%;
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgb(0 0 0 / 12%);
  }
}
