/* Riposa Begriffssuche: ruhig, viel Weissraum, Systemschrift.
   Das eine auffällige Element ist der Textmarker auf dem gefundenen Begriff. */

:root {
  --paper: #f6f7f9;
  --surface: #ffffff;
  --ink: #1d2430;
  --muted: #566170;
  --line: #dce1e8;
  --line-strong: #c3cad4;
  --accent: #2456a6;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef9;
  --marker: #ffe45c;
  --marker-edge: rgba(255, 228, 92, 0.35);
  --marker-ink: #1d2430;
  --group: #3b7a8c;
  --ok: #2e7d4f;
  --ok-soft: #e5f3ea;
  --warn: #8a5300;
  --warn-soft: #fdf1dc;
  --error: #b3261e;
  --error-soft: #fbe7e5;
  --focus: #2456a6;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #13171d;
    --surface: #1a2028;
    --ink: #e8ecf1;
    --muted: #9ea8b6;
    --line: #2b333e;
    --line-strong: #3b4552;
    --accent: #8fb4f2;
    --accent-ink: #0f1622;
    --accent-soft: #1f2c40;
    --marker: #f2d24b;
    --marker-edge: rgba(242, 210, 75, 0.35);
    --marker-ink: #15181d;
    --group: #6fb3c4;
    --ok: #74c895;
    --ok-soft: #1a2e23;
    --warn: #f0b45a;
    --warn-soft: #2e2416;
    --error: #ff8a80;
    --error-soft: #34201f;
    --focus: #8fb4f2;
  }
}

/* ---- Grundlagen ------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 2rem; margin-top: 0.25em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
p { margin: 0 0 0.75em; }
ul, ol { margin: 0; padding: 0; }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

kbd {
  font-family: inherit;
  font-size: 0.95em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  white-space: nowrap;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 10; background: var(--surface); padding: 0.5rem 1rem; }
.skip-link:focus { left: 1rem; }

/* ---- Kopf ------------------------------------------------------------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header__inner {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand__mark { display: block; border-radius: 7px; box-shadow: 0 0 0 1px var(--line-strong); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 0.25rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { border-bottom-color: var(--line-strong); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 600; }
.site-nav__logout { margin: 0; }
.link-button {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0.25rem 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 0.18em;
}
.link-button:hover { color: var(--ink); }

/* ---- Seite -------------------------------------------------------------- */

.page { max-width: 46rem; margin: 0 auto; padding: 2rem 1rem 5rem; }
.page--wide { max-width: 60rem; }
.page--narrow { max-width: 28rem; }
.lead { font-size: 1.1875rem; color: var(--muted); max-width: 38rem; }
.hint { color: var(--muted); font-size: 1rem; }

/* ---- Hinweise ----------------------------------------------------------- */

.notice {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0 0 1.25rem;
}
.notice p:last-child { margin-bottom: 0; }
.notice--warn { border-color: var(--warn); background: var(--warn-soft); }
.notice--error { border-color: var(--error); background: var(--error-soft); }
.notice--success { border-color: var(--ok); background: var(--ok-soft); }

/* ---- Knöpfe und Formulare ----------------------------------------------- */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; line-height: 1.2;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0.65rem 1.1rem; min-height: 2.75rem;
  text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--ink); }
.button--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.button--quiet { background: transparent; }
.button--danger { background: var(--error); border-color: var(--error); color: #fff; }
.button--big { font-size: 1.25rem; padding: 0.95rem 2.25rem; min-height: 3.5rem; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; filter: none; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.button-row form { margin: 0; }
.small-link { font-size: 1rem; }

.form { margin: 1.5rem 0 0; }
.field { margin: 0 0 1.25rem; }
.field > label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.field .hint { margin-bottom: 0.5rem; }

input[type="text"], input[type="password"], input[type="url"], textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
}
textarea { min-height: 15rem; line-height: 1.6; resize: vertical; }
input:focus-visible, textarea:focus-visible { border-color: var(--focus); }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 0.8; }

