:root {
  --bg: #05060b;
  --gold: #ffb43a;
  --gold-2: #ff8a1f;
  --gold-soft: rgba(255, 180, 58, .55);
  --line: rgba(255, 170, 60, .22);
  --glass: rgba(14, 12, 18, .62);
  --text: #f5e7cf;
  --muted: rgba(245, 231, 207, .55);
  --danger: #ff5a4a;
  --ok: #7dffb2;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", "SF Pro Display", Roboto, system-ui, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
.vignette { position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,140,30,.10), transparent 55%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.75) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px); }

/* ---------- HUD top ---------- */
.hud-top { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex;
  justify-content: space-between; align-items: flex-start;
  padding: calc(18px + var(--safe-t)) 24px 0; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.brand-title { font-weight: 300; letter-spacing: .55em; font-size: 18px; color: var(--gold);
  text-shadow: 0 0 12px rgba(255,170,50,.7); }
.brand-sub { margin-top: 6px; font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
.hud-right { display: flex; gap: 12px; align-items: center; }
.clock { font-variant-numeric: tabular-nums; letter-spacing: .15em; color: var(--gold); font-size: 14px; opacity: .85; }
.pill { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  background: rgba(10,8,12,.5); backdrop-filter: blur(8px); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #777; box-shadow: 0 0 8px currentColor; }
.pill.ok .dot { background: var(--ok); color: var(--ok); }
.pill.err .dot { background: var(--danger); color: var(--danger); }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(12,10,14,.55);
  display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); transition: .2s; }
.icon-btn:hover { border-color: var(--gold-soft); box-shadow: 0 0 14px rgba(255,160,40,.35); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--gold); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 14px; height: 14px; }

/* ---------- Core ---------- */
.stage { position: fixed; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; }
.core-wrap { position: relative; width: min(78vmin, 720px); height: min(78vmin, 720px); }
#core { width: 100%; height: 100%; display: block; }
.core-label { position: absolute; left: 50%; bottom: 4%; transform: translateX(-50%); font-size: 11px; letter-spacing: .5em;
  color: var(--gold); opacity: .8; text-shadow: 0 0 10px rgba(255,160,40,.8); white-space: nowrap; }

/* ---------- Chat ---------- */
.chat { position: fixed; z-index: 6; right: 22px; top: 50%; transform: translateY(-50%);
  width: 340px; height: min(62vh, 560px); display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(14px);
  box-shadow: 0 0 40px rgba(0,0,0,.5), inset 0 0 30px rgba(255,140,30,.04); overflow: hidden; }
.chat::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,170,60,.08), transparent 30%); }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
  border-bottom: 1px solid var(--line); font-size: 11px; letter-spacing: .3em; color: var(--gold); }
#chat-close { display: none; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.chat-log::-webkit-scrollbar { width: 4px; } .chat-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.msg { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: rgba(255,160,40,.16); border: 1px solid rgba(255,160,40,.3); }
.msg.bot { align-self: flex-start; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.msg.sys { align-self: center; font-size: 11px; letter-spacing: .08em; color: var(--muted); background: none; padding: 2px 6px; text-align: center; }
.msg.tool { align-self: flex-start; font-size: 11px; color: var(--muted); background: none; border-left: 2px solid var(--line); border-radius: 0; padding: 2px 8px; }
.msg.bot.streaming::after { content: "▍"; color: var(--gold); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg .m-img, .msg .m-file { margin: 6px 0 10px; }
.msg .m-img { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.msg .m-img img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.msg .m-file { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--gold);
  text-decoration: none; font-size: 13px; background: rgba(0,0,0,.25); word-break: break-all; }
.msg .m-file:hover { border-color: var(--gold-soft); }
.msg .m-img { cursor: zoom-in; }
.msg .m-pdf { position: relative; }
.msg .m-pdf img { max-height: 260px; object-fit: cover; object-position: top; }
.msg .m-cap { display: block; padding: 7px 10px; font-size: 12px; color: var(--gold); background: rgba(10,8,12,.92);
  border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Overlays: Dateiliste + Ansicht ---------- */
.overlay[hidden] { display: none; }
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 3vh 3vw;
  background: rgba(2,2,6,.72); backdrop-filter: blur(6px); }
.ov-box { position: relative; display: flex; flex-direction: column; width: min(1000px, 100%); height: min(92vh, 100%);
  background: rgba(12,10,16,.96); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,.6), 0 0 30px rgba(255,140,30,.12); }
.files-box { width: min(560px, 100%); height: min(78vh, 100%); }
.ov-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line); }
.ov-title { font-size: 12px; letter-spacing: .14em; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ov-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ov-btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--text);
  text-decoration: none; background: rgba(0,0,0,.3); }
.ov-btn:hover { border-color: var(--gold-soft); color: var(--gold); }
.ov-search { margin: 10px 12px; padding: 10px 12px; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-size: 15px; outline: none; }
.ov-search:focus { border-color: var(--gold-soft); }
.files-list { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.f-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px;
  background: none; text-align: left; cursor: pointer; }
