:root {
  color-scheme: light;
  --paper: #fcfbf8; --ink: #1f1c18; --soft: #6b645a; --line: #e2ddd3; --tint: #f3eee3; --accent: #8c3b1f; --good: #fff;
  /* Sorts of text. Chosen and checked together, against each paper. */
  --prose: #2a78d6; --speech: #eb6834; --verse: #1baf7a; --direction: #eda100;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --bar: 3rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #171614; --ink: #d8d3c9; --soft: #a1998c; --line: #34312c; --tint: #25221e; --accent: #e39a6f; --good: #171614;
    --prose: #3987e5; --speech: #d95926; --verse: #199e70; --direction: #c98500;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--paper); color: var(--ink); scroll-padding-top: calc(var(--bar) + 1rem); overflow-anchor: none; }
body { margin: 0; font: 400 .9375rem/1.5 var(--sans); }
body.busy, .busy { cursor: progress; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .15em; }
code, .uri { font: .8125rem var(--mono); overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 1px solid var(--line); padding: .25rem .6rem; border-radius: .35rem; cursor: pointer; }
button:hover:enabled { background: var(--tint); }
button:disabled { opacity: .55; cursor: default; }
button.main { background: var(--accent); border-color: var(--accent); color: var(--good); }
button.main:hover:enabled { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
button.danger { color: #b3261e; border-color: currentColor; }
@media (prefers-color-scheme: dark) { button.danger { color: #f2938c; } }
input, select, textarea { width: 100%; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--paper); }
input[type="checkbox"] { width: auto; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
main:focus { outline: none; }
h1 { font: 500 2rem/1.2 var(--serif); margin: 0; text-wrap: balance; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: .8125rem; margin: 1rem 0 .35rem; color: var(--soft); font-weight: 600; }
.soft, .hint { color: var(--soft); }
.error { color: #b3261e; margin: .5rem 0; }
@media (prefers-color-scheme: dark) { .error { color: #f2938c; } }
.warn { font-weight: 600; }
.kind { font: .75rem/1.6 var(--sans); color: var(--soft); white-space: nowrap; }
.acts { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }

/* --- the door --- */
#door { max-width: 22rem; margin: 18vh auto 0; padding: 0 1.25rem; text-align: center; }
#door form, #door label { display: grid; gap: .5rem; margin: 1rem 0; }
#door-says { color: var(--soft); min-height: 1.5em; }

/* --- the bar --- */
#bar { position: sticky; top: 0; z-index: 3; min-height: var(--bar); display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; padding: .4rem 1rem; background: var(--paper); border-bottom: 1px solid var(--line); }
#home { color: inherit; text-decoration: none; font-weight: 600; }
#crumbs { flex: 1; min-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#crumbs a { color: inherit; text-decoration: none; }
#crumbs a:hover { text-decoration: underline; }
#find { flex: 0 1 14rem; }
#state, .state { font-size: .8125rem; color: var(--soft); white-space: nowrap; }
#state.behind, .state.behind { color: var(--accent); font-weight: 600; }
#state.draft::before, .state.draft::before { content: "◌ "; }
#menu { position: absolute; right: 1rem; top: 100%; display: grid; min-width: 12rem; padding: .25rem; background: var(--paper); border: 1px solid var(--line); border-radius: .5rem; box-shadow: 0 6px 24px rgb(0 0 0 / .14); }
#menu button { border: 0; text-align: left; }
#notice { margin: 0; padding: .6rem 1rem; background: var(--tint); border-bottom: 1px solid var(--line); font-weight: 600; }
#say { position: fixed; left: 50%; bottom: 1.25rem; translate: -50%; margin: 0; padding: .4rem .9rem; border-radius: 2rem; background: var(--ink); color: var(--paper); z-index: 4; }
#say:empty { display: none; }

/* --- columns --- */
#text { max-width: 70rem; margin: 0 auto; padding: 2rem 1.25rem 6rem; }
#columns.three { display: grid; grid-template-columns: minmax(12rem, 17rem) minmax(0, 1fr) 20rem; }
#columns.three > #text { width: 100%; max-width: 54rem; padding-top: 1.25rem; }
#outline, #inspector { position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); overflow: auto; padding: 1rem; font-size: .875rem; overscroll-behavior: contain; }
#outline { border-right: 1px solid var(--line); }
#inspector { border-left: 1px solid var(--line); }
#outline ul { list-style: none; margin: 0; padding: 0; }
#outline ul ul { padding-left: .85rem; }
#outline li { margin: .1rem 0; }
#outline a { color: inherit; text-decoration: none; display: inline-block; padding: .05rem .3rem; border-radius: .25rem; }
#outline a:hover { text-decoration: underline; }
#outline a[aria-current] { background: var(--tint); font-weight: 600; }
#outline summary { cursor: default; }
#outline summary a { display: inline; }
#outline li:not(:has(> details)) { padding-left: 1rem; }

.cover { margin-bottom: 1.5rem; }
.cover p { color: var(--soft); margin: .35rem 0; display: flex; gap: .75rem; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; font-weight: 400; padding: .3rem .75rem .3rem 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
thead th { font-size: .8125rem; color: var(--soft); }
td.number { font-variant-numeric: tabular-nums; }
.library th a { font: 1.0625rem var(--serif); }

/* --- the structure of a book --- */
.legend { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; list-style: none; margin: 0 0 1rem; padding: 0; font-size: .875rem; }
.swatch { display: inline-block; width: .65rem; height: .65rem; border-radius: 2px; margin-right: .4rem; }
.structure .name { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: .5rem; align-items: baseline; padding-left: calc(var(--depth) * 1.25rem); max-width: 28rem; }
.structure .name a { color: inherit; text-decoration: none; }
.structure .name a:hover { text-decoration: underline; }
.structure .bar { width: 34%; }
.structure .made { font-size: .8125rem; color: var(--soft); }
.stack { display: flex; gap: 2px; width: max(4px, calc(var(--long) * 100%)); height: 8px; }
.part { flex: var(--size) 0 0; min-width: 2px; border-radius: 1px; }
.part:first-child { border-start-start-radius: 4px; border-end-start-radius: 4px; }
.part:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }
.prose:is(.part, .swatch) { background: var(--prose); }
.speech:is(.part, .swatch) { background: var(--speech); }
.verse:is(.part, .swatch) { background: var(--verse); }
.direction:is(.part, .swatch) { background: var(--direction); }
.structure tbody tr:hover { background: var(--tint); }

/* --- a section --- */
.node { border-radius: .3rem; }
.node:focus { outline: none; }
.row { display: grid; grid-template-columns: 6.25rem minmax(0, 1fr); gap: .5rem; padding: .2rem .5rem; border-radius: .3rem; cursor: default; }
.row:hover { background: color-mix(in srgb, var(--tint) 55%, transparent); }
.chosen > .row { background: var(--tint); box-shadow: inset 3px 0 0 var(--accent); }
.node:focus-visible > .row { outline: 2px solid var(--accent); outline-offset: -1px; }
.row > .kind { padding-top: .15rem; padding-left: .5rem; border-left: 3px solid var(--prose); overflow: hidden; text-overflow: ellipsis; }
.section > .row > .kind, .k-quote > .row > .kind, .k-list > .row > .kind, .k-table > .row > .kind, .k-row > .row > .kind, .k-note > .row > .kind, .k-break > .row > .kind, .k-ref > .row > .kind { border-left-color: var(--line); }
.verse > .row > .kind { border-left-color: var(--verse); }
.speech > .row > .kind { border-left-color: var(--speech); }
.speech > .inside .row > .kind { border-left-color: var(--speech); }     /* as the structure counts it */
.direction.direction > .row > .kind { border-left-color: var(--direction); }
.inside { margin-left: 1.1rem; padding-left: .35rem; border-left: 1px solid var(--line); }
.words { font: 1.0625rem/1.5 var(--serif); overflow-wrap: break-word; min-width: 0; padding-left: calc(var(--indent, 0) * 1.5em); }
.section > .row > .words { font-weight: 600; font-size: 1.2rem; }
.k-speech > .row > .words { font-variant: small-caps; }
.k-stage-direction > .row > .words, .k-cite > .row > .words { font-style: italic; }
.words .link { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .15em; }
.words .span { text-decoration: underline dotted var(--soft); text-underline-offset: .2em; }
.words pre { margin: 0; font: .875rem/1.45 var(--mono); white-space: pre-wrap; }
.words .none, .mark { color: var(--soft); font: .8125rem var(--sans); }
.mark { margin-left: .75rem; }
.shut { font: .875rem var(--sans); margin-left: .75rem; }
.words textarea { font: 1.0625rem/1.5 var(--serif); resize: none; overflow: hidden; display: block; }
.k-code > .row > .words textarea { font: .875rem/1.45 var(--mono); }
.words .acts { font: .875rem var(--sans); font-variant: normal; }
.words .error { font: .875rem var(--sans); font-variant: normal; }

/* --- the inspector --- */
.head { display: grid; gap: .4rem; }
.head select, .head strong { font-weight: 600; }
.uri { border: 0; padding: .1rem 0; text-align: left; color: var(--soft); }
.actions { display: flex; flex-wrap: wrap; gap: .35rem; margin: .9rem 0; }
.actions button { font-size: .8125rem; padding: .2rem .5rem; }
.field { display: grid; gap: .2rem; margin: .6rem 0; }
.field > span { font-size: .8125rem; color: var(--soft); }
.check { display: block; margin: .75rem 0; }
.meta { display: grid; grid-template-columns: minmax(0, 8rem) minmax(0, 1fr) auto; gap: .35rem; align-items: start; margin: .35rem 0; }
.meta > code { padding-top: .35rem; }
.meta > div { display: grid; gap: .25rem; }
.meta input { padding: .2rem .4rem; font-size: .875rem; }
.meta .more:not(:focus) { border-style: dashed; }
.meta button { padding: .15rem .45rem; font-size: .8125rem; }
#inspector details { border-top: 1px solid var(--line); padding: .6rem 0; }
#inspector summary { cursor: pointer; font-weight: 600; font-size: .8125rem; color: var(--soft); }
#inspector ul, #inspector ol { margin: .25rem 0; padding: 0; list-style: none; }
#inspector li { margin: .5rem 0; overflow-wrap: anywhere; }
#inspector li p { margin: 0; }
blockquote { margin: .35rem 0; padding-left: .6rem; border-left: 2px solid var(--line); font-family: var(--serif); max-height: 9em; overflow: auto; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; margin: .5rem 0 0; }
.keys dd { margin: 0; color: var(--soft); }

.hits { list-style: none; padding: 0; margin: 0; }
.hits a { display: grid; grid-template-columns: 6.25rem minmax(0, 1fr); gap: .5rem; padding: .4rem .5rem; color: inherit; text-decoration: none; border-radius: .3rem; font: 1.0625rem/1.5 var(--serif); }
.hits a:hover { background: var(--tint); }
mark { background: color-mix(in srgb, var(--direction) 35%, transparent); color: inherit; }

dialog { width: min(34rem, calc(100vw - 2rem)); max-height: 85vh; overflow: auto; padding: 1.25rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
.log { padding-left: 0; list-style: none; max-height: 55vh; overflow: auto; }

@media (max-width: 68rem) {
  #columns.three { grid-template-columns: minmax(0, 1fr) 19rem; }
  #outline { display: none; }
}
@media (max-width: 48rem) {
  #columns.three { display: block; }
  #inspector { position: sticky; top: auto; bottom: 0; height: auto; max-height: 42vh; border-left: 0; border-top: 1px solid var(--line); background: var(--paper); z-index: 2; }
  #text { padding-inline: 1rem; }
  .row { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .row > .kind { white-space: normal; overflow-wrap: anywhere; }
  .structure .bar { width: 26%; }
  .structure .made, .structure thead th:last-child { display: none; }
  .structure .name { grid-template-columns: minmax(0, 1fr); padding-left: calc(var(--depth) * .75rem); }
  .structure .name .kind { display: none; }
  #crumbs { flex-basis: 100%; order: 5; }
  #find { flex: 1 1 6rem; }
}
