:root {
    --bg: #0b1016;
    --panel: #121a24;
    --panel-2: #18222f;
    --line: #22303f;
    --text: #dbe6f0;
    --muted: #7e94a8;
    --accent: #2dd4bf;
    --accent-2: #8b7cf8;
    --danger: #f2566a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(1200px 700px at 20% -10%, #152433 0%, var(--bg) 60%);
    color: var(--text);
    min-height: 100vh;
}

h1, h2 { font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
h2.mt { margin-top: 26px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.placeholder { color: var(--muted); font-size: 13px; }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; }
.login-card {
    width: min(400px, calc(100vw - 32px));
    margin: 14vh 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 34px 30px;
    box-shadow: 0 30px 70px -30px #000;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 24px; margin: 0; }
.brand-icon { width: 26px; height: 26px; fill: var(--accent); color: var(--accent); }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.login-card .foot { margin: 20px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }

input[type=password], input[type=url], input[type=text], select, textarea {
    width: 100%;
    padding: 11px 13px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    outline: none;
}
input[type=password]:focus, input[type=url]:focus, input[type=text]:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-size: 13.5px; }

button {
    font: inherit;
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    color: #06131a;
    background: linear-gradient(180deg, var(--accent), #14b8a6);
    font-weight: 600;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.login-card button { width: 100%; margin-top: 18px; }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.danger { background: var(--danger); color: #fff; }
.linkbtn { color: var(--muted); text-decoration: none; font-size: 13px; border: 1px solid var(--line); padding: 6px 11px; border-radius: 8px; }
.linkbtn:hover { color: var(--text); }

.alert {
    background: #3a1620;
    border: 1px solid #6d2437;
    color: #ffc2cd;
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 13px;
    margin: 0 0 16px;
}

/* ---------- Kopfzeile ---------- */
.top {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: #0d141cd9; backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 5;
}
.top-left, .top-right { display: flex; align-items: center; gap: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background .2s; }
.dot.live { background: var(--accent); box-shadow: 0 0 0 4px #2dd4bf26; }
.dot.busy { background: #f5b945; }
.dot.err { background: var(--danger); }
.meta { font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--muted); }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr) 300px;
    gap: 18px;
    padding: 18px;
    align-items: start;
    max-width: 1500px;
    margin: 0 auto;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
}
.settings label { display: block; font-size: 12px; color: var(--muted); margin: 16px 0 6px; }
.settings label:first-of-type { margin-top: 0; }
.hint { font-size: 11.5px; color: var(--muted); margin: 18px 0 0; }

/* ---------- Bühne ---------- */
.stage { display: flex; flex-direction: column; align-items: center; }
.orb-wrap { padding: 18px 0 6px; }
.orb { position: relative; width: 170px; height: 170px; display: grid; place-items: center; }
.ring {
    position: absolute; inset: 0; border-radius: 50%;
    /* Absolut positioniert liegen die Ringe ueber dem Button und wuerden
       dessen Klicks abfangen - auch bei opacity: 0. */
    pointer-events: none;
    border: 1px solid #2dd4bf33;
    transform: scale(var(--s, 1));
    transition: transform .09s linear, opacity .3s;
    opacity: 0;
}
.orb.live .ring { opacity: 1; }
.ring.r2 { border-color: #8b7cf833; }
.mic {
    position: relative; z-index: 1;
    width: 104px; height: 104px; border-radius: 50%;
    display: grid; place-items: center; padding: 0;
    background: linear-gradient(160deg, var(--accent), var(--accent-2));
    box-shadow: 0 16px 40px -14px #2dd4bf80;
}
.mic svg { width: 40px; height: 40px; fill: #06131a; color: #06131a; }
.orb.live .mic { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 16px 56px -10px #2dd4bfcc; } }

.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 18px 0 4px; }

.levels { display: flex; gap: 18px; width: 100%; max-width: 420px; margin: 16px 0 8px; }
.lvl { flex: 1; display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--muted); }
.lvl .bar { flex: 1; height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.lvl .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.lvl:last-child .bar i { background: var(--accent-2); }

/* ---------- Transkript ---------- */
.transcript {
    width: 100%; margin-top: 14px; padding-top: 16px;
    border-top: 1px solid var(--line);
    max-height: 46vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
}
.bubble {
    max-width: 82%; padding: 10px 14px; border-radius: 14px;
    font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.bubble.assistant { background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { background: #1d3a40; border: 1px solid #24555c; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.system { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.bubble.live::after { content: '▍'; color: var(--accent); }

/* ---------- Seitenspalte ---------- */
.history { display: flex; flex-direction: column; gap: 6px; max-height: 32vh; overflow-y: auto; }
.hitem {
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 9px; padding: 8px 11px; font-size: 12px;
    cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.hitem:hover { border-color: var(--accent); }
.hitem span:last-child { color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

.log {
    font-family: ui-monospace, Menlo, monospace; font-size: 10.5px;
    color: var(--muted); max-height: 34vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 2px;
}
.log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log .e { color: #ff9eab; }
.log .i { color: var(--accent); }

@media (max-width: 1080px) {
    .layout { grid-template-columns: 1fr; }
    .transcript { max-height: none; }
}

.notice {
    width: 100%; max-width: 560px; margin: 16px 0 0;
    background: #2a2416; border: 1px solid #5c4a1d; color: #f3d99b;
    padding: 11px 14px; border-radius: 10px; font-size: 13px;
}
.notice a { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.notice a:hover { text-decoration: underline; }
.diag {
    width: 100%; max-width: 560px; margin: 12px 0 0;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 14px; font-size: 12px;
    font-family: ui-monospace, Menlo, monospace; color: var(--muted);
    white-space: pre-wrap;
}
.diag b { color: var(--text); font-weight: 600; }
.diag .ok { color: var(--accent); }
.diag .bad { color: #ff9eab; }

button.start { min-width: 120px; }
button.danger { min-width: 120px; }
.hitem.running { border-color: var(--accent); }
.hitem .badge { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.hitem .badge.run { background: #2dd4bf26; color: var(--accent); }
.hitem .badge.open { background: #f5b94526; color: #f5b945; }

/* ---------- Learning-Prompt ---------- */
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
button.small { padding: 6px 10px; font-size: 12.5px; }
select:disabled, input:disabled, textarea:disabled { opacity: .55; }
.lp-card {
    margin-top: 12px; padding: 13px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line);
}
.lp-card label { margin-top: 10px; }
.lp-title { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.lp-title .muted { font-size: 12px; }
.lp-stats { font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.lp-size { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }
.lp-size.warn { color: #f5b945; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lp-dialog {
    width: min(900px, 94vw); height: min(80vh, 900px); padding: 0;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--line); border-radius: 14px;
}
.lp-dialog::backdrop { background: #000a; }
.lp-dialog-head {
    display: flex; gap: 10px; align-items: center; padding: 12px 16px;
    border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel);
}
.lp-dialog-head .muted { flex: 1; font-size: 12px; }
.lp-dialog pre {
    margin: 0; padding: 16px; white-space: pre-wrap; word-break: break-word;
    font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--text);
}
.hitem .badge.lp { background: #8b7cf826; color: var(--accent-2); }

/* ---------- API-Key ---------- */
.key-status { font-size: 12.5px; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.key-status code { color: var(--text); }
.key-status .ok { color: var(--accent); }
.key-status .bad { color: #ff9eab; }
.key-status .warn { color: #f5b945; }
.key-status .muted { font-size: 11.5px; }
button.danger-text { color: #ff9eab; }

/* ---------- Live-Log ---------- */
.livelog { grid-column: 1 / -1; }
.ll-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.ll-head h2 { margin: 0; }
.ll-head h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.ll-count { font-size: 12px; flex: 1; }
.ll-save { font-size: 12.5px; color: var(--text); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.ll-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 10px; }
.ll-tools input[type=search] {
    flex: 1; min-width: 180px; padding: 6px 10px; font-size: 12.5px;
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text);
}
.ll-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.ll-chip {
    font-size: 11.5px; padding: 3px 9px 3px 6px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--line); display: flex; align-items: center; gap: 2px; user-select: none;
}
.ll-chip input { margin: 0 3px 0 0; }
.ll-list {
    height: 46vh; min-height: 260px; overflow-y: auto; border-radius: 10px;
    background: #0a0f15; border: 1px solid var(--line); padding: 6px 0;
    font: 11.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ll-list .placeholder { padding: 10px 14px; font-family: inherit; }
.ll-row {
    display: grid; grid-template-columns: 92px 82px minmax(140px, 260px) 1fr; gap: 10px;
    padding: 1px 12px; cursor: pointer; white-space: nowrap;
}
.ll-row:hover { background: #ffffff0a; }
.ll-row span { overflow: hidden; text-overflow: ellipsis; }
.ll-t { color: var(--muted); }
.ll-src { font-weight: 600; }
.ll-type { color: #b9c7d4; }
.ll-sum { color: var(--text); }
.ll-row.err .ll-sum, .ll-row.err .ll-type { color: #ff9eab; }
.ll-json {
    margin: 2px 12px 6px 12px; padding: 8px 10px; border-radius: 8px;
    background: var(--panel-2); border: 1px solid var(--line);
    white-space: pre-wrap; word-break: break-word; color: var(--text); font: inherit;
}
/* Farben je Kategorie */
.cat-hoert .ll-src, .ll-chip.cat-hoert  { color: #5eead4; }
.cat-sagt .ll-src,  .ll-chip.cat-sagt   { color: #a78bfa; }
.cat-api .ll-src,   .ll-chip.cat-api    { color: #93c5fd; }
.cat-out .ll-src,   .ll-chip.cat-out    { color: #fbbf24; }
.cat-rtc .ll-src,   .ll-chip.cat-rtc    { color: #f9a8d4; }
.cat-stats .ll-src, .ll-chip.cat-stats  { color: #7e94a8; }
.cat-app .ll-src,   .ll-chip.cat-app    { color: #cbd5e1; }
@media (max-width: 1080px) {
    .ll-row { grid-template-columns: 76px 70px 1fr; }
    .ll-row .ll-sum { grid-column: 1 / -1; padding-left: 8px; }
}

/* ---------- Cartesia ---------- */
.ct-on { margin: 0 0 10px; }
.ct-box { transition: opacity .2s; }
.ct-box.dim { opacity: .55; }
.ct-box label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.ct-voice { margin-top: 6px; }
.cat-tts .ll-src, .ll-chip.cat-tts { color: #fb923c; }
