:root {
  --bg: #0e1116; --panel: #161b22; --panel-2: #1c232d; --border: #2a323d;
  --text: #e6edf3; --muted: #8b97a5; --accent: #4f9cf9; --accent-2: #2f6fd0;
  --ok: #3fb950; --warn: #d29922; --danger: #f85149; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button { font: inherit; cursor: pointer; border: none; border-radius: 8px; padding: 9px 16px;
  background: var(--accent); color: #fff; font-weight: 600; transition: filter .15s; }
button:hover { filter: brightness(1.1); }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.ghost.icon { padding: 6px 12px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea, select { font: inherit; width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; font-weight: 600; }
.field { margin-bottom: 16px; }
.hidden { display: none !important; }
a { color: var(--accent); }

/* Login */
#login { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
#login .card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 36px; width: 100%; max-width: 360px; text-align: center; }
#login h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.5px; }
#login p { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* App-Layout */
#app { display: grid; grid-template-columns: 300px 1fr; height: 100vh; }
aside { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
aside header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
aside header .brand { font-weight: 700; letter-spacing: -.3px; }
aside .sitebar { padding: 12px 18px; border-bottom: 1px solid var(--border); }
aside .newbtn { margin: 12px 18px 8px; }
.postlist { flex: 1; overflow-y: auto; padding: 0 10px 10px; min-height: 0; }
.post { padding: 11px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; }
.post:hover { background: var(--panel-2); }
.post.active { background: var(--accent-2); }
.post .t { font-weight: 600; font-size: 14px; }
.post .m { font-size: 12px; color: var(--muted); display: flex; gap: 8px; margin-top: 3px; align-items: center; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.badge.draft { background: rgba(210,153,34,.18); color: var(--warn); }
.badge.live { background: rgba(63,185,80,.18); color: var(--ok); }
.sidenav { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.navbtn { background: transparent; color: var(--muted); text-align: left; font-weight: 600; padding: 9px 12px; }
.navbtn:hover { background: var(--panel-2); color: var(--text); filter: none; }
.navbtn.active { background: var(--panel-2); color: var(--accent); }

main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.toolbar { position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--border);
  padding: 12px 28px; display: flex; align-items: center; gap: 14px; z-index: 5; }
.toolbar .grow { flex: 1; }
.toolbar .saved { color: var(--muted); font-size: 13px; white-space: nowrap; }
.toolbar #edTitle { font-size: 15px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.tab { background: transparent; color: var(--muted); padding: 6px 12px; font-size: 13px; }
.tab:hover { filter: none; color: var(--text); }
.tab.active { background: var(--panel-2); color: var(--text); }

.pane { padding: 24px 28px 60px; max-width: 880px; width: 100%; }
.fm { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.fm .field.full { grid-column: 1 / -1; }
.row-check { display: flex; align-items: center; gap: 9px; }
.row-check input { width: auto; }
.imgfield { display: flex; gap: 8px; align-items: center; }
.imgfield input { flex: 1; }
textarea.body { min-height: 440px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 14px; line-height: 1.7; resize: vertical; border-top-left-radius: 0; border-top-right-radius: 0; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* SEO-Box */
.seo-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; }
.seo-head { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.snippet { background: #fff; border-radius: 8px; padding: 12px 14px; }
.snippet-url { color: #202124; font-size: 13px; }
.snippet-title { color: #1a0dab; font-size: 18px; line-height: 1.3; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-desc { color: #4d5156; font-size: 13px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.seo-meters { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.meter { font-size: 12px; color: var(--muted); }
.meter.good { color: var(--ok); } .meter.warn { color: var(--warn); } .meter.bad { color: var(--danger); }

/* Markdown-Toolbar */
.md-toolbar { display: flex; flex-wrap: wrap; gap: 4px; background: var(--panel); border: 1px solid var(--border);
  border-bottom: none; border-radius: 8px 8px 0 0; padding: 6px; }
.md-toolbar button { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 5px 10px; font-size: 13px; }
.md-toolbar button:hover { filter: none; border-color: var(--accent); }

/* Doc-Panes (Hilfe/Einstellungen) */
.docpane { line-height: 1.65; max-width: 760px; }
.docpane h2 { font-size: 22px; margin: 0 0 6px; }
.docpane h3 { font-size: 16px; margin: 26px 0 6px; color: var(--accent); }
.docpane p, .docpane li { color: var(--text); }
.docpane .lead { color: var(--muted); margin-bottom: 8px; }
.docpane code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.docpane .card2 { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin: 14px 0; }
.docpane table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.docpane td { border: 1px solid var(--border); padding: 8px 12px; vertical-align: top; }
.docpane td:first-child { color: var(--accent); font-weight: 600; white-space: nowrap; }
.kbd { background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, monospace; font-size: 12px; }

/* ── Vorschau (echtes Design via iframe) ── */
.preview-pane { max-width: none; padding: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.preview-note { font-size: 12px; color: var(--muted); padding: 8px 28px; border-bottom: 1px solid var(--border); background: var(--panel); }
#previewFrame { flex: 1; width: 100%; border: none; background: #09090b; min-height: 70vh; }
.preview-missing { padding: 40px 28px; color: var(--muted); }

/* Toast */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel-2); border: 1px solid var(--border); padding: 12px 22px; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); transition: transform .25s; z-index: 50; max-width: 80vw; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: var(--ok); } #toast.bad { border-color: var(--danger); }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  aside { display: none; }
}
