/* Wiki web UI, direction "Papier": Source Serif 4 for titles and reading, Instrument Sans for the interface.
   The fonts are served from /static/fonts (SIL OFL, see the OFL-*.txt files there): no external services. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  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: "Source Serif 4";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-ext-wght-normal.woff2") format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-wght-italic.woff2") format("woff2");
  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: "Source Serif 4";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-latin-ext-wght-italic.woff2") format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  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: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- tokens ------------------------------------------------------------------------------------------------- */
/* Light is the default; dark follows the system unless <html data-theme> says otherwise (set by the theme switch). */

:root {
  --bg: #f8f6f1;
  --sf: #fffdf8;
  --ln: #e5e0d5;
  --fg: #22201c;
  --mu: #6f685c;
  --mu2: #a59d8f;
  --ac: #2e6b4f;
  --acs: #e4efe8;
  --acfg: #fff;
  --red: #b5473a;
  --code: #efebe2;
  --add: #e3f0e6;
  --addfg: #1f4d37;
  --del: #f7e1dc;
  --delfg: #7a2c22;
  --mark: #f3e6b8;
  --warn: #fbf1d3;
  --warnln: #ecd9a0;
  --warnfg: #6b5414;
  --scrim: rgba(34, 32, 28, .45);
  --shadow: 0 6px 20px rgba(0, 0, 0, .18);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --pad: 40px;
  --padt: 32px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614; --sf: #201e1b; --ln: #34312b; --fg: #ece7dd; --mu: #a59d8f; --mu2: #7a7367;
    --ac: #7fc4a0; --acs: #24352c; --acfg: #10241a; --red: #e8907e; --code: #25231f;
    --add: #1f3328; --addfg: #a8dcbf; --del: #3a2420; --delfg: #f0b2a6; --mark: #4a4126;
    --warn: #332b17; --warnln: #574a25; --warnfg: #e9d49a; --scrim: rgba(0, 0, 0, .6); --shadow: 0 6px 20px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --sf: #201e1b; --ln: #34312b; --fg: #ece7dd; --mu: #a59d8f; --mu2: #7a7367;
  --ac: #7fc4a0; --acs: #24352c; --acfg: #10241a; --red: #e8907e; --code: #25231f;
  --add: #1f3328; --addfg: #a8dcbf; --del: #3a2420; --delfg: #f0b2a6; --mark: #4a4126;
  --warn: #332b17; --warnln: #574a25; --warnfg: #e9d49a; --scrim: rgba(0, 0, 0, .6); --shadow: 0 6px 20px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (max-width: 759.98px) {
  :root { --pad: 18px; --padt: 18px; }
}

