/* Pixelboard-Editor — bewusst einfarbig dunkel (LED-Konsole/Arcade-Look). */
:root {
  --bg:        #0a0b0f;
  --bg-2:      #12141b;
  --bg-3:      #1a1d27;
  --line:      #262b38;
  --ink:       #e7ecf5;
  --ink-soft:  #8b93a7;
  --phos:      #00ffcc;   /* Phosphor-Cyan (Akzent) */
  --phos-dim:  #0b3b34;
  --amber:     #ffb300;
  --danger:    #ff5470;
  --radius:    10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* muss display:flex der Panels überstimmen */
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; overflow: hidden;
}
.mono { font-family: var(--mono); }

/* ---- topbar ---- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1rem;
  background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto; flex-wrap: wrap;
}
.brand {
  font-family: var(--mono); font-weight: 700; letter-spacing: .18em; font-size: 1.05rem;
  display: flex; align-items: center; gap: .55rem;
}
.brand .accent { color: var(--phos); }
.brand .dot {
  width: 11px; height: 11px; border-radius: 50%; background: var(--phos);
  box-shadow: 0 0 10px var(--phos), 0 0 3px var(--phos);
}
.top-controls { display: flex; align-items: center; gap: 1.4rem; margin-left: auto; flex-wrap: wrap; }
.ctl { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--ink-soft); }
.ctl.toggle { gap: .35rem; cursor: pointer; }
select, input[type="number"], input[type="text"] {
  font: inherit; background: var(--bg-3); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: .4rem .55rem;
}
input[type="number"] { width: 66px; }
select:focus-visible, input:focus-visible { outline: 2px solid var(--phos); outline-offset: 1px; border-color: var(--phos); }
input[type="range"] { accent-color: var(--phos); }
.custom-dims { display: flex; align-items: center; gap: .4rem; color: var(--ink-soft); font-size: .85rem; }

/* ---- workspace ---- */
.workspace { flex: 1 1 auto; display: grid; grid-template-columns: 68px 1fr 320px; min-height: 0; }

/* ---- tools ---- */
.tools {
  background: var(--bg-2); border-right: 1px solid var(--line); padding: .8rem .6rem;
  display: flex; flex-direction: column; gap: 1.1rem; align-items: center;
}
.tool-group { display: flex; flex-direction: column; gap: .4rem; width: 100%; }
.tool {
  width: 100%; aspect-ratio: 1; border: 1px solid var(--line); background: var(--bg-3);
  color: var(--ink); border-radius: 8px; font-size: 1.15rem; cursor: pointer;
  display: grid; place-items: center;
}
.tool:hover { border-color: var(--phos); }
.tool.on { border-color: var(--phos); background: var(--phos-dim); box-shadow: inset 0 0 0 1px var(--phos); }
.color-block { display: flex; flex-direction: column; gap: .5rem; align-items: center; width: 100%; }
input[type="color"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 34px;
  border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; padding: 2px;
}
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: 100%; }
.sw { aspect-ratio: 1; border-radius: 5px; cursor: pointer; border: 1px solid rgba(255,255,255,.12); }
.sw:hover { transform: scale(1.08); }
.tool-actions { margin-top: auto; width: 100%; }

