:root {
  --bg: #f4ede0; --surface: #faf5e9; --surface-2: #efe6d0; --surface-3: #e6dbbf;
  --border: #d8ccb0; --border-soft: #e7dcc2;
  --text: #2d2650; --text-strong: #1a1638; --text-muted: #6d6790; --text-faint: #a89ec4;
  --accent: #4e5fb8; --accent-dim: #6d7ec8; --accent-soft: #dbe0f5;
  --ok: #4a8560; --ok-soft: #d7e6dc;
  --warn: #b78b3c; --warn-soft: #f4e3c0;
  --crit: #b04a3f; --crit-soft: #f2d5cf;
  --wknd: #ece2c9;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
html[data-theme="dark"] {
  --bg: #1a1830; --surface: #221f3d; --surface-2: #2a2647; --surface-3: #332e56;
  --border: #3b355f; --border-soft: #302b52;
  --text: #d8d3f0; --text-strong: #f2eefb; --text-muted: #a29dc4; --text-faint: #6d6790;
  --accent: #8b9cf5; --accent-dim: #7d8eea; --accent-soft: #2c2f5c;
  --ok: #7fb894; --ok-soft: #2b4636;
  --warn: #d9b06e; --warn-soft: #4a3a1e;
  --crit: #e08579; --crit-soft: #4a2622;
  --wknd: #2a2647;
}
html[data-theme="dark"] .tile.tile-image .tile-cover .badge {
  background: rgba(20, 18, 40, 0.85);
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); gap: 20px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  text-decoration: none; color: inherit;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  display: inline-block; width: 44px; height: 44px; flex: 0 0 auto;
  background-image: url("/static/logos/wingman.png");
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
html[data-theme="dark"] .brand-logo {
  background-color: #f2eefb; border-radius: 50%; padding: 2px;
}
.brand-text {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; line-height: 1.15;
}
.brand-name {
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em; color: var(--text-strong); white-space: nowrap;
}
.brand-sub {
  color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.12em;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .brand-sub { display: none; }
  .brand-logo { width: 36px; height: 36px; }
}
.user-area { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--mono); font-size: 11px; color: var(--text-muted);
  background: var(--surface); white-space: nowrap;
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint);
}
.status-pill.ok .dot { background: var(--ok); }
.status-pill.ok { color: var(--ok); border-color: var(--ok-soft); background: var(--ok-soft); }
.status-pill.bad .dot { background: var(--crit); }
.status-pill.bad { color: var(--crit); border-color: var(--crit-soft); background: var(--crit-soft); }

.settings-link, button.settings-link {
  padding: 5px 12px; background: var(--surface); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 4px;
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  display: inline-block;
}
.settings-link:hover, button.settings-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.role-badge {
  display: inline-block; padding: 2px 8px; background: var(--warn-soft);
  color: var(--warn); font-family: var(--mono); font-size: 10px; font-weight: 700;
  border-radius: 3px; letter-spacing: 0.06em; text-transform: uppercase;
}

/* Hinweis-Banner */
.notice-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 24px; background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--border-soft); font-size: 12.5px; line-height: 1.4;
}
.notice-bar .notice-text { font-family: var(--sans); font-weight: 500; }
.notice-bar .notice-close {
  all: unset; cursor: pointer; color: var(--warn); padding: 2px 8px;
  font-family: var(--mono); font-size: 12px; flex: 0 0 auto;
}
.notice-bar .notice-close:hover { color: var(--text-strong); }

/* Tabs */
.tabs {
  display: flex; gap: 24px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
  padding: 12px 0; font-size: 13px; color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text-strong); border-bottom-color: var(--accent); font-weight: 600; }

/* Layout */
main { max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; color: var(--text-strong); text-wrap: balance; }
h2 { font-size: 14px; color: var(--text-strong); font-weight: 600; letter-spacing: 0.02em; margin: 0 0 8px; }

footer {
  padding: 20px 24px; text-align: center; color: var(--text-faint);
  font-family: var(--mono); font-size: 11px;
  border-top: 1px solid var(--border-soft); margin-top: 40px;
}
footer .copy { color: var(--text-muted); letter-spacing: 0.04em; }

/* Kachel-Grid für Tasks */
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