/* --- base ----------------------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--sans);
  color: var(--fg);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 600; }
p { margin: 0; }
form { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; border-color: var(--ac); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--mu); }
.eyebrow { font: 400 12px var(--sans); color: var(--mu); letter-spacing: .04em; }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* --- shell: sidebar + content --------------------------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.sidebar {
  width: 248px; flex: none; position: sticky; top: 0; height: 100vh; overflow: auto;
  display: flex; flex-direction: column; gap: 24px; padding: 28px 22px 22px 26px;
  background: var(--bg);
}
.brand { font: 600 22px var(--serif); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.side-actions { display: flex; flex-direction: column; gap: 10px; }
.side-new { width: 100%; }
.side-new .kbd { font-size: 11px; opacity: .7; }
.side-search {
  height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--ln); background: var(--sf);
  display: flex; align-items: center; font-size: 13px; color: var(--mu);
}
.side-search:hover { text-decoration: none; border-color: var(--mu2); }
.side-search span:first-child { flex: 1; }
.side-nav { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.side-nav a { color: var(--mu); }
.side-nav a[aria-current="page"] { color: var(--fg); font-weight: 600; }
.side-tags { display: flex; flex-direction: column; gap: 9px; }
.side-tags a { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.side-tags a span:last-child { color: var(--mu2); }
.side-tags a[aria-current="page"] { color: var(--ac); }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--mu); }
.linkbtn { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.theme-btn { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ln); background: none; font-size: 12px; color: var(--mu); }

.mobile-head, .scrim, .fab { display: none; }

@media (max-width: 759.98px) {
  .mobile-head {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; height: 56px; padding: 0 6px 0 4px;
    background: var(--bg); border-bottom: 1px solid var(--ln);
  }
  .mobile-head .brand { flex: 1; font-size: 21px; }
  .icon-btn { width: 44px; height: 44px; border: 0; background: none; font-size: 20px; color: var(--fg); display: grid; place-items: center; }
  .icon-btn:hover { text-decoration: none; }
  .icon-btn.mu { color: var(--mu); font-size: 18px; }

  .sidebar {
    position: fixed; z-index: 21; left: 0; top: 0; width: min(300px, 85vw); padding: 22px 22px 26px; gap: 22px;
    transform: translateX(-105%); transition: transform .18s ease; visibility: hidden;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: var(--scrim); }
  .sidebar .side-actions { display: none; }
  .side-nav { gap: 0; font-size: 16px; }
  .side-nav a, .side-tags a { min-height: 44px; display: flex; align-items: center; }
  .side-tags { gap: 0; }
  .side-tags a { min-height: 40px; font-size: 15px; }
  .side-foot { font-size: 14px; }
  .theme-btn { height: 40px; padding: 0 14px; }

  .fab {
    display: flex; position: fixed; right: 20px; bottom: 24px; z-index: 6; height: 56px; padding: 0 22px; gap: 8px;
    align-items: center; border-radius: 999px; border: 0; background: var(--ac); color: var(--acfg);
    font-size: 16px; font-weight: 500; box-shadow: var(--shadow);
  }
  .fab span { font-size: 22px; line-height: 1; }
}

.content {
  width: 100%; max-width: 1120px; padding: var(--padt) var(--pad) 96px;
  display: flex; flex-direction: column; gap: 20px;
}
.content.narrow-col { max-width: 920px; }
.content.tight-col { max-width: 900px; }
.content.mid-col { max-width: 820px; }

/* --- buttons, inputs, chips ----------------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--ln); background: none;
  color: var(--fg); font-size: 14px; font-weight: 400; white-space: nowrap; cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--mu2); }
.btn-primary { border-color: transparent; background: var(--ac); color: var(--acfg); font-weight: 500; }
.btn-primary:hover { border-color: transparent; filter: brightness(1.06); }
.btn-dark { border-color: transparent; background: var(--fg); color: var(--bg); font-weight: 500; }
.btn-dark:hover { border-color: transparent; opacity: .9; }
.btn-outline-ac { border-color: var(--ac); color: var(--ac); font-weight: 500; }
.btn-danger { color: var(--red); }
.btn-danger-solid { border-color: transparent; background: var(--red); color: var(--bg); font-weight: 500; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-md { height: 38px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn-xl { height: 52px; padding: 0 22px; font-size: 16px; }
.btn-block { width: 100%; }
.btn .plus { font-size: 18px; line-height: 1; }
.btn[disabled] { opacity: .5; cursor: default; }

.input {
  height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--ln); background: var(--sf);
  font-size: 15px; width: 100%; min-width: 0;
}
.input-sm { height: 34px; padding: 0 14px; font-size: 14px; }
.input-md { height: 40px; padding: 0 14px; font-size: 14px; }
.input-strong { height: 52px; padding: 0 20px; border: 2px solid var(--ac); font-size: 17px; }
select.input { appearance: auto; padding-right: 12px; border-radius: 8px; height: 38px; width: auto; }

.chips { display: flex; gap: 8px; font-size: 14px; overflow-x: auto; padding-bottom: 2px; }
.chip {
  flex: none; display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--ln); color: var(--mu); background: transparent;
}
.chip:hover { text-decoration: none; border-color: var(--mu2); }
.chip[aria-current="page"] { background: var(--fg); border-color: var(--fg); color: var(--bg); font-weight: 500; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--code); }
.seg.on-sf { background: var(--sf); border: 1px solid var(--ln); }
.seg > a, .seg > button, .seg > label {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; border: 0;
  background: transparent; color: var(--mu); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.seg.small > a, .seg.small > button { height: 30px; }
.seg > a:hover { text-decoration: none; color: var(--fg); }
.seg > [aria-current="page"], .seg > [aria-pressed="true"], .seg > label:has(input:checked) {
  background: var(--bg); color: var(--fg); font-weight: 500; box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.seg.on-sf > [aria-pressed="true"] { background: var(--bg); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

/* --- headings, notices ---------------------------------------------------------------------------------------- */