/* ---- stage ---- */
.stage { min-width: 0; display: flex; flex-direction: column; background:
  radial-gradient(1200px 500px at 50% -10%, #101219 0%, var(--bg) 70%); }
.canvas-scroll { flex: 1 1 auto; overflow: auto; display: grid; place-items: center; padding: 1.4rem; }
#grid { image-rendering: pixelated; background: #000; border-radius: 4px;
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px -30px #000; cursor: crosshair; }
.stage-foot {
  flex: 0 0 auto; display: flex; justify-content: space-between; padding: .45rem 1rem;
  border-top: 1px solid var(--line); background: var(--bg-2); color: var(--ink-soft); font-size: .8rem;
}

/* ---- side ---- */
.side { background: var(--bg-2); border-left: 1px solid var(--line); padding: 1rem;
  display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; }
.tabs { display: flex; gap: .4rem; background: var(--bg-3); padding: 4px; border-radius: 10px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--ink-soft); font: inherit;
  font-weight: 700; padding: .5rem; border-radius: 7px; cursor: pointer; }
.mode-tabs { flex: 0 0 auto; }
.mode-tabs .tab { flex: 0 0 auto; padding: .4rem .9rem; }
.tab.on { background: var(--phos-dim); color: var(--phos); box-shadow: inset 0 0 0 1px var(--phos); }
.hint { font-size: .78rem; color: var(--ink-soft); line-height: 1.5; margin: .3rem 0 0; }
.fld { display: flex; flex-direction: column; gap: .35rem; font-size: .8rem; color: var(--ink-soft); }
.fld input, .fld select { color: var(--ink); }
.fld-row { display: flex; gap: .6rem; }
.fld-row .fld { flex: 1; }
.panel-text { display: flex; flex-direction: column; gap: .7rem; }

/* ---- seiten / playlist ---- */
.pl-list .li-name { flex: 1; }
.pl-dur { width: 3.4rem; text-align: center; font-size: .8rem; padding: .25rem; }
.panel-playlist { display: flex; flex-direction: column; gap: .7rem; }

/* ---- klappbare gruppen ---- */
.grp { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); }
.grp > summary { cursor: pointer; padding: .55rem .7rem; font-weight: 700; font-size: .82rem;
  list-style: none; display: flex; align-items: center; gap: .5rem; user-select: none; color: var(--ink); }
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::before { content: "▸"; color: var(--phos); font-size: .7rem; }
.grp[open] > summary::before { content: "▾"; }
.grp > summary:hover { color: var(--phos); }
.grp-body { display: flex; flex-direction: column; gap: .6rem; padding: 0 .7rem .7rem; }

/* ---- objekt-composer ---- */
.compose-only { display: none; }
.panel-compose { display: flex; flex-direction: column; gap: .7rem; }
#objProps { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.obj-actions { display: flex; gap: .4rem; }
.obj-actions .btn { flex: 1; }
.stage.compose #grid { cursor: default; }

/* ---- LED preview ---- */
.preview-block { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.preview-head { padding: .45rem .7rem; background: var(--bg-3); color: var(--ink-soft);
  font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; }
.preview-frame { background: #000; padding: 10px; display: grid; place-items: center; }
#preview { image-rendering: auto; max-width: 100%; border-radius: 4px; }

/* ---- save + library ---- */
.save-block { display: flex; flex-direction: column; gap: .7rem; margin-top: auto; }
.save-row { display: flex; gap: .5rem; }
.save-row input { flex: 1; }
.lib-head { display: flex; align-items: center; justify-content: space-between;
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.library { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px;
  max-height: 30vh; overflow-y: auto; }
.library li { display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; }
.library li.empty { justify-content: center; color: var(--ink-soft); border-style: dashed; }
.library .li-name { flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library .li-kind { font-family: var(--mono); font-size: .65rem; color: var(--phos);
  border: 1px solid var(--phos-dim); border-radius: 999px; padding: .05rem .4rem; }
.library .li-del { border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; }
.library .li-del:hover { color: var(--danger); }

/* ---- buttons ---- */
.btn { font: inherit; font-weight: 700; cursor: pointer; border-radius: 8px; padding: .55rem .9rem;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink); }
.btn:hover { border-color: var(--phos); }
.btn-sm { padding: .25rem .5rem; font-size: .8rem; }
.btn-icon { padding: .4rem .55rem; min-width: 2.1rem; line-height: 1; text-align: center; flex: 0 0 auto; }
.save-row .btn-icon { align-self: stretch; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--bg-3); }
.btn-primary { background: var(--phos); color: #04231e; border-color: var(--phos);
  box-shadow: 0 0 16px -4px var(--phos); }
.btn-primary:hover { filter: brightness(1.08); }

/* ---- toast ---- */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-3); border: 1px solid var(--phos); color: var(--ink);
  padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- login ---- */
.login-body { display: block; overflow: auto; }
#ledbg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; }
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: min(360px, 92vw); background: rgba(10, 12, 18, 0.74); backdrop-filter: blur(9px);
  border: 1px solid var(--phos); border-radius: 16px; padding: 2rem 1.6rem;
  box-shadow: 0 0 44px -12px var(--phos), 0 30px 70px -30px #000;
  display: flex; flex-direction: column; gap: 1rem;
}
.login-logo { font-family: var(--mono); font-weight: 700; letter-spacing: .18em; font-size: 1.4rem;
  display: flex; align-items: center; gap: .6rem; justify-content: center; }
