:root {
  --bg: #0f1115;
  --panel: #161922;
  --text: #e6e8ee;
  --muted: #9aa2b1;
  --accent: #7dd3fc;
  --pass: #4ade80;
  --fail: #f87171;
  --border: #262b38;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  margin: 0;
  padding: 2rem;
  line-height: 1.6;
}

main { max-width: 860px; margin: 0 auto; }

h1 { font-size: 1.75rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.2rem; }
p.lede { color: var(--muted); margin-top: 0; }

a { color: var(--accent); }

/* Kategorie-Umschalter der Startseite (index.html/portal.mjs) — #/services,
   #/examples, #/documentation. Nur additiv, keine bestehende Regel oben
   verändert (dieses Stylesheet wird von etlichen anderen Seiten geteilt). */
.category-tabs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.category-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.2rem;
  margin-bottom: -1px;
  cursor: pointer;
}
.category-tab:hover { color: var(--text); }
.category-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.cards-section[hidden] { display: none; }

nav.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 0.4rem 0; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

#summary { font-weight: 600; margin: 1rem 0; }

ul#results { list-style: none; padding: 0; margin: 0; }
ul#results li {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
}
li.pass { background: rgba(74, 222, 128, 0.08); color: var(--pass); }
li.fail { background: rgba(248, 113, 113, 0.1); color: var(--fail); }
li.fail pre { color: var(--text); white-space: pre-wrap; margin: 0.4rem 0 0 0; }

#log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

#content { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 2rem; }
#content h1, #content h2, #content h3 { color: var(--accent); }
#content code { background: #0000004d; padding: 0.15em 0.4em; border-radius: 4px; }
#content pre { background: #00000066; padding: 1rem; border-radius: 8px; overflow-x: auto; }
#content pre code { background: none; padding: 0; }
#content table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
#content th, #content td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
#content blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.2rem 1rem; color: var(--muted); }

.back { display: inline-block; margin-bottom: 1.5rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }

/* --- Visual demo steps --- */
#demo-summary { font-weight: 600; margin: 1rem 0 1.5rem; padding: 0.6rem 1rem; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); }
#demo-summary.warn { color: var(--fail); border-color: var(--fail); }
#demo-summary.ok { color: var(--pass); }