.head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; border-bottom: 1px solid var(--ln); padding-bottom: 14px; }
.head h1 { flex: 1; font-size: clamp(28px, 4vw, 34px); letter-spacing: -.015em; }
.head h1 a { color: var(--ac); }
.head .head-meta { font-size: 13px; color: var(--mu); }
.head.stacked { flex-direction: column; align-items: stretch; gap: 6px; }
.head.stacked .head-meta { font-size: 14px; }
.h2 { font: 600 22px var(--serif); }

.notice { padding: 12px 16px; border-radius: 10px; font-size: 14px; line-height: 1.5; border: 1px solid transparent; }
.notice p + p { margin-top: 4px; }
.notice.ok { background: var(--acs); }
.notice.error { background: var(--del); color: var(--delfg); }
.notice.warn { background: var(--warn); border-color: var(--warnln); color: var(--fg); }
.notice.info { background: var(--sf); border-color: var(--ln); color: var(--mu); }
.notice-row { display: flex; gap: 14px; align-items: flex-start; }
.notice-icon {
  flex: none; width: 28px; height: 28px; border-radius: 999px; background: #e3c26a; color: #3d2f08;
  display: grid; place-items: center; font-weight: 700;
}
.notice strong { font-weight: 600; }

/* --- start page ----------------------------------------------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 0 48px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 0; border-bottom: 1px solid var(--ln);
}
.card:hover { text-decoration: none; }
.card:hover .card-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.card-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--mu); }
.card-title { font: 600 21px/1.25 var(--serif); }
.card-excerpt { font: 400 15px/1.5 var(--serif); color: var(--mu); text-wrap: pretty; }

.empty { display: flex; flex-direction: column; gap: 14px; max-width: 640px; padding: 24px 0; }
.empty h2 { font-size: clamp(26px, 4vw, 32px); letter-spacing: -.015em; }
.empty p { font: 400 17px/1.6 var(--serif); color: var(--mu); }
.empty-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; margin-top: 6px; }
.option-card {
  min-height: 72px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--ln); background: var(--sf);
  display: flex; flex-direction: column; justify-content: center; gap: 2px; text-align: left; cursor: pointer;
}
.option-card:hover { text-decoration: none; border-color: var(--ac); }
.option-card strong { font: 600 18px var(--serif); }
.option-card span { font-size: 13px; color: var(--mu); }
.option-card.primary { background: var(--acs); border-color: var(--ac); }

/* --- page view ------------------------------------------------------------------------------------------------ */

