.filter-token{position:relative}
.filter-tag[data-tag]{cursor:grab;user-select:none}
.filter-tag[data-tag]:active{cursor:grabbing}
.tag-name-editor{box-sizing:border-box;flex:none;min-width:90px;max-width:330px;margin:0;padding:4px 7px;border:1px solid #b7c5cb;border-radius:4px;outline:none;background:#fff;font:inherit;font-size:11px;line-height:1.5;color:#37352f}
.tag-name-editor[aria-invalid=true],.tag-row input[aria-invalid=true]{border-color:#bb8175;background:#fff8f5}
.tag-row[data-tag-row]{position:relative;cursor:grab;touch-action:pan-y}
.tag-row[data-tag-row] input{cursor:text}
.tag-dragging{opacity:.4}
.tag-drop-before:before,.tag-drop-after:after{content:"";position:absolute;pointer-events:none;border-radius:2px;background:#7c96a4}
.filter-token.tag-drop-before:before{left:-5px;top:2px;bottom:2px;width:2px}
.filter-token.tag-drop-after:after{right:-5px;top:2px;bottom:2px;width:2px}
.tag-row.tag-drop-before:before{left:0;right:0;top:0;height:2px}
.tag-row.tag-drop-after:after{left:0;right:0;bottom:0;height:2px}
.tag-row[tabindex]:focus-visible{outline:2px solid #a6becd;outline-offset:3px;border-radius:4px}

.filter-tag[data-tag]{touch-action:none}
.tag-drag-preview{position:fixed;z-index:2001;pointer-events:none;padding:7px 11px;border:1px solid #bdc8ce;border-radius:5px;background:#fff;color:#4e4b44;font:12px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;box-shadow:0 4px 14px #37352f14;white-space:nowrap}
.tag-list.tag-sorting .color-control{width:0;flex-basis:0;opacity:0;pointer-events:none}

/* One quiet colour family across filters, cards and historical records. */
.filter-token,.card-tag,.tag-color-swatch{
  --tag-ink:color-mix(in srgb,var(--tag-color,#687786) 34%,#24282f);
  --tag-surface:color-mix(in srgb,var(--tag-color,#687786) var(--tag-fill,10%),#fff);
  --tag-border:color-mix(in srgb,var(--tag-color,#687786) var(--tag-edge,22%),#fff);
}
.tag-list{gap:8px}
.filter-token{border-radius:8px}
.filter-token .filter-tag{
  min-height:30px;gap:7px;padding:5px 10px;border:1px solid var(--tag-border);border-radius:8px;
  color:var(--tag-ink);background:var(--tag-surface);font-size:11px;line-height:18px;font-weight:500;
  transition:background .15s ease,border-color .15s ease;
}
.filter-token .tag-dot{width:6px;height:6px;background:var(--tag-color);border-radius:50%}
.filter-token .filter-tag-count{min-width:1ch;margin-left:1px;font-size:10px;font-weight:450;font-variant-numeric:tabular-nums;text-align:right}
.filter-token .filter-tag::after{
  content:"";box-sizing:border-box;flex:0 0 9px;width:9px;height:5px;margin-left:2px;
  border-left:1.5px solid currentColor;border-bottom:1.5px solid currentColor;
  transform:translateY(-1px) rotate(-45deg);opacity:0;transition:opacity .15s ease;
}
.filter-token .filter-tag:hover{background:color-mix(in srgb,var(--tag-color) calc(var(--tag-fill,10%) + 5%),#fff);border-color:color-mix(in srgb,var(--tag-color) calc(var(--tag-edge,22%) + 8%),#fff)}
/* Selection uses the check mark; emphasis belongs to matching project cards. */
.filter-token .filter-tag.active,.filter-token .filter-tag.active:hover{background:var(--tag-surface);border-color:var(--tag-border);color:var(--tag-ink)}
.filter-token .filter-tag.active::after{opacity:1}
.filter-tag:focus-visible{outline:2px solid var(--tag-color);outline-offset:2px}

/* The existing colour control sits on the dot, so hovering never shifts neighbours. */
.filter-token .color-control,.filter-token:hover .color-control,.filter-token:focus-within .color-control{
  position:absolute;left:3px;top:50%;transform:translateY(-50%);width:22px;height:22px;flex-basis:22px;
  border-radius:50%;background:transparent;opacity:0;
}
.filter-token:hover .color-control,.filter-token:focus-within .color-control{opacity:1}
.board-reader .filter-token .color-control{display:none!important}
.filter-token .preset-color-trigger{border-radius:50%}
.filter-token .preset-color-trigger:hover,.filter-token .preset-color-trigger[aria-expanded=true]{background:color-mix(in srgb,var(--tag-color) 24%,#fff)}
.filter-token .preset-color-dot{width:6px!important;height:6px!important;border:0;border-radius:50%}
.filter-token:has(.tag-name-editor) .color-control,.tag-list.tag-sorting .color-control{opacity:0;pointer-events:none}
.tag-name-editor{min-height:30px;padding:5px 10px;border-color:var(--tag-color,#9aa99e);border-radius:8px;font-size:11px;line-height:18px;color:var(--tag-ink,#37352f);box-shadow:0 0 0 2px var(--tag-surface,#f3f4f1)}

.card-tag{
  display:inline-flex;align-items:center;gap:5px;box-sizing:border-box;min-height:22px;padding:2px 7px;
  border:1px solid var(--tag-border);border-radius:6px;background:var(--tag-surface);color:var(--tag-ink);
  font-size:10.5px;line-height:16px;font-weight:450;vertical-align:middle;
}
.card-tag[style*="--tag-color"]::before{content:"";flex:0 0 4px;width:4px;height:4px;border-radius:50%;background:var(--tag-color)}
.card-tags{align-items:center}
.detail-tags .card-tag{position:relative;min-height:27px;padding:3px 7px 3px 23px;gap:5px;font-size:11px;line-height:19px}
.detail-tags .card-tag::before{display:none}
.detail-tags .card-tag .color-control{position:absolute;left:4px;top:50%;transform:translateY(-50%);width:18px;height:20px;opacity:1;background:transparent}
.detail-tags .card-tag .preset-color-trigger{min-width:18px;min-height:20px;border-radius:50%;opacity:1}
.detail-tags .card-tag .preset-color-dot{width:6px!important;height:6px!important;border:0;border-radius:50%}
.detail-tags .card-tag button[data-detach-tag]{padding:0;width:14px;min-height:18px;margin-left:1px;border-radius:4px;color:var(--tag-ink);font-size:14px}
.detail-tags .card-tag button[data-detach-tag]:hover{background:color-mix(in srgb,var(--tag-color) 20%,#fff)}
.tag-drag-preview{border-radius:8px;padding:6px 10px}
.preset-color-menu.tag-color-menu{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 8px;
  width:min(266px,calc(100vw - 16px));padding:7px;
}
.tag-color-level{padding:4px 7px 5px;color:#6a6c73;font-size:11px;font-weight:600}
.tag-color-current{grid-column:1/-1;border-bottom:1px solid #eceae7;padding-bottom:4px}
.tag-color-menu .preset-color-option{gap:6px;padding:3px 5px!important}
.tag-color-swatch{
  display:inline-flex;align-items:center;gap:5px;
  padding:2px 7px;border:1px solid var(--tag-border);border-radius:5px;
  background:var(--tag-surface);color:var(--tag-ink);white-space:nowrap;
}
.tag-color-swatch::before{content:"";width:5px;height:5px;border-radius:50%;background:var(--tag-color)}
@media(hover:none){.filter-token .color-control{opacity:1}.filter-token .filter-tag{min-height:34px}}
@media(prefers-reduced-motion:reduce){.filter-token .filter-tag,.filter-token .filter-tag::after{transition:none}}

/* Keep the canvas quiet on entry; filters stay available without an extra dialog. */
.app-shell>.filterbar{flex-basis:auto;height:auto;min-height:40px;flex-wrap:wrap;gap:7px 14px;align-items:center}
.filterbar .tag-disclosure{display:inline-flex;align-items:center;gap:6px;padding:5px 0;color:#646a73;font-size:11px;line-height:20px;cursor:pointer}
.tag-disclosure svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;transition:transform .15s ease}
.tag-disclosure[aria-expanded=true] svg{transform:rotate(90deg)}
.filterbar .filter-controls{margin-left:auto;width:auto;min-height:0;padding-top:0}
.filterbar .tag-panel{display:flex;align-items:flex-start;gap:10px;flex:0 0 100%;min-width:0;padding:2px 0 5px}
.filterbar .tag-panel .tag-list{flex:1;order:0;flex-wrap:wrap;overflow:auto;max-height:124px;gap:8px;min-height:0}
.filterbar .tag-manage{flex:none;min-width:28px;height:30px;padding:3px;color:#8f959e;font-size:17px}
.selected-tag-count{padding:0 5px;border-radius:4px;background:#f2f3f5;color:#4e5969;font-size:10px;font-variant-numeric:tabular-nums}
@media(prefers-reduced-motion:reduce){.tag-disclosure svg{transition:none}}

/* Project assignment stays separate from editing the shared tag catalog. */
.detail-tags .project-tag-chips{display:contents}
.project-tag-chips .card-tag:not(:has(.color-control)){padding-inline:7px}
.project-tag-chips .card-tag:not(:has(.color-control))::before{display:block}
.detail-tags .project-tag-trigger{display:inline-flex;align-items:center;gap:4px;min-height:28px;padding:3px 7px;border:1px solid transparent;border-radius:5px;background:transparent;color:#6f6c64;font:inherit;font-size:12px;line-height:18px;cursor:pointer}
.detail-tags .project-tag-trigger:is(:hover,[aria-expanded="true"]){background:#f3f2ef;color:#37352f}
.project-tag-trigger svg{width:13px;height:13px;flex:none}
.project-tag-picker{position:fixed;inset:auto;z-index:2400;box-sizing:border-box;display:flex;flex-direction:column;width:320px;min-width:0;margin:0;padding:7px;border:1px solid #e6e4df;border-radius:8px;background:#fff;color:#37352f;box-shadow:0 5px 21px #22201a19;font:13px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;overflow:hidden}
.project-tag-search{display:flex;align-items:center;gap:8px;flex:none;min-height:36px;margin-bottom:5px;padding:0 9px;border:1px solid #ebe9e5;border-radius:5px;background:#f8f8f6;color:#78766f}
.project-tag-search:focus-within{border-color:#a5b7cf;background:#fff}
.project-tag-search svg{width:15px;height:15px;flex:none}
.project-tag-picker .project-tag-search input{flex:1;min-width:0;width:100%;min-height:33px;padding:0;border:0;border-radius:0;background:transparent;color:#37352f;font:inherit;outline:none;box-shadow:none}
.project-tag-picker .project-tag-search input::placeholder{color:#77756e}
.project-tag-options{min-height:0;overflow-y:auto;overscroll-behavior:contain}
.project-tag-picker .project-tag-option{display:grid;grid-template-columns:14px minmax(0,1fr) 16px;align-items:center;gap:8px;width:100%;min-height:33px;padding:5px 8px;border:0;border-radius:5px;background:transparent;color:#37352f;text-align:left;font:inherit;cursor:pointer}
.project-tag-picker .project-tag-option:is(:hover,.is-active){background:#f3f2ef}
.project-tag-option>span:nth-child(2){overflow-wrap:anywhere}
.project-tag-dot{width:8px;height:8px;border-radius:50%;justify-self:center}
.project-tag-check{display:grid;place-items:center;color:#51696c;visibility:hidden}
.project-tag-check svg{width:14px;height:14px;stroke-width:1.75}
.project-tag-option[aria-selected="true"] .project-tag-check{visibility:visible}
.project-tag-picker .project-tag-create{color:#4c6076}
.project-tag-create>svg{width:14px;height:14px}
.project-tag-picker .project-tag-create:not(:first-child){position:relative;margin-top:4px}
.project-tag-create:not(:first-child)::before{content:"";position:absolute;top:-3px;left:8px;right:8px;border-top:1px solid #efede8}
.project-tag-picker .project-tag-empty{margin:0;padding:9px 8px;color:#75726a;font-size:12px}
.project-tag-picker footer{display:flex;align-items:center;justify-content:space-between;flex:none;gap:12px;margin-top:5px;padding:6px 1px 0 8px;border-top:1px solid #efede9;color:#77736a;font-size:11px;font-variant-numeric:tabular-nums}
.project-tag-picker .project-tag-done{min-height:25px;padding:3px 8px;border-radius:4px;background:#f4f3f0;color:#4d4942;font:inherit;cursor:pointer}
.project-tag-picker .project-tag-done:hover{background:#eae8e3}
@media(max-width:760px),(pointer:coarse){
  .detail-tags .project-tag-trigger{min-height:35px}
  .project-tag-picker .project-tag-option{min-height:41px}
  .project-tag-picker .project-tag-search input{min-height:38px;font-size:16px}
  .project-tag-picker .project-tag-done{min-height:34px;padding-inline:11px}
}
