/* AeternumX Chat: dunkle, ruhige Oberflaeche mit Aurora-Hintergrund, Glas-Flaechen und einem lebendigen Orb. */
:root {
  --bg: #07080d; --fg: #eceef6; --muted: #9aa1b7; --faint: #6b7189;
  --glass: rgba(20, 22, 34, .62); --glass-strong: rgba(26, 29, 44, .82);
  --line: rgba(255, 255, 255, .09); --line-strong: rgba(255, 255, 255, .16);
  --a1: #7c5cff; --a2: #00d4ff; --a3: #ff8a5c;
  --grad: linear-gradient(135deg, var(--a1), var(--a2) 55%, var(--a3));
  --user: rgba(124, 92, 255, .16); --user-line: rgba(124, 92, 255, .35);
  --code: rgba(0, 0, 0, .38); --danger: #ff6b7a; --ok: #3ddc97;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
  --r: 18px; --side-w: 288px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}
[data-theme="light"] {
  --bg: #f4f5fb; --fg: #151827; --muted: #5a617a; --faint: #8a90a8;
  --glass: rgba(255, 255, 255, .7); --glass-strong: rgba(255, 255, 255, .92);
  --line: rgba(20, 24, 50, .1); --line-strong: rgba(20, 24, 50, .18);
  --user: rgba(124, 92, 255, .1); --user-line: rgba(124, 92, 255, .3);
  --code: rgba(20, 24, 50, .06); --shadow: 0 20px 50px rgba(40, 50, 110, .16);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--a2); outline-offset: 2px; border-radius: 8px; }
kbd { font-family: var(--font); font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: auto; }
.glass { background: var(--glass); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4); border: 1px solid var(--line); }

/* Hintergrund: statisch (kein Animieren grosser Flaechen, schont Browser und Akku) */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(60vmax 50vmax at 8% -10%, rgba(124, 92, 255, .38), transparent 70%),
    radial-gradient(50vmax 45vmax at 105% 28%, rgba(0, 212, 255, .2), transparent 70%),
    radial-gradient(46vmax 40vmax at 40% 112%, rgba(255, 138, 92, .18), transparent 70%),
    var(--bg); }
[data-theme="light"] .bg {
  background:
    radial-gradient(60vmax 50vmax at 8% -10%, rgba(124, 92, 255, .2), transparent 70%),
    radial-gradient(50vmax 45vmax at 105% 28%, rgba(0, 212, 255, .16), transparent 70%),
    radial-gradient(46vmax 40vmax at 40% 112%, rgba(255, 138, 92, .12), transparent 70%),
    var(--bg); }
.blob, .grain { display: none; }

/* Orb */
.orb { position: relative; display: inline-block; border-radius: 50%; flex: none; isolation: isolate; }
.orb::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, var(--a1), var(--a2), var(--a3), var(--a1)); animation: spin 7s linear infinite; z-index: -1; }
.orb::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), rgba(7,8,13,.92) 62%); }
.orb-sm { width: 22px; height: 22px; } .orb-lg { width: 64px; height: 64px; box-shadow: 0 0 50px rgba(124, 92, 255, .55); }
.orb-xl { width: 96px; height: 96px; box-shadow: 0 0 80px rgba(0, 212, 255, .35), 0 0 120px rgba(124, 92, 255, .35); animation: breathe 5s ease-in-out infinite; }
.orb.live::before { animation-duration: 1.6s; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.06); } }

