:root {
  --bg: #07070f;
  --bg-2: #0e0e1c;
  --panel: #12122a;
  --panel-2: #191936;
  --line: #2a2a52;
  --text: #ecebff;
  --muted: #8c8ab8;
  --cyan: #00e5ff;
  --magenta: #ff2bd6;
  --lime: #b6ff3b;
  --amber: #ffb547;
  --violet: #9d7bff;
  --red: #ff4d6d;
  --radius: 14px;
  --glow-cyan: 0 0 0 1px rgba(0, 229, 255, .35), 0 0 18px rgba(0, 229, 255, .25);
  --glow-magenta: 0 0 0 1px rgba(255, 43, 214, .4), 0 0 18px rgba(255, 43, 214, .25);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(157, 123, 255, .14), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(0, 229, 255, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); margin: 0; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #1b1050, #0a2a44); border-color: rgba(0, 229, 255, .6); box-shadow: var(--glow-cyan); }
.btn.danger { color: var(--red); border-color: rgba(255, 77, 109, .4); background: transparent; }
.btn.danger:hover { box-shadow: 0 0 14px rgba(255, 77, 109, .35); border-color: var(--red); }
.btn.icon { padding: 8px 12px; font-size: 18px; line-height: 1; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
label > input, label > select, label > textarea { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 400; }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--glow-magenta);
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; }
.logo { font-size: 38px; filter: drop-shadow(0 0 12px rgba(255, 220, 80, .6)); }

/* ---------- Topbar ---------- */
#app { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: rgba(7, 7, 15, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  margin: 0; font-size: 20px; letter-spacing: .02em;
  background: linear-gradient(90deg, var(--cyan), var(--magenta)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-sm { font-size: 22px; filter: drop-shadow(0 0 8px rgba(255, 220, 80, .6)); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.sync { color: var(--lime); border-color: rgba(182, 255, 59, .5); box-shadow: 0 0 10px rgba(182, 255, 59, .2); }
.badge.local { color: var(--amber); border-color: rgba(255, 181, 71, .5); }

.stats { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.stat {
  display: flex; align-items: baseline; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.stat b { font-size: 16px; color: var(--text); }
.stat.open b { color: var(--cyan); }
.stat.doing b { color: var(--magenta); }
.stat.done b { color: var(--lime); }

.actions { display: flex; gap: 8px; align-items: center; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 250px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6), var(--glow-magenta);
}
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  font: inherit; padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.menu button:hover { background: var(--panel-2); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; padding: 12px 20px 0; }
.filters input { flex: 2; }
.filters select { flex: 1; max-width: 200px; }

/* ---------- Board ---------- */
.board {
  flex: 1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr);
  gap: 14px; padding: 16px 20px calc(24px + var(--safe-bottom)); overflow-x: auto; align-items: start;
}
.column {
  background: linear-gradient(180deg, rgba(18, 18, 42, .9), rgba(14, 14, 28, .7));
  border: 1px solid var(--line); border-radius: var(--radius); min-height: 200px;
  display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s;
}
.column.drop { border-color: var(--col); box-shadow: 0 0 0 1px var(--col), 0 0 22px color-mix(in srgb, var(--col) 35%, transparent); }
.column-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase;
}
.column-head .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--col); box-shadow: 0 0 10px var(--col); }
.column-head .count { margin-left: auto; color: var(--muted); font-weight: 600; }
.column-head .add { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 2px; line-height: 1; }
.column-head .add:hover { color: var(--col); }
.cards { display: grid; gap: 10px; padding: 12px; }

