/* Themes: Farben ausschließlich über Variablen. Ohne Auswahl entscheidet
   prefers-color-scheme (Papier hell / Nacht dunkel); sonst data-theme. */
:root,
:root[data-theme="papier"] {
  --bg: #faf7f0;
  --surface: #ffffff;
  --text: #2b2a27;
  --muted: #6d6a62;
  --accent: #b4441f;
  --border: #e3ddd0;
  --code-bg: #f1ece0;
  --danger: #b3261e;
  --font: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14161a;
    --surface: #1c1f25;
    --text: #e4e6ea;
    --muted: #9aa0ab;
    --accent: #ff8a5c;
    --border: #2b2f38;
    --code-bg: #101216;
    --danger: #ff6b6b;
  }
}

:root[data-theme="nacht"] {
  --bg: #14161a;
  --surface: #1c1f25;
  --text: #e4e6ea;
  --muted: #9aa0ab;
  --accent: #ff8a5c;
  --border: #2b2f38;
  --code-bg: #101216;
  --danger: #ff6b6b;
}

:root[data-theme="terminal"] {
  --bg: #050805;
  --surface: #0a110a;
  --text: #8cf08c;
  --muted: #4fae4f;
  --accent: #d6ff6b;
  --border: #1f3a1f;
  --code-bg: #000000;
  --danger: #ff6b6b;
  --font: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-ui: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

:root[data-theme="ozean"] {
  --bg: #eef5f9;
  --surface: #ffffff;
  --text: #17323f;
  --muted: #5a7686;
  --accent: #0a7ea4;
  --border: #cfe0ea;
  --code-bg: #e3eef4;
  --danger: #b3261e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; font-family: var(--font-ui); }
h1 { font-size: 2rem; margin: 0 0 .5rem; }

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

.container { width: 100%; max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; flex: 1; }

.site-header, .site-footer {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; font-family: var(--font-ui); font-size: .95rem;
  border-color: var(--border); background: var(--surface);
}
.site-header { border-bottom: 1px solid var(--border); }
.site-header nav { display: flex; gap: 1rem; flex: 1; }
.site-header a { text-decoration: none; }
.brand { font-weight: 700; color: var(--text) !important; }
.site-footer { border-top: 1px solid var(--border); justify-content: space-between; color: var(--muted); }
.site-footer a { color: var(--muted); }

select, input[type="text"], input[type="password"], textarea {
  font: inherit; font-family: var(--font-ui);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem;
}

.lead { color: var(--muted); font-size: 1.1rem; margin-top: 0; }
.meta { color: var(--muted); font-family: var(--font-ui); font-size: .875rem; margin: .1rem 0 .6rem; }
.empty { color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.25rem; margin: 1rem 0;
}
.card h2 { margin: 0; font-size: 1.35rem; }
.card h2 a { text-decoration: none; }
.card p { margin: .4rem 0; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: .4rem 0; font-family: var(--font-ui); font-size: .85rem; }
.tags a { text-decoration: none; background: var(--code-bg); border-radius: 999px; padding: .1rem .6rem; }

.prose h2 { margin-top: 2rem; }
.prose pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: .9rem 1rem; overflow-x: auto; font-size: .9rem; line-height: 1.5;
}
.prose code { font-family: var(--font-code); font-size: .9em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--border); padding: .35rem .6rem; }
.prose blockquote { margin-left: 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose img { max-width: 100%; }

/* Formulare und Verwaltung */
.stack { display: flex; flex-direction: column; gap: 1rem; font-family: var(--font-ui); }
.stack label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.stack label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
textarea.editor { font-family: var(--font-code); font-size: .9rem; line-height: 1.5; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.error { color: var(--danger); font-family: var(--font-ui); }
.preview { border: 1px dashed var(--border); border-radius: 8px; padding: 0 1rem 1rem; margin-bottom: 1.5rem; }

button, .button {
  font: inherit; font-family: var(--font-ui); font-size: .9rem; cursor: pointer; touch-action: manipulation;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: .4rem .8rem; text-decoration: none; display: inline-block;
}
button.primary, .button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
button.danger { color: var(--danger); }

.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toolbar h1 { flex: 1; margin: 0; }

.container:has(table.data) { max-width: 64rem; }
table.data { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .92rem; margin-top: 1rem; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th a { color: var(--text); text-decoration: none; white-space: nowrap; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.actions form, form.inline { margin: 0; }
.filter { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; font-family: var(--font-ui); font-size: .9rem; }
.filter a { text-decoration: none; padding: .15rem .7rem; border-radius: 999px; border: 1px solid var(--border); }
.filter a[aria-current] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.badge { font-size: .8rem; padding: .1rem .55rem; border-radius: 999px; background: var(--code-bg); color: var(--muted); }
.badge.live { background: var(--accent); color: var(--bg); }