.page-layout { display: flex; gap: 56px; align-items: flex-start; }
.page-article { flex: 1; min-width: 0; max-width: 700px; display: flex; flex-direction: column; gap: 14px; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--mu); }
.page-actions .back { flex: 1; min-width: 120px; }
.page-article .eyebrow { margin-top: 14px; }
.page-article .eyebrow a:hover { color: var(--fg); }
.page-title { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.page-meta { font-size: 13px; color: var(--mu); }

.rail {
  width: 240px; flex: none; display: flex; flex-direction: column; gap: 28px; padding-top: 96px; font-size: 14px;
  position: sticky; top: 0; align-self: flex-start;
}
.rail-block { display: flex; flex-direction: column; gap: 8px; }
.rail-block a.toc { color: var(--mu); }
.rail-block a.toc.sub { padding-left: 12px; }
.rail-block .back-link { color: var(--ac); }
.missing-card {
  padding: 14px; border-radius: 8px; background: var(--sf); border: 1px solid var(--ln);
  display: flex; flex-direction: column; gap: 6px; color: var(--mu); font-size: 13px;
}
.missing-card .name { color: var(--red); }
.missing-card a { color: var(--ac); font-weight: 500; }
.toc-details { display: none; }

@media (max-width: 1179.98px) {
  .page-layout { flex-direction: column; gap: 0; }
  .rail {
    position: static; width: 100%; max-width: 700px; padding-top: 0; margin-top: 32px; padding-top: 16px;
    border-top: 1px solid var(--ln); gap: 20px; font-size: 15px;
  }
  .rail .rail-toc { display: none; }
  .rail-block .back-link { min-height: 32px; display: flex; align-items: center; }
  .toc-details { display: block; border: 1px solid var(--ln); border-radius: 10px; background: var(--sf); font-size: 14px; }
  .toc-details summary { padding: 10px 14px; cursor: pointer; color: var(--mu); }
  .toc-details nav { display: flex; flex-direction: column; gap: 2px; padding: 0 14px 10px; }
  .toc-details a { min-height: 32px; display: flex; align-items: center; color: var(--mu); }
}

/* rendered markdown */
.prose { display: flex; flex-direction: column; gap: 14px; font: 400 18px/1.7 var(--serif); overflow-wrap: anywhere; margin-top: 6px; }
.prose > * { margin: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.25; scroll-margin-top: 72px; }
.prose h1 { font-size: 28px; margin-top: 12px; }
.prose h2 { font-size: 24px; margin-top: 12px; }
.prose h3 { font-size: 20px; margin-top: 8px; }
.prose h4, .prose h5, .prose h6 { font-size: 18px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 4px; }
.prose li::marker { color: var(--mu); }
.prose a { color: var(--ac); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a.wikilink.missing { color: var(--red); text-decoration-style: dashed; }
.prose code { font: .8em var(--mono); padding: 1px 6px; border-radius: 4px; background: var(--code); }
.prose pre { padding: 14px 18px; border-radius: 6px; background: var(--code); overflow-x: auto; font: 400 14px/1.5 var(--mono); }
.prose pre code { padding: 0; background: none; font: inherit; }
.prose blockquote { padding-left: 16px; border-left: 3px solid var(--ln); color: var(--mu); }
.prose hr { width: 100%; border: 0; border-top: 1px solid var(--ln); }
.prose img { max-width: 100%; border-radius: 6px; }
.prose table { border-collapse: collapse; font-size: 15px; font-family: var(--sans); display: block; overflow-x: auto; }
.prose th, .prose td { padding: 6px 12px; border-bottom: 1px solid var(--ln); text-align: left; }
.prose th { font-weight: 600; }

/* --- dialogs, toast ------------------------------------------------------------------------------------------- */

dialog.sheet {
  width: min(540px, calc(100% - 48px)); max-height: calc(100% - 48px); padding: 22px 22px 24px; border: 0;
  border-radius: 16px; background: var(--bg); color: var(--fg); box-shadow: var(--shadow);
}
dialog.sheet.small { width: min(460px, calc(100% - 48px)); padding: 24px; }
dialog.sheet::backdrop { background: var(--scrim); }
.sheet-body { display: flex; flex-direction: column; gap: 16px; }
.sheet-top { display: flex; align-items: center; }
.sheet-top span { flex: 1; font-size: 13px; color: var(--mu); }
.sheet-close { width: 40px; height: 40px; border: 0; background: none; font-size: 20px; color: var(--mu); }
.sheet-title { font: 600 24px/1.2 var(--serif); }
.sheet-text { font-size: 15px; line-height: 1.55; color: var(--mu); }
.sheet-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.sheet-buttons .btn { flex: 1 1 140px; height: 48px; font-size: 15px; }
.title-input {
  border: 0; border-bottom: 1px solid var(--ln); background: none; padding: 0 0 10px; width: 100%;
  font: 600 clamp(24px, 5vw, 30px)/1.15 var(--serif); letter-spacing: -.015em;
}
.title-input:focus { outline: none; border-bottom-color: var(--ac); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.tpl {
  position: relative; min-height: 64px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--ln);
  background: var(--sf); display: flex; flex-direction: column; justify-content: center; gap: 2px; cursor: pointer;
}
.tpl input { position: absolute; opacity: 0; pointer-events: none; }
.tpl strong { font: 600 17px var(--serif); }
.tpl span { font-size: 12px; color: var(--mu); }
.tpl:has(input:checked) { background: var(--acs); border-color: var(--ac); }
.tpl:has(input:focus-visible) { outline: 2px solid var(--ac); outline-offset: 2px; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 14px; }
.field-row > span { color: var(--mu); }
.field-row .input { flex: 1 1 200px; width: auto; }
.affected { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 10px; background: var(--sf); border: 1px solid var(--ln); font-size: 14px; }
.affected a { color: var(--ac); }

@media (max-width: 759.98px) {
  dialog.sheet, dialog.sheet.small {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92%;
  }
  .sheet-buttons { flex-direction: column-reverse; }
  .sheet-buttons .btn { flex: none; width: 100%; }
}

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 40; padding: 12px 20px;
  border-radius: 999px; background: var(--fg); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
  white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
  animation: toast 2.8s ease forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; visibility: hidden; } }

