:root {
  --kb-purple: #6f35e5;
  --kb-purple-dark: #5f2dd1;
  --kb-bg: #f4f6fb;
  --kb-text: #26313d;
  --kb-muted: #778396;
  --kb-border: #e8ecf3;
  --kb-card-radius: 16px;
  --kb-shadow: 0 10px 26px rgba(36, 49, 66, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--kb-bg);
  color: var(--kb-text);
  font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.kb-dashboard-page { min-width: 0; overflow-x: hidden; }
.kb-dashboard {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--kb-bg);
}

.kb-dashboard__header {
  flex: 0 0 auto;
  padding: 18px 30px 0;
  background: #fff;
  border-bottom: 1px solid var(--kb-border);
}
.kb-dashboard-tabs {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 46px;
  overflow-x: auto;
  scrollbar-width: none;
}
.kb-dashboard-tabs::-webkit-scrollbar { display: none; }
.kb-dashboard-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: #758194;
  padding: 10px 2px 15px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.kb-dashboard-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
}
.kb-dashboard-tab:hover { color: var(--kb-text); }
.kb-dashboard-tab.is-active { color: var(--kb-text); }
.kb-dashboard-tab.is-active::after { background: var(--kb-purple); }

.kb-dashboard-toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
}
.kb-dashboard-search {
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 16px;
  background: #f6f7fa;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #8b96a7;
}
.kb-dashboard-search:focus-within {
  background: #fff;
  border-color: rgba(111,53,229,.28);
  box-shadow: 0 0 0 3px rgba(111,53,229,.08);
}
.kb-dashboard-search svg { width: 21px; height: 21px; fill: currentColor; flex: 0 0 auto; }
.kb-dashboard-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--kb-text);
  font-size: 14px;
}
.kb-dashboard-search input::placeholder { color: #98a1af; }

.kb-dashboard-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 48px;
  padding: 4px;
  background: #f6f7fa;
  border-radius: 12px;
}
.kb-dashboard-view-toggle button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  color: #7c8798;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.kb-dashboard-view-toggle button svg { width: 17px; height: 17px; fill: currentColor; }
.kb-dashboard-view-toggle button.is-active {
  color: var(--kb-purple);
  background: #fff;
  box-shadow: 0 2px 7px rgba(36,49,66,.08);
}

