/* =====================================================================
   Velox – „Schwebende Inseln“: Layout, Dock, Hintergründe, Animationen
   Alle Werte kommen als CSS-Variablen aus dem Design-Studio (studio.js)
   ===================================================================== */
:root {
  --base: #07031a;
  --island: rgba(16, 10, 40, .72);
  --island-solid: #120b2c;
  --island-line: rgba(255, 255, 255, .09);
  --blur: 22px;
  --ri: 22px;
  --gap: 14px;
  --dock-h: 74px;
  --fs: 15px;
  --pad-y: 2px;
  --av-r: 50%;
  --anim: 1;
  --bg-speed: 1;
  --b1: #a855f7; --b2: #ec4899; --b3: #3b82f6;
}
html, body { background: var(--base); font-size: var(--fs); }
body.anim-off *, body.anim-off *::before, body.anim-off *::after { animation: none !important; transition: none !important; }

/* ---------- Hintergrund ---------- */
.bgfx { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--base); pointer-events: none; }
.bgfx > * { position: absolute; inset: 0; }
.bgfx .blob { inset: auto; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(80px); opacity: .55; mix-blend-mode: screen; animation: drift calc(28s / var(--bg-speed)) ease-in-out infinite alternate; }
.bgfx .b1 { background: radial-gradient(circle, var(--b1), transparent 65%); left: -15vmax; top: -20vmax; }
.bgfx .b2 { background: radial-gradient(circle, var(--b2), transparent 65%); right: -20vmax; bottom: -25vmax; animation-duration: calc(34s / var(--bg-speed)); animation-delay: -8s; }
.bgfx .b3 { background: radial-gradient(circle, var(--b3), transparent 65%); left: 30vw; top: 35vh; width: 45vmax; height: 45vmax; opacity: .35; animation-duration: calc(41s / var(--bg-speed)); animation-delay: -15s; }
@keyframes drift { 0% { transform: translate(0, 0) scale(1); } 33% { transform: translate(8vw, 6vh) scale(1.12); } 66% { transform: translate(-6vw, 10vh) scale(.92); } 100% { transform: translate(4vw, -8vh) scale(1.05); } }
.bgfx .bg-grid { display: none; top: 45%; inset-inline: -50%; bottom: -10%; background-image: linear-gradient(var(--b1) 1px, transparent 1px), linear-gradient(90deg, var(--b1) 1px, transparent 1px); background-size: 60px 60px; transform: perspective(500px) rotateX(62deg); opacity: .35; mask-image: linear-gradient(to bottom, transparent, #000 40%); animation: gridmove calc(4s / var(--bg-speed)) linear infinite; }
@keyframes gridmove { to { background-position: 0 60px, 0 0; } }
.bgfx .bg-sun { display: none; inset: auto; left: 50%; top: 18%; width: 34vmin; height: 34vmin; transform: translateX(-50%); border-radius: 50%; background: linear-gradient(var(--b2), var(--b1)); box-shadow: 0 0 120px var(--b2); mask-image: repeating-linear-gradient(to bottom, #000 0 14px, transparent 14px 18px); opacity: .8; }
.bgfx .bg-img { background: var(--bg-image) center / cover no-repeat; filter: blur(var(--bg-blur, 0px)) brightness(var(--bg-dim, .6)); transform: scale(1.06); display: none; }
.bgfx canvas { width: 100%; height: 100%; display: none; }
.bgfx .noise { opacity: .05; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
body[data-bg="grid"] .bg-grid, body[data-bg="grid"] .bg-sun { display: block; }
body[data-bg="grid"] .b3 { display: none; }
body[data-bg="stars"] canvas { display: block; }
body[data-bg="stars"] .blob { opacity: .25; }
body[data-bg="image"] .bg-img { display: block; }
body[data-bg="image"] .blob, body[data-bg="solid"] .blob { display: none; }

/* ---------- Grundgerüst ---------- */
.app { position: fixed; inset: 0; z-index: 1; display: grid; gap: var(--gap); padding: var(--gap); background: transparent;
  grid-template-columns: var(--side) minmax(0, 1fr) 0; grid-template-rows: minmax(0, 1fr) var(--dock-h);
  grid-template-areas: "side main main" "dock dock dock"; }
.app.with-members { grid-template-columns: var(--side) minmax(0, 1fr) var(--members); grid-template-areas: "side main members" "dock dock dock"; }
body.dock-left .app { grid-template-columns: var(--dock-h) var(--side) minmax(0, 1fr) 0; grid-template-rows: minmax(0, 1fr); grid-template-areas: "dock side main main"; }
body.dock-left .app.with-members { grid-template-columns: var(--dock-h) var(--side) minmax(0, 1fr) var(--members); grid-template-areas: "dock side main members"; }
body.desktop .app { top: 34px; }
.island { background: var(--island); border: 1px solid var(--island-line); border-radius: var(--ri); backdrop-filter: blur(var(--blur)) saturate(1.35); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.35); box-shadow: 0 24px 60px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06); overflow: hidden; min-height: 0; }
.side { grid-area: side; border-radius: var(--ri); }
.main { grid-area: main; }
.members { grid-area: members; }
.app:not(.with-members) .members { display: none; }
.side-head { border-radius: 0; }
.main, .app.with-members .main { background: var(--island); border-right: 1px solid var(--island-line); }
.stage { background: transparent; }
.side-head:hover { background: transparent; }

/* Server-Kopf mit Banner */
.ghead { position: relative; flex: none; cursor: pointer; }
.ghead .gbanner { height: 112px; background: var(--gb, linear-gradient(135deg, var(--accent), var(--accent-2))) center / cover; position: relative; }
.ghead .gbanner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, transparent 30%, var(--island-solid)); }
.ghead .gname { position: absolute; left: 16px; right: 12px; bottom: 10px; display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 24px; letter-spacing: .02em; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.ghead .gname span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghead .gtag { position: absolute; left: 16px; top: 12px; font-size: 12px; background: rgba(0,0,0,.45); backdrop-filter: blur(8px); border-radius: 20px; padding: 3px 10px; color: var(--text-2); max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghead.plain .gbanner { height: 64px; }
.ch .cemoji { width: 20px; text-align: center; font-size: 15px; flex: none; }
.ch.colored .name { color: var(--cc); }
.ch .lock { width: 13px; height: 13px; color: var(--faint); }

/* ---------- Dock ---------- */
.dock { grid-area: dock; justify-self: center; align-self: stretch; display: flex; align-items: center; gap: 10px; padding: 8px 10px; max-width: 100%; min-width: 0;
  background: var(--island); border: 1px solid var(--island-line); border-radius: calc(var(--ri) + 6px); backdrop-filter: blur(var(--blur)) saturate(1.4); -webkit-backdrop-filter: blur(var(--blur)) saturate(1.4); box-shadow: 0 18px 50px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.07); }
body.dock-left .dock { flex-direction: column; justify-self: stretch; padding: 10px 8px; }
.dock-servers { display: flex; align-items: center; gap: 8px; overflow-x: auto; overflow-y: visible; scrollbar-width: none; padding: 4px 2px; min-width: 0; }
.dock-servers::-webkit-scrollbar { display: none; }
body.dock-left .dock-servers { flex-direction: column; overflow-x: visible; overflow-y: auto; flex: 1; }
.dock .gi { width: 48px; height: 48px; transition: transform calc(.18s * var(--anim)) cubic-bezier(.3, 1.6, .5, 1), border-radius .2s; transform-origin: bottom center; }
body.dock-left .dock .gi { transform-origin: left center; }
.dock .gi:hover, .dock .gi.active { border-radius: 16px; }
.dock .gi::before { left: 50%; top: auto; bottom: -9px; width: 0; height: 4px; border-radius: 4px; transform: translateX(-50%); transition: width .2s; }
.dock .gi.unread::before { width: 8px; height: 4px; }
.dock .gi:hover::before { width: 16px; height: 4px; }
.dock .gi.active::before { width: 26px; height: 4px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
body.dock-left .dock .gi::before { left: -10px; bottom: auto; top: 50%; width: 4px; height: 0; transform: translateY(-50%); }
body.dock-left .dock .gi.unread::before { width: 4px; height: 8px; }
body.dock-left .dock .gi.active::before { width: 4px; height: 30px; }
.dock .gi .badge { box-shadow: 0 0 0 3px var(--island-solid); }
.dock .rail-sep { width: 2px; height: 30px; margin: 0 2px; }
body.dock-left .dock .rail-sep { width: 30px; height: 2px; margin: 2px 0; }
.dock-sep { width: 1px; align-self: stretch; background: var(--island-line); margin: 4px 2px; flex: none; }
body.dock-left .dock-sep { width: auto; height: 1px; margin: 2px 4px; }
.dock .me-panel { background: none; border: 0; padding: 0; gap: 2px; flex: none; }
body.dock-left .dock .me-panel { flex-direction: column; }
body.dock-left .dock .me-panel .who { display: none; }
.dock .me-panel .me { max-width: 190px; }
.dock .gi.folder .gi-in { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 6px; background: rgba(255,255,255,.07); }

/* Sprachverbindung als Kapsel im Dock */
.vpill { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 16px; background: rgba(0, 255, 136, .08); border: 1px solid rgba(0, 255, 136, .25); flex: none; }
.vpill.wait { background: rgba(255, 182, 39, .08); border-color: rgba(255, 182, 39, .3); }
.vpill .vtxt { line-height: 1.15; min-width: 0; max-width: 160px; cursor: pointer; }
.vpill .vtxt b { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--online); }
.vpill.wait .vtxt b { color: var(--warn); }
.vpill .vtxt small { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vpill .icon-btn { width: 32px; height: 32px; }
.vpill .icon-btn.on { background: var(--accent); color: #fff; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pdot 1.6s infinite; flex: none; }
@keyframes pdot { 0% { box-shadow: 0 0 0 0 rgba(0,255,136,.6); } 70% { box-shadow: 0 0 0 8px rgba(0,255,136,0); } 100% { box-shadow: 0 0 0 0 rgba(0,255,136,0); } }
body.dock-left .vpill { flex-direction: column; padding: 8px 4px; }
body.dock-left .vpill .vtxt { display: none; }

/* ---------- Avatare, Dichte, Schrift ---------- */
.av, .av img { border-radius: var(--av-r); }
.av .st { border-color: var(--island-solid); }
body.density-compact { --pad-y: 0px; }
body.density-compact .msg.head { margin-top: 6px; }
body.density-compact .msg .av { width: 30px; height: 30px; top: 4px; }
body.density-compact .msg { padding-left: 62px; }
body.density-spacious .msg.head { margin-top: 22px; }
body.density-spacious .msg { padding-top: 4px; padding-bottom: 4px; }
.msg { padding-top: var(--pad-y); padding-bottom: var(--pad-y); }

/* ---------- Nachrichten als Sprechblasen ---------- */
body.msg-bubbles .msg { padding-right: 18px; }
body.msg-bubbles .msg .content, body.msg-bubbles .msg .atts, body.msg-bubbles .msg .poll { background: rgba(255,255,255,.06); border-radius: 4px 18px 18px 18px; padding: 8px 13px; display: inline-block; max-width: min(100%, 680px); }
body.msg-bubbles .msg:not(.head) .content { border-radius: 18px; }
body.msg-bubbles .msg.mine { padding-left: 18px; padding-right: 76px; text-align: right; }
body.msg-bubbles .msg.mine .av { left: auto; right: 18px; }
body.msg-bubbles .msg.mine .hdr { justify-content: flex-end; }
body.msg-bubbles .msg.mine .content { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-radius: 18px 4px 18px 18px; text-align: left; }
body.msg-bubbles .msg.mine:not(.head) .content { border-radius: 18px; }
body.msg-bubbles .msg.mine .reacts, body.msg-bubbles .msg.mine .atts { justify-content: flex-end; }
body.msg-bubbles .msg.mine .atts { align-items: flex-end; }
body.msg-bubbles .msg.mine .side-time { left: auto; right: 18px; }
body.msg-bubbles .msg.mine .reply-ref { justify-content: flex-end; }
body.msg-bubbles .msg.mine .reply-ref::before { display: none; }
body.msg-bubbles .msg.mine .content .mention { background: rgba(255,255,255,.25); color: #fff; }
body.msg-bubbles .msg .atts { background: none; padding: 0; }
body.msg-cards .msg.head { margin: 12px 14px 0; border-radius: 16px 16px 0 0; background: rgba(255,255,255,.035); padding-top: 10px; }
body.msg-cards .msg:not(.head) { margin: 0 14px; background: rgba(255,255,255,.035); }

/* ---------- Animationen ---------- */
body.anim-full .msg.new { animation: msgIn .38s cubic-bezier(.2, 1.3, .4, 1); }
body.anim-subtle .msg.new { animation: msgFade .25s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes msgFade { from { opacity: 0; } to { opacity: 1; } }
body:not(.anim-off) .island { transition: border-radius .3s, background .4s, box-shadow .3s; }
body.anim-full .main > *:not(.top) { animation: viewIn .32s cubic-bezier(.2, 1, .4, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
body.anim-full .react.pop { animation: reactPop .45s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes reactPop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
body.anim-full .gi.joined { animation: joinBounce .7s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes joinBounce { 0% { transform: scale(.2) rotate(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
body.anim-full .ch, body.anim-full .mem { transition: background .12s, color .12s, transform .15s; }
body.anim-full .ch:hover, body.anim-full .mem:hover { transform: translateX(3px); }
.ripple { position: fixed; z-index: 500; width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--online); pointer-events: none; animation: ripple .8s ease-out forwards; }
@keyframes ripple { to { transform: scale(12); opacity: 0; } }

/* ---------- Kleinigkeiten ---------- */
.msg.blocked-msg .content { color: var(--faint); font-style: italic; }
.msg.keyword { background: rgba(0, 255, 136, .06); }
.msg.keyword::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--online); }
.msg .bm-on { color: var(--warn); }
.poll { margin: 6px 0 2px; padding: 12px 14px; border-radius: 14px; background: rgba(0,0,0,.25); border: 1px solid var(--line); max-width: 520px; }
.poll b.q { display: block; font-size: 16px; margin-bottom: 8px; }
.poll .opt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: rgba(255,255,255,.05); border: 1px solid transparent; overflow: hidden; }
.poll .opt:hover { border-color: var(--line-2); }
.poll .opt.mine { border-color: var(--accent); }
.poll .opt .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--accent-soft), rgba(236,72,153,.18)); transition: width .5s cubic-bezier(.2,1,.4,1); }
.poll .opt span { position: relative; flex: 1; }
.poll .opt small { position: relative; color: var(--text-2); font-weight: 700; }
.poll .meta { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { height: 32px; padding: 0 12px; border-radius: 9px; color: var(--text-2); font-weight: 600; }
.tabs button:hover { background: var(--hover); color: var(--text); }
.tabs button.on { background: var(--active); color: #fff; }
.tabs button.green { background: var(--online); color: #00140a; }
.friends { flex: 1; overflow-y: auto; padding: 18px 22px; }
.friend { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; border-top: 1px solid var(--line); cursor: pointer; }
.friend:hover { background: var(--hover); border-top-color: transparent; }
.friend .grow { flex: 1; min-width: 0; }
.friend .grow b { display: block; }
.friend .grow small { color: var(--muted); font-size: 13px; }
.friend .acts { display: flex; gap: 6px; }
.friend .acts .icon-btn { background: rgba(255,255,255,.06); border-radius: 50%; width: 38px; height: 38px; }
.dmrow .badge { box-shadow: none; }
.dmrow .x { display: none; }
.dmrow:hover .x { display: inline-grid; }
.studio-prev { border-radius: 18px; overflow: hidden; height: 150px; position: relative; border: 1px solid var(--line-2); margin-bottom: 18px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.preset { border-radius: 14px; height: 78px; position: relative; overflow: hidden; border: 2px solid transparent; text-align: left; padding: 8px 10px; display: flex; align-items: flex-end; font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.7); background: var(--pv); }
.preset.sel { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.preset:hover { transform: translateY(-2px); }
.seg { display: inline-flex; background: rgba(0,0,0,.3); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { height: 32px; padding: 0 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: var(--accent); color: #fff; }
.css-edit { font-family: var(--mono); font-size: 13px; min-height: 180px; }
.call-toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.call-toast .btn { height: 34px; }
.tri { display: inline-flex; border-radius: 9px; overflow: hidden; border: 1px solid var(--line-2); }
.tri button { width: 34px; height: 30px; color: var(--muted); font-weight: 800; }
.tri button.on[data-v="-1"] { background: var(--danger); color: #fff; }
.tri button.on[data-v="0"] { background: rgba(255,255,255,.12); color: #fff; }
.tri button.on[data-v="1"] { background: var(--online); color: #00140a; }

/* Desktop-App: eigene Titelleiste */
.titlebar { display: none; position: fixed; top: 0; left: 0; right: 0; height: 34px; z-index: 50; -webkit-app-region: drag; align-items: center; padding-left: 14px; font-family: var(--display); letter-spacing: .08em; font-size: 15px; color: var(--text-2); }
body.desktop .titlebar { display: flex; }
.titlebar .grow { flex: 1; }
.titlebar .upd { -webkit-app-region: no-drag; font-family: var(--font); letter-spacing: 0; font-size: 12px; font-weight: 700; color: #00140a; background: var(--online); border-radius: 20px; padding: 3px 10px; margin-right: 10px; cursor: pointer; }
.titlebar .wbtn { -webkit-app-region: no-drag; width: 46px; height: 34px; display: grid; place-items: center; color: var(--text-2); }
.titlebar .wbtn:hover { background: rgba(255,255,255,.08); color: #fff; }
.titlebar .wbtn.close:hover { background: #e81123; }
body.solo .side, body.solo .dock, body.solo .members { display: none !important; }
body.solo .app { grid-template-columns: 1fr !important; grid-template-rows: 1fr !important; grid-template-areas: "main" !important; }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  .app, .app.with-members, body.dock-left .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 64px; grid-template-areas: "main" "dock"; gap: 8px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .side { position: fixed; left: 8px; top: 8px; bottom: 80px; width: min(86vw, 340px); z-index: 50; transform: translateX(-110%); transition: transform .25s cubic-bezier(.2,1,.4,1); }
  .app.nav-open .side { transform: none; }
  .members { position: fixed; right: 8px; top: 8px; bottom: 80px; width: min(86vw, 300px) !important; }
  .dock, body.dock-left .dock { flex-direction: row; justify-self: stretch; padding: 6px; border-radius: 20px; }
  body.dock-left .dock-servers { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .dock .gi { width: 44px; height: 44px; }
  .dock .me-panel .who, .dock #deafBtn { display: none; }
  .vpill .vtxt { display: none; }
  .rail { position: static; transform: none; width: auto; }
}
.toasts { top: calc(var(--gap) + 10px); bottom: auto; } body.desktop .toasts { top: 48px; } @keyframes up { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
/* Sprechblasen: jede Blase eigene Zeile, eigene rechtsbündig */
body.msg-bubbles .msg .content, body.msg-bubbles .msg .poll, body.msg-bubbles .msg .atts { display: block; width: fit-content; }
body.msg-bubbles .msg.mine .content, body.msg-bubbles .msg.mine .poll, body.msg-bubbles .msg.mine .atts, body.msg-bubbles .msg.mine .reacts { margin-left: auto; }
body.msg-bubbles .msg .atts { margin-top: 4px; }
body.msg-bubbles .msg.mine .content blockquote { color: rgba(255,255,255,.85); border-left-color: rgba(255,255,255,.45); }
body.msg-bubbles .msg.mine .content pre, body.msg-bubbles .msg.mine .content code { background: rgba(0,0,0,.25); }
/* Einstellungen und Karten auf Glas */
.settings { background: var(--island-solid); }
.settings nav { background: rgba(0, 0, 0, .22); }
.card, .gcard, .changelog, .acc-head { background: rgba(255, 255, 255, .035); }
.profile { background: var(--island-solid); }
.modal { background: var(--island-solid); }
input[type=color] { -webkit-appearance: none; appearance: none; width: 46px; height: 32px; border: 1px solid var(--line-2); border-radius: 9px; padding: 3px; background: rgba(0,0,0,.3); cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
input[type=color]::-moz-color-swatch { border: 0; border-radius: 6px; }