/* --- centered pages: login, errors, delete -------------------------------------------------------------------- */

.center-page { flex: 1; min-height: 100vh; display: grid; place-items: center; padding: 40px var(--pad); }
.main-col .center-page { min-height: 0; }
.center-box { width: min(480px, 100%); display: flex; flex-direction: column; gap: 14px; }
.center-box.login { width: min(380px, 100%); gap: 16px; }
.center-box h1 { font-size: clamp(30px, 5vw, 40px); line-height: 1.15; letter-spacing: -.02em; }
.center-box .login-brand { font: 600 44px var(--serif); letter-spacing: -.02em; }
.center-box .lead { font: 400 17px/1.6 var(--serif); color: var(--mu); }
.center-box .path { font-size: 13px; color: var(--mu); }
.center-box .buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.center-box .details { font-size: 13px; color: var(--mu); margin-top: 10px; }
.center-box .details code { font: 13px var(--mono); }

/* --- search --------------------------------------------------------------------------------------------------- */

.search-input {
  height: 56px; padding: 0 22px; border-radius: 999px; background: var(--sf); border: 2px solid var(--ac);
  font: 400 20px var(--serif); width: 100%;
}
.search-input:focus { outline: none; }
.search-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; color: var(--mu); }
.results { display: flex; flex-direction: column; border-top: 1px solid var(--ln); }
.result { display: flex; flex-direction: column; gap: 6px; padding: 18px 0; border-bottom: 1px solid var(--ln); }
.result:hover { text-decoration: none; }
.result:hover .result-title { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.result-meta { display: flex; gap: 12px; font-size: 12px; color: var(--mu); }
.result-why { margin-left: auto; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--ln); }
.result-title { font: 600 21px var(--serif); }
.result-snippet { font: 400 15px/1.5 var(--serif); color: var(--mu); }
.result-snippet mark, mark { background: var(--mark); color: var(--fg); padding: 0 2px; border-radius: 2px; }
.no-results { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; color: var(--mu); padding-top: 8px; }
.search-hint { font-size: 13px; color: var(--mu); }

/* loading placeholders (HTMX adds .htmx-request while a request runs): the shape of the result list, no spinner */
.skeleton { display: none; flex-direction: column; border-top: 1px solid var(--ln); }
.htmx-request .skeleton, .skeleton.htmx-request { display: flex; }
.htmx-request.results-wrap > :not(.skeleton) { display: none; }
.skel-row { display: flex; flex-direction: column; gap: 10px; padding: 20px 0; border-bottom: 1px solid var(--ln); }
.skel { height: 12px; border-radius: 6px; background: var(--code); animation: pulse 1.2s ease-in-out infinite alternate; }
.skel.w1 { width: 22%; } .skel.w2 { width: 55%; height: 18px; } .skel.w3 { width: 85%; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .skel, .toast { animation: none; } }

/* --- history / diff ------------------------------------------------------------------------------------------- */

.history { display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: flex-start; }
.revs { flex: 1 1 280px; max-width: 380px; display: flex; flex-direction: column; gap: 4px; }
.rev {
  padding: 12px 14px; border-radius: 8px; border: 1px solid transparent; display: flex; flex-direction: column; gap: 3px;
}
.rev:hover { text-decoration: none; background: var(--sf); }
.rev[aria-current="true"] { border-color: var(--ac); background: var(--sf); }
.rev-top { display: flex; gap: 8px; width: 100%; font-size: 14px; font-weight: 600; align-items: baseline; }
.rev-top .when { font-weight: 400; color: var(--mu); }
.rev-top .badge { margin-left: auto; font: 400 11px var(--mono); color: var(--mu); }
.rev-msg { font-size: 13px; color: var(--mu); }
.diff-col { flex: 3 1 400px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.diff-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 14px; }
.diff-head > span { flex: 1; }
.diff-head b { font-weight: 600; }
.diff {
  margin: 0; border-radius: 8px; border: 1px solid var(--ln); background: var(--sf); padding: 8px 0;
  font: 400 13.5px/1.6 var(--mono); overflow-x: auto;
}
.diff span { display: block; padding: 1px 16px; white-space: pre-wrap; min-height: 22px; color: var(--mu); }
.diff .add { background: var(--add); color: var(--addfg); }
.diff .del { background: var(--del); color: var(--delfg); }
.diff .hunk, .diff .meta { color: var(--mu2); }
.placeholder-box { padding: 24px; border-radius: 8px; border: 1px dashed var(--ln); color: var(--mu); font-size: 14px; }

