@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --teal: #15897B;
  --teal-dark: #117063;
  --teal-soft: #E4F1EF;
  --text: #37393C;
  --muted: #8F9092;
  --bg: #F4F8FA;
  --border: #E1E5E8;
  --danger: #B4443C;
  --radius: 10px;
  --shadow: 0 3px 10px rgba(0,0,0,.10);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Poppins, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); }

/* ---------------- Startseite ---------------- */
.home { max-width: 900px; margin: 0 auto; padding: 56px 24px 80px; }
.home header { display: flex; align-items: center; gap: 16px; margin-bottom: 44px; }
.home header img { height: 34px; width: auto; }
.home header .divider { width: 1px; height: 28px; background: var(--border); }
.home header span { font-size: 15px; font-weight: 500; }
.home header .who { margin-left: auto; font-size: 13px; color: var(--muted); }
.home h1 { font-size: 30px; font-weight: 600; margin: 0 0 6px; }
.home .lede { font-size: 15px; color: var(--muted); margin: 0 0 32px; line-height: 1.6; }
.new-row { display: flex; gap: 10px; margin-bottom: 40px; flex-wrap: wrap; }
.new-row input {
  flex: 1; min-width: 240px; font-family: inherit; font-size: 14px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: var(--text);
}
.new-row input:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }
.board-list { display: grid; gap: 10px; }
.board-card {
  display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px;
}
.board-card:hover { border-color: var(--teal); box-shadow: var(--shadow); }
.board-card strong { font-size: 15px; font-weight: 600; }
.board-card .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.board-card .when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { padding: 40px 0; color: var(--muted); font-size: 14px; }

/* ---------------- Board ---------------- */
body.board-page { display: grid; grid-template-rows: auto 1fr; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; background: #fff;
  border-bottom: 1px solid var(--border); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 30px; width: auto; display: block; }
.brand .divider { width: 1px; height: 26px; background: var(--border); }
.brand .meta { min-width: 0; }
.brand .meta strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.brand .meta span { display: block; font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }

.people { display: flex; align-items: center; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #fff;
  border: 2px solid #fff; margin-left: -8px;
}
.avatar:first-child { margin-left: 0; }
.avatar.me { box-shadow: 0 0 0 2px var(--teal); }

.main { display: grid; grid-template-columns: 232px 1fr; min-height: 0; }

