/* Anzeige-Aufnahme-Assistent — refined dark gov-tech theme.
   Pure CSS, system fonts only, no external assets. */

:root {
  --bg: #0d1217;
  --bg-pane: #141b23;
  --bg-elev: #1a2330;
  --bg-inset: #0f151c;
  --border: #28323f;
  --border-soft: #202a34;
  --border-strong: #3a4656;
  --text: #e7ecf2;
  --text-dim: #9aa8b7;
  --text-faint: #687786;
  --accent: #7fb0e3;
  --accent-deep: #2b4560;
  --accent-bg: rgba(127, 176, 227, 0.09);
  --accent-warm: #d8a94f;
  --accent-warm-bg: rgba(216, 169, 79, 0.08);
  --ok: #4fae7f;
  --bad: #d96e68;
  --bad-bg: rgba(217, 110, 104, 0.08);
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { 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, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(1100px 500px at 75% -15%, rgba(70, 110, 155, 0.09), transparent 60%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

button { font: inherit; color: inherit; }

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #17202b, #121920);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-mark { width: 24px; height: 24px; flex: none; }

.brand h1 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.brand .subtitle {
  margin: 0.05rem 0 0;
  font-size: 0.73rem;
  color: var(--text-dim);
}

.topbar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* status pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-inset);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, border-color 0.2s;
}
.pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--text-faint);
}
.pill-conn.connected::before { background: var(--ok); }
.pill-conn.pill-bad { color: var(--bad); border-color: var(--bad); }
.pill-conn.pill-bad::before { background: var(--bad); }
.pill-status[data-state="ready"]::before { background: var(--ok); }
.pill-status[data-state="transcribing"] {
  color: var(--accent);
  border-color: var(--accent-deep);
}
.pill-status[data-state="transcribing"]::before {
  background: var(--accent);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.pill-status[data-state="thinking"] { color: var(--accent-warm); border-color: #5c4a26; }
.pill-status[data-state="thinking"]::before {
  background: var(--accent-warm);
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.pill-status.pulse { animation: pill-pop 0.4s ease; }

@keyframes dot-pulse { 50% { opacity: 0.3; } }
@keyframes pill-pop { 30% { transform: scale(1.07); } }

/* mic button */

.mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.45rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.2s;
}
.mic-btn:hover:not(:disabled) { background: rgba(127, 176, 227, 0.17); }
.mic-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.mic-btn.recording {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
  animation: rec-pulse 1.8s ease-out infinite;
}
@keyframes rec-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 110, 104, 0.45); }
  70% { box-shadow: 0 0 0 13px rgba(217, 110, 104, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 110, 104, 0); }
}

/* evaluate button — primary action next to the mic */

.eval-btn {
  min-height: 44px;
  padding: 0.45rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #5890c4, #3c6f9f);
  color: #0a1622;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.eval-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #66a0d4, #467cae);
  box-shadow: 0 2px 14px rgba(127, 176, 227, 0.3);
}
.eval-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------------------------------------------------------- layout */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(330px, 5fr);
  gap: 1rem;
  padding: 1rem 1.25rem;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
}

.pane {
  background: var(--bg-pane);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.95rem 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane > h2 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
}

.placeholder { color: var(--text-faint); font-size: 0.86rem; line-height: 1.5; }

/* ------------------------------------------------------- conversation pane */

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-right: 0.25rem;
}
.thread-hint {
  margin: auto;
  color: var(--text-faint);
  font-size: 0.85rem;
  text-align: center;
  max-width: 26rem;
}

.msg {
  max-width: 80%;
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: msg-in 0.25s ease;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } }

