:root {
  --bg: #151515;
  --surface: #202020;
  --fg: #ededed;
  --muted: #8f8d88;
  --accent: #e0855f;
  --ok: #6fbf73;
  --bad: #cf6a5a;
  --rule: #2f2f2f;

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", Menlo,
    "DejaVu Sans Mono", Consolas, monospace;

  --measure: 52rem;
  --bar-h: 3.5rem;
  --bar-top: 1rem;
}

* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
}

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

/* ---- pill top bar, floating over the title image ---- */

.topbar {
  position: sticky;
  top: var(--bar-top);
  z-index: 10;
  width: calc(100% - 2.5rem);
  max-width: var(--measure);
  height: var(--bar-h);
  margin: var(--bar-top) auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 0.75rem 0 1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  color: var(--fg);
  text-decoration: none;
}

.brand-mark {
  height: 1.9rem;
  width: auto;
  display: block;
}

.brand-name {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.tabs a {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tabs a:hover,
.tabs a:focus-visible {
  color: var(--fg);
  background: #2a2a2a;
}

/* ---- content ---- */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.75rem;
}

.page > main {
  margin-top: 1rem;
}

h1 {
  margin: 2rem 0 1rem;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--rule);
  font-size: 0.9em;
}

ul,
ol {
  padding-left: 1.25rem;
}

/* ---- cards ---- */

.cards {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
  display: grid;
  /* as many equal columns as fit; 1fr rows make every card as tall as the
     tallest one, so the grid stays even however long a description is */
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.75rem;
}

