:root {
  color-scheme: light dark;
  --canvas: #fff;
  --subtle: #f6f8fa;
  --text: #1f2328;
  --muted: #59636e;
  --border: #d1d9e0;
  --hover: #eff2f5;
  --link: #0969da;
  --primary: #1f8138;
  --primary-hover: #196c2e;
  --success: #dafbe1;
  --success-text: #116329;
  --error: #ffebe9;
  --error-text: #a40e26;
  --tint: #ddf4ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0d1117;
    --subtle: #151b23;
    --text: #f0f6fc;
    --muted: #a3abb5;
    --border: #3d444d;
    --hover: #212830;
    --link: #4493f8;
    --primary: #21783b;
    --primary-hover: #268742;
    --success: #122a1c;
    --success-text: #7ee787;
    --error: #35191e;
    --error-text: #ffa198;
    --tint: #152c43;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, dialog {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font: 14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.topbar { border-bottom: 1px solid var(--border); background: var(--subtle); }
.bar-inner, main { width: min(100% - 40px, 1100px); margin-inline: auto; }
.bar-inner, .heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar-inner { min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.slash { color: var(--muted); }
main { padding: 40px 0 64px; }
.heading { margin-bottom: 18px; }
h1 { margin: 0; font-size: 26px; line-height: 1.3; font-weight: 600; letter-spacing: -.6px; }
.count { vertical-align: middle; border-radius: 20px; background: var(--hover); padding: 2px 8px; font: 500 12px/20px ui-monospace,monospace; }
.button {
  display: inline-flex; justify-content: center; align-items: center; min-height: 34px; padding: 5px 13px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--subtle); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer; box-shadow: 0 1px 0 #1f232809;
}
.button:hover { background: var(--hover); text-decoration: none; }
.primary { background: var(--primary); color: white; border-color: #1b1f241a; }
.primary:hover { background: var(--primary-hover); }
.button:disabled { cursor: wait; opacity: .68; }
#post-list { list-style: none; margin: 0; padding: 0; }
#post-list:not(:empty), .panel, .empty { border: 1px solid var(--border); border-radius: 7px; }
.post-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 22px; }
.post-row + .post-row { border-top: 1px solid var(--border); }
.post-info { min-width: 0; }
.post-title { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.badge { padding: 0 7px; border: 1px solid var(--border); border-radius: 20px; }
.post-meta a { overflow-wrap: anywhere; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.back { display: inline-block; margin-bottom: 10px; }
.panel-head { padding: 12px 18px; margin: 0; font-size: 14px; font-weight: 600; background: var(--subtle); border-radius: 6px 6px 0 0; border-bottom: 1px solid var(--border); }
.panel-body { padding: 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--border); text-align: right; }
.instructions { margin: 0 0 16px; }
.drop-area { position: relative; display: grid; place-content: center; text-align: center; gap: 4px; padding: 32px 16px; border: 1px dashed var(--border); border-radius: 6px; background: var(--subtle); }
.drop-area span { color: var(--link); font-weight: 600; overflow-wrap: anywhere; }
.drop-area small, .label-note { color: var(--muted); font-weight: 400; font-size: 12px; }
.drop-area input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-area.dragging, .drop-area:focus-within { outline: 2px solid var(--link); background: var(--tint); }
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(235px, 30%); align-items: start; gap: 20px; }
.fields { display: grid; gap: 15px; }
.fields label { display: block; font-weight: 600; }
.fields input, .fields textarea, .fields select {
  display: block; width: 100%; margin-top: 5px; min-height: 34px; padding: 5px 9px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--canvas); font-weight: 400; color: var(--text);
}
.fields textarea { resize: vertical; }
.fields .source, code, .slug-field { font-family: ui-monospace,SFMono-Regular,Consolas,monospace; }
.source { line-height: 1.65; tab-size: 4; }
.slug-field { display: flex; align-items: center; margin-top: 5px; }
.slug-field span { display: grid; align-items: center; min-height: 34px; padding: 4px 8px; border: 1px solid var(--border); border-right: 0; border-radius: 6px 0 0 6px; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 400; }
.slug-field input { min-width: 0; margin: 0; border-radius: 0 6px 6px 0; }
.notice { padding: 10px 15px; margin: 0 0 16px; background: var(--success); color: var(--success-text); border-radius: 6px; overflow-wrap: anywhere; }
.notice.error { background: var(--error); color: var(--error-text); }
.error-text { color: var(--error-text); margin: 0; }
dialog { border: none; width: min(360px, 100% - 32px); padding: 4px; margin: min(16vh, 140px) auto auto; }
dialog::backdrop { background: var(--canvas); }
.login-brand { color: var(--muted); font-size: 14px; }
dialog h1 { margin: 10px 0 18px; }
dialog .panel { background: var(--subtle); }
@media (max-width: 720px) {
  main { padding-top: 24px; }
  .edit-grid { grid-template-columns: minmax(0, 1fr); }
  .post-row { padding: 15px; }
  .fields input, .fields textarea, .fields select { font-size: 16px; }
}

.figures-head, .figure-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.figures h3 { margin: 0; font-size: 14px; font-weight: 600; }
.fields .attach { position: relative; font-weight: 500; }
.fields .attach input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.attach:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
#figure-list { list-style: none; padding: 0; margin: 0; }
.figure-row { padding-top: 8px; }
.figure-row code { overflow-wrap: anywhere; font-size: 12px; }
.figure-row button { border: 0; background: none; color: var(--link); font-size: 13px; cursor: pointer; }
.figure-row button:hover { text-decoration: underline; }
.figure-actions { display: flex; }