.step {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}
.step h2 { margin: 0 0 0.35rem 0; color: var(--accent); font-size: 1.05rem; }
.step-desc { color: var(--muted); margin: 0 0 1rem 0; font-size: 0.92rem; }
.step-code {
  background: #00000066;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  margin: 0 0 1rem 0;
}
.step-code code { color: #d6e2ff; }
.step-error .step-code { border: 1px solid rgba(248, 113, 113, 0.35); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.88rem; word-break: break-all; }
.kv-warn dd { color: var(--fail); }

.chat-bubble { background: #0000004d; border-radius: 10px; padding: 0.9rem 1.1rem; max-width: 28rem; }
.chat-meta { color: var(--accent); font-size: 0.82rem; margin-bottom: 0.3rem; }
.chat-text { font-size: 1rem; }
.chat-via { color: var(--muted); font-size: 0.78rem; margin-top: 0.4rem; }

.file-card { display: flex; gap: 1rem; align-items: flex-start; background: #0000004d; border-radius: 10px; padding: 1rem 1.2rem; }
.file-icon { font-size: 1.8rem; }
.file-name { font-weight: 600; }
.file-meta { color: var(--muted); font-size: 0.85rem; margin: 0.15rem 0; }
.file-integrity.ok { color: var(--pass); }
.file-integrity.bad { color: var(--fail); }

.result-box { border-radius: 10px; padding: 0.9rem 1.1rem; }
.result-rejected { background: rgba(74, 222, 128, 0.08); }
.result-fail { background: rgba(248, 113, 113, 0.1); }
.badge { display: inline-block; font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.6rem; border-radius: 999px; margin-bottom: 0.5rem; }
.badge-pass { background: rgba(74, 222, 128, 0.2); color: var(--pass); }
.badge-fail { background: rgba(248, 113, 113, 0.2); color: var(--fail); }
.reject-msg { margin: 0; font-size: 0.85rem; color: var(--text); white-space: pre-wrap; word-break: break-word; }

/* --- Live Chat --- */
.chat-shell { max-width: 960px; }
.chat-status { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.chat-layout { display: grid; grid-template-columns: 1fr 220px; gap: 1.25rem; }
.chat-main { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.chat-side { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; height: fit-content; }
.chat-side h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 1rem 0 0.5rem; }

.messages { list-style: none; margin: 0; padding: 1rem; height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; }
.msg { max-width: 80%; background: #0000004d; border-radius: 10px; padding: 0.55rem 0.8rem; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: rgba(125, 211, 252, 0.15); }
.msg-meta { font-size: 0.72rem; color: var(--muted); margin-bottom: 0.2rem; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
.msg .attachment { margin-top: 0.4rem; font-size: 0.78rem; display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; }
.attachment-status { font-size: 0.75rem; color: var(--muted); font-style: italic; }
.attachment-btn { background: var(--border); color: var(--text); border: none; border-radius: 6px; padding: 0.25rem 0.6rem; font-size: 0.75rem; cursor: pointer; }
.attachment-btn:hover { background: var(--accent); color: #0f1115; }
.attachment-media { max-width: 260px; max-height: 200px; border-radius: 8px; display: block; }
.attachment-preview a { color: var(--accent); font-size: 0.78rem; }
.msg .status { margin-top: 0.25rem; font-size: 0.7rem; color: var(--muted); text-align: right; }

.composer { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border); }
.composer input[type="text"] { flex: 1; background: #00000066; border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; color: var(--text); }
.composer input[type="file"] { max-width: 140px; font-size: 0.75rem; color: var(--muted); }
.composer button { background: var(--accent); color: #0f1115; border: none; border-radius: 8px; padding: 0.5rem 1rem; font-weight: 600; cursor: pointer; }

.presence { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.presence li { padding: 0.2rem 0; }
.presence li.online { color: var(--pass); }
.presence li.offline { color: var(--muted); }

@media (max-width: 720px) {
  body { padding: 1rem; font-size: 15px; }
  main { max-width: 100%; }
  h1 { font-size: 1.35rem; }
  nav.cards { grid-template-columns: 1fr; }

  .chat-layout { grid-template-columns: 1fr; }
  .chat-side { order: -1; } /* presence above the conversation on a phone, not squeezed to the side */
  .messages { height: 50vh; padding: 0.75rem; }
  .msg { max-width: 92%; }

  /* Inputs at 16px+ stop iOS Safari from auto-zooming the page on focus. */
  .composer { flex-wrap: wrap; padding: 0.6rem; }
  .composer input[type="text"] { font-size: 16px; min-width: 0; flex: 1 1 100%; order: 1; }
  .composer input[type="file"] { font-size: 16px; flex: 1 1 auto; order: 2; max-width: none; }
  .composer button { flex: 0 0 auto; order: 3; font-size: 16px; padding: 0.6rem 1rem; }

  #debug-panel { font-size: 0.9rem; }
  #debug-log { max-height: 160px; }
}

/* --- Interactive Lab (docs/lab/) --- */
.lab-section { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem 1.75rem; margin-bottom: 1.5rem; }
.lab-section h2 { margin: 0 0 0.35rem 0; color: var(--accent); }
.lab-toolbar { display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 0; }
.run-btn { background: var(--accent); color: #0f1115; border: none; border-radius: 8px; padding: 0.5rem 1rem; font-weight: 600; cursor: pointer; }
.run-btn:disabled { opacity: 0.6; cursor: default; }
.lab-status { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.lab-status.ok { color: var(--pass); }
.lab-status.warn { color: var(--fail); }
.console-hint { font-size: 0.8rem; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; margin: 0 0 0.5rem 0; }
.lab-toolbar-global { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 2rem; }
.lab-toolbar-global button { background: var(--border); color: var(--text); border: none; border-radius: 6px; padding: 0.4rem 0.8rem; font-size: 0.82rem; cursor: pointer; }
.lab-toolbar-global button:hover { background: var(--fail); color: #0f1115; }

/* --- Reactive live views inside a lab section (e.g. Lab 5) --- */
.lab-live { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border); }
.lab-live h3 { margin: 0 0 0.75rem 0; color: var(--accent); font-size: 1rem; }
.lib-form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.lib-input { background: #00000066; border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem 0.7rem; color: var(--text); font-size: 0.9rem; }
.lib-input[type="text"] { flex: 1 1 12rem; }
.lib-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.lib-entry { background: #0000004d; border-radius: 10px; padding: 0.7rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.lib-name { font-weight: 600; }
.lib-meta { font-size: 0.8rem; color: var(--muted); background: var(--border); border-radius: 999px; padding: 0.1rem 0.6rem; }
.lib-file-area { font-size: 0.82rem; color: var(--muted); }
.lib-file-link { color: var(--accent); text-decoration: none; }
.lib-file-link:hover { text-decoration: underline; }
.lib-note { flex: 1 1 100%; background: #00000066; border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.6rem; color: var(--text); font-size: 0.82rem; font-family: inherit; resize: vertical; }
/* <qu-bind> wraps .lib-note (see labs/05-references-practice.mjs) — layout-
   transparent so the textarea still participates in .lib-entry's flexbox
   directly, exactly as if <qu-bind> weren't there. */
.lib-entry qu-bind { display: contents; }

#debug-panel { margin-top: 1.5rem; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; }
#debug-panel summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.debug-toolbar { display: flex; gap: 1rem; align-items: center; margin: 0.6rem 0; font-size: 0.8rem; color: var(--muted); }
.debug-toolbar button { background: var(--border); color: var(--text); border: none; border-radius: 6px; padding: 0.25rem 0.6rem; font-size: 0.75rem; cursor: pointer; }
#debug-log { max-height: 240px; overflow-y: auto; font-size: 0.72rem; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; margin: 0; color: var(--muted); }
#debug-log .dbg-line { display: block; padding: 0.1rem 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
#debug-log .dbg-scope { color: var(--accent); }
#debug-log .dbg-err { color: var(--fail); }