.card {
  /* grid items default to min-width: auto, which would let a clamped
     one-line text stretch the card instead of being clipped */
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-title a {
  text-decoration: none;
}

.card-title a:hover,
.card-title a:focus-visible {
  text-decoration: underline;
}

.card-stars {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.card-text {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

/* one line only, the rest is cut off with an ellipsis */
.card-text--clamp {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  /* auto top margin pins the chips to the bottom of an equal-height card */
  margin: 0.8rem 0 0;
  padding: 0;
}

.card .chips {
  margin-top: auto;
}

.chips li {
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.8rem;
}

.empty {
  margin-top: 1.5rem;
  color: var(--muted);
}

/* ---- admin: code creation ---- */

.codeform {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
}

.codeform label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.codeform input {
  appearance: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9rem;
}

.codeform input[type="number"] {
  width: 5rem;
}

.codeform input:focus {
  outline: none;
  border-color: var(--muted);
}

.codeform button,
.linkbutton {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.codeform button:hover,
.linkbutton:hover {
  border-color: var(--muted);
}

.linkbutton {
  padding: 0.15rem 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tablewrap {
  overflow-x: auto;
}

.codetable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.codetable th,
.codetable td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  white-space: nowrap;
}

.codetable th {
  color: var(--muted);
  font-weight: 600;
}

.codetable tr.is-expired td {
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
}

.badge--ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

/* ---- floating code entry ---- */

.codebox {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 2.5rem;
  padding: 0 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  /* own compositing layer: a fixed element that changes size while the page
     scrolls otherwise leaves repaint trails in Firefox */
  will-change: transform;
  transform: translateZ(0);
}

.codebox-toggle {
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.codebox:hover .codebox-toggle,
.codebox:focus-within .codebox-toggle {
  color: var(--fg);
}

/* hidden outright until hovered or focused — animating the width of a fixed
   element is what produced the stray repaint lines, so it just toggles */
.codebox-input {
  /* appearance:none is what actually removes Firefox's native field
     rendering; background alone leaves a light 1px artefact behind */
  appearance: none;
  display: none;
  width: 8rem;
  min-width: 0;
  height: 1.6rem;
  padding: 0 0.5rem 0 0.35rem;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  /* masks the typed code without being a password field */
  -webkit-text-security: disc;
  text-security: disc;
}

.codebox-input:focus,
.codebox-input:focus-visible {
  outline: none;
  box-shadow: none;
}

.codebox:hover .codebox-input,
.codebox:focus-within .codebox-input {
  display: block;
}

.codebox-input::placeholder {
  color: var(--muted);
}

.codebox[data-state="pending"] {
  border-color: var(--muted);
}

.codebox[data-state="ok"] {
  border-color: var(--ok);
}

.codebox[data-state="ok"] .codebox-toggle {
  color: var(--ok);
}

.codebox[data-state="denied"] {
  border-color: var(--bad);
}

.codebox[data-state="denied"] .codebox-toggle {
  color: var(--bad);
}

/* ---- markdown-rendered content ---- */

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

.prose h2 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0.9rem 0;
}

.prose li {
  margin: 0.2rem 0;
}

.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

.prose pre {
  margin: 1.2rem 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.875rem;
}

.prose table {
  display: block;
  overflow-x: auto;
  width: 100%;
  margin: 1.2rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--rule);
  text-align: left;
}

.prose th {
  background: var(--surface);
  font-weight: 600;
}

.prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.prose img {
  max-width: 100%;
  height: auto;
}

.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}

/* four tabs plus the brand no longer fit at phone widths */
@media (max-width: 34rem) {
  .topbar {
    gap: 0.5rem;
    padding-left: 0.75rem;
  }

  .brand-name {
    display: none;
  }

  .brand-mark {
    height: 1.5rem;
  }

  .tabs a {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
  }
}

/* ---- admin: the page manager ---- */

.section {
  margin-top: 2.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1rem;
  font-weight: 600;
}

.hint {
  margin: 0.75rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.notice {
  margin: 1rem 0 0;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.85rem;
}

.notice--ok {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
}

.notice--bad {
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  color: var(--bad);
}

.codeform .prefix {
  margin-right: -0.35rem;
  color: var(--muted);
  font-family: var(--mono);
}

.codeform select,
.rowform select {
  appearance: none;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.codeform select:focus,
.rowform select:focus,
.rowform input:focus {
  outline: none;
  border-color: var(--muted);
}

.linkbutton--bad {
  color: var(--bad);
}

.linkbutton:disabled {
  opacity: 0.3;
  cursor: default;
}

.pagetable td {
  white-space: nowrap;
  vertical-align: middle;
}

.pagetable-order {
  display: flex;
  gap: 0.15rem;
}

.pagetable-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.pagetable-actions .linkbutton {
  text-decoration: none;
}

.rowform {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.rowform input[type="text"] {
  appearance: none;
  width: 10rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
}

/* ---- the standalone editor at /edit/page/<slug> ---- */

.editform {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.editform textarea {
  width: 100%;
  min-height: 26rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
}

.editform textarea:focus {
  outline: none;
  border-color: var(--muted);
}

.editform-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.editform-actions button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.editform-actions button:hover {
  border-color: var(--muted);
}

.editform-actions .linkbutton {
  text-decoration: none;
}

/* ---- editing the page where it stands ---- */

/* mirrors the code box in the opposite corner */
.penbox {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  /* same repaint guard as the code box */
  will-change: transform;
  transform: translateZ(0);
}

.penbox:hover,
.penbox:focus-visible {
  border-color: var(--muted);
  color: var(--fg);
}

.editor {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(0 0 0 / 0.6);
}

/* [hidden] loses to the display above unless it is said again */
.editor[hidden] {
  display: none;
}

/* the page behind the panel should not scroll away under it */
body.is-editing {
  overflow: hidden;
}

body.is-editing .penbox,
body.is-editing .codebox {
  display: none;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  width: min(64rem, 100%);
  max-height: min(86vh, 56rem);
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--bg);
  overflow: hidden;
}

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.editor-name {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.editor-grow {
  flex: 1;
}

.editor-state {
  color: var(--muted);
  font-size: 0.78rem;
}

.editor-state[data-tone="ok"] {
  color: var(--ok);
}

.editor-state[data-tone="bad"] {
  color: var(--bad);
}

.editor-tab,
.editor-save,
.editor-close {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.editor-tab:hover,
.editor-save:hover,
.editor-close:hover {
  border-color: var(--muted);
  color: var(--fg);
}

.editor-tab.is-on {
  border-color: var(--muted);
  color: var(--fg);
}

.editor-save {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent);
}

.editor-save:disabled {
  opacity: 0.5;
  cursor: default;
}

.editor-close {
  padding: 0.3rem 0.6rem;
}

.editor-source {
  flex: 1;
  min-height: 16rem;
  padding: 1rem 1.15rem;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.65;
  resize: none;
  outline: none;
  tab-size: 2;
}

.editor-preview {
  flex: 1;
  min-height: 16rem;
  padding: 0.25rem 1.15rem 1rem;
  overflow-y: auto;
}

.editor-hint {
  margin: 0;
  padding: 0.45rem 0.8rem;
  border-top: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
}

.editor-hint kbd {
  padding: 0.05rem 0.3rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  font-family: var(--mono);
  font-size: 0.72rem;
}

@media (max-width: 34rem) {
  .editor {
    padding: 0;
  }

  .editor-panel {
    max-height: 100vh;
    height: 100vh;
    border: 0;
    border-radius: 0;
  }
}