.login-logo .accent { color: var(--phos); }
.login-logo .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--phos);
  box-shadow: 0 0 12px var(--phos), 0 0 4px var(--phos); }
.login-sub { text-align: center; color: var(--ink-soft); font-family: var(--mono); font-size: .7rem;
  letter-spacing: .22em; text-transform: uppercase; margin: -.5rem 0 .3rem; }
.login-card .fld { gap: .4rem; }
.login-card input { padding: .7rem .8rem; font-size: 1rem; }
.login-card .btn-block { margin-top: .3rem; justify-content: center; }
.login-error { background: rgba(255, 84, 112, 0.14); border: 1px solid var(--danger);
  color: #ffd3da; padding: .55rem .7rem; border-radius: 8px; font-size: .85rem; text-align: center; }

/* ---- vollbild-simulator ---- */
.sim-overlay { position: fixed; inset: 0; z-index: 100; background:
  radial-gradient(1200px 700px at 50% 40%, #0b0c10 0%, #050506 70%);
  display: grid; place-items: center; }
.sim-overlay[hidden] { display: none; }
#simCanvas { width: 100%; height: 100%; display: block; }
.sim-bar { position: fixed; top: 1rem; right: 1rem; z-index: 101;
  display: flex; align-items: center; gap: 1rem; }
.sim-bar .mono { color: var(--ink-soft); font-size: .8rem; }

/* ---- text-steuerung (phase 2/3) ---- */
.range-row { display: flex; align-items: center; gap: .6rem; }
.range-row input[type="range"] { flex: 1; }
.range-row .val { font-family: var(--mono); font-size: .8rem; color: var(--phos); min-width: 4.5ch; text-align: right; }
.logout-form { margin: 0; }
textarea { font: inherit; background: var(--bg-3); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; resize: vertical; min-height: 2.4rem; width: 100%; }
textarea:focus-visible { outline: 2px solid var(--phos); outline-offset: 1px; border-color: var(--phos); }
.fld-note { font-size: .62rem; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }
.markup-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: -.2rem; }
.mb-label { font-size: .62rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .1em; }
.mb-swatches { display: flex; gap: 3px; }
.mb-sw { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255,255,255,.15); cursor: pointer; padding: 0; }
.mb-sw:hover { transform: scale(1.12); border-color: var(--phos); }
.mb-size { font: inherit; font-size: .72rem; font-weight: 700; padding: .12rem .4rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--ink); cursor: pointer; }
.mb-size:hover { border-color: var(--phos); }
.panel-draw input[type="file"] { font-size: .82rem; color: var(--ink-soft); }
code { font-family: var(--mono); font-size: .85em; color: var(--phos); background: var(--bg-3);
  padding: .05rem .3rem; border-radius: 4px; }

/* ---- galerie / url (phase 3) ---- */
.url-row { display: flex; gap: .4rem; }
.url-row input { flex: 1; min-width: 0; }
.gallery-block { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: .5rem; }
.gthumb { width: 100%; aspect-ratio: 1; image-rendering: pixelated; background: #000;
  border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.gthumb:hover { border-color: var(--phos); transform: scale(1.06); }

/* ---- variablen (phase 3) ---- */
.vars { margin-top: 1rem; display: flex; flex-direction: column; gap: .55rem;
  border-top: 1px solid var(--line); padding-top: .9rem; }
.var-list { display: flex; flex-direction: column; gap: .4rem; }
.var-row { display: flex; gap: .4rem; align-items: center; }
.var-row input { flex: 1; min-width: 0; font-size: .85rem; padding: .4rem .5rem; }
.var-row .var-key { flex: 0 0 40%; color: var(--phos); font-family: var(--mono); }
.var-row .var-del { border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; }
.var-row .var-del:hover { color: var(--danger); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 56px 1fr; }
  .side { display: none; }
}