.card {
  position: relative; padding: 12px 12px 10px 14px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); overflow: hidden;
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--col); box-shadow: 0 0 10px var(--col); }
.card:hover { border-color: color-mix(in srgb, var(--col) 60%, var(--line)); box-shadow: 0 0 18px color-mix(in srgb, var(--col) 22%, transparent); }
.card.dragging { opacity: .45; }
.card h4 { margin: 0 0 6px; font-size: 15px; line-height: 1.3; padding-right: 18px; }
.card .prio { position: absolute; right: 10px; top: 13px; width: 9px; height: 9px; border-radius: 50%; }
.prio.p1 { background: var(--red); box-shadow: 0 0 8px var(--red); }
.prio.p2 { background: var(--amber); }
.prio.p3 { background: #5c5a85; }
.card .next { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.card .next::before { content: "→ "; color: var(--col); }
.card .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.chip { padding: 2px 8px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-weight: 600; }
.progress { flex: 1; min-width: 60px; display: flex; align-items: center; gap: 6px; }
.bar { flex: 1; height: 4px; border-radius: 4px; background: var(--bg-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--col); box-shadow: 0 0 8px var(--col); }
.card .move { display: none; gap: 4px; margin-top: 8px; }
.card .move button {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 6px; font: inherit; font-size: 12px; cursor: pointer;
}
.card .move button:hover { color: var(--text); border-color: var(--col); }
.card .move button[disabled] { visibility: hidden; }

.empty-hint { text-align: center; color: var(--muted); padding: 0 24px 40px; }

/* ---------- Editor ---------- */
.editor {
  width: min(680px, calc(100% - 24px)); max-height: calc(100% - 40px); padding: 0;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, .7), var(--glow-cyan);
}
.editor::backdrop { background: rgba(3, 3, 10, .7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.editor form { display: grid; gap: 16px; padding: 18px 20px 20px; }
.editor-head { display: flex; gap: 10px; align-items: center; }
.title-input { font-size: 20px; font-weight: 700; background: transparent; border-color: transparent; padding-left: 4px; }
.title-input:focus { background: var(--bg-2); }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.block { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.block h3 { margin: 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.row { display: flex; gap: 8px; }
.subtasks, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.subtasks li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--bg-2); }
.subtasks li input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--lime); flex: none; }
.subtasks li span { flex: 1; }
.subtasks li.done span { color: var(--muted); text-decoration: line-through; }
.subtasks li button, .log li button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.subtasks li button:hover, .log li button:hover { color: var(--red); }
.log li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; font-size: 13.5px; padding: 6px 8px; border-left: 2px solid var(--violet); }
.log li time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.editor-foot { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.editor-foot .muted { flex: 1; font-size: 12px; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--panel-2); border: 1px solid var(--cyan); box-shadow: var(--glow-cyan);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; text-align: center; max-width: calc(100% - 32px); width: max-content;
}

/* ---------- Mobil ---------- */
.tabs { display: none; }

@media (max-width: 760px) {
  .topbar { padding: calc(10px + var(--safe-top)) 14px 10px; gap: 10px; flex-wrap: wrap; }
  .brand h1 { font-size: 18px; }
  .stats { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 6px; }
  .stat { padding: 4px 9px; font-size: 12px; }
  .actions { margin-left: auto; }
  #btn-new { padding: 7px 14px; font-size: 20px; line-height: 1; }
  #btn-new .lbl { display: none; }
  .filters { padding: 10px 14px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters input { grid-column: 1 / -1; }
  .filters select { max-width: none; }

  .tabs {
    display: flex; gap: 6px; padding: 12px 14px 0; overflow-x: auto; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: none; display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  }
  .tab .n { font-size: 12px; padding: 0 6px; border-radius: 999px; background: var(--bg-2); }
  .tab.active { color: var(--text); border-color: var(--col); box-shadow: 0 0 0 1px var(--col), 0 0 14px color-mix(in srgb, var(--col) 35%, transparent); }
  .tab.active .n { color: var(--col); }

  .board { display: block; padding: 12px 14px calc(24px + var(--safe-bottom)); }
  .column { display: none; min-height: 120px; }
  body[data-tab="idee"] .column[data-status="idee"],
  body[data-tab="geplant"] .column[data-status="geplant"],
  body[data-tab="in_arbeit"] .column[data-status="in_arbeit"],
  body[data-tab="fertig"] .column[data-status="fertig"],
  body[data-tab="pausiert"] .column[data-status="pausiert"] { display: flex; }
  .card .move { display: flex; }
  .grid { grid-template-columns: 1fr 1fr; }
  .grid label:first-child { grid-column: 1 / -1; }
  .editor { width: 100%; max-width: 100%; max-height: 92%; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .editor form { padding-bottom: calc(20px + var(--safe-bottom)); }
}
@media (hover: none) { .card .move { display: flex; } }
