/* ============================================================ ClickDown */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f1f2f5;
  --border: #e4e6eb;
  --border-strong: #d3d6dd;
  --text: #1f2329;
  --text-dim: #6b7280;
  --text-faint: #9aa1ad;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.12);
  --danger: #e05252;
  --danger-soft: rgba(224, 82, 82, 0.1);
  --shadow: 0 8px 30px rgba(15, 20, 40, 0.12);
  --shadow-sm: 0 2px 8px rgba(15, 20, 40, 0.07);
  --radius: 10px;
  --sidebar-w: 250px;
  --row-h: 42px;
}

:root[data-theme="dark"] {
  --bg: #16181d;
  --panel: #1e2128;
  --panel-2: #262a33;
  --border: #2e333d;
  --border-strong: #3b414d;
  --text: #e6e8ec;
  --text-dim: #9aa1ad;
  --text-faint: #6b7280;
  --accent: #6d9bf5;
  --accent-soft: rgba(109, 155, 245, 0.16);
  --danger: #e86868;
  --danger-soft: rgba(232, 104, 104, 0.14);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; background: none; border: none; padding: 0; }

#app { height: 100%; }

/* ---------------------------------------------------------------- layout */

.shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
}

.logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  flex: 0 0 28px;
}

.sidebar-head .app-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }

.sidebar-section-title {
  padding: 14px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-lists { flex: 1; overflow-y: auto; padding-bottom: 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--text-dim);
  text-align: left;
  font-weight: 500;
  user-select: none;
  -webkit-user-select: none;
}

.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .dot { width: 8px; height: 8px; border-radius: 3px; background: currentColor; opacity: 0.7; flex: 0 0 8px; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 11px; color: var(--text-faint); font-weight: 500; }
.nav-item.dragging { opacity: 0.35; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border-radius: 8px;
  text-align: left;
}
.user-chip:hover { background: var(--panel-2); }
.user-chip .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.user-chip .meta .n { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta .e { display: block; font-size: 11.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.avatar.sm { width: 24px; height: 24px; flex-basis: 24px; font-size: 10.5px; }
.avatar.empty { background: transparent; border: 1.5px dashed var(--border-strong); color: var(--text-faint); }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--text-dim);
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  min-height: 57px;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hamburger { display: none; }

.view-switch {
  display: flex;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 3px;
  margin-left: 10px;
}
.view-switch button {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-switch button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.view-switch svg { width: 14px; height: 14px; }

.topbar .spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------------------------------------------------------------- content */

.content {
  flex: 1;
  overflow: auto;
  padding: 16px 18px 90px;
  -webkit-overflow-scrolling: touch;
}

.empty-state {
  margin: 60px auto;
  max-width: 380px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state .big { font-size: 42px; margin-bottom: 10px; }
.empty-state h2 { color: var(--text); font-size: 17px; margin: 0 0 6px; }
.empty-state p { margin: 0 0 18px; }

/* ---------------------------------------------------------------- table */

.group { margin-bottom: 26px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  user-select: none;
  -webkit-user-select: none;
}
.group-head .chev {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-faint);
  transition: transform 0.15s;
}
.group-head .chev:hover { background: var(--panel-2); }
.group-head.collapsed .chev { transform: rotate(-90deg); }
.group-head .count { font-size: 12px; color: var(--text-faint); font-weight: 600; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  max-width: 200px;
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.hollow { background: var(--panel-2) !important; color: var(--text-dim); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 640px;
}

table.grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: none;
  color: var(--text-faint);
  text-align: left;
  padding: 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th .th-inner {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 6px;
}
th .th-inner:hover { color: var(--text); background: var(--panel-2); }
th .th-inner .sort-ind { font-size: 10px; color: var(--accent); }
th.dragging { opacity: 0.35; }

th.col-add { width: 44px; }
td.col-add, th.col-add { text-align: center; }
th.col-spacer, td.col-spacer { padding: 0; min-width: 0; }

table.grid td {
  border-bottom: 1px solid var(--border);
  padding: 0;
  height: var(--row-h);
  vertical-align: middle;
  max-width: 340px;
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
tr.task-row.dragging td { background: var(--accent-soft) !important; opacity: 0.55; }

.cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  min-height: var(--row-h);
  cursor: pointer;
  overflow: hidden;
}
.cell .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.num { justify-content: flex-start; font-variant-numeric: tabular-nums; }
.cell .placeholder { color: var(--text-faint); }
.cell input, .cell textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
}

.cell-name { font-weight: 500; }
.row-select {
  flex: 0 0 16px;
  width: 16px;
  display: grid;
  place-items: center;
  opacity: 0;
  margin-left: -2px;
  cursor: pointer;
}
tr.task-row:hover .row-select,
.content.has-selection .row-select,
.row-select.on { opacity: 1; }
.row-select input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.task-id {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
}
tr.task-row.selected td { background: var(--accent-soft) !important; }
.cell-name .drag-dots {
  color: var(--text-faint);
  opacity: 0;
  cursor: grab;
  flex: 0 0 auto;
  touch-action: none;
  padding: 4px 2px;
  margin-left: -6px;
  border-radius: 4px;
}
tr:hover .cell-name .drag-dots { opacity: 1; }
.cell-name .open-task {
  margin-left: auto;
  opacity: 0;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px;
  border-radius: 5px;
  flex: 0 0 auto;
}
tr:hover .cell-name .open-task { opacity: 1; }
.comment-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-faint);
  flex: 0 0 auto;
}
.comment-badge svg { width: 12px; height: 12px; }

