/* VexoClient - Bauplan-Galerie (3D-Ansicht, Entdecken, Profile) */
:root {
  --bg: #0b0914; --bg2: #110e1f; --card: rgba(255,255,255,.045); --card2: rgba(255,255,255,.075);
  --line: rgba(255,255,255,.09); --line2: rgba(255,255,255,.16); --text: #f4f2ff; --soft: #cfc9ea; --muted: #9089b3;
  --accent: #7c5cff; --accent2: #4f8eff; --accent-soft: rgba(124,92,255,.16); --gold: #ffc83d; --green: #4ade80;
  --red: #f87171; --radius: 16px;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.bg-fx { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(40% 35% at 20% 10%, rgba(124,92,255,.22), transparent 70%),
              radial-gradient(35% 30% at 85% 20%, rgba(79,142,255,.14), transparent 70%); }

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; height: 60px; padding: 0 22px;
  background: rgba(var(--glass),.78); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 7px 12px; border-radius: 10px; color: var(--soft); }
.top nav a:hover, .top nav a.on { background: var(--card2); color: var(--text); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 14px; }
.who img { width: 26px; height: 26px; border-radius: 7px; image-rendering: pixelated; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--card);
  padding: 8px 13px; border-radius: 11px; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--card2); }
.btn.accent { background: var(--accent); border-color: transparent; }
.btn.accent:hover { background: #8c70ff; }
.btn.liked span { color: #ff5d8f; }
.btn.wide { width: 100%; justify-content: center; margin-top: 10px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; cursor: pointer; color: var(--soft); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.small button { padding: 4px 8px; font-size: 13px; }
input[type=search] { background: rgba(0,0,0,.25); border: 1px solid var(--line2); border-radius: 11px; padding: 9px 12px;
  outline: none; min-width: 0; }
input[type=search]:focus { border-color: var(--accent); }

/* Liste */
#list-view { max-width: 1240px; margin: 0 auto; padding: 34px 22px 60px; }
.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.list-head h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -.4px; display: flex; align-items: center; gap: 12px; }
.list-head h1 img { width: 40px; height: 40px; border-radius: 10px; image-rendering: pixelated; }
.list-head p { margin: 0; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; }
.tools input { width: 260px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform .15s, border-color .15s; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-3px); border-color: rgba(124,92,255,.55); }
.card .thumb { aspect-ratio: 16/10; background: linear-gradient(135deg, #1a1530, #0f0c1c); display: grid; place-items: center;
  overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.card .thumb .ph { font-size: 42px; opacity: .35; }
.card .body { padding: 12px 14px 14px; }
.card h3 { margin: 0 0 3px; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { display: flex; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: #c9bbff; font-weight: 600; }
.badge.priv { background: rgba(255,255,255,.08); color: var(--soft); }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* 3D-Ansicht */
#view { display: grid; grid-template-columns: 1fr 340px; height: calc(100vh - 60px); }
.stage { position: relative; overflow: hidden; }
#gl { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#gl.drag { cursor: grabbing; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--soft);
  background: rgba(var(--glass),.6); }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--accent);
  animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.hud-top { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; gap: 12px;
  pointer-events: none; flex-wrap: wrap; }
.hud-top > * { pointer-events: auto; }
.title-card { background: rgba(var(--glass),.72); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; max-width: 520px; }
.title-card h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.title-card .by { color: var(--muted); font-size: 13px; }
.title-card .by a { color: #c9bbff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-self: flex-start; }
.actions .btn { background: rgba(var(--glass),.72); backdrop-filter: blur(10px); }
.actions .btn.accent { background: var(--accent); }
.hud-left { position: absolute; left: 16px; top: 100px; display: flex; flex-direction: column; gap: 10px; width: 232px; }
#views button { padding: 4px 6px; }
.panel { background: rgba(var(--glass),.72); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.panel .row { display: flex; justify-content: space-between; }
.panel input[type=range] { width: 100%; accent-color: var(--accent); }
.chk { display: flex; gap: 8px; align-items: center; color: var(--soft); cursor: pointer; }
.chk input { accent-color: var(--accent); }
.help { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 12px;
  background: rgba(var(--glass),.6); padding: 5px 12px; border-radius: 99px; white-space: nowrap; }
.tip { position: absolute; pointer-events: none; background: rgba(var(--glass),.9); border: 1px solid var(--line2); border-radius: 9px;
  padding: 5px 9px; font-size: 13px; white-space: nowrap; transform: translate(14px, 14px); }
.tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.side { border-left: 1px solid var(--line); background: rgba(var(--glass),.55); padding: 18px; overflow-y: auto; display: flex;
  flex-direction: column; gap: 12px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; }
.fact b { display: block; font-size: 17px; }
.fact span { color: var(--muted); font-size: 12px; }
.desc { margin: 0; color: var(--soft); white-space: pre-wrap; }
.desc:empty { display: none; }
.mat-head { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.mats { display: flex; flex-direction: column; gap: 3px; }
.mat { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 9px; cursor: pointer; }
.mat:hover, .mat.on { background: var(--card2); }
.mat i { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.mat span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mat b { font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1d1833; border: 1px solid var(--line2);
  padding: 10px 16px; border-radius: 12px; z-index: 50; box-shadow: 0 10px 40px rgba(0,0,0,.5); }

body.light .stage { background: #dfe6f0; }
body.embed .top, body.embed .side, body.embed .hud-left, body.embed #act-embed { display: none !important; }
body.embed #view { grid-template-columns: 1fr; height: 100vh; }

@media (max-width: 900px) {
  #view { grid-template-columns: 1fr; height: auto; }
  /* Handy: Titel oben, 3D-Ansicht frei (keine Felder darueber), Bedienfelder darunter */
  .stage { height: auto; overflow: visible; display: flex; flex-direction: column; }
  .hud-top { position: static; order: 0; padding: 12px 16px 8px; }
  #gl { order: 1; height: 62vh; }
  .hud-left { position: static; order: 2; width: auto; max-height: none; overflow: visible; padding: 12px 16px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .help { display: none; }
  .tools input { width: 100%; }
  .who .muted { display: none; }
  .top { gap: 12px; padding: 0 14px; }
}

/* Testmodus */
#diff input { width: 100%; background: var(--card); color: var(--text, #fff); border: 1px solid var(--line2);
  border-radius: 9px; padding: 6px 8px; font: inherit; font-size: 13px; box-sizing: border-box; }
#sim select, .sim-add select, .sim-add input { width: 100%; background: var(--card); color: var(--text, #fff); border: 1px solid var(--line2);
  border-radius: 9px; padding: 6px 8px; margin-top: 8px; font: inherit; font-size: 13px; }
.sim-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sim-row .btn { flex: 1 1 80px; min-width: 0; justify-content: center; padding: 5px 8px; font-size: 13px; white-space: nowrap; }
.panel .seg { display: flex; flex-wrap: wrap; }
.panel .seg button { flex: 1 1 auto; min-width: 0; }
.sim-note { display: block; font-size: 11.5px; margin-top: 6px; line-height: 1.35; }
.sim-dialog { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 50; width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.sim-items { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.sim-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; }
.sim-item .btn { padding: 2px 8px; }
.sim-add { display: grid; grid-template-columns: 1fr 70px auto; gap: 6px; align-items: end; }
.sim-add .btn { margin-top: 8px; }
#sim-mode { display: flex; }
#sim-mode button { flex: 1; padding: 4px 4px; }
.real-tex { display: flex; gap: 6px; margin-top: 8px; }
.real-tex .btn { flex: 1; justify-content: center; padding: 5px 8px; font-size: 13px; }
.real-tex #real-clear { flex: 0 0 auto; }
.live-track { height: 6px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 8px; }
.live-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #3ddc84); transition: width .4s; }
.hud-left { max-height: calc(100% - 150px); overflow-y: auto; scrollbar-width: thin; }

/* Gemeinsam ansehen */
.cursors { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cursor { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 3px rgba(0,0,0,.35), 0 0 12px var(--c); transition: left .25s, top .25s; }
.cursor span { position: absolute; left: 14px; top: -6px; white-space: nowrap; font-size: 12px; padding: 2px 7px; border-radius: 8px;
  background: var(--c); color: #111; font-weight: 600; }
.viewers { position: absolute; right: 16px; bottom: 44px; background: rgba(var(--glass),.72); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 12.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: 60%; }
.viewers .vw { padding: 2px 8px; border-radius: 8px; background: color-mix(in srgb, var(--c) 30%, transparent); border: 1px solid var(--c); }
@media (max-width: 900px) { .viewers { position: static; order: 3; margin: 0 16px; max-width: none; } }

/* Aufwands-Rechner */
.cost { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); display: grid; gap: 4px; font-size: 13px; }
.cost-row { display: flex; justify-content: space-between; gap: 8px; }
.cost-row span { color: var(--muted, #a9a3c2); }
.cost-row.warn b { color: #ffb347; }
#sim-time select { padding: 4px 6px; }

/* Kommentare an Bloecken */
.notes { margin-top: 14px; display: grid; gap: 6px; }
.note { position: relative; padding: 8px 30px 8px 10px; border-radius: 10px; background: rgba(255,255,255,.04); cursor: pointer; font-size: 13px; }
.note p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.note .btn { position: absolute; right: 4px; top: 4px; padding: 2px 8px; }
#note-add.on { outline: 2px solid var(--accent, #8b5cf6); }
.pin { position: absolute; width: 20px; height: 20px; margin: -20px 0 0 -10px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: #ffcf4a; color: #222; font: 700 11px/20px system-ui; text-align: center; pointer-events: auto; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.cursors { pointer-events: none; }
#sim-dialog textarea { width: 100%; box-sizing: border-box; margin: 8px 0; border-radius: 8px; padding: 8px; background: rgba(0,0,0,.25); color: inherit; border: 1px solid rgba(255,255,255,.12); }

/* ---- Hell/Dunkel: data-theme="light" am <html> (Schalter oben, gemerkt im Browser) */
:root { --glass: 11, 9, 20; }
html[data-theme="light"] {
  --bg: #f6f4fc; --bg2: #ffffff; --card: rgba(40, 24, 110, 0.045); --card2: rgba(40, 24, 110, 0.08);
  --line: rgba(40, 24, 110, 0.11); --line2: rgba(40, 24, 110, 0.2); --text: #1a1430; --soft: #3d355e; --muted: #6a6390;
  --accent-soft: rgba(124, 92, 255, 0.12); --shadow: 0 16px 44px rgba(40, 20, 90, 0.12); --glass: 246, 244, 252;
  --gold: #b7860b; --green: #15803d; --red: #dc2626; --orange: #c2410c; color-scheme: light;
}
html[data-theme="light"] .bg-fx { opacity: .45; }
html[data-theme="light"] img.pixel, html[data-theme="light"] canvas { color-scheme: dark; }
.theme-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--card); color: var(--text); cursor: pointer; font-size: 17px; line-height: 1; padding: 0; }
.theme-btn:hover { background: var(--card2); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
