/* Twilight Task System — dark theme */
:root {
  --bg: #14131c;
  --bg-raised: #1d1b29;
  --bg-card: #262336;
  --bg-card-hover: #2e2a42;
  --border: #353050;
  --text: #e8e6f2;
  --text-muted: #9b96b3;
  --accent: #7c5cff;
  --danger: #ff5c7a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body { display: flex; flex-direction: column; }

.muted { color: var(--text-muted); }
[hidden] { display: none !important; }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  color: var(--text);
  background: var(--bg-card);
}
button:hover { filter: brightness(1.15); }

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* ---------------- banner ---------------- */
#banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-raised);
  border-bottom: 2px solid var(--accent);
  flex: 0 0 auto;
}
#banner-title { font-weight: 700; white-space: nowrap; }
#project-desc {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 38vw;
}
.spacer { flex: 1; }
.banner-btn {
  padding: 5px 11px;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
#project-switcher { padding: 5px 8px; font-size: 13px; max-width: 240px; }
#readonly-pill {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
#sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  transition: background 0.3s;
}
#sync-dot.live { background: var(--ok); }

/* ---------------- board ---------------- */
#board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: flex-start;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
}

.list {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-top: 3px solid var(--list-color, var(--accent));
  border-radius: var(--radius);
  width: 290px;
  flex: 0 0 290px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}
.list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
}
.list-title {
  font-weight: 600;
  color: var(--list-color, var(--text));
  flex: 1;
  cursor: default;
}
.list-count { font-size: 12px; color: var(--text-muted); }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--bg-card); color: var(--text); }

.task-container {
  padding: 4px 10px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 24px;
  flex: 1;
}

.task {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--list-color, var(--accent));
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}
.task:hover { background: var(--bg-card-hover); }
.task.completed .task-name { text-decoration: line-through; color: var(--text-muted); }
.task-name { flex: 1; overflow-wrap: anywhere; }

.status-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.status-dot.started { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 45%, transparent); }
.status-dot.completed { border-color: var(--ok); background: var(--ok); }

.sortable-ghost { opacity: 0.35; }
.sortable-drag { box-shadow: var(--shadow); }

.add-task-btn {
  margin: 0 10px 10px;
  padding: 6px;
  font-size: 13px;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border);
}
.add-task-btn:hover { color: var(--text); background: var(--bg-card); }

.add-list-btn {
  flex: 0 0 220px;
  padding: 12px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------------- modal ---------------- */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
#modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px 22px;
}
#modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal-row { display: flex; gap: 10px; margin: 12px 0; align-items: center; flex-wrap: wrap; }
.modal-row label { min-width: 86px; color: var(--text-muted); font-size: 13px; }
.modal-row input[type="text"], .modal-row textarea { flex: 1; min-width: 200px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}
.btn-primary { background: var(--accent); padding: 8px 16px; color: #fff; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 8px 14px; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-plain { background: var(--bg-card); border: 1px solid var(--border); padding: 8px 14px; }

.status-picker { display: flex; gap: 6px; }
.status-picker button {
  padding: 5px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}
.status-picker button.active { border-color: var(--accent); color: var(--text); background: var(--bg-card); }

.md-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0;
  overflow-wrap: anywhere;
}
.md-body :first-child { margin-top: 0; }
.md-body :last-child { margin-bottom: 0; }
.md-body a { color: var(--accent); }
.md-body code {
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}
.md-body pre { background: var(--bg-card); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md-body pre code { background: none; padding: 0; }
.md-body blockquote {
  border-left: 3px solid var(--accent);
  margin-left: 0;
  padding-left: 12px;
  color: var(--text-muted);
}

textarea.desc-editor { width: 100%; min-height: 140px; resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }

.token-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.token-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}
.token-list .tok-label { flex: 1; }
.token-list .inactive { opacity: 0.5; }
.tok-link { color: var(--accent); text-decoration: none; word-break: break-all; }

input[type="color"] {
  width: 46px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

/* ---------------- login ---------------- */
.login-body { align-items: center; justify-content: center; }
.login-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 38px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(360px, 90vw);
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card p { margin: 0; font-size: 14px; }
.login-card button { background: var(--accent); color: #fff; padding: 10px; }
.login-error { color: var(--danger); font-size: 14px; }
