:root {
  --ink: #172026;
  --ink-2: #44515c;
  --ink-3: #6b7781;
  --line: #d5dbe0;
  --list: #ebeef1;
  --card: #ffffff;
  --page: #f4f6f8;
  --board: #2f566f;
  --board-dark: #1f3c4e;
  --focus: #f2b632;
  --danger: #b23a2e;
  --radius: 10px;
  --shadow-card: 0 1px 0 rgba(23, 32, 38, 0.18);
  --shadow-pop: 0 12px 32px rgba(23, 32, 38, 0.28);
  --l-red: #d9544a; --l-orange: #e08a2e; --l-yellow: #d9b52b; --l-green: #4e9a5b;
  --l-blue: #3a7bc8; --l-purple: #7d5ab5; --l-pink: #c95a93; --l-gray: #7a8792;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: var(--board); }
#app { height: 100%; }
body {
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--board);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & fields ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600;
  background: var(--board); color: #fff; min-height: 36px;
}
.btn:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: rgba(23, 32, 38, 0.07); filter: none; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.danger:hover { background: rgba(178, 58, 46, 0.1); }
.btn.light { background: rgba(255, 255, 255, 0.18); color: #fff; display: inline-flex; align-items: center; gap: 6px; }
.btn.light:hover { background: rgba(255, 255, 255, 0.28); filter: none; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff;
}
.input:focus { border-color: var(--board); outline: none; box-shadow: 0 0 0 3px rgba(47, 86, 111, 0.2); }
textarea.input { resize: vertical; min-height: 90px; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0 0 10px; }

/* ---------- sign in ---------- */
.signin {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: var(--board);
}
.signin-card {
  width: min(380px, 100%); background: #fff; border-radius: 14px; padding: 28px 26px 22px; box-shadow: var(--shadow-pop);
}
.signin-mark { display: flex; gap: 5px; margin-bottom: 18px; }
.signin-mark span { width: 12px; border-radius: 3px; background: var(--board); }
.signin-mark span:nth-child(1) { height: 30px; }
.signin-mark span:nth-child(2) { height: 20px; opacity: 0.7; }
.signin-mark span:nth-child(3) { height: 25px; opacity: 0.45; }
.signin h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.01em; }
.signin p.sub { margin: 0 0 22px; color: var(--ink-3); }
.signin .btn { width: 100%; }
.signin .note { margin: 16px 0 0; font-size: 13px; color: var(--ink-3); }

