:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #0ea5e9;
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --border: #334155;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0,0,0,.35);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100%; }
button, input, textarea, select {
  font: inherit; color: inherit;
}
a { color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent2); border-color: var(--accent2); color: #0f172a; font-weight: 600; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.input, .textarea, .select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; outline: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { min-height: 90px; resize: vertical; }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.error { color: var(--danger); font-size: 14px; margin-top: 8px; }
.okmsg { color: var(--ok); font-size: 14px; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #0ea5e933, transparent),
              radial-gradient(800px 400px at 100% 100%, #6366f133, transparent), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: .02em; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); font-size: 13px; }
.main { padding: 16px; max-width: 1400px; margin: 0 auto; }

.grid-boards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px;
}
.board-tile {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.board-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.board-tile h3 { margin: 0 0 8px; font-size: 17px; }
.board-tile p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.board-tile .meta { margin-top: 12px; font-size: 12px; color: var(--muted); }

.panel {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; }

.board-header { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.board-header h1 { margin: 0; font-size: 20px; }
.board-columns {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px;
  align-items: flex-start; min-height: 60vh;
}
.column {
  flex: 0 0 280px; width: 280px; background: #0b1220; border: 1px solid var(--border);
  border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 180px);
}
.column-head {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #0b1220; border-radius: 12px 12px 0 0;
}
.column-head .title { font-weight: 600; flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.column-head .count {
  background: var(--bg3); color: var(--muted); font-size: 12px; padding: 2px 7px; border-radius: 999px;
}
.column-body {
  padding: 10px; overflow-y: auto; flex: 1; min-height: 80px;
}
.column-body.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; background: #0ea5e911; }
.column-foot { padding: 8px 10px; border-top: 1px solid var(--border); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  user-select: none; touch-action: none;
}
.card:active { cursor: grabbing; }
.card.dragging { opacity: .45; }
.card.card-overdue { border-color: #f8717188; box-shadow: 0 0 0 1px #f8717144; }
.card h4 { margin: 0 0 6px; font-size: 14px; font-weight: 600; line-height: 1.35; }
.card .desc { color: var(--muted); font-size: 12px; margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; min-height: 0; }
.chip {
  background: var(--bg3); padding: 2px 7px; border-radius: 999px;
}
.chip.due-soon { background: #854d0e55; color: var(--warn); }
.chip.overdue { background: #7f1d1d55; color: var(--danger); }

.label-chip {
  display: inline-flex; align-items: center; border: none; cursor: default;
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg3); color: var(--text);
}
.label-chip.clickable, button.label-chip { cursor: pointer; }
.label-chip.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.label-red { background: #7f1d1d99; color: #fecaca; }
.label-orange { background: #9a341299; color: #fed7aa; }
.label-yellow { background: #854d0e99; color: #fde68a; }
.label-green { background: #14532d99; color: #bbf7d0; }
.label-blue { background: #1e3a8a99; color: #bfdbfe; }
.label-purple { background: #581c8799; color: #e9d5ff; }
.label-gray { background: #33415599; color: #e2e8f0; }

.label-filter-bar {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px;
}
.filter-label { color: var(--muted); font-size: 13px; }

.label-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.label-pick { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.label-manage-list { list-style: none; margin: 0; padding: 0; }
.label-manage-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}

.activity-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow: auto; }
.activity-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.activity-list .who { color: var(--text); font-weight: 500; }
.activity-list .when { float: right; font-size: 11px; opacity: .8; }

.comments-block { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.comments-block h4 { margin: 0 0 8px; font-size: 14px; }
.comment-list { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow: auto; }
.comment-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.comment-list .c-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-list .c-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.empty-n { color: var(--muted); font-size: 13px; padding: 8px 0; }

.notif-wrap { position: relative; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(340px, 90vw);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 40; max-height: 360px; display: flex; flex-direction: column;
}
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.notif-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.notif-list li {
  padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px;
}
.notif-list li:hover { background: #0ea5e911; }
.notif-list li.unread { background: #0ea5e918; }
.notif-list .when { color: var(--muted); font-size: 11px; margin-top: 4px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.72); display: flex; align-items: flex-end; justify-content: center;
  z-index: 50; padding: 16px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 18px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.badge-admin { background: #0369a155; color: var(--accent); font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; }

@media (max-width: 640px) {
  .column { flex: 0 0 85vw; width: 85vw; }
  .main { padding: 12px; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
}

.search-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 12px; padding: 10px 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
}
.search-form { display: flex; gap: 8px; flex: 1; min-width: 200px; align-items: center; }
.search-input { flex: 1; padding: 8px 12px; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.view-tab {
  border: 1px solid var(--border); background: var(--bg3); color: var(--text);
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
}
.view-tab:hover { filter: brightness(1.1); }
.view-tab.active { background: var(--accent2); border-color: var(--accent2); color: #0f172a; font-weight: 600; }
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; transition: border-color .15s;
}
.task-item:hover { border-color: var(--accent); }
.task-item h4 { margin: 0 0 6px; font-size: 14px; }
.task-item .desc {
  color: var(--muted); font-size: 12px; margin: 0 0 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-item .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.mention { color: var(--accent); font-weight: 600; }

/* v5 useful features */
.checklist-block, .attach-block { margin: 14px 0; padding-top: 8px; border-top: 1px solid var(--border); }
.checklist-block h4, .attach-block h4, .comments-block h4 { margin: 0 0 8px; font-size: 14px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checklist .cl-title { flex: 1; font-size: 14px; }
.checklist .cl-title.done { text-decoration: line-through; color: var(--muted); }
.attach-list { list-style: none; margin: 0; padding: 0; }
.attach-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.attach-list .muted, .muted { color: var(--muted); font-size: 12px; }
.label-edit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.chip-danger { background: #7f1d1d55; color: var(--danger); }
.chip-ok { background: #14532d55; color: var(--ok); }
.row-disabled { opacity: .65; }
.column-head[draggable] { cursor: grab; }
.column-head.col-dragging { opacity: .5; }
.column.col-drag-over { outline: 2px dashed var(--accent); }
.card.dragging { opacity: .55; transform: scale(.98); }
.comment-list .c-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comment-list .c-head .btn { padding: 2px 6px; font-size: 12px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* Due-date: typed text + custom Chinese calendar modal */
.due-field .due-input-row {
  display: flex; align-items: center; gap: 8px;
}
.due-combo {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}
.due-field .due-date-input {
  flex: 1; min-width: 0; width: 100%;
  min-height: 42px;
  padding-right: 44px;
  font-variant-numeric: tabular-nums;
}
.due-field .due-date-input.invalid,
.due-field .due-date-input:user-invalid {
  border-color: var(--danger);
}
.due-cal-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  flex-shrink: 0;
  min-width: 34px;
  min-height: 34px;
  padding: 4px 8px;
  line-height: 1;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  z-index: 2;
  cursor: pointer;
}
.due-cal-btn:hover {
  color: var(--accent);
  background: #0ea5e922;
  border-color: transparent;
}
.due-clear-btn {
  flex-shrink: 0;
  color: var(--muted);
  border-color: var(--border);
}
.due-clear-btn:hover { color: var(--danger); border-color: var(--danger); }
.due-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.due-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.3;
}
.due-chip:hover { border-color: var(--accent); color: var(--accent); }
.due-chip.active {
  background: #0ea5e933;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.due-chip-clear { color: var(--muted); }
.due-chip-clear:hover, .due-chip-clear.active {
  color: var(--danger); border-color: var(--danger); background: #7f1d1d33;
}
.due-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  min-height: 1.2em;
}
.due-hint.empty { opacity: .7; }
.due-hint.overdue { color: var(--danger); }
.due-hint.due-soon { color: var(--warn); }
.due-hint.invalid { color: var(--danger); font-weight: 500; }

/* Custom calendar overlay (above card modal) */
.due-cal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, .72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
@media (min-width: 520px) {
  .due-cal-overlay { align-items: center; }
}
.due-cal-sheet {
  width: 100%;
  max-width: 360px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}
.due-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.due-cal-head strong { font-size: 16px; }
.due-cal-nav {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 10px;
}
.due-cal-ym {
  flex: 1;
  display: flex; gap: 6px; min-width: 0;
}
.due-cal-ym .select {
  flex: 1;
  min-width: 0;
  padding: 8px 8px;
  font-size: 15px;
}
.due-cal-prev, .due-cal-next {
  min-width: 36px; min-height: 36px;
  font-size: 20px; line-height: 1;
  padding: 0;
}
.due-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.due-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.due-cal-cell {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.due-cal-cell.empty { cursor: default; pointer-events: none; }
.due-cal-cell.day:hover { background: #0ea5e922; color: var(--accent); }
.due-cal-cell.today { box-shadow: inset 0 0 0 1px var(--accent); }
.due-cal-cell.selected {
  background: var(--accent2);
  color: #0f172a;
  font-weight: 700;
}
.due-cal-cell.past { color: var(--muted); }
.due-cal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px; flex-wrap: wrap;
}
@media (max-width: 480px) {
  .due-chip { padding: 6px 12px; font-size: 13px; }
  .due-field .due-date-input { font-size: 16px; /* avoid iOS zoom */ }
  .due-cal-ym .select { font-size: 16px; }
  .due-cal-cell { min-height: 44px; font-size: 16px; }
}

/* Private work notes (sticky diary) */
.notes-panel-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.notes-panel-head .muted { color: var(--muted); }
.notes-empty {
  color: var(--muted); font-size: 13px; padding: 8px 0;
}
.sticky-notes {
  list-style: none; margin: 0; padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.sticky-notes.compact {
  grid-template-columns: 1fr;
  max-height: 220px;
  overflow: auto;
}
.sticky-notes.overview {
  grid-template-columns: 1fr;
}
.sticky-note {
  background: linear-gradient(180deg, #fef9c3 0%, #fde68a 100%);
  color: #422006;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 6px #00000033, inset 0 1px 0 #fff8;
  border: 1px solid #f59e0b55;
  min-height: 72px;
}
.sticky-note .sticky-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 11px; color: #78350f; margin-bottom: 6px;
}
.sticky-note .sticky-meta .when { opacity: .85; }
.sticky-note .sticky-meta .spacer { flex: 1; }
.sticky-note .sticky-meta .btn {
  padding: 1px 6px; font-size: 11px;
  color: #78350f; border-color: #b4530955; background: #fff8;
}
.sticky-note .sticky-meta .btn:hover { background: #fff; }
.sticky-note .sticky-body {
  font-size: 13px; white-space: pre-wrap; word-break: break-word;
  line-height: 1.45;
}
.sticky-scope {
  background: #b4530922 !important;
  color: #78350f !important;
  font-size: 11px;
}
.notes-block {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.notes-block h4 { margin: 0 0 8px; font-size: 14px; }
.notes-block .sticky-note {
  /* keep yellow sticky look inside dark modal */
}



/* @-mention autocomplete (card comments) */
.comment-compose .mention-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.comment-compose .mention-wrap .input {
  width: 100%;
}
.mention-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 50;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  max-height: min(220px, 40vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg2, #0f172a);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mention-item:hover,
.mention-item.active {
  background: #0ea5e922;
}
.mention-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mention-user {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
