@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/TitilliumWeb-Regular-latin-ext.woff2") format("woff2"),
    url("fonts/TitilliumWeb-Regular.ttf") format("truetype");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/TitilliumWeb-Regular-latin.woff2") format("woff2"),
    url("fonts/TitilliumWeb-Regular.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/TitilliumWeb-Bold-latin-ext.woff2") format("woff2"),
    url("fonts/TitilliumWeb-Bold.ttf") format("truetype");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Titillium Web";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/TitilliumWeb-Bold-latin.woff2") format("woff2"),
    url("fonts/TitilliumWeb-Bold.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Spline Sans Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/SplineSansMono-Regular-latin-ext.woff2") format("woff2"),
    url("fonts/SplineSansMono-Regular.ttf") format("truetype");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Spline Sans Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/SplineSansMono-Regular-latin.woff2") format("woff2"),
    url("fonts/SplineSansMono-Regular.ttf") format("truetype");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

html,
body {
  min-height: 100%;
}

/* Color variables and theme stuff */
.light {
  /* Light theme */
  --bg: #fff;
  --sidebar-bg: #ddd;
  --code: #f8f8f8;

  --table: #ccc;
  --blockquote: #ddd;
  --borders: #ddd;
  --borders-bright: #777;
  --current-page: #444;

  --footer: #888;
  --text-color: black;
  --link-color: #4183c4;
  --link-hover: blue;
  --editor-bg: #f8fafc;
  --editor-fg: #0f172a;
  --editor-border: rgba(15, 23, 42, 0.12);
}

body {
  /* Default dark theme */
  --bg: #100b16;
  --sidebar-bg: #150f1c;
  --code: #181818;

  --table: #333;
  --blockquote: #444;
  --borders: #666;
  --borders-bright: #aaa;
  --current-page: #ccc;

  --footer: #666;
  --text-color: white;
  --link-color: coral;
  --link-hover: lightgreen;
  --editor-bg: #0f172a;
  --editor-fg: #e2e8f0;
  --editor-border: rgba(148, 163, 184, 0.25);

  background-color: var(--bg);
  color: var(--text-color);
  max-width: 1600px;
  font-family: "Titillium Web", sans-serif;
  margin: 0 auto;
  padding: 0 5vw 1em;
  font-size: 1.1rem;
  word-wrap: break-word;
}

.hidden {
  display: none !important;
}

li {
  margin: 0.2em;
}

hr {
  background-color: var(--borders);
  height: 2px;
  border: 0;
}

blockquote {
  color: var(--borders-bright);
  font-style: italic;
  border-left: 0.3em solid var(--blockquote);
  margin: 0;
  padding-left: 1em;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 1.25rem;
}

