:root {
  /* ---- palette ---- */
  --bg:         #262626;  /* 15% white */
  --panel:      #2f2f2f;  /* slightly lighter */
  --panel-alt:  #363636;
  --line:       #3d3d3d;
  --hover:      #383838;
  --text:       #e6e6e6;  /* 90% white — main text & accent */
  --muted:      #737373;
  --accent:     #e6e6e6;  /* 90% white */
  --accent-soft:#333333;

  /* ---- priority colors (colorful for dark bg) ---- */
  --p0: #4a4a4a;
  --p1: #3d8fd4;
  --p2: #cc8020;
  --p3: #c0392b;

  /* ---- status colors ---- */
  --s0: #585858;
  --s1: #3d8fd4;
  --s2: #27ae60;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Space Grotesk", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #e05555; min-height: 18px; font-size: 13px; }
button { font: inherit; cursor: pointer; }
a { color: var(--text); text-decoration: underline; }
::selection { background: #555; color: var(--text); }

/* ---- Auth ---- */
.auth-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5.6px 5.6px 14px 5.6px;
  padding: 28px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.auth-card h1 { margin: 0; font-size: 28px; }
.auth-card p  { margin: 0 0 6px; }
.auth-card input {
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3.6px 3.6px 9px 3.6px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.auth-card input::placeholder { color: var(--muted); }
.auth-card input:focus { border-color: var(--accent); }
.auth-card button[type=submit] {
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  padding: 11px;
  border-radius: 3.6px 3.6px 9px 3.6px;
  font-weight: 700;
  letter-spacing: .02em;
}
.auth-card button[type=submit]:hover { background: #f0f0f0; }
.switch { font-size: 13px; text-align: center; color: var(--muted); }

/* ---- App layout ---- */
.app-view { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 700; color: var(--text); }
.spacer { flex: 1; }
.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3.2px 3.2px 8px 3.2px;
  padding: 6px 9px;
  font-size: 17px;
  line-height: 1;
  color: var(--text);
}
.icon-btn:hover { background: var(--hover); }
#sidebar-toggle { display: none; }

.view-tabs { display: flex; gap: 4px; margin-left: 6px; }
.tab {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 3.2px 3.2px 8px 3.2px;
  color: var(--muted);
}
.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 230px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.project-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.project-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 3.2px 3.2px 8px 3.2px;
  cursor: pointer;
}
.project-list li:hover { background: var(--hover); }
.project-list li.active {
  background: var(--accent-soft);
  outline: 1px solid var(--line);
}
.project-list li .pname {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-list li .row-actions { display: none; gap: 2px; }
.project-list li:hover .row-actions,
.project-list li.active .row-actions { display: flex; }
.mini-btn {
  background: transparent; border: none; padding: 2px 5px;
  border-radius: 2.4px 2.4px 6px 2.4px; font-size: 13px; color: var(--muted);
}
.mini-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20;
}

.main { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 20px 60px; }
.project-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.project-header h2 { margin: 0; font-size: 20px; font-weight: 700; }
.btn-sm {
  background: var(--accent); color: #1a1a1a; border: none;
  padding: 7px 12px; border-radius: 3.2px 3.2px 8px 3.2px; font-weight: 700; flex-shrink: 0;
}
.btn-sm:hover { background: #f0f0f0; }
.empty-state { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---- Drop indicator ---- */
.drop-indicator {
  height: 2px;
  background: var(--accent);
  border-radius: 0.8px 0.8px 2px 0.8px;
  margin: 2px 0;
  pointer-events: none;
  position: relative;
}
.drop-indicator::before {
  content: '';
  position: absolute;
  left: -1px; top: -4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

/* ---- Tree ---- */
.tree-children { list-style: none; margin: 0; padding-left: 22px; }
.tree-view > .tree-node-list { padding-left: 0; }
.tree-node-list { list-style: none; margin: 0; padding: 0; }

.task-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--p0);
  border-radius: 3.6px 3.6px 9px 3.6px;
  padding: 7px 9px;
  margin: 3px 0;
  user-select: none;
  position: relative;
}
.task-card.prio-0 { border-left-color: var(--p0); }
.task-card.prio-1 { border-left-color: var(--p1); }
.task-card.prio-2 { border-left-color: var(--p2); }
.task-card.prio-3 { border-left-color: var(--p3); }

.task-card.dragging { opacity: .35; }

/* nest-drop: highlight the whole card */
.task-card.drop-nest {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.twist {
  width: 18px; text-align: center; color: var(--muted);
  cursor: pointer; flex-shrink: 0; font-size: 11px;
}
.twist.placeholder { visibility: hidden; }

.status-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid; flex-shrink: 0; cursor: pointer;
  background: transparent; flex-shrink: 0;
}
.status-dot.s0 { border-color: var(--s0); }
.status-dot.s1 {
  border-color: var(--s1);
  background: radial-gradient(circle, var(--s1) 38%, transparent 42%);
}
.status-dot.s2 { border-color: var(--s2); background: var(--s2); }

.drag-handle {
  cursor: grab; color: var(--muted); flex-shrink: 0;
  touch-action: none; padding: 0 2px; font-size: 14px;
}
.drag-handle:active { cursor: grabbing; }

.task-title {
  flex: 1; min-width: 0; padding: 3px 5px; border-radius: 2.4px 2.4px 6px 2.4px;
  border: 1px solid transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: text; background: transparent; color: var(--text);
}
.task-title:hover { background: var(--hover); }
.task-title.editing {
  white-space: normal; background: var(--bg);
  border-color: var(--accent); outline: none;
}
.task-card.done .task-title { color: var(--muted); text-decoration: line-through; }

.prio-pick { display: flex; gap: 4px; flex-shrink: 0; }
.prio-swatch {
  width: 13px; height: 13px; border-radius: 1.2px 1.2px 3px 1.2px;
  cursor: pointer; opacity: .3; border: 1px solid transparent;
}
.prio-swatch:hover { opacity: .7; }
.prio-swatch.active { opacity: 1; outline: 2px solid var(--text); outline-offset: 1px; }
.prio-swatch.p0 { background: var(--p0); }
.prio-swatch.p1 { background: var(--p1); }
.prio-swatch.p2 { background: var(--p2); }
.prio-swatch.p3 { background: var(--p3); }

.card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.task-card .card-actions { opacity: 0; transition: opacity .12s; }
.task-card:hover .card-actions,
.task-card:focus-within .card-actions { opacity: 1; }
@media (hover: none) { .task-card .card-actions { opacity: 1; } }

.root-drop {
  margin-top: 10px; padding: 10px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 3.6px 3.6px 9px 3.6px; font-size: 13px;
}
.root-drop.drop-target {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
}

/* floating ghost during drag */
.drag-ghost {
  position: fixed; z-index: 1000; pointer-events: none;
  background: var(--panel-alt); border: 1px solid var(--accent);
  border-radius: 3.6px 3.6px 9px 3.6px; padding: 7px 14px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.5); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}

/* ---- Kanban ---- */
.kanban-view { display: flex; gap: 12px; align-items: flex-start; }
.kanban-col {
  flex: 1; min-width: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: 4.8px 4.8px 12px 4.8px; padding: 10px;
}
.kanban-col h3 {
  margin: 0 0 10px; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; display: flex; align-items: center; gap: 8px; color: var(--muted);
}
.col-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.col-dot.s0 { background: var(--s0); }
.col-dot.s1 { background: var(--s1); }
.col-dot.s2 { background: var(--s2); }
.col-count { font-weight: 400; color: var(--muted); }
.col-drop-area { min-height: 40px; }
.col-drop-area.drop-target { background: var(--accent-soft); border-radius: 3.2px 3.2px 8px 3.2px; }

.kanban-card {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-left: 4px solid var(--p0);
  border-radius: 3.2px 3.2px 8px 3.2px; padding: 8px 10px; margin-bottom: 6px;
  cursor: grab; touch-action: none;
}
.kanban-card.prio-0 { border-left-color: var(--p0); }
.kanban-card.prio-1 { border-left-color: var(--p1); }
.kanban-card.prio-2 { border-left-color: var(--p2); }
.kanban-card.prio-3 { border-left-color: var(--p3); }
.kanban-card.dragging { opacity: .35; }
.kanban-card .ktitle { font-size: 14px; color: var(--text); }
.kanban-card .kpath { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-alt); color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 3.6px 3.6px 9px 3.6px;
  z-index: 2000; font-size: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 1.6px 1.6px 4px 1.6px; }

/* ---- Mobile ---- */
@media (max-width: 720px) {
  #sidebar-toggle { display: inline-block; }
  .view-tabs { margin-left: auto; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    width: 78%; max-width: 290px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 6px 0 24px rgba(0,0,0,.4);
  }
  .sidebar.open { transform: translateX(0); }
  #user-email { display: none; }
  .main { padding: 12px 12px 60px; }
  .kanban-view { flex-direction: column; }
  .kanban-col { width: 100%; }
}