/* --- list rows: tokens, tags ---------------------------------------------------------------------------------- */

.rows { display: flex; flex-direction: column; }
.row-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--ln); font-size: 15px; }
.row-item .name { flex: 1 1 160px; font-weight: 500; }
.row-item .meta { flex: 1 1 220px; color: var(--mu); font-size: 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form .input { flex: 1 1 220px; max-width: 380px; }
.token-box { padding: 16px 18px; border-radius: 10px; background: var(--acs); display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.token-line { display: flex; flex-wrap: wrap; gap: 10px; }
.token-line code {
  flex: 1 1 240px; min-height: 42px; padding: 10px 14px; border-radius: 6px; background: var(--bg);
  font: 400 14px var(--mono); overflow-wrap: anywhere;
}
.token-line .btn { border-radius: 6px; height: 42px; }

.tag-row { gap: 4px 14px; padding: 0 10px; min-height: 52px; }
.tag-row.selected { background: var(--acs); }
.tag-row .check { width: 20px; height: 20px; accent-color: var(--ac); flex: none; }
.tag-row .name { flex: 1 1 160px; font-weight: 600; }
.tag-row .count { color: var(--mu); font-size: 14px; min-width: 90px; }
.tag-row .act { display: flex; gap: 14px; font-size: 14px; color: var(--mu); }
.tag-row .act .del { color: var(--red); }
.rename-form { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 12px 34px; }
.rename-form .input { max-width: 280px; }
.merge-bar {
  position: sticky; bottom: 24px; align-self: center; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 8px 8px 8px 20px; border-radius: 999px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: 14px;
}
.merge-bar select { height: 36px; border-radius: 999px; border: 0; padding: 0 10px; background: var(--bg); color: var(--fg); }

/* --- import / export, settings -------------------------------------------------------------------------------- */

.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 40px; align-items: start; }
@media (max-width: 999.98px) { .two-col { grid-template-columns: 1fr; } }
.section { display: flex; flex-direction: column; gap: 14px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 118px; padding: 20px; border: 2px dashed var(--ln); border-radius: 12px; text-align: center; font-size: 14px;
}
.drop.over, .drop:focus-within { border-color: var(--ac); background: var(--acs); }
.drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop .sub { font-size: 13px; color: var(--mu); }
.drop .sub u { color: var(--ac); }
.drop .files { font-size: 13px; color: var(--fg); }
.radios { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 14px; }
.radios > span { color: var(--mu); }
.radios label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.radios input { accent-color: var(--ac); width: 16px; height: 16px; }
.panel { border: 1px solid var(--ln); border-radius: 12px; background: var(--sf); overflow: hidden; }
.panel-head { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--ln); font-size: 14px; font-weight: 600; }
.panel-head .counts { margin-left: auto; display: flex; gap: 10px; font-weight: 400; }
.panel-pad { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ok-fg { color: var(--ac); }
.red-fg { color: var(--red); }
.import-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-table td { padding: 9px 16px; border-bottom: 1px solid var(--ln); vertical-align: top; }
.import-table tr:last-child td { border-bottom: 0; }
.import-table td:first-child { font-family: var(--mono); overflow-wrap: anywhere; }
.import-table td:nth-child(2) { color: var(--mu); }
.import-table td:last-child { text-align: right; }
.hint-box { padding: 16px 18px; border-radius: 12px; background: var(--acs); font-size: 14px; line-height: 1.5; }
.hint-box a { color: var(--ac); }
.lead-serif { font: 400 17px/1.5 var(--serif); color: var(--mu); }

.settings-grid { display: grid; grid-template-columns: 200px 1fr; gap: 16px 24px; align-items: center; font-size: 15px; }
.settings-grid > span, .settings-grid > label { color: var(--mu); }
@media (max-width: 759.98px) { .settings-grid { grid-template-columns: 1fr; gap: 6px; } .settings-grid > span { margin-top: 10px; } }
.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.status-card { padding: 16px; border-radius: 10px; border: 1px solid var(--ln); background: var(--sf); display: flex; flex-direction: column; gap: 4px; }
.status-card .label { font-size: 13px; color: var(--mu); display: flex; align-items: center; gap: 8px; }
.status-card .value { font: 600 19px var(--serif); }
.status-card .sub { font-size: 13px; color: var(--mu); }
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--mu2); flex: none; }
.dot.ok { background: #3f9b6e; }
.dot.warn { background: #d1a632; }
.dot.bad { background: var(--red); }
pre.cmd { margin: 0; padding: 14px 18px; border-radius: 8px; background: var(--code); font: 13px/1.6 var(--mono); overflow-x: auto; white-space: pre; }

/* --- editor --------------------------------------------------------------------------------------------------- */

.editor { flex: 1; display: flex; flex-direction: column; height: 100vh; min-height: 0; }
.editor-bar {
  height: 60px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 var(--pad);
  border-bottom: 1px solid var(--ln);
}
.editor-bar .cancel { flex: 1; font-size: 14px; color: var(--mu); }
.editor-bar .center-label { font-size: 13px; color: var(--mu); text-align: center; }
.editor-bar .right { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.editor-bar .right .kbd { font-size: 12px; color: var(--mu2); }
.editor-wrap { width: 100%; margin: 0 auto; }
.editor[data-mode="focus"] .editor-wrap { max-width: 820px; }
.editor-meta { flex: none; padding: 18px var(--pad) 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--ln); }
.editor-title {
  border: 0; background: none; padding: 0; width: 100%;
  font: 600 clamp(26px, 4vw, 34px) var(--serif); letter-spacing: -.015em;
}
.editor-title:focus { outline: none; }
.editor-tags { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; color: var(--mu); }
.editor-tags .input { flex: 1 1 180px; max-width: 320px; }
.editor-tags .slug { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.editor-tags .slug input {
  border: 0; border-bottom: 1px dashed var(--ln); background: none; color: var(--mu); font-size: 13px; padding: 2px 0; width: 22ch;
}
.editor-tags .slug input:focus { outline: none; border-bottom-color: var(--ac); color: var(--fg); }
.toolbar { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px var(--pad); border-bottom: 1px solid var(--ln); font-size: 13px; overflow-x: auto; }
.toolbar .tool {
  flex: none; min-width: 36px; height: 34px; padding: 0 9px; border-radius: 6px; border: 0; background: transparent; color: var(--fg);
}
.toolbar .tool:hover { background: var(--code); }
.toolbar .tool.b { font-weight: 700; }
.toolbar .tool.i { font-style: italic; }
.toolbar .tool.wl { background: var(--acs); color: var(--ac); }
.toolbar .sep { width: 1px; height: 18px; background: var(--ln); margin: 0 6px; flex: none; }
.toolbar .write-tabs { margin-left: auto; }
.suggest {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px var(--pad); background: var(--sf);
  border-bottom: 1px solid var(--ln); overflow-x: auto; font-size: 14px;
}
.suggest > span { flex: none; font-size: 12px; color: var(--mu); }
.suggest button {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--ln); background: var(--bg); color: var(--fg);
  display: inline-flex; gap: 8px; align-items: center;
}
.suggest button small { color: var(--mu); font-size: 12px; }
.suggest button.active { background: var(--acs); border-color: var(--acs); color: var(--ac); }
.suggest button.new { background: transparent; color: var(--ac); }
.editor-panes { flex: 1; min-height: 0; display: flex; }
.editor-panes textarea {
  flex: 1; min-width: 0; border: 0; resize: none; background: transparent; padding: 20px var(--pad);
  font: 400 14.5px/1.75 var(--mono); tab-size: 4;
}
.editor-panes textarea:focus { outline: none; }
.editor[data-mode="split"] .editor-panes textarea { border-right: 1px solid var(--ln); }
.editor[data-mode="focus"] .editor-panes textarea { font: 400 19px/1.75 var(--serif); }
.preview-pane { flex: 1; min-width: 0; overflow: auto; padding: 20px var(--pad); background: var(--sf); }
.preview-pane .eyebrow { font-weight: 500; margin-bottom: 12px; }
.preview-pane .prose { font-size: 17px; line-height: 1.65; gap: 12px; margin: 0; }
.editor[data-mode="split"] .write-tabs { display: none; }
.editor[data-mode="focus"][data-tab="write"] .preview-pane { display: none; }
.editor[data-mode="focus"][data-tab="preview"] textarea { display: none; }
.editor-foot {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 10px var(--pad);
  border-top: 1px solid var(--ln); font-size: 13px; color: var(--mu);
}
.editor-foot .input { flex: 1 1 200px; max-width: 420px; border-radius: 6px; height: 34px; padding: 0 12px; font-size: 14px; }
.editor-foot .count { margin-left: auto; }
.editor-notice { padding: 12px var(--pad) 0; }
.editor-notice .notice.info { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.editor-notice .notice.info > span { flex: 1 1 260px; }

@media (max-width: 759.98px) {
  .editor { height: auto; min-height: 100vh; }
  .editor-bar { padding: 0 6px 0 var(--pad); }
  .editor-bar .center-label, .editor-bar .mode-toggle, .editor-bar .kbd { display: none; }
  .editor .editor-panes textarea { min-height: 50vh; padding: 16px 18px; font: 400 14.5px/1.75 var(--mono); border-right: 0; }
  .editor .preview-pane { padding: 16px 18px; }
  .editor .write-tabs { display: inline-flex !important; }
  .editor[data-tab="write"] .preview-pane { display: none; }
  .editor[data-tab="preview"] textarea { display: none; }
  .editor-foot .count { display: none; }
}

/* version conflict */
.conflict { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px var(--pad); }
.conflict-col { display: flex; flex-direction: column; min-height: 0; border: 1px solid var(--ln); border-radius: 12px; background: var(--sf); overflow: hidden; }
.conflict-col.mine { border: 2px solid var(--ac); }
.conflict-head { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--ln); font-size: 14px; font-weight: 600; }
.conflict-head span { font-weight: 400; color: var(--mu); font-size: 13px; }
.conflict-col textarea { flex: 1; min-height: 320px; border: 0; resize: none; background: transparent; padding: 16px; font: 13.5px/1.75 var(--mono); }
.conflict-col textarea:focus { outline: none; }
.conflict-lines { flex: 1; min-height: 320px; overflow: auto; padding: 16px 0; font: 13.5px/1.75 var(--mono); }
.conflict-lines span { display: block; padding: 0 16px; white-space: pre-wrap; min-height: 1.75em; }
.conflict-lines .theirs { background: var(--warn); color: var(--warnfg); }
.conflict-lines .mine { background: var(--add); color: var(--addfg); }
.conflict-foot { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--ln); }
.conflict-foot .btn { flex: 1 1 160px; }
@media (max-width: 899.98px) { .conflict { grid-template-columns: 1fr; } }

/* --- print: A4, no navigation, wiki links become footnote-like references -------------------------------------- */

.print-only { display: none; }
@media print {
  @page { size: A4; margin: 18mm 20mm; }
  :root { --bg: #fff; --sf: #fff; --fg: #000; --mu: #555; --ln: #ccc; --code: #f2f2f2; --ac: #000; --red: #000; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .mobile-head, .fab, .page-actions, .rail, .toc-details, .toast, .scrim, dialog { display: none !important; }
  .shell, .main-col { display: block; min-height: 0; }
  .content { padding: 0; max-width: none; }
  .page-article { max-width: none; }
  .print-only { display: block; }
  .print-head { display: flex; justify-content: space-between; font: 9pt var(--sans); color: #555; border-bottom: 1px solid #ccc; padding-bottom: 6px; }
  .prose { font-size: 11.5pt; line-height: 1.55; }
  .prose pre { white-space: pre-wrap; border: 1px solid #ddd; break-inside: avoid; }
  .prose h1, .prose h2, .prose h3 { break-after: avoid; }
  .prose a { color: #000; text-decoration: none; }
  .prose a.wikilink::after { content: " (" attr(href) ")"; font: 8.5pt var(--sans); color: #555; }
  .prose a.wikilink.missing::after { content: " (existiert noch nicht)"; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font: 8.5pt var(--sans); color: #555; overflow-wrap: anywhere; }
}