td,
th {
  border: 1px solid var(--table);
  padding: 0.2em 0.5em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

:not(pre) > code {
  background-color: var(--code);
  padding: 0 0.3em;
  border-radius: 0.4em;
  font-family: "Titillium Web", sans-serif;
  font-size: 0.9em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

img {
  max-width: 100%;
}

pre {
  border-radius: 0.5em;
  padding: 0.4em;
  overflow-x: auto;
  scrollbar-width: thin;
  color: var(--gray);
  background-color: var(--background);
}

pre > code {
  font-family: "Spline Sans Mono", monospace;
  font-size: 1rem;
}

details:hover {
  cursor: default;
}

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

a.external-link {
  position: relative;
}

a.external-link::after {
  content: "";
  display: inline-block;
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  margin-top: -2px;
  margin-left: 4px;
  --icon: url("data:image/svg+xml, %3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' %3E%3Cpath d='M0 0h24v24H0V0z' fill='none' /%3E%3Cpath d='M9 5v2h6.59L4 18.59 5.41 20 17 8.41V15h2V5H9z' /%3E%3C/svg%3E");
  mask-image: var(--icon);
  background-repeat: no-repeat;
  background-size: contain;
  vertical-align: middle;
  background-color: var(--link-color);
}

a.external-link:hover::after,
a.external-link:active::after,
a.external-link:focus-visible::after {
  background-color: var(--link-hover);
}

a:hover,
a:active,
a:focus-visible {
  color: var(--link-hover);
}

.content > article a {
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.content > article a:hover,
.content > article a:active,
.content > article a:focus-visible {
  text-underline-offset: 5px;
}

.doc-meta {
  margin: 1.5rem auto;
  font-size: 0.95rem;
  color: var(--footer);
  display: flex;
  gap: 0.6em;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.doc-meta time {
  font-weight: 600;
}

.doc-meta__hash {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.85em;
  padding: 0.05em 0.4em;
}

.top {
  margin-top: 1em;
  display: grid;
  grid-template-rows: auto auto;
}

.logo-wrapper {
  display: flex;
}

.logo {
  width: 150px;
  height: 75px;
  display: block;
}

.logo svg {
  max-height: 100%;
  width: 100%;
  object-fit: cover;
  --st0: #3c3c3b;
  --st1: #575756;
  --st2: #706f6f;
  --st3: #9d9d9c;
  --st4: #878787;
  --text: #fff;
}

body.light .logo svg {
  --text: #000;
}

.header-switches {
  margin: auto 0 auto auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-switches button {
  background: none;
  cursor: pointer;
  border: none;
  padding: 0;
  display: flex;
}

.header-switches noscript {
  font-size: 0.75rem;
  color: var(--borders-bright);
}

.header-switches svg:hover {
  fill: #fff;
}

body.light .header-switches svg:hover {
  fill: #000;
}

.header-switches .moon,
body.light .header-switches .sun {
  opacity: 0;
}

body.light .header-switches .moon {
  opacity: 1;
}

#sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: inherit;
  border-radius: 50%;
  transition: color 0.2s ease;
}

#sidebar-toggle svg {
  width: 28px;
  height: 28px;
}

#sidebar-toggle:hover,
#sidebar-toggle:focus-visible {
  color: var(--link-hover);
}

.header-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
}

.utility-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 1rem;
}

.utility-bar .search {
  flex: 1 1 260px;
}

.utility-bar .toolbar {
  margin-left: auto;
}

.header-html {
  flex: 1 1 50%;
}

.header-html > *:first-child {
  margin-top: 0;
}

.header {
  text-align: right;
  margin: 0;
  line-height: 1em;
  align-self: end;
}

@media only screen and (max-width: 800px) {
  .header-wrapper {
    flex-direction: column;
    align-items: flex-start;
  }

  .header,
  .header-switches {
    text-align: left;
  }
}

.current-page {
  color: var(--current-page);
}

/* Main content */
.grid {
  display: grid;
  grid-template-columns: clamp(220px, 18vw, 280px) minmax(0, 1fr) clamp(
      220px,
      20vw,
      320px
    );
  grid-template-areas: "summary content sidebar";
  gap: 1.75rem clamp(2.25rem, 4vw, 3rem);
  width: 100%;
  align-items: start;
}

.grid--no-summary {
  grid-template-columns: minmax(0, 1fr) clamp(220px, 24vw, 320px);
  grid-template-areas: "content sidebar";
}

.grid--compact {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "content";
}

.summary-panel {
  grid-area: summary;
  align-self: start;
  background-color: var(--sidebar-bg);
  border-radius: 12px;
  padding: 1rem;
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

body.light .summary-panel {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.summary-panel.summary-inline {
  position: static;
  max-height: none;
  margin: 1.25rem auto;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  max-width: min(500px, 100%);
}

body.light .summary-panel.summary-inline {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.summary-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--current-page);
}

.summary-panel ul {
  padding-right: 0.25rem;
}

.content {
  grid-area: content;
  overflow-x: hidden;
}

.sidebar {
  grid-area: sidebar;
  align-self: start;
  border: none;
  border-radius: 12px;
  background-color: var(--sidebar-bg);
  max-width: 320px;
}

.sidebar-block {
  padding: 1rem;
}

.sidebar-block ul {
  padding-inline-start: 1.5rem;
}

@media only screen and (max-width: 1280px) {
  .grid:not(.grid--no-summary):not(.grid--compact) {
    grid-template-columns: clamp(200px, 26vw, 240px) minmax(0, 1fr);
    grid-template-areas:
      "summary content"
      "summary sidebar";
    gap: 1.5rem clamp(1.75rem, 3vw, 2.25rem);
  }

  .grid--no-summary {
    grid-template-columns: minmax(0, 1fr) clamp(200px, 30vw, 260px);
    grid-template-areas: "content sidebar";
    gap: 1.5rem clamp(1.75rem, 3vw, 2.25rem);
  }

  .sidebar {
    display: none;
  }

  #sidebar-toggle {
    display: flex;
  }
}

