.task-template-heading-btn {
  border-color: #d9d4ff;
  background: #f3f1ff;
  color: #5d4dc8;
  font-weight: 700;
}

.task-create-modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
}

.task-name-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.task-name-picker input { min-width: 0; }

.task-name-template-btn {
  min-height: 39px;
  padding: 0 12px;
  border: 1px solid #d9d4ff;
  border-radius: 8px;
  background: #f3f1ff;
  color: #5d4dc8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.task-name-template-btn:hover { background: #e9e5ff; }

.selected-template-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -7px 0 14px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #f5f3ff;
  color: #7567cf;
  font-size: 11px;
}

.selected-template-hint button {
  color: #8b82d8;
  font-size: 11px;
  font-weight: 700;
}

.selected-template-hint button:hover { color: #5848c1; }

.task-template-library-backdrop { z-index: 35; }

.task-template-library-modal {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 28px));
  overflow: auto;
  padding: 26px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(23, 31, 56, .28);
}

.task-template-library-intro {
  margin: -7px 0 18px;
  color: #8793a6;
  font-size: 13px;
  line-height: 1.6;
}

.task-template-library-modal .template-search-row { margin-bottom: 14px; }

.task-template-library-modal .task-template-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: 480px;
  padding: 2px;
}

.task-template-library-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid #edf0f5;
}

.task-template-library-foot > span {
  color: #6656d6;
  font-size: 12px;
  font-weight: 700;
}

.task-template-library-foot > div { display: flex; gap: 8px; }

.task-template-library-foot .primary-btn:disabled { cursor: not-allowed; opacity: .5; }

.task-create-type-switch {
  display: inline-flex;
  gap: 4px;
  margin: -5px 0 20px;
  padding: 4px;
  border: 1px solid #e4e7ef;
  border-radius: 9px;
  background: #f7f8fb;
}

.task-create-type-tab {
  padding: 8px 13px;
  border-radius: 6px;
  color: #7c879a;
  font-size: 12px;
  font-weight: 700;
}

.task-create-type-tab span {
  display: inline-flex;
  min-width: 20px;
  justify-content: center;
  margin-left: 4px;
  padding: 2px 5px;
  border-radius: 10px;
  background: #e9e7fb;
  color: #6b5bd4;
  font-size: 10px;
}

.task-create-type-tab.active {
  background: #fff;
  color: #5d4dc8;
  box-shadow: 0 2px 7px rgba(50, 54, 90, .08);
}

.task-create-panel[hidden] { display: none; }

.template-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.template-panel-head strong {
  color: #2d3953;
  font-size: 16px;
}

.template-panel-head p {
  margin: 5px 0 0;
  color: #8d98aa;
  font-size: 12px;
}

.template-panel-head > span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 7px;
  background: #f0eeff;
  color: #6656d6;
  font-size: 11px;
  font-weight: 700;
}

.template-search-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 9px 11px;
  border: 1px solid #dfe4ed;
  border-radius: 8px;
  background: #fafbfe;
  color: #98a3b4;
}

.template-search-row input {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #2d3953;
  font-size: 13px;
}

.task-template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 2px;
}

.task-template-card {
  display: grid;
  grid-template-columns: 18px 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 10px;
  border: 1px solid #e1e5ee;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.task-template-card:hover {
  border-color: #c9c2f5;
  background: #fcfbff;
}

.task-template-card.selected {
  border-color: #8d7fe5;
  background: #f5f3ff;
  box-shadow: 0 3px 10px rgba(102, 86, 214, .09);
}

.task-template-card > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.task-template-check {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid #cbd2df;
  border-radius: 5px;
  background: #fff;
  color: transparent;
  font-size: 11px;
  font-weight: 800;
}

.task-template-card.selected .task-template-check {
  border-color: #7160dc;
  background: #7160dc;
  color: #fff;
}

.task-template-index {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #eef0f7;
  color: #8490a4;
  font-size: 9px;
  font-weight: 700;
}

.task-template-card.selected .task-template-index {
  background: #e4e0ff;
  color: #6656d6;
}

.task-template-copy {
  min-width: 0;
}

.task-template-copy strong,
.task-template-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-template-copy strong {
  color: #3e4a62;
  font-size: 13px;
}

.task-template-copy small {
  margin-top: 3px;
  color: #98a3b4;
  font-size: 10px;
}

.task-template-empty {
  grid-column: 1 / -1;
  padding: 28px 12px;
  border: 1px dashed #dfe3ec;
  border-radius: 9px;
  color: #9aa5b5;
  text-align: center;
}

.task-template-empty strong,
.task-template-empty span {
  display: block;
}

.task-template-empty strong { color: #68758b; font-size: 13px; }
.task-template-empty span { margin-top: 4px; font-size: 11px; }

.template-common-fields { margin-top: 16px; }

@media (max-width: 620px) {
  .task-create-modal { max-height: calc(100vh - 16px); }
  .task-template-library-modal { padding: 20px; max-height: calc(100vh - 16px); }
  .task-template-library-modal .task-template-grid,
  .task-template-grid { grid-template-columns: 1fr; max-height: 270px; }
  .template-panel-head { flex-direction: column; gap: 9px; }
  .template-panel-head > span { align-self: flex-start; }
  .task-name-picker { grid-template-columns: 1fr; }
  .task-name-template-btn { width: 100%; }
  .task-template-library-foot { align-items: stretch; flex-direction: column; }
  .task-template-library-foot > div button { flex: 1; }
}

@media (min-width: 621px) and (max-width: 820px) {
  .task-template-library-modal .task-template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