.add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px 9px 14px;
  color: var(--text-faint);
  cursor: text;
  border-top: 1px solid var(--border);
  background: var(--panel);
  border-radius: 0 0 var(--radius) var(--radius);
}
.add-row:hover { color: var(--text-dim); background: var(--panel-2); }
.add-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 0;
}

/* ---------------------------------------------------------------- kanban */

.kanban {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 20px;
  -webkit-overflow-scrolling: touch;
}

.kcol {
  flex: 0 0 280px;
  width: 280px;
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 10px;
  max-height: calc(100dvh - 160px);
  display: flex;
  flex-direction: column;
}

.kcol-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 10px;
}
.kcol-head .count { font-size: 12px; color: var(--text-faint); font-weight: 600; }

.kcol-cards { overflow-y: auto; flex: 1; min-height: 40px; display: flex; flex-direction: column; gap: 8px; }

.kcard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.kcard .t { font-weight: 600; margin-bottom: 6px; }
.kcard .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-faint); font-size: 12px; }
.kcard.dragging { opacity: 0.4; }

.kadd {
  margin-top: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 12.5px;
  text-align: left;
  width: 100%;
}
.kadd:hover { background: var(--panel); color: var(--text-dim); }

.drop-indicator {
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
  margin: 1px 0;
}
tr.drop-above td { box-shadow: inset 0 2px 0 var(--accent); }
tr.drop-below td { box-shadow: inset 0 -2px 0 var(--accent); }
th.drop-left { box-shadow: inset 2px 0 0 var(--accent); }
th.drop-right { box-shadow: inset -2px 0 0 var(--accent); }
.nav-item.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.nav-item.drop-below { box-shadow: inset 0 -2px 0 var(--accent); }
.kcol.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }

.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.95;
}

/* ---------------------------------------------------------------- popover */

#popover-layer { position: fixed; inset: 0; z-index: 400; pointer-events: none; }
#popover-layer .backdrop { position: absolute; inset: 0; pointer-events: auto; }

.popover {
  position: absolute;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 200px;
  max-width: 300px;
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
}

.popover .p-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  text-align: left;
  font-weight: 500;
}
.popover .p-item:hover { background: var(--panel-2); }
.popover .p-item.selected { background: var(--accent-soft); }
.popover .p-item.danger { color: var(--danger); }
.popover .p-sep { height: 1px; background: var(--border); margin: 5px 8px; }
.popover .p-title { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }

/* ---------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 14, 24, 0.5);
  display: grid;
  place-items: center;
  padding: 18px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 20px;
}
.modal.wide { max-width: 560px; }
.modal h2 { margin: 0 0 16px; font-size: 16px; }

.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }

.input, .form-row input[type="text"], .form-row input[type="email"], .form-row input[type="password"],
.form-row input[type="number"], .form-row select, .form-row textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus, .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row textarea { resize: vertical; min-height: 80px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-actions .left { margin-right: auto; }

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* dropdown choice editor */
.choice-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.choice-row input[type="text"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  outline: none;
}
.choice-row input[type="text"]:focus { border-color: var(--accent); }
.color-swatch {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
  padding: 0;
  position: relative;
  overflow: hidden;
}
.color-swatch input[type="color"] {
  position: absolute;
  inset: -6px;
  width: 44px;
  height: 44px;
  border: none;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}