@media only screen and (max-width: 1000px) {
  .grid {
    display: block;
  }

  .summary-panel {
    position: static;
    max-height: none;
    margin-bottom: 0;
    box-shadow: none;
  }

  .summary-panel h2 {
    margin-bottom: 0.5rem;
  }

  .summary-panel ul {
    padding-right: 0;
  }

  .summary-panel.summary-inline {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    padding: 1rem 1.2rem;
  }

  body.light .summary-panel.summary-inline {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  }

  .content,
  .sidebar {
    max-width: none;
  }

  .sidebar {
    display: none;
  }
}

.footer {
  color: var(--footer);
  font-style: italic;
  margin: 0;
  font-size: 1rem;
}

.footer > p {
  margin: 0 0 2em;
}

/* Sidebar blocks */
.sidebar-block + .sidebar-block {
  margin-top: 1.5rem;
}

.sidebar-block h2,
.sidebar-block h3 {
  margin-top: 0;
}

.sidebar-block li {
  font-size: 1rem;
}

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

.summary li {
  margin: 0.25rem 0;
  font-size: 1rem;
}

.summary li[data-level="2"] {
  margin-left: 12px;
}
.summary li[data-level="3"] {
  margin-left: 24px;
}
.summary li[data-level="4"] {
  margin-left: 36px;
}
.summary li[data-level="5"] {
  margin-left: 48px;
}
.summary li[data-level="6"] {
  margin-left: 60px;
}

.summary a {
  color: inherit;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  display: inline-block;
}

.summary a.active {
  background: rgba(255, 255, 255, 0.1);
  font-weight: bold;
}

/* Toolbar & search */
.toolbar {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar-group {
  display: inline-flex;
  gap: 0;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar button {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--borders);
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  color: inherit;
  position: relative;
  z-index: 0;
}

.toolbar button:hover {
  border-color: var(--borders-bright);
  color: var(--link-hover);
  z-index: 2;
}

.toolbar-group > button:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.toolbar-group > button:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  z-index: 0;
}

.toolbar-group > button:focus {
  z-index: 2;
}

.toolbar-group > button:hover + button,
.toolbar-group > button:focus-visible + button {
  border-left-color: var(--borders-bright);
}

.search {
  position: relative;
  width: min(280px, 100%);
}

.search input[type="search"] {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--borders);
  background: transparent;
  color: inherit;
  font-size: 0.95rem;
}

.search input[type="search"]:focus {
  outline: none;
  border-color: var(--borders-bright);
}

.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--borders);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.35);
  max-height: 360px;
  overflow-y: auto;
  padding: 0.35rem 0;
  z-index: 40;
}

.search-results.hidden {
  display: none;
}

.search-hit {
  padding: 0.55rem 0.9rem;
  display: block;
  color: inherit;
  cursor: pointer;
}

.search-hit strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  color: var(--link-hover);
}

.search-hit span {
  font-size: 0.82rem;
  color: var(--borders-bright);
}

.search-error {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  color: var(--borders-bright);
}

.search-message {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  color: var(--borders-bright);
}

.search-hit.active,
.search-hit:focus {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

body.light .search-hit.active,
body.light .search-hit:focus {
  background: rgba(0, 0, 0, 0.08);
}

.history-loading,
.history-error,
.history-empty {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--borders);
  border-radius: 10px;
  margin-bottom: 1rem;
}

.history-loading {
  color: var(--borders-bright);
}

.history-empty {
  color: var(--borders-bright);
  font-style: italic;
}

