/* ============================================================
   Karl-Doku – Haupt-Stylesheet (Hell & Dunkel)
   Karl-Zeit-Look: Themes über CSS-Variablen, data-theme am <html>.
   Öffentliches Handbuch: Kopfleiste + Brotkrümel + Inhalt (+ optionale TOC).
   ============================================================ */

:root {
  --bg:        #eef2f7;
  --bg-grad-1: #dbe6f3;
  --bg-grad-2: #f4f7fb;
  --surface:   #ffffff;
  --surface-2: #f6f8fb;
  --border:    #dde3ec;
  --text:      #1f2a37;
  --muted:     #6b7685;
  --primary:   #1f3b5c;
  --primary-2: #2a5483;
  --accent:    #2f80ed;
  --shadow:    0 8px 28px rgba(31, 59, 92, .10);
  --radius:    14px;
  --mark:      #fff3bf;
}
html[data-theme="dark"] {
  --bg:        #0f141b;
  --bg-grad-1: #131b26;
  --bg-grad-2: #0c1118;
  --surface:   #161d27;
  --surface-2: #1c2531;
  --border:    #2a3645;
  --text:      #e6ebf2;
  --muted:     #93a1b3;
  --primary:   #4f86c6;
  --primary-2: #3f6fa8;
  --accent:    #5aa2ff;
  --shadow:    0 8px 28px rgba(0, 0, 0, .45);
  --mark:      #5a4a12;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg:#0f141b; --bg-grad-1:#131b26; --bg-grad-2:#0c1118;
    --surface:#161d27; --surface-2:#1c2531; --border:#2a3645;
    --text:#e6ebf2; --muted:#93a1b3; --primary:#4f86c6; --primary-2:#3f6fa8;
    --accent:#5aa2ff; --shadow:0 8px 28px rgba(0,0,0,.45); --mark:#5a4a12;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 60%) fixed;
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Kopfleiste ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.tb-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.tb-brand:hover { text-decoration: none; }
.tb-mark {
  font-size: 20px; width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; background: var(--primary); color: #fff;
}
.tb-brandname { font-size: 17px; }
.tb-search { flex: 1; max-width: 560px; margin: 0 auto; display: flex; position: relative; }
.tb-search input {
  width: 100%; padding: 9px 40px 9px 14px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text);
}
.tb-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tb-search-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 15px;
}
.tb-actions { display: flex; align-items: center; gap: 10px; }
.tb-op {
  font-size: 12px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; white-space: nowrap;
  text-decoration: none;
}
a.tb-op:hover { border-color: var(--accent); text-decoration: none; }

/* Entwickler-Bereich: dezente Abgrenzung vom öffentlichen Handbuch */
.dev-topbar { border-bottom: 2px solid var(--accent); }
.dev-badge {
  font-size: 12px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 6px; padding: 1px 7px; vertical-align: middle;
}
.doc.dev .doc-content { border-top: 3px solid var(--accent); }
.tb-btn {
  width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 16px;
}
.tb-btn:hover { border-color: var(--accent); }

/* ---------------- Brotkrümel ---------------- */
.crumbs { background: transparent; }
.crumbs-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 20px 0;
  font-size: 13px; color: var(--muted);
}
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 8px; opacity: .6; }
.crumbs .cur { color: var(--text); font-weight: 600; }

/* ---------------- Inhaltsbereich ---------------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px; }
.wrap.wide { max-width: 1240px; }
.muted { color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card.pad, .pad { padding: 22px 24px; }

/* Hero auf der Startseite */
.hero { padding: 12px 4px 22px; }
.hero h1 { font-size: 28px; margin: 6px 0 8px; }
.hero p { color: var(--muted); max-width: 720px; margin: 0; }

/* Kategorie-Überschrift */
.cat-h { font-size: 15px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 28px 6px 12px; }

/* App-Kacheln */
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tile {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; color: var(--text);
}
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px);
  transition: .12s ease; }
.tile-emoji { font-size: 26px; line-height: 1.1; width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; }
.tile-body { min-width: 0; }
.tile-title { font-weight: 700; font-size: 16px; margin-bottom: 2px; }
.tile-tag { color: var(--muted); font-size: 13.5px; }

/* ---------------- Handbuch-Seite (Layout mit TOC) ---------------- */
.doc-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
.toc {
  position: sticky; top: 76px; align-self: start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
  max-height: calc(100vh - 96px); overflow: auto;
}
.toc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0 0 2px; }
.toc a { display: block; padding: 5px 8px; border-radius: 8px; color: var(--text); font-size: 13.5px; }
.toc a:hover { background: var(--surface-2); text-decoration: none; }
.toc a.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }

.doc-main { min-width: 0; }
.app-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.app-head .emoji { font-size: 34px; }
.app-head .app-open { margin-left: auto; }