.choice-row .rm { color: var(--text-faint); }
.choice-row .rm:hover { color: var(--danger); }

.swatch-grid { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 2px; }
.swatch-grid button {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 2px solid transparent;
}
.swatch-grid button.on { border-color: var(--text); }

/* user management table */
.u-table { width: 100%; border-collapse: collapse; }
.u-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.u-table tr:last-child td { border-bottom: none; }
.role-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--text-dim);
}
.role-tag.admin { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- task panel */

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(10, 14, 24, 0.35);
}

.task-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 260;
  width: min(460px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.18s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }

.task-panel .tp-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.tp-head .tp-id {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--panel-2);
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.tp-head textarea.tname {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1.35;
}
.tp-head textarea.tname:focus { background: var(--panel-2); }

.task-panel .tp-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(20px + env(safe-area-inset-bottom)); }

.tp-field { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 4px; border-radius: 8px; padding: 7px 8px; }
.tp-field:hover { background: var(--panel-2); }
.tp-field .k { flex: 0 0 120px; color: var(--text-faint); font-size: 12.5px; font-weight: 600; padding-top: 2px; }
.tp-field .v { flex: 1; min-width: 0; cursor: pointer; }
.tp-field .v .placeholder { color: var(--text-faint); }
.tp-field .v input, .tp-field .v textarea {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  padding: 5px 8px;
  outline: none;
}

.tp-section { margin-top: 18px; }
.tp-section > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); margin: 0 0 8px; }
.tp-section textarea.desc {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 9px 11px;
  outline: none;
  resize: vertical;
}
.tp-section textarea.desc:focus { border-color: var(--accent); }

.comment { display: flex; gap: 9px; margin-bottom: 12px; }
.comment .c-body { flex: 1; min-width: 0; }
.comment .c-meta { font-size: 11.5px; color: var(--text-faint); margin-bottom: 2px; display: flex; gap: 8px; align-items: baseline; }
.comment .c-meta .who { font-weight: 700; color: var(--text-dim); }
.comment .c-text { white-space: pre-wrap; word-break: break-word; }
.comment .c-del { opacity: 0; font-size: 11px; color: var(--danger); }
.comment:hover .c-del { opacity: 1; }

.comment-box { display: flex; gap: 8px; margin-top: 10px; }
.comment-box textarea {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  padding: 8px 10px;
  outline: none;
  resize: none;
  min-height: 38px;
}
.comment-box textarea:focus { border-color: var(--accent); }

/* ---------------------------------------------------------------- auth */

.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 28px;
}
.auth-card .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-card h1 { font-size: 19px; margin: 0; }
.auth-card .sub { color: var(--text-dim); margin: 0 0 20px; font-size: 13px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }

/* ---------------------------------------------------------------- toast */

#toast-layer {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- bulk action bar */

#bulk-bar {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 240;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--text);
  color: var(--bg);
  padding: 7px 8px 7px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: toast-in 0.16s ease-out;
  max-width: calc(100vw - 24px);
}
#bulk-bar .bb-count { margin-right: 6px; white-space: nowrap; font-size: 13px; }
#bulk-bar .bb-count b { font-size: 14px; }
#bulk-bar .bb-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
#bulk-bar .bb-btn[data-act="delete"] { background: var(--danger); color: #fff; }
#bulk-bar .bb-btn:hover { filter: brightness(1.08); }
#bulk-bar .bb-btn.ghost { background: transparent; color: var(--bg); opacity: 0.8; }
#bulk-bar .bb-btn.ghost:hover { opacity: 1; filter: none; }

/* ---------------------------------------------------------------- mobile */