.rail { background: #fff; border-right: 1px solid var(--border); padding: 18px 14px; overflow-y: auto; }
.rail h2 {
  font-size: 11px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 12px 6px;
}
.step {
  display: flex; gap: 11px; align-items: flex-start; width: 100%;
  text-align: left; background: none; border: 0;
  padding: 9px 10px; border-radius: var(--radius); color: var(--text); margin-bottom: 2px;
}
.step:hover { background: var(--bg); }
.step[aria-current="true"] { background: var(--teal-soft); }
.step .num {
  flex: none; width: 21px; height: 21px; border-radius: 50%;
  background: var(--bg); color: var(--muted);
  font-size: 11px; font-weight: 600; display: grid; place-items: center; margin-top: 1px;
}
.step[aria-current="true"] .num { background: var(--teal); color: #fff; }
.step > span:last-child { display: block; min-width: 0; }
.step .label { display: block; font-size: 13px; font-weight: 500; line-height: 1.35; }
.step .hint { display: block; font-size: 11px; color: var(--muted); line-height: 1.4; margin-top: 3px; }
.rail .tip {
  margin-top: 18px; padding: 12px; background: var(--bg);
  border-radius: var(--radius); font-size: 11.5px; color: var(--muted); line-height: 1.55;
}

.stage {
  position: relative; overflow: hidden; background-color: var(--bg);
  /* Das Punktraster liegt auf der Buehne, nicht auf dem Board. Dadurch hat die
     Flaeche keine sichtbare Kante mehr — Groesse und Lage setzt applyView(). */
  background-image: radial-gradient(circle, #DDE4E8 1px, transparent 1px);
}
.stage.panning { cursor: grabbing; }
.stage.spacebar, .stage.spacebar .zone { cursor: grab; }

#board {
  /* Bewusst ohne Breite und Hoehe: reiner Transform-Container. Absolut
     positionierte Kinder duerfen beliebig weit darueber hinausragen. */
  position: absolute; top: 0; left: 0; width: 0; height: 0;
  transform-origin: 0 0; overflow: visible;
}
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer > * { pointer-events: auto; }

.zone {
  position: absolute; border: 1px solid var(--border);
  background: rgba(255,255,255,.72); border-radius: 14px; cursor: grab;
}
.zone.moving { cursor: grabbing; box-shadow: 0 14px 30px rgba(0,0,0,.13); }
.zone.accent { background: rgba(21,137,123,.055); border-color: rgba(21,137,123,.3); }
.zone .zone-head { position: absolute; top: 14px; left: 20px; right: 108px; }
.zone [data-zfield] {
  outline: none; border-radius: 5px; padding: 1px 4px; margin-left: -4px;
  overflow-wrap: anywhere; cursor: text;
}
.zone [data-zfield]:hover { background: rgba(0,0,0,.035); }
.zone [data-zfield]:focus { background: #fff; box-shadow: 0 0 0 2px var(--teal); }
.zone .zone-title { font-size: 17px; font-weight: 600; }
.zone .zone-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.zone [data-zfield]:empty::before { content: attr(data-placeholder); color: rgba(55,57,60,.35); }

.zone-tools {
  position: absolute; top: 14px; right: 14px; display: flex; gap: 4px;
  opacity: .4; transition: opacity .15s;
  transform: scale(var(--inv, 1)); transform-origin: top right;
}
.zone:hover .zone-tools, .zone-tools:focus-within { opacity: 1; }
.zone-tools button {
  height: 26px; min-width: 26px; padding: 0 6px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 7px; font-size: 12px; line-height: 1; display: grid; place-items: center;
}
.zone-tools button:hover { color: var(--text); border-color: var(--muted); }
.zone-tools button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.zone-tools button.wide { width: auto; padding: 0 10px; font-size: 11.5px; font-weight: 500; color: var(--danger); border-color: #E7B5B1; }
.zone-grip { cursor: grab; color: var(--text); }
.zone-grip svg { display: block; }
.zone-grip:hover { background: var(--teal); border-color: var(--teal); color: #fff; }
.zone-grip:active { cursor: grabbing; }
/* Alle Anfasser rechnen den Zoom heraus, damit sie bei 20 % genauso
   greifbar bleiben wie bei 100 %. --inv wird in applyView() gesetzt. */
.zone-resize {
  position: absolute; right: 0; bottom: 0;
  width: calc(24px * var(--inv, 1)); height: calc(24px * var(--inv, 1));
  cursor: nwse-resize; opacity: 0;
  background: linear-gradient(135deg, transparent 46%, var(--teal) 46%, var(--teal) 62%, transparent 62%);
}
.zone-edge {
  position: absolute; opacity: 0; background: var(--teal);
  border-radius: calc(3px * var(--inv, 1));
}
.zone-edge.r {
  top: 12%; height: 76%; right: calc(-5px * var(--inv, 1));
  width: calc(6px * var(--inv, 1)); cursor: ew-resize;
}
.zone-edge.b {
  left: 12%; width: 76%; bottom: calc(-5px * var(--inv, 1));
  height: calc(6px * var(--inv, 1)); cursor: ns-resize;
}
.zone:hover .zone-resize { opacity: .75; }
.zone:hover .zone-edge { opacity: .35; }
.zone-edge:hover, .zone-resize:hover { opacity: 1 !important; }
.zone-add {
  position: absolute; bottom: 14px; left: 20px;
  border: 1px dashed #C4CFD4; background: transparent; color: var(--muted);
  border-radius: var(--radius); padding: 7px 13px; font-size: 12.5px; font-weight: 500;
}
.zone-add:hover { border-color: var(--teal); color: var(--teal); }

.axis { position: absolute; pointer-events: none; }
.axis .line { position: absolute; left: 0; right: 0; top: 8px; height: 2px; background: linear-gradient(90deg, #C9D6DB, var(--teal)); }
.axis .head { position: absolute; right: -1px; top: 2px; width: 0; height: 0; border-left: 12px solid var(--teal); border-top: 7px solid transparent; border-bottom: 7px solid transparent; }
.axis .tick { position: absolute; top: 0; width: 2px; height: 18px; background: #C9D6DB; }
.axis .cap { position: absolute; top: 26px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.axis .cap.end { color: var(--teal); }

.card {
  position: absolute; width: 208px; min-height: 96px;
  border-radius: var(--radius); padding: 13px 13px 26px;
  box-shadow: var(--shadow); cursor: grab;
  font-size: 13.5px; line-height: 1.45; border: 1px solid rgba(0,0,0,.06);
}
.card.dragging { cursor: grabbing; box-shadow: 0 12px 26px rgba(0,0,0,.19); z-index: 50; }
.card.selected { outline: 2px solid var(--teal); outline-offset: 2px; }
.card .text { outline: none; min-height: 40px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card .text:empty::before { content: attr(data-placeholder); color: rgba(55,57,60,.4); }
.card .who { position: absolute; left: 13px; bottom: 8px; font-size: 10.5px; color: rgba(55,57,60,.5); font-weight: 500; }
.card .tools { position: absolute; top: 6px; right: 6px; display: none; gap: 3px; }
.card:hover .tools, .card.selected .tools { display: flex; }
.card .tools button {
  width: 21px; height: 21px; border: 0; border-radius: 6px;
  background: rgba(255,255,255,.75); color: var(--text);
  font-size: 11px; line-height: 1; display: grid; place-items: center;
}
.card .tools button:hover { background: #fff; }
.vote {
  position: absolute; right: 8px; bottom: 6px;
  display: flex; align-items: center; gap: 5px;
  border: 0; border-radius: 20px; padding: 3px 9px;
  background: rgba(255,255,255,.8); font-size: 11.5px; font-weight: 600;
  font-family: inherit; color: var(--text);
}
.vote:hover { background: #fff; }
.vote .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.vote[data-voted="true"] { background: var(--teal); color: #fff; }
.vote[data-voted="true"] .dot { background: #fff; }

.zoomer {
  position: absolute; right: 18px; bottom: 18px; z-index: 15;
  display: flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; box-shadow: var(--shadow);
}
.zoomer button { border: 0; background: none; width: 30px; height: 30px; border-radius: 7px; font-size: 15px; color: var(--text); }
.zoomer button:hover { background: var(--bg); }
.zoomer .pct { font-size: 12px; color: var(--muted); width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 400px;
  background: #fff; border-left: 1px solid var(--border);
  z-index: 30; overflow-y: auto; padding: 22px 24px 40px;
  transform: translateX(100%); transition: transform .25s ease;
}
.drawer.open { transform: none; }
.drawer h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.drawer .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 22px; }
.drawer .close { position: absolute; top: 18px; right: 18px; border: 0; background: none; font-size: 17px; color: var(--muted); }
.res-group { margin-bottom: 22px; }
.res-group h3 { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.res-item { display: flex; gap: 9px; font-size: 13.5px; line-height: 1.5; padding: 6px 0; border-bottom: 1px solid var(--border); }
.res-item .bar { flex: none; width: 3px; border-radius: 2px; background: var(--teal); }
.res-item .n { flex: none; font-size: 11.5px; font-weight: 600; color: var(--teal); padding-top: 2px; }
.res-empty { font-size: 12.5px; color: var(--muted); font-style: italic; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 13px;
  padding: 10px 18px; border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.bad { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .drawer, .toast { transition: none; }
  #board { transition: none !important; }
}