.history-error {
  color: #ff5f5f;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 90;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  background: var(--bg);
  color: inherit;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.45);
  width: min(960px, 92vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

#editor-modal {
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

.modal.modal--narrow {
  width: min(520px, 90vw);
}

.modal.modal--diff {
  width: min(85%, 96vw);
  max-height: 92vh;
  z-index: 120;
}

.modal.modal--fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  transform: translate(-50%, -50%) scale(0.97);
}

.modal.modal--fullscreen.active {
  transform: translate(-50%, -50%) scale(1);
}

.modal.modal--fullscreen .modal-header,
.modal.modal--fullscreen .modal-footer {
  padding: 1.25rem 2rem;
}

.modal.modal--fullscreen .modal-body {
  padding: 2rem;
}

@media (max-width: 720px) {
  .modal.modal--fullscreen .modal-header,
  .modal.modal--fullscreen .modal-footer,
  .modal.modal--fullscreen .modal-body {
    padding: 2rem 1.25rem;
  }
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.sidebar-modal .modal-body {
  padding: 0;
}

.sidebar-modal__body {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.sidebar-modal__container {
  flex: 1 1 auto;
  overflow-y: auto;
  background: var(--sidebar-bg);
  padding: 1.5rem;
}

.sidebar-modal__container .sidebar {
  display: block;
  max-width: none;
  width: 100%;
  background: transparent;
  border-radius: 0;
  min-height: 100%;
}

.sidebar-modal__container .sidebar-block {
  padding: 0;
}

.modal-header,
.modal-footer {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--borders);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-footer {
  border-top: 1px solid var(--borders);
  border-bottom: none;
}

.modal-body {
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
  margin: 0.5rem;
}

.icon-button {
  border: none;
  background: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--borders-bright);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button:hover {
  color: var(--link-hover);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  border: 1px solid var(--borders);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font: inherit;
  background: transparent;
  color: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: 2px solid rgba(255, 255, 255, 0.15);
  border-color: var(--borders-bright);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--borders-bright);
  margin: 0;
}

.form-hint.error {
  color: #ff5f5f;
}

.button-primary,
.button-secondary {
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-primary {
  background: var(--link-color);
  color: #ffffff;
  border-color: var(--link-color);
}

.button-secondary {
  background: transparent;
  color: inherit;
  border: 1px solid var(--borders);
}

.button-primary:disabled,
.button-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-group {
  display: flex;
  gap: 0.75rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-entry {
  border: 1px solid var(--borders);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-title {
  font-weight: 600;
}

.history-meta {
  font-size: 0.8rem;
  color: var(--borders-bright);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-select {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.85;
  cursor: pointer;
}

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

.history-actions label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.history-diff-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  height: 100%;
}

.history-diff-body .diff-view {
  flex: 1 1 auto;
  max-height: none;
  margin: 0;
}

.diff-view {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 12px;
  overflow: auto;
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.82rem;
  max-height: 300px;
  margin-top: 1rem;
  white-space: pre;
}

.diff-view .line-add {
  color: #16a34a;
}
.diff-view .line-del {
  color: #dc2626;
}
.diff-view .line-info {
  color: #60a5fa;
}
.diff-view .line-meta {
  color: #fbbf24;
}

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.editor-tabs {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--borders);
  border-radius: 8px;
  width: fit-content;
}

.editor-tabs button {
  border: none;
  background: transparent;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 600;
  border-radius: 8px;
  color: inherit;
}

.editor-tabs button.active {
  background: var(--link-color);
  color: #ffffff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.editor-toolbar button {
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--borders);
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: inherit;
}

.editor-toolbar button:hover {
  border-color: var(--borders-bright);
}

.editor-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.editor-workspace textarea,
.editor-workspace .editor-preview {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
}

.editor-workspace textarea {
  font-family: "Spline Sans Mono", monospace;
  font-size: 0.9rem;
  resize: vertical;
  background: var(--editor-bg);
  color: var(--editor-fg);
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  padding: 1rem;
  line-height: 1.55;
}

.editor-preview {
  border: 1px solid var(--editor-border);
  border-radius: 12px;
  padding: 1rem;
  overflow-y: auto;
  background: var(--editor-bg);
  color: var(--editor-fg);
}

.editor-workspace--preview .editor-preview {
  min-height: 320px;
}

.editor-status {
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: var(--borders-bright);
}

.editor-status.error {
  color: #ff5f5f;
}
.editor-status.success {
  color: #16a34a;
}

body.modal-open {
  overflow: hidden;
}

.z-back-to-top {
  position: fixed;
  right: 4vw;
  bottom: 4vw;
  background: var(--sidebar-bg);
  color: var(--borders-bright);
  border: 1px solid var(--borders);
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
  z-index: 120;
}

.z-back-to-top::before {
  content: "";
  width: 100%;
  height: 100%;
  background-color: var(--editor-fg);
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M12%206l-6%206h4v6h4v-6h4z%22/%3E%3C/svg%3E")
    no-repeat center / contain;
}

body.light .z-back-to-top {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.z-back-to-top:hover,
.z-back-to-top:focus-visible {
  border-color: var(--borders-bright);
  color: var(--link-hover);
}

.z-back-to-top--active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.directory {
  display: block;
}

.directory h1 {
  margin: 0 0 0.75rem;
}

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

.directory-list--root {
  margin-top: 0.75rem;
}

@media (min-width: 960px) {
  .directory-list--root {
    column-count: 2;
    column-gap: 2.5rem;
  }
}

.directory-item {
  display: block;
  margin: 0.3rem 0;
  break-inside: avoid;
  scroll-margin-top: 96px;
}

.directory-item--page > a,
.directory-branch > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: inherit;
  text-decoration: none;
}

.directory-item--page > a {
  font-weight: 400;
}

.directory-item--page > a:hover,
.directory-item--page > a:focus-visible {
  text-decoration: underline;
}

.directory-item--page > a::before {
  content: "";
  display: inline-block;
  width: 1.1rem;
  height: 1.25rem;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8%201.5h7l5%205V20a2%202%200%200%201-2%202H8a2%202%200%200%201-2-2V3.5a2%202%200%200%201%202-2Z'/%3E%3Crect x='9.2' y='10.2' width='8.6' height='1.8' rx='0.9'/%3E%3Crect x='9.2' y='14' width='9.8' height='1.8' rx='0.9'/%3E%3Crect x='9.2' y='17.8' width='6.8' height='1.8' rx='0.9'/%3E%3C/svg%3E")
    no-repeat center / contain;
  opacity: 0.85;
}

.directory-branch {
  display: block;
}

.directory-branch > summary {
  cursor: pointer;
  padding: 0.15rem 0;
  list-style: none;
  font-weight: 600;
}

.directory-branch > summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: currentColor;
  opacity: 0.6;
  transition: transform 0.15s ease;
}

.directory-branch[open] > summary::before {
  transform: rotate(90deg);
}

.directory-label {
  flex: 1;
}

.directory-count {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.14);
  color: var(--link-hover);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}

