/* ── Sponti – Shared Design System ─────────────────────────────────────────
   Alle Seiten linken auf diese Datei. Seiten-spezifische Regeln kommen in
   einen lokalen <style>-Block in der jeweiligen PHP-Datei.

   Kontrast-Ziel: WCAG 2.1 AAA (≥ 7:1 für Normaltext, ≥ 4.5:1 für Grosstext).
   Getestet auf Hintergrund --bg (#0f1a12, L≈0.007).
   ─────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0f1a12;   /* Waldboden-Dunkel             L≈0.007 */
  --surface:   #172219;   /* Kartenoberfläche             L≈0.012 */
  --border:    #2a3c2c;
  --shadow:    0 2px 24px rgba(0,0,0,.55);
  --shadow-sm: 0 1px 8px  rgba(0,0,0,.35);
  --text:      #ece8df;   /* warmes Off-White             L≈0.845 → ~14:1 */
  --muted:     #a8bca9;   /* helles Grau-Grün             L≈0.44  → ~8.6:1 */
  --faint:     #1e2e20;

  --accent:    #82b890;   /* Salbeigrün (entsättigt)      L≈0.41  → ~8.1:1 */
  --accent-dk: #6ca07a;
  --accent-lt: #1a3320;

  --sky:       #75baff;   /* Bergblau                    L≈0.44  → ~8.6:1 */
  --sky-lt:    #152540;

  --amber:     #f2b840;   /* Sonnenwärme                 L≈0.47  → ~9.0:1 */
  --amber-lt:  #2a1c06;

  --red:       #f28888;   /* Warnung (aufgehellt)        L≈0.46  → ~8.8:1 */
  --red-lt:    #2a1010;
}

/* ── Scrollbars ────────────────────────────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar        { width: 5px; height: 5px; }
*::-webkit-scrollbar-track  { background: transparent; }
*::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-dk); }

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
  font: 14px/1.6 system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Standard-Seitenbreite für Tool-/Debug-Seiten */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 { color: var(--accent); font-weight: 800; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Navigation ────────────────────────────────────────────────────────────── */
nav {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

nav a {
  padding: .4rem 1rem;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  transition: all .15s;
}

nav a:hover  { border-color: var(--accent); color: var(--accent); background: var(--accent-lt); }
nav a.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: flex-end;
}

label {
  font-size: .78rem;
  color: var(--muted);
  display: block;
  margin-bottom: .2rem;
  font-weight: 600;
}

input, select, textarea {
  padding: .45rem .8rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

input[type=range] {
  flex: 1;
  accent-color: var(--accent);
  height: 3px;
  cursor: pointer;
  padding: 0;
  border: none;
  background: transparent;
}

.checkboxes {
  display: flex;
  gap: .8rem;
  align-items: center;
  font-size: .82rem;
  color: var(--muted);
}

.checkboxes label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: .3rem;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
button, .btn {
  padding: .45rem 1.1rem;
  background: var(--accent);
  color: var(--bg);           /* dark text on light-green bg → ~8.5:1 ✓ */
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: .9rem;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  font-family: inherit;
  transition: background .15s;
}

button:hover, .btn:hover { background: var(--accent-dk); }

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  font-weight: 600;
}

.btn-secondary:hover { background: var(--faint); color: var(--text); }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  background: var(--faint);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge.leicht        { background: var(--accent-lt); color: var(--accent); }
.badge.mittel        { background: var(--amber-lt);  color: var(--amber); }
.badge.anspruchsvoll { background: var(--red-lt);    color: var(--red); }
.badge.diff-rating   { background: var(--sky-lt);    color: var(--sky); }

/* ── Trail tags ────────────────────────────────────────────────────────────── */
.trail-tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 6px;
  margin-bottom: .45rem;
}

.trail-ok         { background: var(--accent-lt); border: 1px solid var(--accent); color: var(--accent); }
.trail-unverified { background: var(--amber-lt);  border: 1px solid var(--amber);  color: var(--amber); }

/* ── Step list (SSE/Loading) ───────────────────────────────────────────────── */
.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column-reverse;
  gap: .4rem;
  margin-bottom: 1rem;
}

.step-item {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  font-size: .88rem;
  opacity: .35;
  transition: opacity .2s;
  padding: .4rem .6rem;
  border-radius: 6px;
}

.step-item.active { opacity: 1; background: var(--accent-lt); }
.step-item.done   { opacity: .55; }
.step-item.error  { opacity: 1; color: var(--red); background: var(--red-lt); }

.step-icon { width: 1rem; flex-shrink: 0; margin-top: .05rem; color: var(--accent); }
.step-stage {
  font-size: .6rem;
  font-weight: 600;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--text);
  background: none;
  border: 1px solid var(--muted);
  border-radius: 3px;
  padding: .05rem .28rem;
  line-height: 1.4;
  flex-shrink: 0;
  align-self: center;
  letter-spacing: .04em;
}
.step-item.error .step-icon { color: var(--red); }

