/* IBBrain — sober internal tool, self-contained (ADR-5: no external assets,
   no CDN, no web fonts). Operate mode: familiar, scannable, state-rich. */

:root {
  /* neutrals */
  --ink: #1b1e24;
  --muted: #5c636f;
  --faint: #868d99;
  --line: #dce0e6;
  --line-strong: #c4cad3;

  /* surfaces */
  --paper: #ffffff;   /* content surface */
  --panel: #f5f7f9;   /* second neutral layer: toolbars, panels, history */
  --tint: #eef1f4;    /* code, inline chips */

  /* accent */
  --accent: #16457c;
  --accent-ink: #0f3159;
  --accent-soft: #e7eef7;

  /* semantic */
  --warn-bg: #fdf4d9;
  --warn-line: #d9b23c;
  --warn-ink: #77590f;
  --error-bg: #fbe6e6;
  --error-line: #c4494f;
  --error-ink: #8c2c31;
  --ok-bg: #e4f2e7;
  --ok-line: #3e8a4f;
  --ok-ink: #21592e;
  --info-bg: #e5eef7;
  --info-line: #3f6fa6;
  --info-ink: #234a72;

  --danger: #b23b40;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(20, 32, 54, 0.05), 0 2px 6px rgba(20, 32, 54, 0.05);
  --shadow: 0 1px 2px rgba(20, 32, 54, 0.06), 0 6px 20px rgba(20, 32, 54, 0.07);

  --measure: 52rem;
  --measure-wide: 64rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- header / nav --------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-weight: 700;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  text-decoration: none;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.92rem;
  margin-left: auto;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.site-header nav a:hover { color: var(--ink); background: var(--tint); }
.site-header nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.nav-sep { width: 1px; align-self: stretch; margin: 0.15rem 0.35rem; background: var(--line); }
.nav-user { color: var(--faint); padding: 0.3rem 0.2rem; }

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
}

main.main-wide { max-width: var(--measure-wide); }

.site-footer {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.82rem;
}

/* --- typography ----------------------------------------------------------- */

h1 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 0.35rem; }
h2 { font-size: 1.18rem; letter-spacing: -0.01em; margin: 2rem 0 0.6rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 0.4rem; }
p { margin: 0.5rem 0; }
a { color: var(--accent); text-underline-offset: 2px; }

.page-intro { color: var(--muted); max-width: 46rem; margin: 0 0 1.5rem; }
.lead { font-size: 1.02rem; }

/* --- forms / controls ----------------------------------------------------- */

.search-form, .drop-form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 2rem;
}

.search-form label, .drop-form label { font-size: 0.82rem; color: var(--muted); font-weight: 500; }

input[type="text"], input[type="password"], input[type="file"], select, textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  max-width: 100%;
}

input[type="text"]:focus, input[type="password"]:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}

textarea { resize: vertical; }

button, .btn {
  font: inherit;
  font-weight: 500;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover, .btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
button:disabled, .btn:disabled, .btn[aria-disabled="true"] {
  background: var(--tint);
  border-color: var(--line-strong);
  color: var(--faint);
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--tint); border-color: var(--line-strong); color: var(--ink); }

.btn-danger {
  background: var(--paper);
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

.hint { color: var(--muted); font-size: 0.88rem; }

/* --- results -------------------------------------------------------------- */

.results { list-style: none; margin: 0; padding: 0; }

.result { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.result:first-child { padding-top: 0.25rem; }
.result h2 { margin: 0 0 0.3rem; font-size: 1.05rem; }
.result h2 a { text-decoration: none; }
.result h2 a:hover { text-decoration: underline; }
.result .summary { margin: 0.15rem 0; color: var(--ink); }
.meta { color: var(--faint); font-size: 0.83rem; margin: 0.2rem 0 0; }
.empty { color: var(--muted); }

/* --- badges / pills ------------------------------------------------------- */

.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  vertical-align: middle;
  white-space: nowrap;
}

.badge { margin-left: 0.45rem; }

.badge-auto { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.badge-curated { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.badge-count { background: var(--tint); color: var(--muted); border: 1px solid var(--line-strong); margin-left: 0; }
.badge-block { background: var(--error-bg); color: var(--error-ink); border: 1px solid var(--error-line); margin-left: 0; }

.pill-running { background: var(--info-bg); color: var(--info-ink); border: 1px solid var(--info-line); }
.pill-succeeded { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.pill-failed { background: var(--error-bg); color: var(--error-ink); border: 1px solid var(--error-line); }

.dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: currentColor; flex: none; }
.pill-running .dot { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pill-running .dot { animation: none; } }

/* --- boxes / callouts ----------------------------------------------------- */

.box {
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 1rem 0;
  font-size: 0.93rem;
}

.box-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.box-error { background: var(--error-bg); border-color: var(--error-line); color: var(--error-ink); }
.box-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.box-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.box strong { font-weight: 600; }
.box ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* --- panels --------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin: 1.2rem 0;
  box-shadow: var(--shadow-sm);
}

.panel > h2, .panel > h3 { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- artifact / review detail -------------------------------------------- */

.artifact .content, .review .content { margin: 1.3rem 0; }

.content h1 { font-size: 1.3rem; margin-top: 1.6rem; }
.content h2 { font-size: 1.12rem; }
.content pre {
  background: var(--tint);
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.9rem;
}
.content code {
  background: var(--tint);
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
}
.content pre code { background: none; padding: 0; }

.doc-title { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }

.topics { margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.topic {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--muted);
}

.assets img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.assets figure { margin: 0.8rem 0; }
.assets figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }

.provenance ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.provenance li { font-size: 0.92rem; }

/* meta grid (review + detail headers) */
.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1.1rem;
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
}
.meta-grid dt { color: var(--faint); }
.meta-grid dd { margin: 0; color: var(--ink); }

/* --- flags (fidelity + person) ------------------------------------------- */

.flags { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.flag {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  background: var(--paper);
  font-size: 0.9rem;
}
.flag-warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.flag-block { border-color: var(--error-line); background: var(--error-bg); color: var(--error-ink); }
.flag-head { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.flag-kind {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.06);
}
.flag code { background: rgba(0, 0, 0, 0.06); padding: 0.05rem 0.3rem; border-radius: 3px; }
.flag p { margin: 0.25rem 0 0; }

/* --- tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--paper); }
.table th, .table td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { background: var(--panel); color: var(--muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--panel); }
.table .num { font-variant-numeric: tabular-nums; color: var(--muted); }

/* --- log console ---------------------------------------------------------- */

.log {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #0f1720;
  color: #d6dde6;
  border-radius: var(--radius-sm);
  font-family: "Cascadia Code", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log:empty::after { content: "Noch keine Ausgabe."; color: #79828d; }

/* --- empty states --------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 2.75rem 1.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}
.empty-state h2 { margin: 0 0 0.4rem; color: var(--ink); border: 0; }
.empty-state p { margin: 0.2rem auto 0; max-width: 34rem; }

/* --- misc ----------------------------------------------------------------- */

.stack-sm > * + * { margin-top: 0.5rem; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-top: 2rem; font-size: 0.9rem; }