/* Handbuch-Typografie */
.doc-content { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 30px; }
.doc-content .doc-h1 { font-size: 26px; margin: 0 0 10px; }
.doc-content .doc-h2 {
  font-size: 20px; margin: 30px 0 10px; padding-top: 8px;
  border-top: 1px solid var(--border); scroll-margin-top: 76px;
}
.doc-content .doc-h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 12px; }
.doc-content .doc-h3 { font-size: 16.5px; margin: 20px 0 6px; }
.doc-content p { margin: 10px 0; }
.doc-content ul, .doc-content ol { margin: 10px 0; padding-left: 22px; }
.doc-content li { margin: 4px 0; }
.doc-content code {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px; font-size: .9em;
  font-family: "Cascadia Code", Consolas, monospace;
}
.doc-content hr { border: 0; border-top: 1px solid var(--border); margin: 22px 0; }
.doc-content .anchor {
  color: var(--muted); opacity: 0; margin-left: -18px; padding-right: 6px;
  font-weight: 400; text-decoration: none;
}
.doc-content .doc-h2:hover .anchor { opacity: .7; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }

/* Bilder / Screenshots im Handbuch */
.shot { margin: 16px 0; }
.shot img { max-width: 100%; height: auto; display: block; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); }
.shot figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }
.shot-empty .shot-slot {
  display: grid; place-items: center; min-height: 150px;
  background: var(--surface-2); border: 2px dashed var(--border); border-radius: 12px;
}
.shot-empty .shot-ico { font-size: 30px; opacity: .5; }
.shot-empty figcaption::before { content: "Bild folgt: "; font-weight: 600; }

/* Toolbar über dem Handbuch (Bearbeiten/Drucken) */
.doc-tools { display: flex; gap: 10px; align-items: center; margin: 14px 0 18px; flex-wrap: wrap; }

/* ---------------- Suche ---------------- */
.search-head { margin-bottom: 8px; }
.search-head h1 { font-size: 22px; margin: 6px 0; }
.result { display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 12px;
  color: var(--text); }
.result:hover { text-decoration: none; border-color: var(--accent); }
.result .r-top { font-weight: 600; margin-bottom: 4px; }
.result .r-emoji { margin-right: 6px; }
.result .r-app { color: var(--muted); font-weight: 400; }
.result .r-snip { color: var(--muted); font-size: 14px; }

/* ---------------- Buttons / Notes ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 15px; border-radius: 10px; border: 1px solid var(--border);
  font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text);
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--primary-2); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 11px; font-size: 13px; }

.note { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0 0 12px; }
.note.ok   { background: #e7f6ec; color: #16653a; }
.note.err  { background: #fdeaea; color: #a31616; }
.note.warn { background: #fff4e0; color: #8a5a08; }
html[data-theme="dark"] .note.ok   { background: #14301f; color: #7ee2a8; }
html[data-theme="dark"] .note.err  { background: #3a1717; color: #ffb3b3; }
html[data-theme="dark"] .note.warn { background: #3a2c12; color: #ffd591; }

.section-h { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.changelog { padding-left: 18px; }
.changelog li { margin: 6px 0; }
.log-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-family: monospace; font-size: 13px; margin: 8px 0; }

/* Editor */
.editor textarea {
  width: 100%; min-height: 60vh; padding: 14px; font-size: 14px; line-height: 1.5;
  font-family: "Cascadia Code", Consolas, monospace;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="search"] {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
}

/* ---------------- Auth-Karten (Setup/Update) ---------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 60%); }
.auth-wrap { width: 100%; max-width: 460px; padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 30px 28px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark { font-size: 26px; width: 46px; height: 46px; border-radius: 12px; display: grid;
  place-items: center; background: var(--primary); color: #fff; }
.brand-name { font-size: 20px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

/* ---------------- Footer ---------------- */
.app-footer { max-width: 1100px; margin: 30px auto 24px; padding: 16px 20px 0;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; text-align: center; }
.app-footer a { color: var(--muted); }

/* ---------------- Responsiv ---------------- */
@media (max-width: 860px) {
  .doc-layout { grid-template-columns: 1fr; }
  .toc { position: static; max-height: none; order: -1; }
  .tb-brandname { display: none; }
}
@media (max-width: 560px) {
  .tb-search { max-width: none; }
  .doc-content { padding: 20px 18px; }
}

/* ---------------- Druck ---------------- */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .crumbs, .toc, .doc-tools, .app-footer, .app-head .app-open, .anchor { display: none !important; }
  .doc-layout { display: block; }
  .doc-content { border: 0; box-shadow: none; padding: 0; }
  a { color: #000; text-decoration: none; }
  .doc-content .doc-h2 { break-after: avoid; }
}


/* KARL_DARKMODE_OFF – Dunkelmodus abgeschaltet (22.09.2026): Umschalter ausblenden. */
[data-theme-toggle], #themeToggle { display: none !important; }