.step-icon.spin { display: inline-block; animation: spin .7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.step-text   { flex: 1; min-width: 0; line-height: 1.35; }
.step-detail { display: block; font-size: .75rem; color: var(--muted); margin-top: .25rem; overflow-wrap: break-word; word-break: break-all; }
.step-time   { font-size: .72rem; color: var(--muted); flex-shrink: 0; align-self: center; }
.step-thinking-content {
  display: block;
  margin-top: .3rem;
  padding: .35rem .6rem;
  background: var(--bg);
  border-left: 2px solid var(--border);
  border-radius: 0 4px 4px 0;
  white-space: pre-wrap;
  font-style: italic;
  font-size: .73rem;
  color: var(--muted);
}
.step-timer  {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
  padding-left: .5rem;
  font-variant-numeric: tabular-nums;
  max-width: 5rem;
}

/* ── Signal-Panel ──────────────────────────────────────────────────────────── */
.signal-list { display: flex; flex-direction: column; gap: .25rem; max-height: 300px; overflow-y: auto; }
/* p-Tag-Margins innerhalb des Flex-Containers zurücksetzen */
.signal-list p { margin: 0; }
.signal-word {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
}
.signal-term  { flex: 1; min-width: 0; color: var(--text); word-break: break-all; }
.signal-score { flex-shrink: 0; font-size: .7rem; font-weight: 600; margin-left: .5rem; white-space: nowrap; }
.signal-bad     { background: color-mix(in srgb, var(--red) 15%, var(--surface)); }
.signal-bad     .signal-score { color: var(--red); }
.signal-good    { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); }
.signal-good    .signal-score { color: var(--accent); }
.signal-neutral { background: var(--surface); }
.signal-neutral .signal-score { color: var(--muted); }
.signal-backoff { background: color-mix(in srgb, #8899aa 15%, var(--surface)); border: 1px solid var(--border); }
.signal-backoff .signal-score { color: #8899aa; }
.signal-backoff .signal-term  { color: var(--muted); }
.signal-word--llm  { border-left: 2px solid var(--accent); padding-left: .35rem; }
.signal-word--llm  .signal-term::before { content: '✦ '; font-size: .6rem; color: var(--accent); vertical-align: middle; }
.signal-word--full { font-size: .72rem; padding: .25rem .5rem; }
.signal-word--full .signal-term { word-break: break-word; white-space: normal; line-height: 1.3; }
.signal-query-active { outline: 1px solid var(--accent); outline-offset: -1px; }
.signal-chips { display: flex; flex-wrap: wrap; gap: .2rem; margin-bottom: .25rem; }
.signal-chip { font-size: .68rem; padding: .1rem .35rem; border-radius: 3px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); word-break: break-all; }
.signal-chip-good { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }

/* ── Signal-Panel Wrapper ──────────────────────────────────────────────────── */
.signal-panel { margin-top: 1rem; }
.signal-panel-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 .3rem;
}
.signal-panel-title .kw-count { font-weight: 400; text-transform: none; letter-spacing: 0; }
.signal-subsection {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
  margin: .3rem 0 .15rem;
}
.signal-subsection.accent { color: var(--accent); }

/* ── Pipeline-Stats-Bar ─────────────────────────────────────────────────────── */
.stats-bar {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .6rem; margin-bottom: .75rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.stats-tiles {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem;
}
.stats-tile {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: .3rem .4rem; text-align: center; line-height: 1.25;
}
.stats-tile .st-num  { display: block; font-size: .85rem; font-weight: 800; color: var(--text); }
.stats-tile .st-lbl  { display: block; font-size: .6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats-tile .st-avg  { display: block; font-size: .6rem; color: var(--muted); margin-top: .15rem; }
.stats-tile.st-good  .st-num { color: var(--accent); }
.stats-tile.st-bad   .st-num { color: #8899aa; }
.stats-tile.st-muted .st-num { color: var(--muted); }
.stats-reject {
  font-size: .67rem; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: .3rem;
}
.stats-reject-title { font-weight: 700; color: var(--text); font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .2rem; }
.stats-reject-row   { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; padding: .05rem 0; }
.sr-lbl { flex: 1; }
.sr-num { flex-shrink: 0; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ── Misc shared ───────────────────────────────────────────────────────────── */
.meta { font-size: .78rem; color: var(--muted); margin-bottom: 1rem; }
.meta strong { color: var(--text); }

.section-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-bottom: .7rem;
  font-weight: 700;
}

.error-box {
  color: var(--red);
  background: var(--red-lt);
  border: 1px solid #4a2020;
  border-radius: 8px;
  padding: .8rem 1rem;
  margin-bottom: 1rem;
  font-size: .85rem;
}

.empty { color: var(--muted); font-style: italic; font-size: .88rem; }

details { margin-top: 1rem; }
summary { cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 600; }

pre {
  background: var(--faint);
  border: 1px solid var(--border);
  padding: .8rem;
  border-radius: 8px;
  font-size: .75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text);
  max-height: 350px;
  overflow-y: auto;
  margin-top: .4rem;
}

/* ── Status colours ────────────────────────────────────────────────────────── */
.ok    { color: var(--accent); }
.warn  { color: var(--amber); }
.err   { color: var(--red); }
.fit   { color: var(--accent); }
.nofit { color: var(--red); }
.dim   { color: var(--muted); }
