:root {
  --bg: #14161a;
  --panel: #1c1f25;
  --panel2: #252932;
  --line: #2f343e;
  --text: #e8e6e1;
  --muted: #9aa0aa;
  --accent: #d97757;
  --accent2: #f0a585;
  --danger: #e5534b;
  --ok: #57ab5a;
  --user: #2b3240;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#top { display: flex; align-items: center; gap: 4px; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; border-bottom: 1px solid var(--line); background: var(--bg); }
#title { flex: 1; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
.icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon:active { background: var(--panel2); }
.toggle.on { color: var(--accent); background: rgba(217,119,87,.12); }
.toggle:not(.on) .wave { opacity: .25; }

#view { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

/* Listen */
.list { padding: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; background: var(--panel); margin-bottom: 8px; width: 100%; text-align: left; }
.item:active { background: var(--panel2); }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .ttl { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; flex: none; }
@keyframes pulse { 50% { opacity: .3; } }
.newbtn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 12px; border: 1px dashed var(--accent); color: var(--accent2); margin-bottom: 12px; font-weight: 600; }
.section { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 16px 6px 8px; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

/* Login */
.login { padding: 60px 24px; display: flex; flex-direction: column; gap: 14px; max-width: 380px; margin: 0 auto; }
.login h1 { font-size: 22px; margin: 0 0 10px; }
input[type=password], input[type=text] { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; width: 100%; }
.btn { background: var(--accent); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; }
.btn.secondary { background: var(--panel2); color: var(--text); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Chat */
.chat { padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); padding: 9px 13px; border-radius: 16px 16px 4px 16px; max-width: 88%; white-space: pre-wrap; }
.msg.user .img { color: var(--muted); font-size: 13px; }
.msg.assistant { padding: 2px 2px; }
.msg.assistant p { margin: 0 0 .6em; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 16px; margin: .8em 0 .3em; }
.msg.assistant ul, .msg.assistant ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.msg.assistant a { color: var(--accent2); }
.msg code { font: 13.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
.msg pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; margin: .4em 0 .7em; }
.msg pre code { background: none; padding: 0; white-space: pre; }
.msg table { border-collapse: collapse; font-size: 14px; margin: .4em 0 .7em; display: block; overflow-x: auto; }
.msg td, .msg th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.msg th { background: var(--panel); }
.tools { color: var(--muted); font-size: 13px; }
.tools summary { cursor: pointer; list-style: none; padding: 4px 8px; border-radius: 8px; background: var(--panel); display: inline-block; }
.tools summary::-webkit-details-marker { display: none; }
.tools .t { padding: 3px 8px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools .t.err { color: var(--danger); }
.speak-btn { color: var(--muted); font-size: 13px; padding: 2px 0; display: inline-flex; align-items: center; gap: 4px; }
.speak-btn svg { width: 16px; height: 16px; }
.more { align-self: center; color: var(--accent2); font-size: 14px; padding: 6px 12px; }
.live { opacity: .9; }
.live::after { content: "▍"; color: var(--accent); animation: pulse 1s infinite; }

/* Eingabe */
#composer { border-top: 1px solid var(--line); background: var(--bg); padding: 8px 8px calc(env(safe-area-inset-bottom) + 8px); }
#composer .row { display: flex; align-items: flex-end; gap: 6px; }
#input { flex: 1; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px; resize: none; max-height: 40vh; min-height: 42px; line-height: 1.4; }
#input:focus { outline: none; border-color: var(--accent); }
.icon.big { width: 44px; height: 44px; border-radius: 50%; }
.icon.primary { background: var(--accent); color: #fff; }
.icon.danger { background: var(--danger); color: #fff; }
#mic.rec { background: var(--danger); color: #fff; animation: pulse 1.2s infinite; }
#status { color: var(--muted); font-size: 13px; padding: 0 6px 6px; display: flex; align-items: center; gap: 8px; }
#thumbs { display: flex; gap: 6px; padding: 0 4px 8px; overflow-x: auto; }
#thumbs .th { position: relative; flex: none; }
#thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; display: block; }
#thumbs button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 14px; line-height: 1; }

/* Menü */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--panel); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 10px; }
.sheet h3 { margin: 0 0 4px; font-size: 16px; }
.sheet label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.sheet select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; max-width: 60%; }
.sheet input[type=range] { width: 50%; }
.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--panel2); padding: 10px 16px; border-radius: 10px; z-index: 20; font-size: 14px; max-width: 90%; }
