:root {
  --bg: #0b0d12;
  --bg-2: #0f1218;
  --panel: #161a22;
  --panel-2: #1d222c;
  --line: #262b36;
  --line-strong: #303644;
  --text: #e8ebf1;
  --muted: #98a2b3;
  --muted-2: #6b7280;
  --accent: #5b8def;
  --accent-2: #7c5bef;
  --ok: #3fb950;
  --warn: #f0b441;
  --err: #f85149;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 91, 239, 0.08), transparent 60%),
    radial-gradient(1000px 600px at -10% 110%, rgba(91, 141, 239, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
input, textarea, button, select { font: inherit; color: inherit; }

input, textarea, select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.18);
}

button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: filter .15s ease, transform .05s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
button.link { background: transparent; color: var(--accent); padding: 4px 6px; }
button.link:hover { text-decoration: underline; }

label {
  display: block;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
label input, label textarea, label select { margin-top: 4px; color: var(--text); }

.row { display: flex; gap: 8px; align-items: center; }

/* ─── auth ─────────────────────────────────────────────────────────────── */
.auth {
  max-width: 400px;
  margin: 7vh auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.auth h1 { font-size: 22px; }
.auth .sub { color: var(--muted); margin: 6px 0 18px; }
.msg { min-height: 18px; margin: 10px 0 0; font-size: 13px; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.tabs { display: flex; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.tab {
  flex: 1; background: transparent; color: var(--muted); border: 0;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
  transition: background .15s ease, color .15s ease;
}
.tab.active { background: var(--panel); color: var(--text); }

.project-browser { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.project-browser h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.public-projects { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.project-pick {
  width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); padding: 10px 12px; border-radius: 10px; cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.project-pick:hover { border-color: var(--accent); background: var(--panel); }
.project-pick .pname { font-weight: 600; grid-column: 1; }
.project-pick .pid { grid-column: 2; grid-row: 1 / span 2; font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); }
.project-pick .pcount { grid-column: 1; font-size: 12px; color: var(--muted); }

/* ─── shell ────────────────────────────────────────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(22, 26, 34, 0.7);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 16px; letter-spacing: 0.01em; }
.logo {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: transparent;
}
.who { color: var(--muted); display: flex; align-items: center; gap: 12px; font-size: 13px; }

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 22px;
  padding: 22px;
  max-width: 1180px;
  margin: 0 auto;
}
.app.single { grid-template-columns: 1fr; max-width: 760px; }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } }

.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; line-height: 1.5; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-head h2 {
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700;
}

.projects, .todos, .members {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.badge {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--muted);
}

/* ─── members ──────────────────────────────────────────────────────────── */
.members { height: fit-content; position: sticky; top: 76px; }
.member-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; transition: background .15s ease; }
.member:hover { background: var(--panel-2); }
.member.me { background: var(--panel-2); }
.member.idle .avatar { filter: grayscale(0.6) brightness(0.85); }

.avatar {
  position: relative;
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.avatar .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted-2);
  border: 2px solid var(--panel);
  box-sizing: content-box;
}
.member.active .avatar .dot { background: var(--ok); box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.18); }
.member.me .avatar .dot { border-color: var(--panel-2); }

.mname { font-size: 14px; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.mname .you { color: var(--muted); font-size: 12px; }
.mname .seen { color: var(--muted); font-size: 11px; margin-top: 1px; }
.member.active .mname .seen { color: var(--ok); }

/* ─── todos panel ──────────────────────────────────────────────────────── */
.project-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 14px;
}
.project-header h2 { font-size: 20px; margin-bottom: 6px; }

.stats {
  display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; margin-bottom: 18px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
}
.stat { display: flex; flex-direction: column; min-width: 56px; }
.stat.grow { flex: 1; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.progress {
  width: 100%; height: 6px; background: var(--line);
  border-radius: 999px; overflow: hidden; margin-bottom: 6px;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0; transition: width .45s cubic-bezier(.2,.8,.2,1);
}

.todo-form {
  display: grid; gap: 10px; margin-bottom: 16px;
  padding: 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px;
}
.todo-form input, .todo-form textarea { background: var(--panel); }
.todo-form textarea { min-height: 60px; resize: vertical; }
.todo-form-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.todo-form-row label { flex: 1; min-width: 180px; margin: 0; }
.todo-form-row select { width: 100%; background: var(--panel); }
.todo-form-row button { white-space: nowrap; }

.form-assignees { display: flex; flex-direction: column; gap: 6px; }
.form-label { color: var(--muted); font-size: 13px; }
.chip-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 36px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.chip-row:empty::before { content: attr(data-empty); color: var(--muted-2); font-size: 12px; padding: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; cursor: pointer; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on {
  background: rgba(91, 141, 239, 0.18); color: var(--accent);
  border-color: rgba(91, 141, 239, 0.55);
}
.chip-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; display: grid; place-items: center; font-weight: 700; font-size: 11px;
}
.chip .me-tag { color: var(--muted-2); font-size: 12px; }

/* inline assignee badges + edit popover */
.assignees-inline { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.title-row { position: relative; }

.edit-assignees { font-size: 11px; padding: 1px 6px; color: var(--muted); }
.edit-assignees:hover { color: var(--accent); }

.assignee-popover {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  min-width: 240px; max-width: 320px;
}
.ap-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.ap-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.ap-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  margin: 0; color: var(--text); font-size: 13px;
}
.ap-row:hover { background: var(--panel-2); }
.ap-row input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); flex-shrink: 0; }
.ap-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.ap-actions .ap-done { padding: 6px 14px; }

.toolbar {
  display: flex; gap: 10px; margin-bottom: 12px; align-items: center;
}
.toolbar .search { flex: 1; }
.toolbar .search input { padding-left: 11px; }
.toolbar-filter { margin: 0; flex: 0 0 160px; }
.toolbar-filter select { padding: 8px 10px; }

.todo-section { margin-bottom: 14px; }
.todo-section-head {
  display: flex; gap: 10px; align-items: center;
  font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 700; padding: 8px 4px;
  margin: 0; border: 0;
}
.todo-section-head .dim { color: var(--muted-2); font-weight: 600; }
.todo-section-head.toggle {
  background: transparent; cursor: pointer; width: 100%; text-align: left;
  border-radius: 6px;
}
.todo-section-head.toggle:hover { color: var(--text); }
.todo-section-head .chev { margin-left: auto; transition: transform .15s ease; color: var(--muted-2); }
.todo-section-head.toggle.open .chev { transform: rotate(90deg); }

.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.todo {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .15s ease, transform .15s ease, opacity .15s ease;
  animation: rowIn .22s ease both;
}
.todo:hover { border-color: var(--line-strong); }
.todo.done { opacity: 0.7; }
.todo.done .title { text-decoration: line-through; color: var(--muted); }
.todo.pending { opacity: 0.55; }

@keyframes rowIn {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: none; }
}

.check input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.title-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.title { font-weight: 600; }
.todo .details { color: var(--muted); white-space: pre-wrap; margin-top: 4px; font-size: 14px; }
.todo .meta {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: 8px; font-size: 12px;
}
.meta-by { color: var(--muted); }
.todo .reassign select {
  background: var(--panel); padding: 3px 8px; font-size: 12px; border-radius: 6px;
  width: auto; min-width: 110px;
}

.assigned {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(91, 141, 239, 0.15); color: var(--accent);
  letter-spacing: 0.01em;
}
.assigned.unassigned { background: var(--panel); color: var(--muted-2); }

.due {
  display: inline-flex; align-items: center; cursor: pointer;
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line);
  transition: border-color .12s ease;
}
.due:hover { border-color: var(--accent); }
.due.none { color: var(--muted-2); }
.due.today { background: rgba(240, 180, 65, 0.15); color: var(--warn); border-color: rgba(240, 180, 65, 0.4); }
.due.soon { background: rgba(91, 141, 239, 0.12); color: var(--accent); border-color: rgba(91, 141, 239, 0.4); }
.due.overdue { background: rgba(248, 81, 73, 0.15); color: var(--err); border-color: rgba(248, 81, 73, 0.45); }
.due.later { color: var(--muted); }
.due-edit { display: inline-flex; gap: 6px; align-items: center; }
.due-edit input[type=date] { padding: 3px 6px; font-size: 12px; width: auto; }