.check { display: grid; grid-template-columns: auto 1fr; column-gap: 0.65rem; align-items: start; margin: 0 0 0.9rem; }
.check input { width: 1.3rem; height: 1.3rem; margin: 0.15rem 0 0; accent-color: var(--accent); }
.check label { font-weight: 500; }
.check .hint { grid-column: 2; margin: 0.15rem 0 0; }
.check--inline { margin: 0; }

details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; width: 0.5rem; height: 0.5rem; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.15s ease; margin-right: 0.15rem;
}
details[open] > summary::before { transform: rotate(45deg); }

/* ---- Startseite --------------------------------------------------------- */

.steps { list-style: none; counter-reset: step; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin: 0 0 1.75rem; color: var(--muted); }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 0.5rem; }
.steps li::before {
  content: counter(step);
  display: inline-grid; place-items: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  border: 1.5px solid var(--line-strong); color: var(--ink); font-weight: 700; font-size: 0.95rem;
}
.steps li:first-child { color: var(--ink); font-weight: 600; }
.steps li:first-child::before { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }

.preview { margin: -0.5rem 0 1.5rem; padding: 0.75rem 1rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.preview__count { font-weight: 600; margin: 0; }
.preview__terms { list-style: none; columns: 2 14rem; column-gap: 2rem; margin-top: 0.4rem; color: var(--muted); font-size: 1rem; }
.preview__terms li { break-inside: avoid; }
.preview__terms:empty, .preview__warnings:empty { display: none; }
.preview__arrow { color: var(--muted); }
.preview__warnings { list-style: none; margin-top: 0.5rem; color: var(--warn); font-size: 1rem; }
.preview__warnings li { padding-left: 1rem; position: relative; }
.preview__warnings li::before { content: "!"; position: absolute; left: 0; font-weight: 700; }

.advanced { margin: 0 0 1.75rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced > summary { padding: 0.8rem 0; font-weight: 600; }
.advanced__body { padding: 0.25rem 0 0.75rem; }

/* ---- Textmarker --------------------------------------------------------- */

mark {
  color: var(--marker-ink);
  background-color: var(--marker);
  background-image: linear-gradient(100deg, var(--marker-edge) 0, var(--marker) 0.35em, var(--marker) calc(100% - 0.35em), var(--marker-edge) 100%);
  padding: 0.05em 0.3em;
  margin: 0 -0.08em;
  border-radius: 0.35em 0.2em 0.4em 0.25em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---- Fortschritt -------------------------------------------------------- */

.sweep { position: relative; height: 0.5rem; border-radius: 1rem; background: var(--line); overflow: hidden; margin: 1rem 0 1.5rem; }
.sweep span {
  position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: var(--marker); border-radius: 1rem;
  animation: sweep 1.8s ease-in-out infinite;
}
@keyframes sweep { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .sweep span { animation: none; left: 0; width: 100%; opacity: 0.6; }
  details > summary::before { transition: none; }
}
.progress__message { font-size: 1.25rem; font-weight: 600; }
.progress__current { color: var(--muted); overflow-wrap: anywhere; }
.progress__offline { color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 1rem; margin: 1.5rem 0; }
.stats div { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.stats dt { color: var(--muted); font-size: 0.95rem; }
.stats dd { margin: 0; font-size: 1.875rem; font-weight: 700; line-height: 1.2; }
.stats--small dd { font-size: 1.5rem; }
.stats--small { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.cancel { margin-top: 2rem; }
.cancel__confirm { margin-top: 0.75rem; padding: 1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }

/* ---- Ergebnisse --------------------------------------------------------- */

.result-head { margin-bottom: 2rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.75rem 2.5rem; margin: 0.5rem 0 1.5rem; }
.facts dt { color: var(--muted); font-size: 0.95rem; }
.facts dd { margin: 0; font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.actions__rerun { margin: 0 0 0 auto; }

.compare { margin: 0 0 2.5rem; padding: 1.25rem 1.25rem 0.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.compare h2 { font-size: 1.25rem; }
.compare__delta { font-size: 1.25rem; font-weight: 600; }
.compare__counts { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin-bottom: 0.75rem; }
.compare__number { font-weight: 700; font-size: 1.25rem; }
.compare__fixed > summary { padding: 0.4rem 0; }
.fixed-list { list-style: none; margin: 0.5rem 0; }
.fixed-list li { padding: 0.5rem 0; border-top: 1px solid var(--line); text-decoration: line-through; text-decoration-color: var(--muted); }
.fixed-list__term { font-weight: 600; text-decoration: none; }

.summary { margin: 0 0 2rem; }
.summary h2 { font-size: 1.25rem; }
.summary__list { list-style: none; border-top: 1px solid var(--line); }
.summary__row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.summary__term { font-weight: 600; }
.summary__arrow { color: var(--muted); }
.summary__label { color: var(--muted); }
.summary__done { margin-left: auto; font-size: 0.95rem; color: var(--muted); white-space: nowrap; }
.summary__done.is-complete { color: var(--ok); font-weight: 600; }

.viewbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; margin: 0 0 1rem; position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented a { padding: 0.45rem 0.95rem; color: var(--ink); text-decoration: none; font-weight: 500; }
.segmented a + a { border-left: 1px solid var(--line-strong); }
.segmented a[aria-current="page"] { background: var(--ink); color: var(--paper); font-weight: 600; }
.save-error { color: var(--error); font-weight: 600; }

.term-block { margin: 2.5rem 0 0; scroll-margin-top: 4.5rem; }
.term-block__title { font-size: 1.625rem; margin-bottom: 0.2rem; }
.term-block__replacement { color: var(--muted); font-weight: 500; }
.term-block__label { color: var(--muted); margin-bottom: 1.25rem; }
.subhead { font-size: 1rem; font-weight: 600; color: var(--muted); margin: 1.5rem 0 0.25rem; }

.page-block { margin: 1.75rem 0 0; }
.page-block__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.75rem; font-size: 1.125rem; margin-bottom: 0.25rem; }
.page-block__url { font-weight: 400; font-size: 0.95rem; color: var(--muted); overflow-wrap: anywhere; }
.page-block__note { font-size: 0.95rem; color: var(--muted); }
.page-block__meta { margin: 0.25rem 0 0; }
.page-block__meta > summary { color: var(--muted); font-size: 1rem; padding: 0.5rem 0; }

.items { list-style: none; }
.item {
  display: grid; grid-template-columns: 4.75rem minmax(0, 1fr); gap: 0.25rem 0.75rem;
  padding: 0.9rem 0; border-top: 1px solid var(--line);
}
.item--group { border-left: 4px solid var(--group); padding-left: 0.75rem; border-top-color: var(--line); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 0.5rem; }
.item__check { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding-top: 0.15rem; }
.item__check input { width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--ok); cursor: pointer; }
.item__check label { font-size: 0.875rem; color: var(--muted); cursor: pointer; }
.item__term { font-weight: 600; margin-bottom: 0.25rem; }
.item__arrow { color: var(--muted); }
.item__group { font-weight: 600; color: var(--group); margin-bottom: 0.25rem; }
.item__context { font-size: 1.1875rem; line-height: 1.6; margin-bottom: 0.35rem; max-width: 42rem; }
.item__replacement { font-weight: 600; margin-bottom: 0.35rem; }
.item__page { font-size: 1rem; margin-bottom: 0.35rem; }
.item__url { color: var(--muted); font-size: 0.95rem; overflow-wrap: anywhere; }
.item__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; font-size: 1rem; margin: 0; }
.item__link { margin-left: 0.25rem; font-weight: 600; }
.item__note { font-size: 0.95rem; color: var(--muted); margin: 0.35rem 0 0; }
.item__pages { margin-top: 0.4rem; font-size: 1rem; }
.item__pages > summary { color: var(--muted); padding: 0.2rem 0; }
.item__pages ul { list-style: none; margin: 0.35rem 0 0 1.1rem; max-height: 22rem; overflow-y: auto; }
.item__pages li { padding: 0.15rem 0; }

.item.is-done .item__body { opacity: 0.55; }
.item.is-done .item__context { text-decoration: line-through; text-decoration-color: var(--muted); }
.item.is-done .item__check label { color: var(--ok); font-weight: 600; }
.hide-done .item.is-done { display: none; }

.badge {
  display: inline-block; font-size: 0.875rem; line-height: 1.3; font-weight: 500;
  padding: 0.1rem 0.5rem; border: 1px solid var(--line-strong); border-radius: 1rem; color: var(--muted);
  white-space: nowrap;
}
.badge--warn { border-color: var(--warn); color: var(--warn); }
.badge--new { border-color: var(--accent); color: var(--accent); }

.empty { padding: 2rem 0; }
.empty--success h2 { font-size: 1.75rem; }

.extras { margin-top: 4rem; padding-top: 1.5rem; border-top: 2px solid var(--line-strong); }
.extras h2 { font-size: 1.375rem; }
.extra { border-bottom: 1px solid var(--line); }
.extra > summary { padding: 0.85rem 0; font-weight: 600; }
.extra > *:last-child { margin-bottom: 1rem; }
.extra--broken > summary { color: var(--error); }
.count { display: inline-block; min-width: 1.75rem; text-align: center; font-size: 0.875rem; padding: 0 0.45rem; border-radius: 1rem; background: var(--line); color: var(--ink); font-weight: 600; }
.link-list { list-style: none; }
.link-list > li { padding: 0.6rem 0; border-top: 1px solid var(--line); }
.link-list p { margin: 0; }
.link-list__url { overflow-wrap: anywhere; font-weight: 500; }
.link-list__detail { color: var(--error); font-size: 0.95rem; margin-left: 0.25rem; }
.link-list__sources { color: var(--muted); font-size: 0.95rem; }
.link-list__pages { list-style: none; margin: 0.2rem 0 0 1rem; font-size: 1rem; }
.link-list__pages a { overflow-wrap: anywhere; }
.folder { font-size: 1rem; font-weight: 600; margin: 1rem 0 0.25rem; overflow-wrap: anywhere; color: var(--muted); }
.doc-list { list-style: none; font-size: 1rem; }
.doc-list li { padding: 0.15rem 0; overflow-wrap: anywhere; }

/* ---- Verlauf ------------------------------------------------------------ */

.history { list-style: none; margin-top: 1.5rem; }
.history__item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 1.5rem; padding: 1.1rem 0; border-top: 1px solid var(--line); }
.history__main { flex: 1 1 22rem; min-width: 0; }
.history__date { font-weight: 600; margin-bottom: 0.15rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.history__terms { margin-bottom: 0.15rem; }
.history__facts { color: var(--muted); font-size: 1rem; margin: 0; }
.history__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.history__actions form { margin: 0; }

.status { font-size: 0.875rem; font-weight: 600; padding: 0.05rem 0.55rem; border-radius: 1rem; border: 1px solid currentColor; }
.status--running { color: var(--accent); }
.status--done { color: var(--ok); }
.status--cancelled { color: var(--muted); }
.status--interrupted { color: var(--warn); }
.status--failed { color: var(--error); }

/* ---- Handy -------------------------------------------------------------- */

@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  h1 { font-size: 1.625rem; }
  .page { padding: 1.25rem 1rem 4rem; }
  .button--big { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats--small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats dd { font-size: 1.5rem; }
  .stats > div:nth-child(4) { grid-column: 1 / -1; }
  .actions__rerun { margin-left: 0; }
  .item { grid-template-columns: 3.75rem minmax(0, 1fr); gap: 0.25rem 0.5rem; }
  .item__context { font-size: 1.0625rem; }
  .summary__done { margin-left: 0; }
  .term-block__title { font-size: 1.375rem; }
}
