/* Admin shelf, code editor, changes, history and finder. */
.admin-page {
  max-width: 34em;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--ink);
}
.admin-invite,
.admin-note,
.admin-warn {
  color: var(--dim);
}
.admin-warn {
  color: var(--pin);
}
.admin-gate {
  display: flex;
  gap: 0.6em;
  align-items: center;
}
.admin-code {
  font: inherit;
  letter-spacing: 0.5em;
  width: 6.5em;
  padding: 0.35em 0.6em 0.35em 1.1em;
  background: none;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid var(--hairline);
  outline: none;
}
.admin-go,
.admin-add {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0.35em 0;
}
.admin-go:not(:disabled):hover,
.admin-add:not(:disabled):hover {
  color: var(--ink);
}
.admin-go:disabled {
  color: var(--hairline);
  cursor: default;
}
.admin-row {
  display: flex;
  align-items: baseline;
  gap: 1em;
  padding: 0.45em 0;
  border-bottom: 1px solid var(--hairline);
}
.admin-row-head {
  border-bottom: none;
  margin-top: 0.5em;
}
.admin-col-title {
  flex: 1;
}
.admin-counts {
  color: var(--dim);
}
.admin-face-name {
  flex: 1;
}
.admin-face-file {
  color: var(--dim);
}
.admin-row-new .admin-face-name::after {
  content: " · staged";
  color: var(--dim);
}
.admin-row-out {
  opacity: 0.45;
}
.admin-row-out .admin-face-name {
  text-decoration: line-through;
}
.admin-face-del {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
}
.admin-face-del:hover {
  color: var(--ink);
}
.admin-move {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0 0.25em;
}
.admin-move:not(:disabled):hover {
  color: var(--ink);
}
.admin-move:disabled {
  opacity: 0.3;
  cursor: default;
}
.admin-row-add,
.admin-row-publish {
  border-bottom: none;
  margin-top: 1.2em;
}
.admin-row-publish {
  gap: 1.4em;
  align-items: center;
}
.admin-rollback {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
}
.admin-rollback:hover {
  color: var(--ink);
}

/* ---- the code editor and the changes folder -------------------------------
 * the admin idiom stretched wide: the code's titles where titles live, the
 * text in the main area; verizon folds the titles over the text */
.editor-page,
.changes-page,
.shelf-page,
.history-page {
  max-width: none;
}
.admin-nav {
  border-bottom: none;
  gap: 1.4em;
  margin-top: 0.4em;
}
.admin-nav-link {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0.3em 0;
}
.admin-nav-link.on,
.admin-nav-link:not(.on):hover {
  color: var(--ink);
}
/* the editor in the story idiom: the code's titles in the titles column (they fold under
   their dot), the file itself in the text column, as wide as the measure says */
.editor-story {
  margin-top: 0.8em;
}
.editor-head {
  position: relative;
}
.editor-list-fold {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.55s ease;
}
.editor-list-fold.open {
  grid-template-rows: 1fr;
}
.editor-list-fold > .editor-titles {
  overflow: hidden;
  min-height: 0;
}
.editor-titles {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  align-items: flex-start;
  margin-top: 6px;
  max-height: 62vh;
  overflow-y: auto;
}
.editor-title {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  text-align: left;
  padding: 0.3em 0;
  white-space: nowrap;
}
.editor-title.on {
  color: var(--ink);
}
.editor-title.out {
  opacity: 0.45;
  text-decoration: line-through;
}
.changes-open > .admin-face-del {
  display: block;
  margin-bottom: 0.8em;
}
.editor-title:not(.on):hover {
  color: var(--ink);
}
.editor-body {
  max-width: var(--measure, 29em);
  margin-top: 0;
  font-size: var(--fs);
}
.editor-body > * {
  font-size: var(--fs-mono);
}
.editor-body > .code-surface {
  font-size: var(--admin-code-size);
}
.editor-loading {
  min-height: 20vh;
}

/* the code surface: a transparent textarea over the colored lines; the caret is his,
   the colors and the numbers are the page's. One font metric for both layers. */
