:root {
  --font: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  --mono: 'JetBrains Mono Variable', ui-monospace, monospace;
  --bg: #f4f2ec;
  --panel: #ffffff;
  --fg: #17150f;
  --muted: #6e6a5f;
  --line: #e0dcd0;
  --accent: #ff4f1f;
  --accent-fg: #ffffff;
  --ok: #1f8f4e;
  --warn: #b26a00;
  --danger: #c62828;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111110; --panel: #1b1a18; --fg: #efece4; --muted: #99948a; --line: #2e2c28; --accent: #ff6a3d; --accent-fg: #111110; --ok: #5fd08c; --warn: #f0b24d; --danger: #ff7b72; }
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, p, ul { margin: 0; }
ul { list-style: none; padding: 0; }
a { color: inherit; }
code { font: 0.85em var(--mono); background: var(--bg); padding: 0.1em 0.35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Leiste */
.bar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 1.5rem; padding: 0.7rem clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.bar-brand { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; white-space: nowrap; }
.bar-brand span { color: var(--accent); }
.bar-brand em { font: 500 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-left: 0.3rem; }
.bar-nav { display: flex; gap: 0.3rem; flex: 1; flex-wrap: wrap; }
.bar-nav a { text-decoration: none; font-weight: 500; font-size: 0.92rem; padding: 0.4rem 0.75rem; border-radius: 99px; color: var(--muted); }
.bar-nav a:hover { color: var(--fg); }
.bar-nav a[aria-current] { background: var(--fg); color: var(--bg); }

/* Knöpfe */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; font: 600 0.95rem/1 var(--font); padding: 0.8rem 1.2rem; border-radius: 99px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform 0.12s, background 0.15s, border-color 0.15s; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--fg); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { background: var(--danger); color: var(--panel); }
.btn-small { font-size: 0.85rem; padding: 0.55rem 0.9rem; }
.btn-block { width: 100%; padding-block: 1rem; }

/* Seiten */
.page { width: min(100% - 2rem, 980px); margin: 0 auto; padding: 2.5rem 0 5rem; }
.page-narrow { width: min(100% - 2rem, 760px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.8rem; }
.page-head h1 { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.sub { color: var(--muted); font: 500 0.78rem var(--mono); margin-top: 0.6rem; }
.stack { display: grid; gap: 1.2rem; margin-bottom: 1.2rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem; }
.panel + .panel { margin-top: 1.2rem; }
.stack .panel + .panel { margin-top: 0; }
.panel h2 { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: 0.88rem; margin-top: 0.9rem; }
.panel .hint + .btn { margin-top: 1rem; }
.flash { background: color-mix(in srgb, var(--ok) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); border-radius: 10px; padding: 0.7rem 1rem; margin-bottom: 1.2rem; font-weight: 500; }
.flash-error { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

.field { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field > span { font-weight: 600; font-size: 0.88rem; }
.field small { color: var(--muted); font-size: 0.8rem; }
.field-short { max-width: 12rem; }
input[type='text'], input[type='number'], input[type='datetime-local'], textarea { width: 100%; font: 400 1rem/1.4 var(--font); color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem; }
textarea { resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.badge { display: inline-block; font: 600 0.68rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; padding: 0.4rem 0.6rem; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge-live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge-planned { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* Beitragsliste */
.post-rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.post-rows li { display: flex; align-items: center; gap: 1rem; padding: 0.8rem 1rem; }
.post-rows li + li { border-top: 1px solid var(--line); }
.post-rows li:hover { background: color-mix(in srgb, var(--bg) 60%, var(--panel)); }
.row-main { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 0; text-decoration: none; }
.row-thumb { width: 72px; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; flex: none; background: var(--bg); --c0: #ece6d8; --c1: #ff4f1f; --c2: #1f3dff; --c3: #f7c531; --c4: #17150f; }
.row-thumb img, .row-thumb svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-thumb .c0 { fill: var(--c0); } .row-thumb .c1 { color: var(--c1); } .row-thumb .c2 { color: var(--c2); } .row-thumb .c3 { color: var(--c3); } .row-thumb .c4 { color: var(--c4); }
.row-thumb :is(.c1, .c2, .c3, .c4) { fill: currentColor; }
.row-thumb .stroke { fill: none; stroke: currentColor; }
.row-text { display: grid; min-width: 0; }
.row-text strong { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text small, .row-date { font: 500 0.74rem var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 3.5rem 1rem; text-align: center; display: grid; gap: 1.2rem; justify-items: center; color: var(--muted); }

/* Themes */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.8rem; }
.theme-card { position: relative; display: grid; gap: 0.35rem; align-content: start; padding: 0.9rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.theme-card input { position: absolute; opacity: 0; }
.theme-card:hover { border-color: var(--muted); }
.theme-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.theme-card:has(input:checked) strong::after { content: ' ✓'; color: var(--accent); }
.theme-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-swatches { display: flex; height: 54px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 0.4rem; }
.theme-swatches i { flex: 1; }
.theme-card small { color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.theme-card a { font: 500 0.74rem var(--mono); color: var(--muted); margin-top: 0.3rem; }
.theme-card a:hover { color: var(--accent); }

/* Passkeys */
.key-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.key-list div { display: grid; }
.key-list small { font: 500 0.74rem var(--mono); color: var(--muted); }
.key-add { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.key-add input { flex: 1; min-width: 12rem; }
.auth-error { color: var(--danger); font-weight: 500; font-size: 0.92rem; margin-top: 0.9rem; }

/* Anmeldung */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(700px 420px at 50% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%), var(--bg); }
.auth-card { width: min(100%, 420px); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 2.2rem; display: grid; gap: 1.1rem; box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.35); }
.auth-mark { font-size: 2.4rem; line-height: 1; color: var(--accent); }
.auth-card h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.auth-card p { color: var(--muted); }
.auth-card .field { margin: 0; }
.auth-card .note { background: var(--bg); border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.9rem; }
.auth-card .auth-error { margin: 0; color: var(--danger); }
.auth-back { font: 500 0.76rem var(--mono); color: var(--muted); text-decoration: none; }
.auth-back:hover { color: var(--fg); }

/* Editor */
.editor-page { width: min(100% - 2rem, 1320px); margin: 0 auto; padding-bottom: 5rem; }
.editor-top { position: sticky; top: 3.35rem; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: 0.8rem 0; background: var(--bg); }
.back { font: 500 0.78rem var(--mono); color: var(--muted); text-decoration: none; }
.back:hover { color: var(--fg); }
.save-state { flex: 1; font: 500 0.74rem var(--mono); color: var(--muted); text-align: right; }
.editor-actions { display: flex; gap: 0.5rem; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.editor-main { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.2rem, 3vw, 2.5rem); min-width: 0; }
.title-input { display: block; width: 100%; border: 0; background: none; padding: 0; margin-bottom: 1.2rem; resize: none; overflow: hidden; font: 800 clamp(1.9rem, 4vw, 3rem) / 1.05 var(--font); letter-spacing: -0.04em; color: var(--fg); border-radius: 0; }
.title-input:focus { outline: none; border: 0; box-shadow: none; }
.title-input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.editor-side { display: grid; gap: 1rem; position: sticky; top: 7.4rem; }
.editor-side .panel + .panel { margin-top: 0; }
.status-line { margin-bottom: 1rem; }
.cover-box { border: 1px dashed var(--line); border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 2; display: grid; place-items: center; background: var(--bg); }
.cover-box img { width: 100%; height: 100%; object-fit: cover; }
.cover-box p { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 1rem; }
.cover-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.cover-actions label { cursor: pointer; }

/* Toast UI an das Backend anpassen */
.toastui-editor-defaultUI { border: 1px solid var(--line) !important; border-radius: 12px !important; font-family: var(--font); }
.toastui-editor-defaultUI-toolbar { border-radius: 12px 12px 0 0; position: sticky; top: 7.2rem; z-index: 5; }
.toastui-editor-contents { font-family: var(--font) !important; font-size: 1.08rem !important; line-height: 1.7; }
.toastui-editor-contents p, .toastui-editor-contents li { color: var(--fg) !important; }
.toastui-editor-contents h1, .toastui-editor-contents h2, .toastui-editor-contents h3 { color: var(--fg) !important; border: 0 !important; letter-spacing: -0.02em; }
.toastui-editor-contents pre, .toastui-editor-contents code { font-family: var(--mono) !important; }
.toastui-editor-mode-switch { border-radius: 0 0 12px 12px; }

.toast { position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%); z-index: 100; background: var(--fg); color: var(--bg); font-weight: 600; font-size: 0.92rem; padding: 0.75rem 1.2rem; border-radius: 99px; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.5); max-width: calc(100vw - 2rem); }
.toast.is-error { background: var(--danger); color: #fff; }

@media (max-width: 960px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
}
@media (max-width: 640px) {
  .bar { flex-wrap: wrap; gap: 0.6rem; }
  .bar-nav { order: 3; flex-basis: 100%; }
  .bar form { margin-left: auto; }
  .editor-top { position: static; flex-wrap: wrap; }
  .toastui-editor-defaultUI-toolbar { position: static; }
  .row-date, .post-rows .btn { display: none; }
}

/* Protokoll */
.log-scroll { overflow-x: auto; }
.log { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.log th { text-align: left; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 0.8rem 0.6rem 0; }
.log td { padding: 0.45rem 0.8rem 0.45rem 0; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.log .nowrap { white-space: nowrap; }
.log tr.is-warn td:first-child { box-shadow: inset 3px 0 0 var(--danger); padding-left: 0.6rem; }
