/* ================================================================ tokens */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --column: #ebecf0;
  --text: #172b4d;
  --muted: #6b778c;
  --border: #dfe1e6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --hover: rgba(9, 30, 66, 0.06);
  --shadow: 0 1px 2px rgba(9, 30, 66, 0.18);
  --shadow-lg: 0 12px 32px rgba(9, 30, 66, 0.25);
  --radius: 8px;
  --c-red: #ef4444; --c-orange: #f97316; --c-yellow: #eab308; --c-green: #22c55e; --c-teal: #14b8a6;
  --c-blue: #3b82f6; --c-purple: #a855f7; --c-pink: #ec4899; --c-gray: #64748b;
  --pill-text: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #1c1f26; --surface-2: #22262e; --column: #16181d; --text: #e6e8eb; --muted: #9aa3b2;
    --border: #2c313a; --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: rgba(59, 130, 246, 0.18);
    --hover: rgba(255, 255, 255, 0.06); --shadow: 0 1px 2px rgba(0, 0, 0, 0.5); --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
    --pill-text: #0f1115;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #1c1f26; --surface-2: #22262e; --column: #16181d; --text: #e6e8eb; --muted: #9aa3b2;
  --border: #2c313a; --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: rgba(59, 130, 246, 0.18);
  --hover: rgba(255, 255, 255, 0.06); --shadow: 0 1px 2px rgba(0, 0, 0, 0.5); --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
  --pill-text: #0f1115;
  color-scheme: dark;
}

/* ================================================================ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
kbd { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.pad { padding: 12px; }
[hidden] { display: none !important; }

/* ================================================================ forms & buttons */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
input[type="file"] { padding: 5px; }
input:disabled, select:disabled, textarea:disabled { opacity: .7; cursor: not-allowed; }
textarea { resize: vertical; }
label { display: block; font-weight: 500; margin-bottom: 12px; }
label > input, label > select, label > textarea, label > .row { margin-top: 4px; font-weight: 400; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; white-space: nowrap; cursor: pointer; }
.checks { display: grid; gap: 8px; }
.helptext { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; padding: 7px 14px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); background: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
button.link.small { font-size: 12px; }
.icon-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer; flex: none;
  width: 28px; height: 28px; border-radius: 6px; font-size: 20px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.tiny { width: 22px; height: 22px; }

