:root {
  --scale: 1;
  --bg: #ffffff;
  --text: #111111;
  --strong: #000000;
  --muted: #5c5c5c;
  --soft: #3d3d3d;
  --rule: #e2e2e2;
  --code-bg: #f4f4f4;
  --accent: #e8590c;
  --accent-ink: #b93c0a;
  --on-accent: #ffffff;
  --accent-wash: rgba(232, 89, 12, 0.07);
  --accent-tint: rgba(232, 89, 12, 0.13);
  --quote-tint: rgba(232, 89, 12, 0.16);
  --quote-tint-strong: rgba(232, 89, 12, 0.3);
  --card-bg: #f6f6f6;
  --card-border: #dddddd;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --link: #0b57d0;
  --table-head: #f2f2f2;
  --quote-bar: #cfcfcf;
  --raw-bg: #f4f4f4;
  --focus: rgba(232, 89, 12, 0.28);
  --sans: "Atkinson Hyperlegible Next", -apple-system, system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, Menlo, monospace;
  --serif: "Literata", Georgia, serif;
  --inline-code-bg: #f0f0f0;
  --section-rule: #d4d4d4;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: calc(1.1875rem * var(--scale));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

p,
li,
blockquote,
aside.review {
  text-wrap: pretty;
}

#doc {
  max-width: calc(38em + 88px);
  margin: 0 auto;
  padding: 26px 44px 120px;
  position: relative;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--strong);
  scroll-margin-top: 56px;
}

h1 {
  font-size: 1.75em;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  line-height: 1.25;
  font-weight: 650;
}

h2 {
  font-size: 1.4em;
  margin: 2.45em 0 0.45em;
  position: relative;
  letter-spacing: -0.01em;
  font-weight: 620;
  line-height: 1.35;
}

h2::before {
  content: "";
  position: absolute;
  top: -0.65em;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--section-rule);
}

h3 {
  font-size: 1.15em;
  margin: 1.6em 0 0.35em;
  font-weight: 620;
  line-height: 1.4;
}

h4,
h5,
h6 {
  font-size: 0.95em;
  margin: 1.4em 0 4px;
  font-weight: 620;
  color: var(--soft);
}

div.meta {
  font-size: 0.83em;
  color: var(--muted);
  margin-bottom: 18px;
}

p,
li,
blockquote {
  font-family: var(--serif);
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

strong {
  color: var(--strong);
  font-weight: 620;
}

hr {
  border: 0;
  border-top: 1px solid var(--section-rule);
  margin: 22px 0;
}

img {
  max-width: 100%;
  border-radius: 6px;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--inline-code-bg);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

li {
  margin: 6px 0;
}

li > ul,
li > ol {
  margin: 2px 0 2px;
}

li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.3em;
}

input[type="checkbox"] {
  margin: 0 6px 0 0;
  vertical-align: -1px;
  accent-color: var(--accent);
}

blockquote {
  border-radius: 0;
  margin: 0 0 1em;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--quote-bar);
  color: var(--soft);
}

blockquote > :last-child {
  margin-bottom: 0;
}

table {
  border-collapse: collapse;
  margin: 0 0 14px;
  font-size: 0.93em;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

th,
td {
  border: 1px solid var(--rule);
  padding: 5px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--table-head);
  font-weight: 600;
}

figure.code {
  margin: 0 0 14px;
  background: #181825;
  color: #cdd6f4;
  border-radius: 8px;
  overflow: hidden;
}

figure.code figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 13px;
  color: #7f849c;
  padding: 5px 8px 5px 14px;
  border-bottom: 1px solid #313244;
}

figure.code .lang {
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

figure.code .copy {
  font: inherit;
  color: #7f849c;
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}

figure.code .copy:hover {
  color: #cdd6f4;
  background: #313244;
}

figure.code pre {
  margin: 0;
  padding: 10px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86em;
  line-height: 1.55;
}

figure.code code,
figure.code code.hljs {
  display: block;
  background: transparent;
  padding: 0 14px;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
  width: max-content;
  min-width: 100%;
}

figure.code .ln {
  display: inline-block;
  min-width: calc(100% + 28px);
  margin: 0 -14px;
  padding: 0 14px;
  vertical-align: top;
}

figure.code .ln:empty::before {
  content: "\200b";
}

.ln.add {
  background: rgba(166, 227, 161, 0.12);
  color: #a6e3a1;
  box-shadow: inset 3px 0 #a6e3a1;
}

.ln.del {
  background: rgba(243, 139, 168, 0.12);
  color: #f38ba8;
  box-shadow: inset 3px 0 #f38ba8;
}

.ln.hunk {
  color: #89b4fa;
  background: rgba(137, 180, 250, 0.1);
}

.ln.meta {
  color: #7f849c;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-built_in,
.hljs-doctag {
  color: #cba6f7;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-template-variable {
  color: #a6e3a1;
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-attr,
.hljs-attribute {
  color: #fab387;
}

.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: #89b4fa;
}

.hljs-type,
.hljs-title.class_,
.hljs-class .hljs-title {
  color: #f9e2af;
}

.hljs-comment,
.hljs-quote {
  color: #7f849c;
  font-style: italic;
}

.hljs-variable,
.hljs-params,
.hljs-name,
.hljs-tag {
  color: #cdd6f4;
}

.hljs-meta,
.hljs-subst {
  color: #89dceb;
}

.hljs-deletion {
  color: #f38ba8;
}

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

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

pre.raw-html {
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--raw-bg);
  border: 1px dashed var(--rule);
  border-radius: 6px;
  overflow-x: auto;
  color: var(--muted);
  font-size: 0.86em;
  line-height: 1.5;
}

pre.raw-html code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

[data-kind] {
  border-radius: 6px;
}

[data-kind].hovering {
  background: var(--accent-wash);
  box-shadow: -12px 0 0 var(--accent-wash), 12px 0 0 var(--accent-wash);
}

li[data-kind].hovering {
  position: relative;
  isolation: isolate;
  background: none;
  box-shadow: none;
}

li[data-kind].hovering::before {
  content: "";
  position: absolute;
  inset: 0 -12px 0 calc(-1.5em - 12px);
  z-index: -1;
  border-radius: 6px;
  background: var(--accent-wash);
}

figure.code[data-kind].hovering {
  background: #181825;
  box-shadow: 0 0 0 4px var(--accent-wash);
}

#plus {
  position: absolute;
  z-index: 5;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

#plus::before,
#plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  border-radius: 1px;
  background: var(--on-accent);
  transform: translate(-50%, -50%);
}

#plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

#plus:hover {
  transform: scale(1.1);
}

#quote {
  position: absolute;
  z-index: 5;
  padding: 2px 10px;
  border: 0;
  border-radius: 999px;
  font: 600 11.5px/1.5 var(--sans);
  color: var(--on-accent);
  background: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

#quote:hover {
  filter: brightness(1.08);
}

aside.review {
  position: relative;
  border-left: 3px solid var(--accent);
  background: var(--card-bg);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin: 2px 0 14px;
  font-size: 0.9em;
  line-height: 1.5;
  box-shadow: var(--card-shadow);
}

li > aside.review {
  margin: 4px 0 8px;
}

aside.review .review-label {
  font-size: 13px;
  color: var(--accent-ink);
  font-weight: 600;
  margin-bottom: 2px;
}

aside.review .review-quote {
  margin: 0;
  padding: 2px 8px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9em;
}

::highlight(review-quote) {
  background-color: var(--quote-tint);
}

::highlight(review-quote-active) {
  background-color: var(--quote-tint-strong);
}

aside.review .review-actions {
  position: absolute;
  top: 6px;
  right: 8px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

aside.review:hover .review-actions,
aside.review.linked .review-actions,
aside.review:focus-within .review-actions {
  opacity: 1;
}

aside.review.editing .review-actions,
aside.review.editing .review-body,
aside.review.editing .review-quote {
  display: none;
}

aside.review.pending {
  opacity: 0.55;
  transition: opacity 0.15s ease 0.3s;
}

aside.review.pending .review-actions {
  display: none;
}

aside.review.flash {
  animation: flash 1.2s ease-out;
}

@keyframes flash {
  0% {
    box-shadow: 0 0 0 3px var(--focus);
  }
  100% {
    box-shadow: var(--card-shadow);
  }
}

.reveal {
  animation: reveal 1.4s ease-out;
  border-radius: 4px;
}

@keyframes reveal {
  from {
    background-color: var(--accent-tint);
    box-shadow: 0 0 0 4px var(--accent-tint);
  }
}

.review-actions button {
  font: 500 13px var(--sans);
  color: var(--soft);
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
}

.review-actions button:hover {
  background: var(--accent-tint);
  color: var(--accent-ink);
}

.comment-box {
  margin: 4px 0 14px;
  padding: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  box-shadow: var(--card-shadow);
}

aside.review .comment-box {
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.comment-box.pending {
  opacity: 0.55;
  transition: opacity 0.15s ease 0.3s;
}

.comment-box.pending textarea {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.comment-box .box-quote {
  margin-bottom: 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.85em;
  color: var(--muted);
}

.comment-box textarea {
  display: block;
  width: 100%;
  min-height: 64px;
  resize: vertical;
  font: inherit;
  font-size: 0.9em;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 8px;
  outline: none;
}

.comment-box textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.comment-box .row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.comment-box .hint {
  margin-right: auto;
  font-size: 13px;
  color: var(--muted);
}

.comment-box button {
  font: 500 12px var(--sans);
  border-radius: 6px;
  padding: 3px 11px;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--soft);
}

.comment-box button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

#banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-bottom: 1px solid var(--card-border);
  font-size: 15px;
  line-height: 1.4;
}

#banner[hidden] {
  display: none;
}

#banner-text {
  flex: 1;
}

#banner-close {
  font-size: 16px;
  line-height: 1;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

#banner-close:hover {
  background: var(--card-border);
}

.local-image {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85em;
  border: 1px dashed currentColor;
  border-radius: 4px;
  padding: 0 0.4em;
}

.local-link {
  color: inherit;
  text-decoration: none;
}

@media (pointer: coarse) {
  #doc {
    padding-right: max(44px, env(safe-area-inset-right, 0px));
    padding-left: max(44px, env(safe-area-inset-left, 0px));
    -webkit-tap-highlight-color: transparent;
    overflow-wrap: anywhere;
  }

  #doc table {
    overflow-wrap: normal;
  }

  figure.code .copy {
    min-height: 44px;
  }

  aside.review .review-actions {
    position: static;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    opacity: 1;
  }

  .review-actions button {
    min-height: 44px;
    padding: 0 12px;
    font-size: 15px;
  }

  .comment-box textarea {
    font-size: max(17px, 1rem);
    line-height: 1.5;
  }

  .comment-box .hint {
    display: none;
  }

  .comment-box .row {
    justify-content: flex-end;
  }

  .comment-box button {
    min-height: 44px;
    padding: 0 16px;
    font-size: 15px;
  }
}

@media (width < 760px) and (pointer: coarse) {
  #doc p,
  #doc li,
  #doc blockquote {
    hyphens: auto;
  }

  #doc code {
    hyphens: manual;
  }

  #doc {
    max-width: none;
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
  }
}