body.light .directory-count {
  background: rgba(0, 0, 0, 0.12);
  color: var(--link-color);
  border-color: rgba(0, 0, 0, 0.18);
}

.directory-list ul {
  list-style: none;
  margin: 0.25rem 0 0.35rem 0.8rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--borders);
}

.directory-list ul > li {
  position: relative;
  padding-left: 0.8rem;
  margin: 0.25rem 0;
}

.directory-list ul > li::before {
  content: "";
  position: absolute;
  top: 0.85em;
  left: -0.8rem;
  width: 0.75rem;
  border-top: 1px solid var(--borders);
  opacity: 0.6;
}

.directory-branch > summary:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.directory-branch > summary:hover {
  color: var(--link-hover);
}

.directory-item--group .directory-count {
  margin-left: auto;
}

.directory-item--active > a,
.directory-item--active > .directory-branch > summary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--link-hover);
  border-radius: 6px;
  padding: 0.18rem 0.55rem;
}

body.light .directory-item--active > a,
body.light .directory-item--active > .directory-branch > summary {
  background: rgba(0, 0, 0, 0.08);
}

.directory-item--active > .directory-branch > summary::before {
  opacity: 0.85;
}

.directory-item:target > a,
.directory-item:target > .directory-branch > summary {
  box-shadow: inset 0 0 0 1px var(--link-hover);
  border-radius: 6px;
}