.form > div { margin-bottom: 14px; }
.form > div > label, .form section > div > label { margin-bottom: 4px; }
.form .helptext ul { margin: 4px 0 0; padding-left: 18px; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: 4px 0; font-size: 13px; }
.form div:has(> input[type="checkbox"]) { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form div:has(> input[type="checkbox"]) > label { order: 2; margin: 0; }
.form div:has(> input[type="checkbox"]) > .helptext { order: 3; flex-basis: 100%; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form > input, .inline-form > select { width: auto; flex: 1 1 180px; }
.inline-form.compact > select { flex: 0 0 auto; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segmented label { margin: 0; font-weight: 500; }
.segmented input { display: none; }
.segmented span, .segmented a { display: block; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.segmented input:checked + span, .segmented a.on { background: var(--primary-soft); color: var(--primary); }
.segmented a:hover { text-decoration: none; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, monospace; font-size: 12px; }

/* ================================================================ topbar */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 2px; }
.mainnav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.mainnav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.mainnav a.active { color: var(--primary); background: var(--primary-soft); }
.global-search { flex: 1; max-width: 360px; margin-left: auto; }
.global-search input { padding: 6px 10px; background: var(--surface-2); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.bell-btn { position: relative; width: 36px; height: 36px; }
.bell-count {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.notif-panel { width: 360px; max-width: calc(100vw - 24px); }
.notif-head, .notif-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
.notif-head { border-bottom: 1px solid var(--border); }
.notif-foot { border-top: 1px solid var(--border); }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.notif-list a { display: flex; gap: 10px; padding: 10px 14px; color: var(--text); }
.notif-list a:hover { background: var(--hover); text-decoration: none; }
.notif-list li.unread a { background: var(--primary-soft); }
.notif-body { display: flex; flex-direction: column; gap: 2px; }
.notif-icon { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.k-assigned { background: var(--c-blue); } .k-mention { background: var(--c-purple); } .k-comment { background: var(--c-teal); }
.k-due_soon { background: var(--c-yellow); } .k-due_today { background: var(--c-orange); } .k-overdue { background: var(--c-red); }
.k-completed { background: var(--c-green); } .k-added { background: var(--c-gray); }
.avatar-btn { background: none; border: 0; padding: 2px; cursor: pointer; border-radius: 50%; }
.menu-panel { width: 220px; padding: 6px; }
.menu-panel a, .menu-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-panel a:hover, .menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-panel form { margin: 0; }
.menu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ================================================================ general layout */
.container { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }
.narrow { max-width: 600px; margin: 0 auto; }
.narrow.wide { max-width: 760px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 12px; }
summary.section-title { cursor: pointer; }
.messages { max-width: 1100px; margin: 12px auto 0; padding: 0 20px; }
.msg { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); }
.msg-success { border-left: 4px solid var(--ok); }
.msg-error { border-left: 4px solid var(--danger); }
.msg-close { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.panel > summary { cursor: pointer; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-weight: 500; white-space: nowrap; }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.count { font-size: 12px; color: var(--muted); background: var(--hover); padding: 0 7px; border-radius: 999px; font-weight: 500; }
.count.over { background: var(--danger); color: #fff; }

/* colour helpers: lc-* (labels/dots/swatches) and bc-* (board accents) */
.lc-red { --lc: var(--c-red); } .lc-orange { --lc: var(--c-orange); } .lc-yellow { --lc: var(--c-yellow); }
.lc-green { --lc: var(--c-green); } .lc-teal { --lc: var(--c-teal); } .lc-blue { --lc: var(--c-blue); }
.lc-purple { --lc: var(--c-purple); } .lc-pink { --lc: var(--c-pink); } .lc-gray { --lc: var(--c-gray); } .lc-none { --lc: var(--border); }
.bc-red { --bc: var(--c-red); } .bc-orange { --bc: var(--c-orange); } .bc-yellow { --bc: var(--c-yellow); }
.bc-green { --bc: var(--c-green); } .bc-teal { --bc: var(--c-teal); } .bc-blue { --bc: var(--c-blue); }
.bc-purple { --bc: var(--c-purple); } .bc-pink { --bc: var(--c-pink); } .bc-gray { --bc: var(--c-gray); }
.label-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lc); margin-right: 3px; vertical-align: middle; }
.label-pill {
  display: inline-flex; align-items: center; gap: 3px; min-width: 32px; min-height: 18px;
  padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 16px;
  background: var(--lc); color: var(--pill-text); border: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.label-chip { display: inline-block; padding: 2px 10px; border-radius: 4px; background: var(--lc); color: var(--pill-text); font-size: 12px; font-weight: 600; }
.swatch { display: inline-block; width: 28px; height: 22px; border-radius: 5px; background: var(--lc); border: 2px solid transparent; cursor: pointer; }
.swatch.selected { outline: 2px solid var(--text); outline-offset: 2px; }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.swatch-radio { margin: 0; }
.swatch-radio input { position: absolute; opacity: 0; }
.swatch-radio input:checked + .swatch { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch-radio input:focus-visible + .swatch { outline: 2px solid var(--primary); outline-offset: 2px; }
.color-select { width: 110px !important; flex: none !important; border-left: 8px solid var(--lc); }
.prio { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.prio-2 { color: var(--c-yellow); } .prio-3 { color: var(--c-orange); } .prio-4 { color: var(--c-red); }

/* avatars */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; background: var(--c-gray); user-select: none; }
.avatar-sm { width: 22px; height: 22px; font-size: 9px; }
.avatar-md { width: 30px; height: 30px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.unassigned, .avatar.more { background: var(--hover); color: var(--muted); }
.avatars { display: inline-flex; margin-left: auto; }
.avatars .avatar + .avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.member { display: inline-flex; align-items: center; gap: 8px; }

/* due badges */
.badge.due.soon { background: color-mix(in srgb, var(--c-yellow) 28%, transparent); color: var(--text); }
.badge.due.overdue { background: var(--danger); color: #fff; }
.badge.due.done { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.due.empty { background: transparent; }

/* ================================================================ dialogs, toast, menus */
dialog { padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(9, 30, 66, 0.5); }
.ui-dialog { width: min(440px, calc(100vw - 32px)); padding: 20px; }
.ui-dialog h3 { font-size: 16px; margin-bottom: 8px; }
.ui-dialog p { margin: 0 0 12px; color: var(--muted); }
.ui-dialog form > input { margin-bottom: 4px; }
.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { white-space: nowrap; width: 45%; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; gap: 14px; align-items: center;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
}
.toast .link { color: var(--bg); font-weight: 700; text-decoration: underline; }
.menu {
  position: absolute; z-index: 50; width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px;
}
.menu button, .menu a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 4px; color: var(--text); font: inherit; cursor: pointer; }
.menu button:hover, .menu a:hover { background: var(--hover); text-decoration: none; }
.menu .danger { color: var(--danger); }
.mention-box { position: fixed; z-index: 200; list-style: none; margin: 0; padding: 4px; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); }
.mention-box li { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.mention-box li.active, .mention-box li:hover { background: var(--primary-soft); }
.mention { color: var(--primary); background: var(--primary-soft); border-radius: 4px; padding: 0 3px; font-weight: 500; }

/* ================================================================ auth */
.auth-page main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); padding: 32px; border-radius: 12px; box-shadow: var(--shadow-lg); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card > p { margin-top: 0; margin-bottom: 20px; }
.auth-card .small { margin: 16px 0 0; text-align: center; }

/* ================================================================ boards list */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.board-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); border-top: 4px solid var(--bc, var(--primary)); transition: transform .1s ease, box-shadow .1s ease;
}
.board-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.board-tile.is-archived { opacity: .65; }
.tile-link { display: flex; flex-direction: column; gap: 8px; min-height: 104px; padding: 14px 40px 14px 16px; color: var(--text); }
.tile-link:hover { text-decoration: none; }
.board-tile-name { font-weight: 600; font-size: 16px; }
.tile-desc { flex: 1; }
.star-form { position: absolute; top: 10px; right: 8px; margin: 0; }
.star-form.inline { position: static; }
.star-btn { background: none; border: 0; padding: 4px; cursor: pointer; color: var(--muted); fill: none; border-radius: 4px; display: inline-flex; }
.star-btn:hover { color: var(--c-yellow); background: var(--hover); }
.star-btn.on { color: var(--c-yellow); }
.star-btn.on svg { fill: var(--c-yellow); }
.import-panel { margin-top: 28px; }
.archived-boards { margin-top: 12px; }

/* ================================================================ lists (my work, search, notifications, archive) */
.group { margin-bottom: 24px; }
.group h2 { display: flex; align-items: center; gap: 8px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-row, .list-row, .notif-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.card-row:last-child, .list-row:last-child, .notif-row:last-child { border-bottom: 0; }
.card-row:hover, .notif-row:hover { background: var(--hover); text-decoration: none; }
.card-row .badge.due { min-width: 64px; justify-content: center; }
.card-row.is-archived, .card-row.is-done { opacity: .6; }
.row-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; color: var(--text); }
a.row-main:hover { text-decoration: none; }
.row-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.notif-row.unread { background: var(--primary-soft); }
.notif-row.unread .row-title { font-weight: 600; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 18px 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { opacity: .5; }
.row-actions { display: flex; gap: 12px; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }

.member-list, .label-admin { list-style: none; padding: 0; margin: 0 0 14px; }
.member-list li, .label-admin li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 8px; flex-wrap: wrap; }
.member-list form, .label-admin form { margin: 0; }
.label-admin form { width: 100%; }

.activity-feed { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.activity-feed li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.activity-feed li:last-child { border-bottom: 0; }
.activity-feed .day-sep { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 14px; }
.act-text { flex: 1; min-width: 0; }
.act-text a { color: var(--text); }

/* ================================================================ calendar */
.cal-nav h1 { min-width: 200px; text-align: center; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal-dow { background: var(--surface-2); padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.cal-day { background: var(--surface); min-height: 110px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: var(--surface-2); }
.cal-day.other .cal-date { color: var(--muted); }
.cal-date { font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.cal-day.today .cal-date { background: var(--primary); color: #fff; border-radius: 999px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-card { display: block; font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--hover); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-card:hover { background: var(--primary-soft); text-decoration: none; }
.cal-card.overdue { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.cal-card.is-done { opacity: .55; text-decoration: line-through; }
.cal-more { color: var(--muted); }

/* ================================================================ board */
.board-main { padding: 14px 16px 0; height: calc(100vh - 52px); display: flex; flex-direction: column; border-top: 3px solid var(--bc, transparent); }
.board-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.board-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.board-title h1 { margin: 0; font-size: 20px; }
.board-desc { margin: 2px 0 0; max-width: 640px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding: 6px 8px; border-radius: 8px; }
.filter-bar.active { background: var(--primary-soft); }
.filter-bar input[type="search"] { width: 220px; padding: 5px 10px; }
.filter-bar select { width: auto; padding: 5px 8px; font-size: 13px; }
#board { flex: 1; min-height: 0; }
.columns { display: flex; gap: 12px; align-items: flex-start; height: 100%; overflow-x: auto; padding-bottom: 16px; }

.column { flex: 0 0 284px; max-height: 100%; display: flex; flex-direction: column; background: var(--column); border-radius: 10px; }
.column.over-limit { box-shadow: inset 0 0 0 2px var(--danger); }
.column-head { display: flex; align-items: center; gap: 4px; padding: 8px 6px 4px 6px; cursor: grab; }
.column-head h2 { flex: 1; margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.collapse-btn { width: 24px; height: 24px; }
.done-mark { color: var(--ok); display: inline-flex; }
.column.collapsed { flex: 0 0 44px; align-items: center; padding: 10px 0; cursor: pointer; gap: 10px; min-height: 160px; }
.column.collapsed h2 { writing-mode: vertical-rl; font-size: 14px; margin: 0; white-space: nowrap; }
.column.collapsed:hover { background: var(--hover); }
.cards { flex: 1; overflow-y: auto; padding: 4px 8px; min-height: 16px; display: flex; flex-direction: column; gap: 8px; }

.card { position: relative; background: var(--surface); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--shadow); cursor: pointer; user-select: none; }
.card:hover { box-shadow: 0 0 0 1px var(--primary); }
.card:focus { outline: none; }
.card.selected, .card:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.card.filtered { display: none; }
.card.completed .card-title { color: var(--muted); }
.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.card-labels .label-pill { font-size: 10px; min-height: 16px; line-height: 14px; padding: 1px 6px; }
.card-title { word-wrap: break-word; white-space: pre-wrap; }
.done-tick { color: var(--ok); margin-right: 4px; vertical-align: -1px; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.card-num { font-size: 11px; color: var(--muted); }
.icon-meta { display: inline-flex; align-items: center; gap: 3px; }
.icon-meta.complete { color: var(--ok); }
.card-ghost { opacity: .35; }
.card-drag { transform: rotate(2deg); box-shadow: var(--shadow-lg); }
.add-card, .add-column { padding: 6px 8px 10px; }
.add-card textarea { margin-bottom: 2px; }
.add-btn { width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: 8px; color: var(--muted); cursor: pointer; font: inherit; }
.add-btn:hover { background: var(--hover); color: var(--text); }
.add-column { background: transparent; border: 2px dashed var(--border); }

/* ================================================================ card dialog */
.card-dialog { width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.card-dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog-head { display: flex; gap: 8px; align-items: center; padding: 14px 14px 6px 20px; }
.card-number { font-weight: 600; }
.title-input { font-size: 18px; font-weight: 600; border-color: transparent; padding: 6px 8px; background: transparent; }
.title-input:hover:not(:disabled) { border-color: var(--border); }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 22px; padding: 8px 20px 16px; overflow-y: auto; }
.dialog-main { min-width: 0; }
.cf-section { margin-bottom: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.section-head h3 { margin: 0; }
.label-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.label-chips:empty { display: none; }
.md { line-height: 1.55; word-wrap: break-word; }
#cf-desc-view { padding: 8px 10px; border-radius: 6px; background: var(--surface-2); min-height: 44px; cursor: text; }
.readonly #cf-desc-view { cursor: default; }
.md p { margin: 0 0 8px; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md code { font: 12px ui-monospace, Menlo, monospace; background: var(--hover); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--hover); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--muted); }
.md table { border-collapse: collapse; margin-bottom: 8px; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; }
.md h1, .md h2, .md h3 { font-size: 15px; margin: 8px 0 6px; }
.progress { height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; margin-bottom: 8px; }
.progress span { display: block; height: 100%; background: var(--primary); transition: width .2s; }
.progress.complete span { background: var(--ok); }
.checklist { list-style: none; margin: 0 0 8px; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 6px; }
.checklist li:hover { background: var(--hover); }
.check-text { flex: 1; word-break: break-word; }
.check-text.done { text-decoration: line-through; color: var(--muted); }
.grip { color: var(--muted); cursor: grab; display: inline-flex; }
.inline-edit { flex: 1; padding: 3px 6px; }
.attachments { list-style: none; margin: 0 0 8px; padding: 0; }
.attachments li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.thumb { flex: none; width: 56px; height: 42px; border-radius: 6px; overflow: hidden; background: var(--hover); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-body a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btn { margin: 0; }
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 10px; text-align: center; color: var(--muted); font-size: 12px; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }
.comment-new { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.comments, .history { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.comment-actions { margin-left: auto; display: inline-flex; gap: 10px; }
.comment-body { margin-top: 2px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.comment-edit textarea { margin: 4px 0; }
.history li { padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.history li:last-child { border-bottom: 0; }
.dialog-side label { margin-bottom: 14px; }
.dialog-side .row input { flex: 1; }
.field-label { font-weight: 500; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: baseline; }
.assignee-picker, .label-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 2px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 12px; }
.chip:not(.on) .avatar { filter: grayscale(1); opacity: .55; }
.chip.on { border-color: var(--primary); background: var(--primary-soft); }
.chip:disabled { cursor: default; }
.label-picker .label-pill { cursor: pointer; opacity: .45; font-size: 12px; padding: 3px 8px; }
.label-picker .label-pill.on { opacity: 1; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--lc); }
.label-picker .label-pill:disabled { cursor: default; }
#cf-watch { margin-bottom: 8px; }
#cf-watch.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.side-actions { display: grid; gap: 6px; margin-bottom: 12px; }
.dialog-foot { display: flex; gap: 8px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
.card-dialog.readonly .edit-only { display: none !important; }
#cf-dirty { color: var(--warn); font-weight: 500; }

/* ================================================================ mobile */
@media (max-width: 860px) {
  .global-search { display: none; }
}
@media (max-width: 700px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand span { display: none; }
  .mainnav a { padding: 6px 7px; font-size: 13px; }
  .container { padding: 18px 12px; }
  .board-main { padding: 10px 10px 0; }
  .filter-bar input[type="search"] { width: 100%; }
  .column { flex-basis: 85vw; }
  .dialog-body { grid-template-columns: 1fr; }
  .calendar { font-size: 11px; }
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-card { padding: 1px 3px; font-size: 10px; }
  .cal-dow { padding: 4px; font-size: 10px; }
  .card-row { flex-wrap: wrap; }
}