.code-surface {
  /* line 1's baseline sits on the story head's calibration constant, so the code's first
       baseline meets the title's baseline exactly as the text's does on every story */
  --code-pad: calc(
    (0.817 + (var(--lh) - 1) / 2) * var(--fs) - 1.05 * var(--fs-mono)
  );
  position: relative;
  height: 62vh;
  min-height: 300px;
  font-family: var(--admin-code-font);
  font-variation-settings: var(--fvs-mono);
  font-size: var(--admin-code-size);
  line-height: var(--admin-code-line-height);
}
.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: var(--code-pad) 0 0 44px;
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
  background: transparent;
  color: transparent;
  caret-color: #dc143c;
  border: 0;
  outline: none;
  resize: none;
  white-space: pre-wrap; /* the code reflows to the measure - the width grip re-lays lines, never covers them */
  word-break: break-all;
  tab-size: 8;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none; /* the site's own scroller hides it too - and a gutter here would skew the wrap math */
}
.code-input::-webkit-scrollbar {
  display: none;
}
.code-input::selection {
  background: #dc143c;
  color: transparent;
}
.code-view,
.code-gutter {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.code-shift {
  position: absolute;
  top: var(--code-pad);
  left: 0;
  width: 100%;
  will-change: transform;
} /* full width: the view's wrap column is the textarea's, to the pixel */
.code-line {
  position: absolute;
  left: 44px;
  width: calc(100% - 44px);
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 8;
  color: var(--ink);
}
.code-measure {
  position: absolute;
  top: var(--code-pad);
  left: 44px;
  width: calc(100% - 44px);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-all;
  tab-size: 8;
} /* the wrap yardstick: the textarea's own text box, offstage */
.code-measure > div {
  min-height: calc(var(--admin-code-line-height) * 1em);
}
.code-gutter {
  width: 44px;
  right: auto;
}
.code-num {
  position: absolute;
  left: 0;
  width: 32px;
  height: calc(var(--admin-code-line-height) * 1em);
  text-align: right;
  color: var(--dim);
  user-select: none;
}
.tok-com,
.tok-pun {
  color: var(--dim);
}
.tok-str {
  color: #dc143c;
}

/* the admin rings' slot in the rail's stack: one flex child holding the page's rings in the
   same column rhythm, so the whole stack - page buttons and admin rings alike - travels with
   the horizon and nothing overlaps (his ruling, 27 Sep 21:00) */
.admin-slot {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* the ring atom outside the rail: the same 34px hairline circle, the word in the tip */
.ring-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  text-decoration: none;
  transition:
    color 0.35s ease,
    border-color 0.35s ease;
}
.ring-btn:hover:not(:disabled),
.ring-btn:focus-visible:not(:disabled) {
  color: var(--ink);
  border-color: var(--ink);
}
.ring-btn:disabled {
  color: var(--hairline);
  cursor: default;
}
.ring-btn[data-tip]:hover:not(:disabled)::after {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-variation-settings: var(--fvs-mono);
  font-size: 9.5pt;
  letter-spacing: 0.04em;
  color: var(--dim);
  pointer-events: none;
}
.admin-apply {
  font: inherit;
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0.55em 0;
  letter-spacing: 0.06em;
}
.admin-apply:not(:disabled):hover {
  color: var(--ink);
}
.admin-apply:disabled {
  color: var(--hairline);
  cursor: default;
}
.changes-title {
  flex: 1;
  font: inherit;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 0;
}
.diff-block {
  padding: 0.4em 0 0.9em 1.2em;
  line-height: 1.5;
}
.diff-block div {
  white-space: pre-wrap;
  word-break: break-all;
}
.diff-out {
  color: var(--dim);
  text-decoration: line-through;
}
.diff-in {
  color: var(--ink);
}
.diff-ctx {
  color: var(--hairline);
}
@media (max-aspect-ratio: 1/1) {
  .code-surface {
    height: 50vh;
  }
}

/* The four admin sections share one title axis. There is no duplicate heading above
   their content: the right column alone changes when a title is chosen. */
.admin-page {
  position: relative;
  min-height: calc(100vh - var(--pin));
  --admin-index-font: var(--font-mono);
  --admin-index-size: 9pt;
  --admin-index-line-height: 1.5;
  --admin-code-font: var(--font-mono);
  --admin-code-size: 9pt;
  --admin-code-line-height: 1.5;
}
.admin-titles {
  position: fixed;
  left: calc(48px + var(--index-inset));
  top: calc(
    var(--pin) + (0.817 + (var(--lh) - 1) / 2) * var(--fs) - 1.05 *
      var(--fs-mono)
  );
  width: calc(300px - var(--index-inset));
  font: var(--admin-index-size)/var(--admin-index-line-height)
    var(--admin-index-font);
  font-variation-settings: var(--fvs-mono);
  letter-spacing: 0;
}
.admin-title-group {
  margin-bottom: calc(1.42 * var(--fs-mono));
}
.admin-title-group + .admin-title-group {
  margin-top: calc(1.42 * var(--fs-mono));
}
.admin-title-group:first-child > .admin-children {
  margin-top: 4px;
}
.admin-section-title,
.admin-child,
.admin-upload {
  font: inherit;
  letter-spacing: inherit;
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.admin-section-title {
  display: flex;
  gap: calc(2 * (1ch + 0.04em));
  align-items: baseline;
  white-space: nowrap;
}
.admin-section-title:hover,
.admin-title-group.on .admin-section-title,
.admin-child:hover,
.admin-child.on {
  color: var(--ink);
}
.admin-title-dot {
  display: inline-block;
  width: calc(1ch + 0.04em);
  color: var(--ink);
}
.admin-children {
  display: none;
}
.admin-children.open {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: calc(0.4 * var(--fs-mono));
}
.admin-upload {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.admin-head-row {
  display: flex;
  align-items: baseline;
  width: 100%;
}
/* The metadata and font rows share one story-body width and flex columns.
   Keep a full empty line between metadata and row 01. */
.shelf-page > .story {
  padding-top: calc(
    (0.817 + (var(--lh) - 1) / 2) * var(--fs) - 1.05 * var(--fs-mono)
  );
}
.admin-shelf-meta {
  display: flex;
  align-items: baseline;
  gap: 1em;
  width: var(--shelf-measure, 735px);
  max-width: calc(100vw - 48px - 300px - 40px - 56px);
  font: var(--admin-index-size)/var(--admin-index-line-height)
    var(--admin-index-font);
  font-variation-settings: var(--fvs-mono);
  letter-spacing: 0;
  margin-bottom: calc(1.5 * var(--fs-mono));
  min-height: calc(var(--admin-index-size) * var(--admin-index-line-height));
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.admin-meta-number {
  min-width: 2.5ch;
}
.admin-meta-name {
  flex: 1;
}
.admin-meta-kind {
  flex: none;
  margin-left: auto;
}
.admin-meta-ghost {
  visibility: hidden;
  pointer-events: none;
}
.admin-child {
  display: block;
  white-space: nowrap;
  position: relative;
  margin-left: calc(3 * (1ch + 0.04em));
}
.admin-kind {
  display: flex;
  justify-content: space-between;
  width: calc(100% - 3 * (1ch + 0.04em));
}
.admin-kind-count {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.admin-page > .story {
  display: block;
  margin-left: 340px;
  margin-top: 0;
}
.admin-page .story-fold {
  display: block;
  opacity: 1;
}
.admin-page .story-body {
  overflow: visible;
}
.admin-page .editor-body {
  margin-top: 0;
}
.admin-face-number {
  color: var(--dim);
  min-width: 2.5ch;
}
.admin-kindpick {
  position: relative;
  flex: none;
}
.admin-kindpick-btn,
.admin-kindpick-one {
  font: inherit;
  letter-spacing: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.admin-kindpick-btn:hover,
.admin-kindpick-one:hover {
  color: var(--ink);
}
.admin-kindpick-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
.admin-kindpick-one.on {
  color: var(--ink);
}
.admin-ring-gap {
  height: 34px;
  display: block;
}
.controls .admin-return {
  position: fixed;
  right: 14px;
  bottom: 14px;
  font: var(--fs-mono)/1 var(--font-mono);
}
@media (max-width: 700px) {
  .controls .admin-return {
    right: 8px;
    bottom: 8px;
  }
}
.tok-num {
  color: #ed788e;
}
.code-num {
  color: #626262;
}
.code-num.active {
  color: #b7b7b7;
}
.code-input::selection {
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.code-line .code-picked {
  background: #dc143c;
  color: #000;
}
.code-line .tok-str.code-picked {
  color: #23ebc3;
} /* inverse of crimson */
.code-line .tok-num.code-picked {
  color: #23ebc3;
} /* bright cyan contrasts the crimson field */
@media (max-aspect-ratio: 1/1) {
  .admin-titles {
    position: relative;
    left: 0;
    top: 0;
    width: calc(100% - 42px);
    padding-bottom: 18px;
  }
  .admin-page > .story {
    margin-left: 0;
    margin-right: 42px;
  } /* keep both the index and rows clear of the mobile control rail */
}

/* The source starts at the horizon, then flows through the page scroller to the top
   edge and all the way down, exactly like the main text; no nested scroll box. */
.editor-page .code-surface {
  height: auto;
  min-height: calc(100vh - var(--pin));
}
.editor-page .code-input {
  position: relative;
  display: block;
  height: auto;
  min-height: calc(100vh - var(--pin));
  overflow: hidden;
  resize: none;
}
.editor-page .code-view,
.editor-page .code-gutter {
  overflow: hidden;
}

/* The code's own finder: a horizon stroke on the right of its text area. The
   hit area is larger than the hairline; the code itself never moves. */
.admin-finder {
  position: fixed;
  top: calc(var(--hline) - 17px);
  width: 34px;
  height: 34px;
  z-index: 12;
  font: var(--admin-code-size)/var(--admin-code-line-height)
    var(--admin-code-font);
}
.admin-find-line {
  position: absolute;
  right: 0;
  top: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: none;
  cursor: text;
}
.admin-finder.open .admin-find-line {
  pointer-events: none;
}
.admin-find-line::after {
  content: "";
  position: absolute;
  right: 0;
  top: 17px;
  width: 34px;
  height: 1px;
  background: var(--hairline);
  transition:
    width 0.26s ease,
    background 0.26s ease,
    box-shadow 0.26s ease;
}
.admin-finder:hover .admin-find-line::after,
.admin-finder:focus-within .admin-find-line::after {
  width: 43px;
  background: var(--ink);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ink) 40%, transparent);
}
.admin-find-input {
  position: absolute;
  right: 0;
  bottom: 17px;
  width: 0;
  height: 18px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  caret-color: #dc143c;
  font: inherit;
  text-align: right;
  pointer-events: none;
}
.admin-finder.open .admin-find-input {
  width: min(var(--find-width, 34px), 260px);
  pointer-events: auto;
}
.admin-finder.open .admin-find-line::after {
  width: min(var(--find-width, 34px), 260px);
}
.admin-find-count {
  position: absolute;
  right: calc(min(var(--find-width, 34px), 260px) + 12px);
  top: 0;
  line-height: 34px;
  color: var(--dim);
  white-space: nowrap;
}
.code-fold {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 14px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
}
.code-fold:hover,
.code-fold:focus-visible {
  color: var(--ink);
}
.code-fold.closed {
  color: var(--ink);
}
.code-match {
  text-decoration: underline;
  text-decoration-color: #dc143c;
  text-underline-offset: 3px;
}

.code-gutter {
  pointer-events: auto;
}
.code-gutter .code-shift {
  pointer-events: none;
}
.code-gutter .code-fold {
  pointer-events: auto;
}

.code-gutter {
  z-index: 2;
}
.code-fold {
  z-index: 3;
}