/* Buttons */
.btn { border: 1px solid var(--line-strong); background: var(--glass); border-radius: 14px; padding: 11px 16px; font-weight: 600; transition: transform .15s, background .2s, border-color .2s; }
.btn:hover { border-color: var(--a1); transform: translateY(-1px); }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 10px 30px rgba(124, 92, 255, .35); }
.btn.primary:hover { filter: brightness(1.08); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.icon-btn:hover { background: var(--glass); border-color: var(--line); color: var(--fg); }

/* Anmeldung */
.auth { position: relative; z-index: 1; min-height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; }
.auth-card { width: min(420px, 100%); border-radius: 28px; padding: 36px 32px 28px; text-align: center; box-shadow: var(--shadow); animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
.brand { margin: 18px 0 4px; font-size: 28px; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 0 0 22px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--code); margin-bottom: 18px; }
.tab { border: 0; background: transparent; padding: 9px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--glass-strong); color: var(--fg); box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
.form { display: grid; gap: 14px; text-align: left; }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--code); font-size: 16px; }
.form input:focus { outline: none; border-color: var(--a2); box-shadow: 0 0 0 3px rgba(0, 212, 255, .18); }
.hint { font-weight: 400; color: var(--faint); font-size: 12px; } .center { text-align: center; margin: 0; }
.auth-msg { min-height: 22px; margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.auth-msg.err { color: var(--danger); } .auth-msg.ok { color: var(--ok); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* Layout */
.app { position: relative; z-index: 1; height: 100%; display: grid; grid-template-columns: var(--side-w) 1fr; }
.side { display: flex; flex-direction: column; gap: 12px; padding: 14px; margin: 12px 0 12px 12px; border-radius: 24px; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.new { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.plus { font-size: 20px; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.convs { flex: 1; overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.grp { margin: 14px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); font-weight: 700; }
.conv { position: relative; display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 9px 10px; border-radius: 12px; color: var(--muted); }
.conv span.t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.conv:hover { background: var(--glass); color: var(--fg); }
.conv.active { background: var(--glass-strong); border-color: var(--line-strong); color: var(--fg); }
.conv.active::before { content: ""; position: absolute; left: -7px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--grad); }
.conv .acts { display: none; gap: 2px; }
.conv:hover .acts, .conv:focus-within .acts { display: flex; }
.acts button { width: 26px; height: 26px; border: 0; border-radius: 8px; background: transparent; color: var(--faint); font-size: 14px; }
.acts button:hover { background: var(--line); color: var(--fg); }
.empty { padding: 18px 10px; color: var(--faint); font-size: 14px; }
.side-foot { position: relative; border-top: 1px solid var(--line); padding-top: 12px; }
.user { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px; border-radius: 14px; text-align: left; }
.user:hover { background: var(--glass); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--grad); flex: none; }
.uinfo { display: grid; min-width: 0; } .uinfo b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .uinfo small { color: var(--faint); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--a3); margin-left: auto; box-shadow: 0 0 10px var(--a3); }
.menu { position: absolute; left: 0; right: 0; bottom: 64px; border-radius: 16px; padding: 6px; z-index: 5; box-shadow: var(--shadow); background: var(--glass-strong); animation: rise .18s ease-out both; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; }
.menu button:hover { background: var(--line); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.top { display: flex; align-items: center; gap: 8px; padding: 12px 20px 4px; }
.top-title { flex: 1; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model { appearance: none; -webkit-appearance: none; background: var(--glass-strong) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239aa1b7' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center; color: var(--fg); color-scheme: dark; border: 1px solid var(--line-strong); border-radius: 12px; padding: 7px 32px 7px 12px; max-width: 230px; font-size: 13px; }
[data-theme="light"] .model { color-scheme: light; }
.model option { background: #14161f; color: #eceef6; }
[data-theme="light"] .model option { background: #fff; color: #151827; }
.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 8px 20px 24px; }
.thread, .welcome { max-width: 780px; margin: 0 auto; }

/* Willkommen */
.welcome { display: grid; justify-items: center; text-align: center; padding-top: min(14vh, 120px); }
.greet { margin: 26px 0 6px; font-size: clamp(30px, 5vw, 46px); letter-spacing: -.03em; line-height: 1.25; padding-bottom: .08em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome .sub { font-size: 18px; margin-bottom: 34px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; }
.card { text-align: left; border: 1px solid var(--line); background: var(--glass); border-radius: var(--r); padding: 16px 18px; transition: transform .2s, border-color .2s, background .2s; animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
.card:nth-child(2) { animation-delay: .07s; } .card:nth-child(3) { animation-delay: .14s; } .card:nth-child(4) { animation-delay: .21s; }
.card:hover { transform: translateY(-3px); border-color: var(--a1); background: var(--glass-strong); }
.card b { display: block; margin-bottom: 3px; } .card span { color: var(--muted); font-size: 14px; }

/* Nachrichten */
.thread { display: grid; gap: 26px; padding-top: 10px; }
.msg { display: flex; gap: 14px; animation: rise .35s ease-out both; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 82%; padding: 11px 16px; border-radius: 20px 20px 6px 20px; background: var(--user); border: 1px solid var(--user-line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ai .orb { margin-top: 4px; }
.body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tools { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity .2s; }
.msg.ai:hover .tools, .msg.ai:focus-within .tools { opacity: 1; }
.tool { border: 0; background: transparent; color: var(--faint); font-size: 13px; padding: 4px 9px; border-radius: 8px; }
.tool:hover { background: var(--glass); color: var(--fg); }
.err-note { color: var(--danger); font-size: 14px; margin-top: 8px; }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--grad); animation: bounce 1.1s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-5px); opacity: 1; } }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--a2); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; } .md ul, .md ol { margin: 0 0 .85em; padding-left: 1.4em; } .md li { margin: .2em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 .5em; line-height: 1.25; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md a { color: var(--a2); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.md blockquote { margin: 0 0 .85em; padding: 2px 14px; border-left: 3px solid var(--a1); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line-strong); margin: 1.2em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code); padding: .15em .4em; border-radius: 6px; }
.code { margin: 0 0 1em; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--code); }
.code-h { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 12px; font-family: var(--mono); }
.code pre { margin: 0; padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
.code pre code { background: none; padding: 0; font-size: inherit; }
.tbl { overflow-x: auto; margin: 0 0 1em; } .md table { border-collapse: collapse; width: 100%; font-size: .94em; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 7px 11px; text-align: left; } .md th { background: var(--code); }

/* Eingabe */
.composer-wrap { position: relative; padding: 0 20px 14px; }
.composer { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 20px; border-radius: 28px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: transparent; box-shadow: var(--shadow), 0 0 0 1.5px var(--a1), 0 0 40px rgba(124, 92, 255, .25); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; padding: 8px 0; max-height: 220px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--grad); color: #fff; flex: none; transition: transform .15s, opacity .2s, filter .2s; box-shadow: 0 6px 20px rgba(124, 92, 255, .4); }
.send:hover:not(:disabled) { transform: scale(1.07); }
.send:disabled { opacity: .3; box-shadow: none; cursor: default; }
.send.stop { background: var(--glass-strong); color: var(--fg); border: 1px solid var(--line-strong); box-shadow: none; }
.fine { max-width: 780px; margin: 8px auto 0; text-align: center; color: var(--faint); font-size: 12px; }
.jump { position: absolute; left: 50%; top: -46px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--glass-strong); color: var(--fg); display: grid; place-items: center; box-shadow: var(--shadow); }

/* Admin + Hinweise */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(3, 4, 8, .6); backdrop-filter: blur(6px); }
.modal-card { width: min(720px, 100%); max-height: 84vh; overflow: auto; border-radius: 24px; padding: 20px 22px; background: var(--glass-strong); box-shadow: var(--shadow); animation: rise .25s ease-out both; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; } .modal-head h3 { margin: 0; }
.urow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--line); }
.urow:first-child { border-top: 0; } .urow small { color: var(--faint); display: block; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 6px; background: var(--line); color: var(--muted); }
.badge.pending { background: rgba(255, 138, 92, .2); color: var(--a3); } .badge.active { background: rgba(61, 220, 151, .16); color: var(--ok); } .badge.rejected { background: rgba(255, 107, 122, .16); color: var(--danger); }
.uact { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.uact button { border: 1px solid var(--line-strong); background: var(--glass); border-radius: 10px; padding: 6px 11px; font-size: 13px; }
.uact button:hover { border-color: var(--a1); } .uact button.ok { border-color: var(--ok); color: var(--ok); } .uact button.no { color: var(--danger); }
.uact input { width: 86px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--code); }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 30; padding: 10px 18px; border-radius: 99px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 14px; animation: rise .25s ease-out both; max-width: 90vw; }
.scrim { position: fixed; inset: 0; z-index: 9; background: rgba(3, 4, 8, .55); }
.only-mobile { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 10; left: 0; top: 0; bottom: 0; width: min(86vw, 330px); margin: 8px; transform: translateX(-110%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); background: var(--glass-strong); }
  .side.open { transform: none; }
  .only-mobile { display: grid; }
  .cards { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .tools { opacity: 1; }
  .conv .acts { display: flex; }
  .welcome { padding-top: 6vh; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* iPhone/Handy: dynamische Hoehe (Adressleiste), Notch/Home-Balken, 16px gegen Auto-Zoom, grosse Tippflaechen */
@supports (height: 100dvh) { body, .app { height: 100dvh; } }
.composer-wrap { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
@media (max-width: 860px) {
  .top { padding: calc(10px + env(safe-area-inset-top)) 12px 4px; }
  .scroll { padding: 8px 14px 20px; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .side { padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .icon-btn { width: 44px; height: 44px; }
  .model, .form input, .composer textarea { font-size: 16px; }
  .greet { font-size: clamp(28px, 9vw, 40px); }
  .orb-xl { width: 76px; height: 76px; }
  .welcome .sub { font-size: 16px; margin-bottom: 24px; }
  .fine { font-size: 11px; }
  .msg { gap: 10px; }
  .code pre { font-size: 12.5px; }
  .modal { padding: 10px; }
  .urow { grid-template-columns: 1fr; }
  .uact { justify-content: flex-start; }
}