.msg-assistant {
  align-self: flex-start;
  background: var(--bg-elev);
  border: 1px solid #2c3b4d;
  border-left: 3px solid var(--accent);
  border-top-left-radius: 4px;
}
/* user "messages" are raw STT transcript lines — kept visually secondary */
.msg-user {
  align-self: flex-end;
  background: rgba(127, 176, 227, 0.05);
  border: 1px dashed var(--border);
  border-bottom-right-radius: 4px;
  color: var(--text-dim);
  font-size: 0.84rem;
}
.msg-meta {
  margin-top: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.msg-user .msg-meta { text-align: right; }

.partial {
  min-height: 2.6rem;
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-inset);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  font-style: italic;
  font-size: 0.86rem;
  color: var(--text-dim);
}
.partial:empty::before {
  content: "Live-Transkript erscheint hier…";
  color: var(--text-faint);
}
.partial:not(:empty)::after {
  content: "▌";
  font-style: normal;
  margin-left: 2px;
  color: var(--accent);
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* -------------------------------------------------------------- form pane */

.pane-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border-soft);
}
.pane-head h2 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.completeness { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.completeness-caption {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.completeness-row { display: flex; align-items: center; gap: 0.55rem; }
.completeness-bar {
  width: 130px;
  height: 9px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
#completeness-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3d6d9e, var(--accent));
  transition: width 0.4s ease;
}
.completeness-bar.complete #completeness-fill {
  background: linear-gradient(90deg, #2f7a55, var(--ok));
}
#completeness-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
  text-align: right;
}

.form-grid {
  flex: 3 1 auto;
  min-height: 0;
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.form-field {
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  background: rgba(255, 255, 255, 0.012);
  transition: border-color 0.2s, background 0.2s;
}
.form-label {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.req { color: var(--accent-warm); font-weight: 700; }
label.form-label { cursor: text; }

/* editable field inputs — borderless-ish on the tinted row, underline on
   hover/focus so fields read as values, not boxes */
.form-input {
  display: block;
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.18rem 0.1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
}
.form-input:hover { border-bottom-color: var(--border); }
.form-input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  background: rgba(127, 176, 227, 0.04);
}
.form-input::placeholder { color: var(--text-faint); font-style: italic; }
textarea.form-input {
  min-height: 8rem;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}
select.form-input {
  width: auto;
  min-width: 12rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}
input[type="checkbox"].form-input {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.35rem;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="number"].form-input { width: 10rem; }

/* states: missing is subtle, confirmation amber, error red, filled green */
.form-field.missing { border-left-style: dashed; border-left-color: var(--border-strong); }
.form-field.filled { border-left-color: var(--ok); }
.form-field.needs-confirmation {
  border-left-color: var(--accent-warm);
  background: var(--accent-warm-bg);
}
.form-field.needs-confirmation .form-label::after {
  content: "· zur Bestätigung";
  color: var(--accent-warm);
  text-transform: none;
  letter-spacing: 0;
}
.form-field.error {
  border-color: var(--bad);
  border-left: 3px solid var(--bad);
  background: var(--bad-bg);
}
.form-field.error .form-label::after {
  content: "· bitte prüfen";
  color: var(--bad);
  text-transform: none;
  letter-spacing: 0;
}

/* ------------------------------------------------------------- actions */

.pane-actions { margin-top: 0.8rem; display: flex; justify-content: flex-end; }
.submit-btn {
  min-height: 44px;
  padding: 0.5rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.submit-btn:hover:not(:disabled):not(.ready) {
  border-color: var(--text-faint);
  color: var(--text);
}
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.submit-btn.ready:not(:disabled) {
  background: linear-gradient(180deg, #57b687, #3f9a6c);
  border-color: transparent;
  color: #08130d;
  box-shadow: 0 2px 14px rgba(79, 174, 127, 0.35);
}

/* ------------------------------------------------------------ findings */

.findings-title { margin-top: 1.1rem; }
.findings-disclaimer {
  font-size: 0.72rem;
  color: var(--accent-warm);
  margin: -0.35rem 0 0.6rem;
}
.findings {
  flex: 2 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.finding {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent-warm);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  animation: msg-in 0.25s ease;
}
.finding-unlikely { border-left-color: var(--border-strong); opacity: 0.72; }

.finding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.finding-provision {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid #31475e;
  padding: 0.16rem 0.55rem;
  border-radius: 6px;
}
.finding-unlikely .finding-provision {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}
.finding-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--accent-warm);
  color: var(--accent-warm);
  background: var(--accent-warm-bg);
}
.finding-unlikely .finding-badge {
  border-color: var(--border-strong);
  color: var(--text-dim);
  background: transparent;
}

.finding-desc { margin-top: 0.5rem; line-height: 1.5; }
.finding-meta {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.73rem;
  color: var(--text-dim);
}
.conf-meter { display: inline-flex; gap: 3px; }
.conf-meter i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
}
.conf-meter.conf-low i:nth-child(1),
.conf-meter.conf-medium i:nth-child(-n + 2),
.conf-meter.conf-high i { background: var(--accent-warm); }

.finding-sec { margin-top: 0.55rem; }
.finding-sec-title {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.finding-list { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.finding-list li { margin-top: 0.15rem; font-size: 0.76rem; line-height: 1.45; }
.finding-cite { color: var(--accent); }
.finding-missing { color: #e0a3a0; }
.finding-disclaimer {
  margin-top: 0.6rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--border-soft);
  font-size: 0.7rem;
  color: var(--text-faint);
  font-style: italic;
}

/* -------------------------------------------------------------- footer */

.footnote {
  padding: 0.55rem 1.25rem;
  font-size: 0.73rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-soft);
  background: #11171e;
}

.toast {
  position: fixed;
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: #241a1a;
  border: 1px solid var(--bad);
  color: #f0c4c1;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-size: 0.86rem;
  max-width: 92vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

/* ----------------------------------------------------------- scrollbars */

.thread, .form-grid, .findings {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid var(--bg-pane);
}
::-webkit-scrollbar-track { background: transparent; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 960px) {
  body { height: auto; min-height: 100vh; }
  .topbar { padding: 0.6rem 0.9rem; }
  .topbar-right { width: 100%; justify-content: flex-end; gap: 0.5rem; }
  .mic-btn { flex: 1 1 auto; }
  .layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    overflow: visible;
  }
  .pane { padding: 0.85rem 0.9rem; }
  .thread { flex: none; max-height: 46vh; min-height: 10rem; }
  .form-grid { flex: none; overflow: visible; }
  .findings { flex: none; overflow: visible; }
  .pane-actions { justify-content: stretch; }
  .submit-btn { width: 100%; }
  .msg { max-width: 92%; }
}

@media (max-width: 480px) {
  .brand .subtitle { display: none; }
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