.kb-button {
  height: 48px;
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.kb-button svg { width: 19px; height: 19px; fill: currentColor; }
.kb-button--primary {
  color: #fff;
  background: var(--kb-purple);
  box-shadow: 0 8px 18px rgba(111,53,229,.22);
}
.kb-button--primary:hover { background: var(--kb-purple-dark); }

.kb-dashboard__content {
  flex: 1 1 auto;
  width: 100%;
  padding: 26px 30px 34px;
}
.kb-board-section + .kb-board-section { margin-top: 34px; }
.kb-board-section[hidden] { display: none !important; }
.kb-board-section__header {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.kb-board-section__title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kb-board-section__icon { width: 22px; height: 22px; color: #7d8999; display: inline-flex; }
.kb-board-section__icon svg { width: 100%; height: 100%; fill: currentColor; }
.kb-board-section h2 { margin: 0; font-size: 14px; line-height: 1; color: #667385; font-weight: 700; }
.kb-board-section__create {
  border: 0;
  background: transparent;
  color: var(--kb-purple);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 2px;
}
.kb-board-section__create svg { width: 17px; height: 17px; fill: currentColor; }

.kb-boards-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
.kb-dashboard[data-kb-view="list"] .kb-boards-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}

.kb-board-card {
  --kb-cover-1: #d8c4ff;
  --kb-cover-2: #efe8ff;
  --kb-accent: #7b55d8;
  min-width: 0;
  min-height: 236px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(223,228,237,.85);
  border-radius: var(--kb-card-radius);
  box-shadow: 0 3px 10px rgba(36,49,66,.04);
  position: relative;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  outline: none;
}
.kb-board-card:hover {
  transform: translateY(-2px);
  border-color: rgba(111,53,229,.13);
  box-shadow: var(--kb-shadow);
}
.kb-board-card:focus-within {
  box-shadow: 0 0 0 3px rgba(111,53,229,.15), var(--kb-shadow);
  border-color: rgba(111,53,229,.35);
}
.kb-board-card__link {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  outline: none;
}
.kb-board-card__cover {
  position: relative;
  flex: 0 0 112px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--kb-cover-1), var(--kb-cover-2));
}
.kb-board-card__cover::before,
.kb-board-card__cover::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255,255,255,.28);
  transform: rotate(-12deg);
}
.kb-board-card__cover::before { width: 62%; height: 120%; left: -17%; top: 30%; }
.kb-board-card__cover::after { width: 74%; height: 110%; right: -12%; top: 23%; background: rgba(255,255,255,.18); }
.kb-board-card__cover-mark {
  position: absolute;
  z-index: 2;
  width: 54px;
  height: 54px;
  right: 20px;
  top: 29px;
  border: 5px solid rgba(255,255,255,.7);
  border-radius: 14px;
  transform: rotate(45deg);
  opacity: .85;
}
.kb-board-card__content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 15px 13px;
}
.kb-board-card__heading { display: flex; align-items: flex-start; gap: 10px; }
.kb-board-card__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  line-height: 1.22;
  font-weight: 700;
  color: var(--kb-text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.kb-board-card__menu-button {
  position: absolute;
  z-index: 4;
  right: 10px;
  top: 124px;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #909aaa;
  cursor: pointer;
}
.kb-board-card__menu-button:hover { color: #596577; background: #f5f7fa; }
.kb-board-card__menu-button svg { width: 18px; height: 18px; fill: currentColor; }
.kb-board-card__meta { min-height: 26px; display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--kb-muted); font-size: 12px; }
.kb-board-card__location {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f4f6fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-board-card__star { width: 20px; height: 20px; color: #f3b229; }
.kb-board-card__star svg { width: 100%; height: 100%; fill: currentColor; }
.kb-board-card__footer { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kb-board-card__avatars { display: flex; align-items: center; }
.kb-board-card__avatar {
  width: 27px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--kb-accent);
  color: #fff;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .01em;
}
.kb-board-card__avatar + .kb-board-card__avatar { margin-left: -6px; }
.kb-board-card__avatar--secondary { color: #7c8798; background: #e8edf4; }
.kb-board-card__open-label { color: #9aa4b2; font-size: 11px; font-weight: 600; }

.kb-dashboard[data-kb-view="list"] .kb-board-card { min-height: 92px; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__link { flex-direction: row; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__cover { flex: 0 0 144px; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__menu-button { top: 12px; right: 12px; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__content { padding: 13px 16px; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__meta { margin-top: 4px; }
.kb-dashboard[data-kb-view="list"] .kb-board-card__footer { padding-top: 6px; }

.kb-dashboard-empty {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #8994a4;
  text-align: center;
}
.kb-dashboard-empty[hidden] { display: none; }
.kb-dashboard-empty__icon { width: 44px; height: 44px; color: #a8b1be; margin-bottom: 4px; }
.kb-dashboard-empty__icon svg { width: 100%; height: 100%; fill: currentColor; }
.kb-dashboard-empty strong { color: #697587; font-size: 16px; }
.kb-dashboard-empty span { font-size: 13px; }

.kb-dashboard-footer {
  flex: 0 0 auto;
  min-height: 58px;
  padding: 0 30px;
  border-top: 1px solid var(--kb-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #8a95a5;
  font-size: 12px;
}
.kb-dashboard-footer__actions { display: flex; align-items: center; gap: 24px; }
.kb-dashboard-footer__actions button { border: 0; background: transparent; color: #7b8798; font-size: 12px; cursor: pointer; padding: 6px 0; }
.kb-dashboard-footer__actions button:hover { color: var(--kb-purple); }
.kb-dashboard-footer__status { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.kb-dashboard-footer__dot { width: 7px; height: 7px; border-radius: 50%; background: #4caf50; box-shadow: 0 0 0 3px rgba(76,175,80,.12); }

.kb-board-menu {
  position: fixed;
  z-index: 1000;
  width: 200px;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  border: 0;
  box-shadow: 0 8px 24px rgba(38,50,56,.08);
  transform-origin: 0 0;
}
.kb-board-menu[hidden] { display: none; }
.kb-board-menu__item {
  width: 100%;
  height: 34px;
  margin: 0;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(38,50,56,.9);
  display: flex;
  align-items: center;
  text-align: left;
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease;
}
.kb-board-menu__item:hover,
.kb-board-menu__item:focus-visible {
  background: #f8f9fa;
  outline: none;
}
.kb-board-menu__icon {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(38,50,56,.3);
}
.kb-board-menu__icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}
.kb-board-menu__label {
  min-width: 0;
  flex: 1 1 auto;
  color: rgba(38,50,56,.9);
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  white-space: nowrap;
}
.kb-board-menu__divider {
  height: 16px;
  padding-top: 7px;
  pointer-events: none;
}
.kb-board-menu__divider::before {
  content: "";
  display: block;
  height: 2px;
  margin-left: -8px;
  width: calc(100% + 16px);
  background: rgba(235,237,242,.5);
}

.kb-board-card__rename-input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 31px;
  margin: -5px 0 -4px;
  padding: 4px 7px;
  border: 1px solid rgba(111,53,229,.45);
  border-radius: 6px;
  outline: 0;
  background: #fff;
  color: var(--kb-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.22;
  font-weight: 700;
  box-shadow: 0 0 0 3px rgba(111,53,229,.1);
}
.kb-board-card.is-renaming {
  transform: none;
}
.kb-board-card.is-renaming .kb-board-card__link {
  cursor: default;
}
.kb-board-card.is-renaming .kb-board-card__title {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

/* Keep five board cards across normal desktop widths. */
@media (max-width: 1120px) {
  .kb-boards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .kb-boards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Native Templates view --------------------------------------------------- */
.kb-templates-content[hidden] { display: none !important; }
.kb-template-section { width: 100%; }
.kb-template-section__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.kb-template-section__header h1 {
  margin: 0;
  color: var(--kb-text);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 800;
}
.kb-template-section__header p {
  margin: 7px 0 0;
  max-width: 620px;
  color: var(--kb-muted);
  font-size: 13px;
  line-height: 1.5;
}
.kb-template-categories {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--kb-border);
  border-radius: 12px;
  background: #fff;
  flex: 0 0 auto;
}
.kb-template-categories button {
  height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #7c8798;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.kb-template-categories button:hover { color: var(--kb-text); }
.kb-template-categories button.is-active {
  color: var(--kb-purple);
  background: #f2edff;
}

.kb-templates-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
.kb-dashboard[data-kb-view="list"] .kb-templates-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}
.kb-template-card {
  min-width: 0;
  min-height: 318px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(223, 228, 237, .9);
  border-radius: var(--kb-card-radius);
  background: #fff;
  box-shadow: 0 3px 10px rgba(36, 49, 66, .04);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.kb-template-card:hover {
  transform: translateY(-2px);
  border-color: rgba(111, 53, 229, .16);
  box-shadow: var(--kb-shadow);
}
.kb-template-card:focus-within {
  border-color: rgba(111, 53, 229, .34);
  box-shadow: 0 0 0 3px rgba(111, 53, 229, .12), var(--kb-shadow);
}
.kb-template-card__preview {
  flex: 0 0 142px;
  width: 100%;
  min-height: 142px;
  padding: 0;
  border: 0;
  overflow: hidden;
  position: relative;
  background: #e8ebf0;
  cursor: pointer;
}
.kb-template-card__image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  transition: transform .2s ease;
}
.kb-template-card:hover .kb-template-card__image { transform: scale(1.018); }
.kb-template-card__preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: rgba(35, 42, 53, .34);
  opacity: 0;
  transition: opacity .16s ease;
  font-size: 12px;
  font-weight: 800;
}
.kb-template-card__preview:hover .kb-template-card__preview-overlay,
.kb-template-card__preview:focus-visible .kb-template-card__preview-overlay { opacity: 1; }
.kb-template-card__preview-overlay svg { width: 19px; height: 19px; fill: currentColor; }
.kb-template-card__content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 15px 15px;
}
.kb-template-card__heading { min-width: 0; }
.kb-template-card__category {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f2edff;
  color: var(--kb-purple);
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .01em;
}
.kb-template-card__title {
  margin: 8px 0 0;
  color: var(--kb-text);
  font-size: 15px;
  line-height: 1.24;
  font-weight: 800;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.kb-template-card__description {
  margin: 8px 0 0;
  color: #778396;
  font-size: 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.kb-template-card__actions {
  margin-top: auto;
  padding-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.kb-template-card__secondary,
.kb-template-card__use {
  height: 36px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.kb-template-card__secondary {
  border: 1px solid #e3e7ee;
  background: #fff;
  color: #677386;
}
.kb-template-card__secondary:hover { background: #f7f8fa; color: var(--kb-text); }
.kb-template-card__use {
  border: 0;
  background: var(--kb-purple);
  color: #fff;
}
.kb-template-card__use:hover { background: var(--kb-purple-dark); }
.kb-template-card__use:disabled,
#kb-template-preview-use:disabled {
  opacity: .58;
  cursor: wait;
}

.kb-dashboard[data-kb-view="list"] .kb-template-card {
  min-height: 118px;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
}
.kb-dashboard[data-kb-view="list"] .kb-template-card__preview {
  min-height: 118px;
  height: 100%;
}
.kb-dashboard[data-kb-view="list"] .kb-template-card__content {
  padding: 13px 15px;
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(280px, 1.5fr) auto;
  grid-template-rows: auto 1fr;
  column-gap: 20px;
  align-items: center;
}
.kb-dashboard[data-kb-view="list"] .kb-template-card__heading {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.kb-dashboard[data-kb-view="list"] .kb-template-card__description {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
  -webkit-line-clamp: 3;
}
.kb-dashboard[data-kb-view="list"] .kb-template-card__actions {
  grid-column: 3;
  grid-row: 1 / span 2;
  margin: 0;
  padding: 0;
  width: 206px;
}

.kb-template-preview-modal[hidden] { display: none !important; }
.kb-template-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.kb-template-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(24, 31, 42, .54);
  cursor: default;
}
.kb-template-preview-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(940px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(21, 28, 40, .30);
}
.kb-template-preview-modal__close {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .92);
  color: #657184;
  box-shadow: 0 4px 14px rgba(36, 49, 66, .1);
  cursor: pointer;
}
.kb-template-preview-modal__close svg { width: 19px; height: 19px; fill: currentColor; }
.kb-template-preview-modal__visual {
  min-height: 420px;
  background: #eef1f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.kb-template-preview-modal__visual img {
  width: 100%;
  height: 100%;
  max-height: 620px;
  object-fit: cover;
  display: block;
}
.kb-template-preview-modal__content {
  padding: 44px 34px 34px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.kb-template-preview-modal__category {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f2edff;
  color: var(--kb-purple);
  font-size: 11px;
  font-weight: 800;
}
.kb-template-preview-modal__content h2 {
  margin: 14px 0 0;
  color: var(--kb-text);
  font-size: 25px;
  line-height: 1.2;
}
.kb-template-preview-modal__content p {
  margin: 14px 0 24px;
  color: #6f7b8d;
  font-size: 14px;
  line-height: 1.65;
}
.kb-template-preview-modal__content .kb-button { margin-top: auto; min-width: 150px; }
body.kb-template-modal-open { overflow: hidden; }

.kb-dashboard.is-templates .kb-dashboard-toolbar > [data-kb-create-board] { display: none; }
.kb-dashboard.is-templates .kb-dashboard-toolbar {
  grid-template-columns: minmax(320px, 1fr) auto auto;
}

@media (max-width: 1500px) {
  .kb-templates-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1220px) {
  .kb-templates-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kb-template-section__header { align-items: flex-start; flex-direction: column; }
}

/* Templates is a focused creation surface. Do not expose dashboard footer
   controls here until those product actions have dedicated native flows. */
.kb-dashboard.is-templates .kb-dashboard-footer__actions { display: none; }

/* All Boards manual ordering ------------------------------------------------
   Pointer-driven board DnD mirrors the lifted-card interaction used on the
   Kanban surface: the source keeps its grid slot, a live preview follows the
   pointer, and surrounding boards animate into their new slots. */
.kb-boards-grid--sortable .kb-board-card:not(.is-renaming) {
  cursor: grab;
}
.kb-boards-grid--sortable .kb-board-card:not(.is-renaming) .kb-board-card__link {
  cursor: grab;
}
.kb-boards-grid--sortable .kb-board-card__title,
.kb-boards-grid--sortable .kb-board-card__menu-button,
.kb-boards-grid--sortable .kb-board-card__rename-input {
  cursor: pointer;
}
.kb-boards-grid--sortable .kb-board-card__rename-input { cursor: text; }
.kb-board-dragging,
.kb-board-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}
.kb-boards-grid--dragging .kb-board-card:hover {
  transform: none;
}
.kb-board-card--drag-source {
  pointer-events: none !important;
}
.kb-board-card--drag-preview {
  border-color: rgba(111,53,229,.24) !important;
  box-shadow: 0 22px 50px rgba(36,49,66,.22), 0 4px 14px rgba(111,53,229,.12) !important;
  opacity: .985;
  overflow: hidden;
  transform-origin: center center;
}
.kb-board-card--drag-preview .kb-board-card__menu-button {
  opacity: .55;
}
.kb-boards-grid--sortable .kb-board-card__link {
  -webkit-user-drag: none;
}

/* Board sharing invitations ------------------------------------------------ */
.kb-dashboard-invitations {
  margin: 0 0 28px;
  padding: 18px 20px;
  border: 1px solid #e4def3;
  border-radius: 14px;
  background: linear-gradient(180deg, #fbf9ff 0%, #fff 100%);
  box-shadow: 0 4px 18px rgba(67, 45, 112, .06);
}
.kb-dashboard-invitations__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.kb-dashboard-invitations__header h2 {
  margin: 0;
  color: var(--kb-text);
  font-size: 16px;
  line-height: 22px;
}
.kb-dashboard-invitations__header p {
  margin: 3px 0 0;
  color: #788395;
  font-size: 12px;
  line-height: 18px;
}
.kb-dashboard-invitations__count {
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ede7f8;
  color: #6846b7;
  font-size: 12px;
  font-weight: 800;
}
.kb-dashboard-invitations__list { display: grid; gap: 8px; }
.kb-dashboard-invitation {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid #ebe7f3;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: #fff;
}
.kb-dashboard-invitation__avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eee8fb;
  color: #6846b7;
  font-size: 12px;
  font-weight: 800;
}
.kb-dashboard-invitation__body { min-width: 0; flex: 1; }
.kb-dashboard-invitation__title {
  overflow: hidden;
  color: #2d3440;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-dashboard-invitation__meta {
  margin-top: 2px;
  overflow: hidden;
  color: #7a8492;
  font-size: 11px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-dashboard-invitation__role {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2eef9;
  color: #5e4791;
  font-size: 11px;
  font-weight: 700;
}
.kb-dashboard-invitation__actions { display: flex; gap: 7px; flex: 0 0 auto; }
.kb-dashboard-invitation__button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid #d7dbe0;
  border-radius: 7px;
  background: #fff;
  color: #46505d;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.kb-dashboard-invitation__button:hover { background: #f7f7f9; }
.kb-dashboard-invitation__button--primary { border-color: #6846b7; background: #6846b7; color: #fff; }
.kb-dashboard-invitation__button--primary:hover { background: #5e3fa6; }
.kb-dashboard-invitation__button:disabled { opacity: .55; cursor: default; }
@media (max-width: 720px) {
  .kb-dashboard-invitation { align-items: flex-start; flex-wrap: wrap; }
  .kb-dashboard-invitation__actions { width: 100%; padding-left: 47px; }
}

/* My Tasks / cross-board workspace ----------------------------------------- */
.kb-my-tasks-content { padding-top: 22px; }
.kb-my-tasks { max-width: 1180px; margin: 0 auto; }
.kb-my-tasks__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.kb-my-tasks__header h1 { margin: 0; font-size: 24px; line-height: 1.2; color: #27313d; }
.kb-my-tasks__header p { margin: 6px 0 0; color: #7a8595; font-size: 13px; }
.kb-my-tasks__group { display: flex; align-items: center; gap: 9px; color: #788395; font-size: 12px; font-weight: 700; }
.kb-my-tasks__group select {
  height: 38px;
  min-width: 132px;
  padding: 0 30px 0 11px;
  border: 1px solid #e1e5ec;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: #3f4855;
  font: inherit;
  cursor: pointer;
}
.kb-my-tasks__group select:focus { border-color: rgba(111,53,229,.35); box-shadow: 0 0 0 3px rgba(111,53,229,.08); }
.kb-my-tasks-scopes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.kb-my-tasks-scope {
  height: 36px;
  padding: 0 11px;
  border: 1px solid #e3e7ed;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #697586;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.kb-my-tasks-scope:hover { border-color: #d4c9ee; color: #5f43a4; }
.kb-my-tasks-scope.is-active { border-color: #c9b8ee; background: #f4f0fc; color: #603eaf; }
.kb-my-tasks-scope__count {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #f2f4f8;
  color: #7c8795;
  font-size: 10px;
  font-weight: 800;
}
.kb-my-tasks-scope.is-active .kb-my-tasks-scope__count { background: #e8def9; color: #603eaf; }
.kb-my-tasks__subheader { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 7px; color: #7b8694; font-size: 11px; font-weight: 700; }
.kb-my-tasks__status { color: #7d6e9d; font-weight: 600; }
.kb-my-tasks__status.is-error { color: #c04f61; }
.kb-my-tasks-list { display: grid; gap: 16px; }
.kb-my-task-group { overflow: hidden; border: 1px solid #e6e9ef; border-radius: 13px; background: #fff; box-shadow: 0 3px 12px rgba(36,49,66,.035); }
.kb-my-task-group__heading { height: 42px; padding: 0 15px; display: flex; align-items: center; gap: 8px; background: #fafbfc; border-bottom: 1px solid #edf0f4; }
.kb-my-task-group__heading h2 { margin: 0; color: #5d6878; font-size: 12px; font-weight: 800; }
.kb-my-task-group__heading span { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: #eef1f5; color: #7b8593; font-size: 10px; font-weight: 800; }
.kb-my-task-group__items { display: grid; }
.kb-my-task { min-height: 76px; display: flex; align-items: stretch; border-bottom: 1px solid #eef1f5; background: #fff; }
.kb-my-task:last-child { border-bottom: 0; }
.kb-my-task:hover { background: #fcfbff; }
.kb-my-task__main { min-width: 0; flex: 1 1 auto; padding: 11px 8px 11px 15px; color: inherit; text-decoration: none; outline: none; }
.kb-my-task__main:focus-visible { box-shadow: inset 3px 0 0 var(--kb-purple); }
.kb-my-task__title { margin: 0; overflow: hidden; color: #2e3743; font-size: 14px; font-weight: 700; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
.kb-my-task__location { margin-top: 2px; overflow: hidden; color: #8a94a2; font-size: 11px; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
.kb-my-task__meta { min-height: 21px; margin-top: 7px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.kb-my-task-chip { height: 21px; padding: 0 7px; border-radius: 999px; display: inline-flex; align-items: center; background: #f2f4f7; color: #697483; font-size: 10px; font-weight: 700; white-space: nowrap; }
.kb-my-task-chip--due { background: #f0ebfb; color: #6545aa; }
.kb-my-task-chip--overdue { background: #fcebed; color: #b94b5d; }
.kb-my-task-chip--snoozed { background: #fff2df; color: #a96c19; }
.kb-my-task-chip--priority { background: #eef2f8; color: #56677e; text-transform: capitalize; }
.kb-my-task-chip--recurring { background: #e9f5ef; color: #3e7d5e; }
.kb-my-task-chip--shared { background: #edf1fb; color: #5770a4; text-transform: capitalize; }
.kb-my-task-chip--tag { background: #f4f5f7; color: #76808d; }
.kb-my-task__open { width: 52px; flex: 0 0 52px; border: 0; border-left: 1px solid transparent; background: transparent; color: #9aa3b0; cursor: pointer; }
.kb-my-task__open:hover { background: #f6f2fd; color: var(--kb-purple); border-left-color: #eee8f8; }
.kb-my-task__open svg { width: 18px; height: 18px; fill: currentColor; }
.kb-my-tasks-empty { min-height: 280px; }
.kb-dashboard.is-my-tasks .kb-dashboard-footer__actions { display: none; }


/* Release-candidate polish: responsive dashboard + keyboard focus --------- */
.kb-dashboard-tab:focus-visible,
.kb-dashboard-view-toggle button:focus-visible,
.kb-button:focus-visible,
.kb-board-section__create:focus-visible,
.kb-board-card__menu-button:focus-visible,
.kb-dashboard-footer__actions button:focus-visible,
.kb-dashboard-invitation__button:focus-visible,
.kb-my-tasks-scope:focus-visible,
.kb-my-task__open:focus-visible,
.kb-template-categories button:focus-visible,
.kb-template-card button:focus-visible,
.kb-template-preview-modal__close:focus-visible {
  outline: 2px solid var(--kb-purple);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .kb-dashboard__header { padding: 14px 18px 0; }
  .kb-dashboard-tabs { gap: 20px; min-height: 44px; }
  .kb-dashboard-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    padding: 14px 0;
  }
  .kb-dashboard-search { grid-column: 1 / -1; min-width: 0; }
  .kb-dashboard__content { padding: 22px 18px 30px; }
  .kb-boards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .kb-templates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .kb-dashboard-footer { min-height: 54px; padding: 10px 18px; flex-wrap: wrap; }
  .kb-dashboard-footer__actions { gap: 16px; flex-wrap: wrap; }
  .kb-template-preview-modal { padding: 18px; }
  .kb-template-preview-modal__dialog {
    width: min(720px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    grid-template-columns: 1fr;
  }
  .kb-template-preview-modal__visual { min-height: 250px; max-height: 42vh; }
  .kb-template-preview-modal__content { padding: 28px 24px 24px; }
  .kb-template-preview-modal__content .kb-button { margin-top: 8px; }
  .kb-my-tasks__header { align-items: flex-start; }
}

@media (max-width: 600px) {
  .kb-dashboard__header { padding: 10px 14px 0; }
  .kb-dashboard-tabs { gap: 18px; }
  .kb-dashboard-tab { padding-top: 9px; padding-bottom: 13px; }
  .kb-dashboard-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
  .kb-dashboard-search { height: 44px; border-radius: 10px; }
  .kb-dashboard-view-toggle { height: 44px; padding: 3px; border-radius: 10px; }
  .kb-dashboard-view-toggle button { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .kb-dashboard-view-toggle button span { display: none; }
  .kb-dashboard-toolbar .kb-notification-center__button { width: 44px !important; height: 44px !important; border-radius: 10px !important; }
  .kb-dashboard-toolbar > .kb-button { width: 44px; height: 44px; padding: 0; }
  .kb-dashboard-toolbar > .kb-button span { display: none; }
  .kb-dashboard__content { padding: 18px 14px 26px; }
  .kb-board-section + .kb-board-section { margin-top: 26px; }
  .kb-board-section__header { height: auto; min-height: 34px; }
  .kb-boards-grid,
  .kb-templates-grid { grid-template-columns: 1fr; gap: 12px; }
  .kb-board-card { min-height: 218px; }
  .kb-dashboard[data-kb-view="list"] .kb-board-card { min-height: 88px; }
  .kb-dashboard[data-kb-view="list"] .kb-board-card__cover { flex-basis: 104px; }
  .kb-dashboard[data-kb-view="list"] .kb-board-card__open-label { display: none; }
  .kb-dashboard-footer { align-items: flex-start; padding: 11px 14px; gap: 8px; }
  .kb-dashboard-footer__actions { width: 100%; gap: 14px; }
  .kb-dashboard-footer__status { width: 100%; }
  .kb-template-section__header,
  .kb-my-tasks__header { flex-direction: column; align-items: stretch; gap: 14px; }
  .kb-template-categories { width: 100%; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .kb-template-categories::-webkit-scrollbar { display: none; }
  .kb-template-categories button { flex: 0 0 auto; }
  .kb-my-tasks__group { justify-content: space-between; }
  .kb-my-tasks__group select { flex: 1 1 auto; min-width: 0; max-width: 220px; }
  .kb-my-tasks-scopes { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .kb-my-tasks-scopes::-webkit-scrollbar { display: none; }
  .kb-my-tasks-scope { flex: 0 0 auto; }
  .kb-my-tasks__subheader { align-items: flex-start; flex-direction: column; gap: 3px; }
  .kb-my-task { min-height: 78px; }
  .kb-my-task__main { padding-left: 12px; }
  .kb-my-task__title { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .kb-my-task__open { width: 44px; flex-basis: 44px; }
  .kb-dashboard-invitations { padding: 15px; }
  .kb-dashboard-invitation__actions { padding-left: 0; }
  .kb-template-preview-modal { padding: 10px; }
  .kb-template-preview-modal__dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); border-radius: 14px; }
  .kb-template-preview-modal__visual { min-height: 190px; max-height: 34vh; }
  .kb-template-preview-modal__content { padding: 24px 18px 20px; }
  .kb-template-preview-modal__content h2 { font-size: 22px; }
  .kb-template-preview-modal__close { top: 8px; right: 8px; }
  .kb-board-menu { max-width: calc(100vw - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  .kb-board-card,
  .kb-board-menu__item { transition: none; }
}
