/* Helix Design System – ruhig, hochwertig, konsistent. Eine Akzentfarbe plus
   Statusfarben; grosszuegige Abstaende; klare Typografie; keine Neon-/Terminal-
   /Bootstrap-Optik. Details: docs/DESIGN_SYSTEM.md. */

:root {
  color-scheme: light dark;

  /* Farbrollen (Light). */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b1f24;
  --text-muted: #5b6470;
  --border: #e2e6ea;
  --accent: #2f5bd0;
  --accent-ink: #ffffff;

  /* Statustoene (Text + Symbol tragen die Information mit). */
  --progress: #2f5bd0;
  --attention: #a8651a;
  --critical: #b3261e;
  --success: #1f7a4d;
  --neutral: #6b7280;

  /* Spacing-Skala (4er-Basis). */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* Radius, Typo, Motion. */
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(20, 24, 30, 0.04), 0 4px 16px rgba(20, 24, 30, 0.06);
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --surface-2: #232833;
    --text: #e7eaee;
    --text-muted: #a3adba;
    --border: #2c333d;
    --accent: #6f9bff;
    --accent-ink: #10131a;
    --progress: #6f9bff;
    --attention: #e0a458;
    --critical: #f0857d;
    --success: #6cc79a;
    --neutral: #9aa4b0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}
h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 650;
  margin: 0;
}
h1 {
  font-size: 1.35rem;
}
h2 {
  font-size: 1.05rem;
}
p {
  margin: 0;
}
button {
  font: inherit;
  min-height: var(--tap);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.16em;
  fill: currentColor;
}

/* Layout. */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-weight: 700;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #7a5cff));
}
main {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--s5);
  display: grid;
  gap: var(--s5);
}
@media (max-width: 640px) {
  main {
    padding: var(--s4);
    gap: var(--s4);
  }
  .app-header {
    padding: var(--s3) var(--s4);
  }
}

/* Card. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s5);
}
.card > * + * {
  margin-top: var(--s4);
}
.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--s2);
}
.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Inputs. */
select,
textarea,
input {
  width: 100%;
  padding: var(--s3);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
}
textarea {
  min-height: 120px;
  resize: vertical;
}

/* Modus-Auswahl als ruhige Chips. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: var(--s2) var(--s4);
  cursor: pointer;
  min-height: 40px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
  font-weight: 600;
}

/* Buttons. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s ease, background 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  filter: brightness(1.05);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-block {
  width: 100%;
}

/* Statusanzeige: Farbe + Text + Symbol. */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px var(--s3);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.status[data-tone="progress"] {
  color: var(--progress);
  background: color-mix(in srgb, var(--progress) 12%, transparent);
}
.status[data-tone="attention"] {
  color: var(--attention);
  background: color-mix(in srgb, var(--attention) 14%, transparent);
}
.status[data-tone="critical"] {
  color: var(--critical);
  background: color-mix(in srgb, var(--critical) 12%, transparent);
}
.status[data-tone="success"] {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
}
.status[data-tone="neutral"] {
  color: var(--neutral);
  background: color-mix(in srgb, var(--neutral) 14%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .spin {
    animation: helix-spin 1.2s linear infinite;
  }
}
@keyframes helix-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Auftragskarten. */
.job {
  display: grid;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.job.decision {
  border-color: var(--attention);
}
.job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.job-title {
  font-weight: 600;
}
.progress {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.job-actions {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
}
.result dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s2) var(--s4);
  margin: 0;
}
.result dt {
  color: var(--text-muted);
}

/* Entscheidungsdialog. */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s5);
  max-width: 460px;
  width: calc(100% - 2 * var(--s4));
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(10, 12, 16, 0.45);
}
.dialog-actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s5);
}

/* Zustaende. */
.empty,
.loading,
.error {
  color: var(--text-muted);
  text-align: center;
  padding: var(--s6) var(--s4);
}
.error {
  color: var(--critical);
}

/* Expertenbereich (Progressive Disclosure). */
.expert {
  margin-top: var(--s3);
}
.expert summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.expert pre {
  margin-top: var(--s3);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  max-height: 320px;
  overflow: auto;
  font-size: 0.85rem;
}