.tile {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 18px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; color: inherit;
  text-decoration: none; transition: border-color .12s, transform .12s;
  min-height: 150px; overflow: hidden;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.tile .badge {
  align-self: flex-start; padding: 2px 8px; background: var(--accent-soft);
  color: var(--accent); font-family: var(--mono); font-size: 10px; font-weight: 700;
  border-radius: 3px; letter-spacing: 0.08em; text-transform: uppercase;
}
.tile .t-title { font-size: 15px; font-weight: 600; color: var(--text-strong); }
.tile .t-desc { color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.tile .t-meta {
  margin-top: auto; display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--text-faint);
}
.tile .t-meta .arrow { color: var(--accent); }
.tile .tile-body { display: flex; flex-direction: column; gap: 10px; flex: 1; }

/* Kachel-Variante mit Cover-Bild — ganze Grafik sichtbar, quadratischer Cover-Bereich */
.tile.tile-image { padding: 0; gap: 0; min-height: 0; }
.tile.tile-image .tile-cover {
  position: relative;
  aspect-ratio: 1 / 1;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.tile.tile-image .tile-cover .badge {
  position: absolute; top: 10px; left: 10px;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
}
.tile.tile-image .tile-body {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 14px;
}

.tile.placeholder {
  background: transparent; border-style: dashed;
  color: var(--text-muted); align-items: center; justify-content: center; text-align: center;
}
.tile.placeholder:hover { border-color: var(--accent-dim); transform: none; }

/* Info-Boxen */
.status {
  padding: 14px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; font-family: var(--mono); font-size: 13px; margin-bottom: 20px;
}
.status .ok { color: var(--ok); font-weight: 600; }
.status .bad { color: var(--crit); font-weight: 600; }

.panel {
  padding: 20px 22px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 8px; margin-bottom: 20px;
}
.panel h2 { margin-bottom: 12px; }
.panel .placeholder { color: var(--text-muted); font-size: 13px; line-height: 1.55; }

/* Formularelemente */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; background: var(--accent); color: var(--bg); border: 0;
  border-radius: 6px; font-family: var(--mono); font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-dim); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn.danger { background: var(--crit); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

select, input[type="text"], textarea {
  background: var(--surface); color: var(--text-strong); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; font-family: var(--sans); font-size: 13px;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Tabelle */
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; font-size: 13px;
}
table.data th, table.data td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border-soft);
}
table.data th {
  background: var(--surface-2); font-family: var(--mono); font-weight: 600;
  color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}
table.data tr:last-child td { border-bottom: 0; }

/* Progressbar für Ollama-Pull */
.progress {
  height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden;
  margin: 8px 0;
}
.progress .bar {
  height: 100%; background: var(--accent); width: 0%;
  transition: width .2s ease;
}
.progress-label {
  font-family: var(--mono); font-size: 11px; color: var(--text-muted);
  display: flex; justify-content: space-between;
}

/* Recording UI */
.record-panel {
  padding: 24px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; text-align: center;
}
.record-btn {
  width: 88px; height: 88px; border-radius: 50%; border: 3px solid var(--accent);
  background: var(--bg); color: var(--accent); font-family: var(--mono); font-size: 12px;
  font-weight: 700; cursor: pointer; transition: all .15s;
}
.record-btn:hover { background: var(--accent-soft); }
.record-btn.recording {
  background: var(--crit); color: var(--bg); border-color: var(--crit);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(176, 74, 63, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(176, 74, 63, 0); }
}
.record-hint {
  margin-top: 12px; font-family: var(--mono); font-size: 12px; color: var(--text-muted);
}
.timer { font-family: var(--mono); font-size: 24px; color: var(--text-strong); margin-top: 8px; }

/* Ausgabe-Panel */
.output-panel {
  padding: 18px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; margin-top: 20px;
}
.output-panel .header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
  font-family: var(--mono); font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.output-panel .body {
  white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.6;
  color: var(--text-strong); min-height: 80px;
}
.output-panel .body.streaming::after {
  content: "▍"; color: var(--accent); animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.transcript-box {
  padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 6px; font-size: 13px; line-height: 1.5; margin-bottom: 12px;
  color: var(--text); white-space: pre-wrap;
}
.transcript-box.empty { color: var(--text-faint); font-style: italic; }