.f-item:hover { background: rgba(255,170,60,.08); }
.f-ico { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }
.f-txt { display: flex; flex-direction: column; min-width: 0; }
.f-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  -webkit-overflow-scrolling: touch; }
.v-img { max-width: 100%; height: auto; border-radius: 6px; background: #fff; }
.v-page { width: 100%; max-width: 900px; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 4px 24px rgba(0,0,0,.5); min-height: 200px; }
.v-pno { font-size: 11px; color: var(--muted); letter-spacing: .1em; margin-bottom: 14px; }
.v-note { color: var(--muted); font-size: 14px; padding: 30px 10px; text-align: center; }
.v-text { width: 100%; max-width: 900px; margin: 0; white-space: pre-wrap; word-wrap: break-word; font: 13px/1.5 ui-monospace, Consolas, monospace; }
.v-media { width: 100%; max-width: 900px; }
.md { width: 100%; max-width: 760px; font-size: 15px; line-height: 1.6; align-self: center; }
.md h2, .md h3, .md h4, .md h5 { color: var(--gold); font-weight: 500; margin: 1.2em 0 .4em; }
.md h2 { font-size: 22px; } .md h3 { font-size: 18px; } .md h4, .md h5 { font-size: 16px; }
.md p { margin: .5em 0; } .md ul, .md ol { margin: .4em 0; padding-left: 1.4em; }
.md code { font: 13px ui-monospace, Consolas, monospace; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 4px; }
.md pre { white-space: pre-wrap; background: rgba(0,0,0,.35); padding: 10px; border-radius: 8px; font: 13px/1.45 ui-monospace, Consolas, monospace; }
.md strong { color: #fff; }
.md-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 14px; }
@media (max-width: 860px) {
  .overlay { padding: 0; }
  .ov-box, .files-box { width: 100%; height: 100%; border-radius: 0; border: 0; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
  .viewer-body { padding: 10px; }
  .ov-btn { padding: 6px 9px; }
}
.approval { align-self: stretch; border: 1px solid var(--gold-soft); border-radius: 12px; padding: 10px 12px; background: rgba(255,150,30,.08); font-size: 13px; }
.approval .ttl { color: var(--gold); font-size: 11px; letter-spacing: .2em; margin-bottom: 6px; }
.approval pre { white-space: pre-wrap; word-wrap: break-word; margin: 6px 0; font: 12px/1.4 ui-monospace, Consolas, monospace; color: var(--text); max-height: 180px; overflow: auto; }
.approval .row { display: flex; gap: 8px; margin-top: 8px; }
.approval button { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(0,0,0,.3); cursor: pointer; }
.approval button.yes { border-color: rgba(125,255,178,.5); color: var(--ok); }
.approval button.no { border-color: rgba(255,90,74,.5); color: var(--danger); }
.approval.done { opacity: .55; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 15px; outline: none; }
.chat-input input:focus { border-color: var(--gold-soft); }

/* ---------- Controls ---------- */
.controls { position: fixed; z-index: 7; left: 50%; transform: translateX(-50%); bottom: calc(26px + var(--safe-b));
  display: flex; align-items: center; gap: 22px; }
#chat-toggle { display: none; }
.ctrl-side { width: 48px; height: 48px; }
#mute .off { display: none; } #mute.muted .on { display: none; } #mute.muted .off { display: block; }
.talk { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 26px 0 8px; height: 64px;
  border-radius: 999px; border: 1px solid var(--gold-soft); cursor: pointer;
  background: linear-gradient(180deg, rgba(255,160,40,.20), rgba(255,110,20,.08)); backdrop-filter: blur(10px);
  box-shadow: 0 0 24px rgba(255,140,30,.35), inset 0 0 18px rgba(255,170,60,.15); transition: .25s; }
.talk:hover { box-shadow: 0 0 36px rgba(255,140,30,.55), inset 0 0 18px rgba(255,170,60,.25); }
.talk-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, #ffd27a, #ff9a2a 60%, #c25a00); box-shadow: 0 0 18px rgba(255,160,40,.9); }
.talk-icon svg { width: 22px; height: 22px; fill: none; stroke: #1a0d00; stroke-width: 2; stroke-linecap: round; }
.talk-icon .stop { display: none; fill: #1a0d00; stroke: none; }
.talk-text { font-size: 14px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); white-space: nowrap; }
.talk-ring { position: absolute; left: 8px; top: 8px; width: 48px; height: 48px; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(255,160,40,.6); }
.talk.active { border-color: rgba(255,90,74,.6); background: linear-gradient(180deg, rgba(255,90,40,.22), rgba(255,60,20,.08)); }
.talk.active .mic { display: none; } .talk.active .stop { display: block; }
.talk.active .talk-icon { background: radial-gradient(circle, #ffb18a, #ff5a2a 60%, #a02800); }
.talk.active .talk-ring { animation: ring 1.6s ease-out infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(255,120,40,.6); } 100% { box-shadow: 0 0 0 22px rgba(255,120,40,0); } }

.toast { position: fixed; z-index: 20; left: 50%; top: calc(80px + var(--safe-t)); transform: translateX(-50%);
  background: rgba(40,10,5,.85); border: 1px solid rgba(255,90,74,.5); color: #ffd6cf; padding: 10px 16px;
  border-radius: 10px; font-size: 13px; max-width: 90vw; }

@media (min-width: 861px) and (max-width: 1400px) {
  .stage { padding-right: 360px; }
  .core-wrap { width: min(78vmin, calc(100vw - 420px), 720px); height: min(78vmin, calc(100vw - 420px), 720px); }
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .core-wrap { width: min(94vw, 62vh); height: min(94vw, 62vh); margin-top: -8vh; }
  .hud-top { padding: calc(14px + var(--safe-t)) 16px 0; }
  .brand-title { font-size: 15px; letter-spacing: .4em; }
  .clock { display: none; }
  #chat-toggle { display: grid; }
  #chat-close { display: grid; }
  .chat { left: 10px; right: 10px; width: auto; top: auto; bottom: calc(108px + var(--safe-b)); transform: translateY(120%);
    height: 56vh; opacity: 0; pointer-events: none; transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .25s; }
  .chat.open { transform: none; opacity: 1; pointer-events: auto; }
  .controls { gap: 14px; }
  .talk { height: 60px; padding-right: 20px; }
  .talk-text { font-size: 12px; letter-spacing: .12em; }
}
@media (max-width: 380px) { .talk-text { display: none; } .talk { padding: 0 8px; } }