.sidebar-backdrop { display: none; }

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease-out;
    box-shadow: none;
    width: min(300px, 84vw);
    flex-basis: auto;
  }
  .shell.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(10, 14, 24, 0.4);
  }
  .shell.sidebar-open .sidebar-backdrop { display: block; }

  .hamburger { display: inline-grid; }
  .topbar { padding: 10px 12px; }
  .content { padding: 12px 12px 90px; }
  .view-switch { margin-left: 0; }
  .view-switch button span.vs-label { display: none; }
  .view-switch button { padding: 6px 10px; }
  .kcol { flex-basis: 260px; width: 260px; }
  .tp-field .k { flex-basis: 96px; }
  table.grid { min-width: 560px; }
  .cell-name .drag-dots, .cell-name .open-task, .row-select { opacity: 1; }
}

/* ---------------------------------------------------------------- rich text */

a.rich-link { color: var(--accent); text-decoration: none; word-break: break-all; }
a.rich-link:hover { text-decoration: underline; }

.rich-img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 6px 0;
  cursor: zoom-in;
}

.desc-view {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  padding: 9px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.desc-view .placeholder { color: var(--text-faint); }
.paste-hint { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

/* ---------------------------------------------------------------- column resize */

th[data-col] { position: relative; }
.col-resize {
  position: absolute;
  top: 0; right: -4px; bottom: 0;
  width: 9px;
  cursor: col-resize;
  z-index: 3;
  touch-action: none;
}
.col-resize::after {
  content: '';
  position: absolute;
  top: 6px; bottom: 6px; left: 4px;
  width: 1px;
  background: transparent;
}
.col-resize:hover::after, .col-resize.resizing::after { background: var(--accent); width: 2px; }

/* ---------------------------------------------------------------- subtasks */

tr.subtask-row .cell-name { padding-left: 40px; }
tr.subtask-row .cell-name::before {
  content: '↳';
  color: var(--text-faint);
  margin-right: 2px;
}
.expand-btn {
  width: 20px; height: 20px;
  flex: 0 0 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  color: var(--text-faint);
  transition: transform 0.12s;
  margin-left: -4px;
}
.expand-btn:hover { background: var(--panel-2); color: var(--text); }
.expand-btn.open { transform: rotate(90deg); }
.sub-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-faint);
  flex: 0 0 auto;
}
.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.subtask-item:hover { background: var(--panel-2); }
.subtask-item .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtask-item .rm { opacity: 0; color: var(--text-faint); }
.subtask-item:hover .rm { opacity: 1; }
.subtask-item .rm:hover { color: var(--danger); }

/* ---------------------------------------------------------------- filter */

.filter-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 6px;
}
.p-check {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}
.p-check:hover { background: var(--panel-2); }
.p-check input { accent-color: var(--accent); }

/* ---------------------------------------------------------------- search */

.search-modal { max-width: 560px; padding: 12px; }
.search-head { display: flex; gap: 8px; align-items: center; }
.search-head input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  padding: 8px 6px;
}
.scope-chip {
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--text-dim);
  white-space: nowrap;
}
.scope-chip.on { background: var(--accent-soft); color: var(--accent); }
.search-results { max-height: 50vh; overflow-y: auto; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.search-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
}
.search-hit:hover { background: var(--panel-2); }
.search-hit .body { flex: 1; min-width: 0; }
.search-hit .body .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit .body .s { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { color: var(--text-faint); text-align: center; padding: 18px 0 10px; }

/* ---------------------------------------------------------------- chat */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}
.chat-msgs { flex: 1; overflow-y: auto; padding: 4px 2px 12px; }
.chat-msg { display: flex; gap: 10px; margin-bottom: 14px; }
.chat-msg .m-body { flex: 1; min-width: 0; }
.chat-msg .m-meta { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.chat-msg .m-meta .who { font-weight: 700; color: var(--text-dim); margin-right: 8px; }
.chat-msg .m-text { white-space: pre-wrap; word-break: break-word; }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--border);
}
.chat-input textarea {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--panel);
  padding: 9px 12px;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 140px;
}
.chat-input textarea:focus { border-color: var(--accent); }
.content.chat-mode { display: flex; flex-direction: column; padding-bottom: 12px; }

.nav-item .fa-solid { width: 16px; text-align: center; flex: 0 0 16px; opacity: 0.8; }

/* icon picker */
.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-grid button {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  border: 2px solid transparent;
  background: var(--panel-2);
  font-size: 15px;
}
.icon-grid button:hover { color: var(--text); }
.icon-grid button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.cell.overdue { color: var(--danger); font-weight: 600; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