/* ---------- shell ---------- */
.shell { height: 100%; display: flex; flex-direction: column; background: var(--board); transition: background 0.2s; }
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 52px;
  background: rgba(10, 16, 20, 0.28); color: #fff; flex-wrap: wrap;
}
.topbar .switch {
  display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, 0.16); border: 0; color: #fff;
  border-radius: 8px; padding: 6px 10px; font-weight: 700; min-height: 36px; max-width: 46vw;
}
.topbar .switch .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .switch:hover { background: rgba(255, 255, 255, 0.26); }
.topbar .title {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em; background: transparent; border: 0; color: #fff;
  padding: 4px 8px; border-radius: 6px; min-width: 60px; max-width: 40vw;
}
.topbar .title:hover { background: rgba(255, 255, 255, 0.14); }
.topbar input.title { background: #fff; color: var(--ink); }
.topbar .spacer { flex: 1; }
.avatars { display: flex; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: #fff; border: 2px solid rgba(255, 255, 255, 0.85); margin-left: -6px; flex: none; user-select: none;
}
.avatars .avatar:first-child { margin-left: 0; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; border-width: 1.5px; margin-left: -4px; border-color: #fff; }

/* ---------- board ---------- */
.board {
  flex: 1; display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px 24px;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
}
.list {
  flex: 0 0 280px; max-height: 100%; display: flex; flex-direction: column; background: var(--list);
  border-radius: var(--radius); box-shadow: 0 1px 0 rgba(10, 16, 20, 0.25);
}
.list-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 10px; cursor: grab; touch-action: pan-y; }
.list-head .lname {
  flex: 1; font-weight: 700; border: 0; background: transparent; padding: 5px 6px; border-radius: 6px; text-align: left;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-head .lname:hover { background: rgba(23, 32, 38, 0.07); }
.list-head input.lname { background: #fff; box-shadow: inset 0 0 0 2px var(--board); }
.count { font-size: 12px; color: var(--ink-3); font-weight: 600; padding: 0 4px; }
.icon-btn {
  border: 0; background: transparent; border-radius: 6px; width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--ink-2); flex: none;
}
.icon-btn:hover { background: rgba(23, 32, 38, 0.09); }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 4px; overflow-y: auto; min-height: 8px; }
.card {
  background: var(--card); border-radius: 8px; padding: 8px 10px 8px; box-shadow: var(--shadow-card);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; position: relative;
  border: 0; text-align: left; width: 100%; display: block;
}
.card:hover { box-shadow: 0 0 0 2px var(--board), var(--shadow-card); }
.card .ctitle { font-weight: 500; overflow-wrap: anywhere; }
.card.is-done .ctitle { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.chip { height: 8px; width: 40px; border-radius: 4px; }
.chip.wide { height: auto; width: auto; padding: 1px 8px; font-size: 12px; font-weight: 700; color: #fff; border-radius: 4px; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.badges:empty { display: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: 4px; }
.badge svg { width: 14px; height: 14px; }
.badge.due-soon { background: #f6d77a; color: #4a3a05; }
.badge.overdue { background: var(--danger); color: #fff; }
.badge.complete { background: var(--l-green); color: #fff; }
.badges .avatars { margin-left: auto; }
.add-card { margin: 4px 8px 8px; }
.add-card .ghost-btn, .add-list .ghost-btn {
  width: 100%; text-align: left; border: 0; border-radius: 8px; padding: 8px 10px; background: transparent; color: var(--ink-2); font-weight: 600;
}
.add-card .ghost-btn:hover { background: rgba(23, 32, 38, 0.08); }
.add-card form, .add-list form { display: grid; gap: 8px; }
.add-card .row, .add-list .row { display: flex; gap: 6px; align-items: center; }
.add-list { flex: 0 0 280px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.18); padding: 6px; }
.add-list .ghost-btn { color: #fff; }
.add-list .ghost-btn:hover { background: rgba(255, 255, 255, 0.12); }
.add-list form { background: var(--list); padding: 8px; border-radius: 8px; }

/* drag */
.drag-ghost { position: fixed; z-index: 50; pointer-events: none; transform: rotate(2.5deg); box-shadow: var(--shadow-pop); opacity: 0.95; }
.placeholder { border-radius: 8px; background: rgba(23, 32, 38, 0.12); flex: none; }
.list.placeholder { background: rgba(255, 255, 255, 0.2); }
.dragging-source { opacity: 0.35; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }

/* ---------- empty state ---------- */
.empty {
  margin: auto; width: min(460px, calc(100% - 32px)); background: #fff; border-radius: 14px; padding: 26px; box-shadow: var(--shadow-pop);
}
.empty h2 { margin: 0 0 6px; font-size: 22px; }
.empty p { margin: 0 0 18px; color: var(--ink-2); }
.empty .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- popovers & dialogs ---------- */
.pop {
  position: fixed; z-index: 40; background: #fff; border-radius: 10px; box-shadow: var(--shadow-pop); padding: 10px;
  width: min(300px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow: auto;
}
.pop h3 { margin: 2px 6px 10px; font-size: 13px; color: var(--ink-3); text-align: center; font-weight: 700; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 6px; padding: 8px 10px; min-height: 36px;
}
.menu-item:hover { background: rgba(23, 32, 38, 0.07); }
.menu-item.current { font-weight: 700; }
.menu-item.danger { color: var(--danger); }
.swatch { width: 22px; height: 16px; border-radius: 4px; flex: none; }
.sep { height: 1px; background: var(--line); margin: 8px 0; }
.colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 14px; }
.color-opt { height: 32px; border-radius: 6px; border: 3px solid transparent; }
.color-opt[aria-pressed="true"] { border-color: var(--ink); }

dialog {
  border: 0; padding: 0; border-radius: 14px; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-pop); color: var(--ink); background: var(--page);
}
dialog::backdrop { background: rgba(10, 16, 20, 0.55); }
.dlg { padding: 20px 22px 22px; }
.dlg-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 4px; }
.dlg-head textarea {
  flex: 1; font-size: 20px; font-weight: 700; border: 0; background: transparent; resize: none; padding: 4px 6px;
  border-radius: 6px; line-height: 1.3; overflow: hidden;
}
.dlg-head textarea:focus { background: #fff; outline: none; box-shadow: inset 0 0 0 2px var(--board); }
.dlg-sub { margin: 0 0 18px 6px; color: var(--ink-3); font-size: 14px; }
.dlg-sub select { border: 0; background: transparent; font-weight: 700; color: var(--ink-2); text-decoration: underline; padding: 0; }
.dlg-grid { display: grid; grid-template-columns: 1fr 190px; gap: 22px; }
@media (max-width: 640px) { .dlg-grid { grid-template-columns: 1fr; } }
.section { margin-bottom: 22px; }
.section h4 { margin: 0 0 8px; font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 20px; }
.meta-row .meta h5 { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); font-weight: 700; }
.meta-row .chips { margin: 0; }
.side h5 { margin: 0 0 6px; font-size: 12px; color: var(--ink-3); font-weight: 700; }
.side .btn { display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 6px; background: #e3e8ec; color: var(--ink); font-weight: 600; }
.side .btn:hover { background: #d7dee3; filter: none; }
.side .btn.danger { background: transparent; color: var(--danger); }
.desc-view { white-space: pre-wrap; overflow-wrap: anywhere; background: #fff; border-radius: 8px; padding: 10px 12px; min-height: 54px; cursor: text; }
.desc-view.empty-desc { color: var(--ink-3); }
.check-bar { height: 8px; background: #dde3e8; border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.check-bar span { display: block; height: 100%; background: var(--l-blue); transition: width 0.2s; }
.check-bar.full span { background: var(--l-green); }
.check-item { display: flex; align-items: center; gap: 10px; padding: 4px 4px; border-radius: 6px; }
.check-item:hover { background: rgba(23, 32, 38, 0.05); }
.check-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--board); flex: none; }
.check-item .ctext { flex: 1; overflow-wrap: anywhere; }
.check-item.done .ctext { color: var(--ink-3); text-decoration: line-through; }
.check-item .icon-btn { opacity: 0; }
.check-item:hover .icon-btn, .check-item .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .check-item .icon-btn { opacity: 1; } }
.inline-add { display: flex; gap: 6px; margin-top: 6px; }
.comment { display: flex; gap: 10px; margin-top: 12px; }
.comment .avatar { margin: 0; border: 0; }
.comment .cbody { flex: 1; min-width: 0; }
.comment .cmeta { font-size: 13px; color: var(--ink-3); margin-bottom: 3px; }
.comment .cmeta b { color: var(--ink); }
.comment .ctext { background: #fff; border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-card); }
.comment .del { border: 0; background: none; color: var(--ink-3); font-size: 12px; padding: 2px 0; text-decoration: underline; }
.label-opt { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.label-opt button.lab {
  flex: 1; text-align: left; border: 0; border-radius: 6px; padding: 7px 10px; color: #fff; font-weight: 700; min-height: 34px;
  display: flex; justify-content: space-between; align-items: center;
}
.label-opt button.lab:hover { filter: brightness(1.08); }
.member-opt { display: flex; align-items: center; gap: 10px; }
.member-opt .avatar { margin: 0; border: 0; }
.member-opt .tick { margin-left: auto; font-weight: 800; }
.members-list .member-opt { padding: 6px 4px; }
.members-list .who { display: grid; }
.members-list .who small { color: var(--ink-3); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow-pop); max-width: calc(100vw - 32px);
}
.loading { margin: auto; color: rgba(255, 255, 255, 0.85); font-weight: 600; }

@media (max-width: 560px) {
  .list, .add-list { flex-basis: 84vw; }
  .topbar .switch { max-width: 60vw; }
  .topbar .title { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .drag-ghost { transform: none; }
}

/* ---------- presence ---------- */
.live { display: flex; align-items: center; gap: 8px; }
.live:empty { display: none; }
.live-label { font-size: 12.5px; font-weight: 600; color: rgba(255, 255, 255, 0.85); }
.avatar.live-dot { position: relative; overflow: visible; }
.avatar.live-dot::after {
  content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%;
  background: #4fd17a; border: 2px solid var(--board-dark);
}
.card .watchers { position: absolute; top: 6px; right: 6px; display: flex; align-items: center; gap: 4px; }
.card .watchers .avatar { margin-left: -4px; }
.card .watchers .pen {
  font-size: 10.5px; font-weight: 800; color: #fff; background: var(--l-orange); border-radius: 4px; padding: 0 5px; line-height: 16px;
}
.card.is-edited { box-shadow: 0 0 0 2px var(--l-orange), var(--shadow-card); }
.adding-note { margin: 2px 12px 0; font-size: 12.5px; color: var(--ink-3); font-style: italic; }
.here { margin: -10px 0 14px 6px; display: grid; gap: 6px; }
.here:empty { display: none; }
.here-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.here-row .avatar { margin: 0; border: 0; }
.here-row.editing { color: #8a4b0b; font-weight: 600; }
.here-row.editing::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--l-orange); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.member-tools { padding: 4px 4px 10px 38px; }
.member-tools .error { margin: 6px 0 0; min-height: 0; }
dialog.acct { width: min(480px, calc(100vw - 24px)); }
@media (prefers-reduced-motion: reduce) { .here-row.editing::before { animation: none; } }
