:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #2563eb; --accent-soft: #dbeafe; --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --card: #131c2e; --text: #e2e8f0; --muted: #94a3b8; --line: #23304a;
    --accent: #60a5fa; --accent-soft: #1e3a5f; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase;
  line-height: 1; padding-left: .24em; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav a { padding: 7px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.on { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; }
select, input, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; }
input, textarea { width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 26px 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.center { max-width: 460px; margin: 40px auto; }
.center .card { padding: 24px; }
.loading { margin: 60px auto; width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 10px; padding: 8px 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.red { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.big { width: 100%; padding: 12px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: none; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.iconbtn:hover { background: var(--bg); color: var(--text); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: #fef3c7; color: #92400e; } .badge.bad { background: #fee2e2; color: #991b1b; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.grey { background: var(--bg); color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* Startseite: Kacheln */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; text-align: center; color: var(--text); text-decoration: none; transition: transform .1s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; overflow: hidden;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 20px; }
.tile .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.tile b { font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.tile small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.tile .more { position: absolute; top: 4px; right: 4px; }
.tile .warnmark { position: absolute; top: 8px; left: 8px; }
.menu { position: fixed; z-index: 20; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 6px; min-width: 210px; }
.menu button { display: flex; width: 100%; gap: 8px; align-items: center; border: none; background: none; color: var(--text);
  font: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--bg); }
.menu .code { margin-left: auto; font-family: ui-monospace, Consolas, monospace; color: var(--accent); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }
.menu button[data-a="del"] { color: var(--bad); }
.toolbar .grp { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }

/* Löschen-Abfrage */
.delcard { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }
.delcard .ico { width: 44px; height: 44px; flex: none; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 18px; }
.delcard .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.delcard small { display: block; color: var(--muted); font-size: 13px; }
.warnbox { background: color-mix(in srgb, var(--warn) 14%, transparent); border-left: 3px solid var(--warn); padding: 8px 10px; border-radius: 6px; }

/* Kategorien verwalten */
.catlist { display: grid; gap: 4px; max-height: 50vh; overflow: auto; margin: 4px 0 8px; }
.catrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.catrow:hover { background: var(--bg); }
.catrow .cn { flex: 1; overflow-wrap: anywhere; }
.catrow small { color: var(--muted); white-space: nowrap; }

/* Formulare */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.form label small { font-weight: 400; }
.two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.pw { display: flex; gap: 6px; }
.pw input { font-family: ui-monospace, Consolas, monospace; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter > div { height: 100%; width: 0; transition: width .2s; }
.icopick { display: flex; align-items: center; gap: 10px; }
.icopick .ico { width: 40px; height: 40px; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.icopick .ico img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

dialog { border: none; border-radius: 16px; padding: 0; background: var(--card); color: var(--text); width: min(560px, calc(100vw - 24px));
  box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog > div { padding: 20px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.recovery { font: 600 20px/1.6 ui-monospace, Consolas, monospace; letter-spacing: .06em; text-align: center; padding: 14px;
  border: 2px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); user-select: all; word-break: break-all; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 12px; }
.steps li { counter-increment: s; padding-left: 30px; position: relative; margin-bottom: 8px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
.factbox { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); padding: 0; overflow: hidden; margin-bottom: 14px; }
.factbox > div { padding: 12px 16px; border-right: 1px solid var(--line); }
.factbox > div:last-child { border-right: none; }
.factbox span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.factbox b { font-size: 22px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: #0f172a; color: #fff;
  padding: 10px 16px; border-radius: 10px; transition: transform .2s; z-index: 30; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- McFly Wiki */
main { max-width: none; margin: 0; padding: 24px 28px 60px; min-width: 0; }
.top #search { max-width: 520px; } .top #search input { width: 100%; }
.me #who { color: var(--muted); font-weight: 600; }
.wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 58px); }
#side { border-right: 1px solid var(--line); padding: 16px 10px; background: var(--card); position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; border-left: 1px solid var(--line); margin-left: 10px; }
.tree a { display: block; padding: 5px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.35; }
.tree > li > a { font-weight: 700; margin-top: 4px; }
.tree a:hover { background: var(--bg); } .tree a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nolang { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; }
#newtop { margin: 14px 10px 0; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; } .crumbs a { color: var(--muted); }
.page { max-width: 880px; }
.pagehead { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; } .pagehead h1 { flex: 1; min-width: 200px; }
.pagehead .tools { display: flex; gap: 6px; }
.langnote { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; border-radius: 10px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.pagefoot { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
/* Seiteninhalt */
.md { font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.md h2 { font-size: 21px; margin: 30px 0 10px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 17px; margin: 22px 0 8px; }
.md p { margin: 0 0 12px; } .md ul, .md ol { margin: 0 0 12px; padding-left: 24px; } .md li { margin: 3px 0; }
.md img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.md blockquote { margin: 14px 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.md blockquote p:last-child { margin: 0; }
.md code { font: 14px ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); }
.md pre { background: var(--bg); padding: 12px; border-radius: 10px; overflow: auto; border: 1px solid var(--line); } .md pre code { border: none; padding: 0; }
.md table { margin: 10px 0 16px; font-size: 15px; } .md th { background: var(--bg); }
.md kbd { font: 13px ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }
mark { background: #fde68a; color: #1f2937; border-radius: 3px; padding: 0 1px; }
/* Bearbeiten */
.editor { display: grid; gap: 12px; } .editor label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.editor .toolbar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split textarea { min-height: 62vh; font: 14px/1.5 ui-monospace, Consolas, monospace; }
.preview { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; max-height: 62vh; overflow: auto; background: var(--card); }
.hit { display: grid; gap: 4px; margin-bottom: 10px; text-decoration: none; color: var(--text); } .hit span { color: var(--muted); font-size: 14px; }
.hit:hover { border-color: var(--accent); }
.verbox { margin-top: 16px; } .red-text { color: var(--bad) !important; }
.login { text-align: center; } .login img { border-radius: 16px; margin-bottom: 8px; } .login .btn { margin-top: 10px; }
@media (max-width: 900px) {
  .wrap { grid-template-columns: 1fr; }
  #side { display: none; position: fixed; top: 58px; left: 0; width: min(320px, 86vw); z-index: 8; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
  body.sideopen #side { display: block; }
  main { padding: 16px 14px 50px; } .split { grid-template-columns: 1fr; } .preview { max-height: none; }
}
@media (max-width: 640px) { .me #who { display: none; } .top #search { order: 3; flex-basis: 100%; max-width: none; } }
@media print {
  .top, #side, .noprint, .tools, #toast { display: none !important; }
  .wrap { display: block; } main { padding: 0; } .md { font-size: 12pt; } .md a { color: #000; }
}