/* edit-in-place */
.editable { cursor: text; padding: 1px 3px; margin: -1px -3px; border-radius: 4px; transition: background .12s ease; }
.editable:hover { background: var(--panel); }
.editable.placeholder { color: var(--muted-2); font-style: italic; }
.inline-edit {
  background: var(--panel); border: 1px solid var(--accent);
  border-radius: 6px; padding: 4px 6px; font: inherit;
  width: 100%; box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.18);
}
textarea.inline-edit { min-height: 56px; resize: vertical; }
input.inline-edit.title { font-weight: 600; }

/* comments */
.toggle-comments { font-size: 12px; padding: 2px 6px; }
.comments-thread {
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
}
.comment-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.comment {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px;
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px;
}
.avatar.small { width: 24px; height: 24px; font-size: 11px; }
.cbody { min-width: 0; }
.chead { font-size: 13px; }
.chead .ctime { color: var(--muted); font-size: 11px; margin-left: 6px; }
.ctext { font-size: 13px; margin-top: 2px; white-space: pre-wrap; }
.icon-btn.small { width: 24px; height: 24px; font-size: 14px; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { background: var(--panel); }

.icon-btn {
  background: transparent; color: var(--muted-2); border: 1px solid transparent;
  width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: 18px;
  display: grid; place-items: center; align-self: start;
}
.icon-btn:hover:not(:disabled) { background: rgba(248, 81, 73, 0.12); color: var(--err); border-color: rgba(248, 81, 73, 0.35); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.empty {
  color: var(--muted); padding: 20px; text-align: center; list-style: none;
  background: transparent; border: 1px dashed var(--line); border-radius: 12px;
  font-size: 13px;
}

/* ─── role / status badges ─────────────────────────────────────────────── */
.role-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.01em;
}
.role-badge.admin   { background: rgba(124, 91, 239, 0.18); color: var(--accent-2); border: 1px solid rgba(124, 91, 239, 0.4); }
.role-badge.pending { background: rgba(240, 180, 65, 0.15); color: var(--warn);     border: 1px solid rgba(240, 180, 65, 0.4); }
.role-badge.private { background: rgba(248, 81, 73, 0.12);  color: var(--err);      border: 1px solid rgba(248, 81, 73, 0.35); }
.role-badge.public  { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.sub-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; margin: 12px 0 6px; }
.pending-section { padding: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.pending-section .member { background: transparent; }

.member-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.member-actions .link { font-size: 11px; padding: 2px 6px; }
.member-actions .reject, .member-actions .remove { color: var(--err); }
.member-actions .reject:hover, .member-actions .remove:hover { color: var(--err); text-decoration: underline; }

/* ─── pending banner (own pending state) ───────────────────────────────── */
.pending-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 18px; margin-bottom: 14px;
  background: rgba(240, 180, 65, 0.08); border: 1px solid rgba(240, 180, 65, 0.4);
  border-radius: 12px;
}
.pending-banner strong { color: var(--warn); }
.pending-banner p { margin: 4px 0 0; }

.claim-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; margin-bottom: 14px;
  background: rgba(124, 91, 239, 0.10); border: 1px solid rgba(124, 91, 239, 0.4);
  border-radius: 12px;
}
.claim-banner strong { color: var(--accent-2); }
.claim-banner p { margin: 4px 0 0; }
.claim-banner button { background: var(--accent-2); }

.admin-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 10px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12px;
}
.admin-summary .link { white-space: nowrap; }

.admin-manager {
  position: absolute; right: 16px; top: 100px; z-index: 30;
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  min-width: 280px; max-width: 360px;
}
@media (max-width: 860px) {
  .admin-manager { position: fixed; right: 16px; left: 16px; top: auto; bottom: 16px; max-width: none; }
}
.admin-manager .ap-list { max-height: 280px; overflow: auto; }
.am-save { padding: 6px 14px; }

/* ─── project header ───────────────────────────────────────────────────── */
.project-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#privacy-toggle { font-size: 12px; }

/* ─── toasts ───────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line);
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  transform: translateY(8px); opacity: 0;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s ease;
  min-width: 160px; max-width: 360px;
}
.toast.in  { transform: none; opacity: 1; }
.toast.out { transform: translateY(4px); opacity: 0; }
.toast.ok    { border-color: rgba(63, 185, 80, 0.5); }
.toast.error { border-color: rgba(248, 81, 73, 0.55); color: #ffd2cf; }

/* dialog (kept for parity) */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; min-width: 320px;
}
dialog::backdrop { background: rgba(0,0,0,0.55); }
